121 lines
3.8 KiB
PHP
121 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Amqp\Producer\PrescriptionDistributePhProducer;
|
|
use App\Constants\HttpEnumCode;
|
|
use App\Exception\BusinessException;
|
|
use App\Model\DoctorInquiryTime;
|
|
use App\Model\OrderInquiry;
|
|
use App\Request\UserRequest;
|
|
use App\Services\UserDoctorService;
|
|
use App\Services\UserService;
|
|
use App\Utils\Http;
|
|
use Extend\Wechat\Wechat;
|
|
use Extend\Wechat\WechatPay;
|
|
use Hyperf\Amqp\Producer;
|
|
use Hyperf\DbConnection\Db;
|
|
use Hyperf\Snowflake\IdGeneratorInterface;
|
|
use Hyperf\Utils\ApplicationContext;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\DecodingExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|
|
|
class UserController extends AbstractController
|
|
{
|
|
/**
|
|
* 修改用户头像
|
|
* @return ResponseInterface
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
public function putUserAvatar(): ResponseInterface
|
|
{
|
|
$request = $this->container->get(UserRequest::class);
|
|
$request->scene('putUserAvatar')->validateResolved();
|
|
|
|
$UserService = new UserService();
|
|
$data = $UserService->putUserAvatar();
|
|
return $this->response->json($data);
|
|
}
|
|
|
|
/**
|
|
* 修改用户名
|
|
* @return ResponseInterface
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
public function putUserName(): ResponseInterface
|
|
{
|
|
$request = $this->container->get(UserRequest::class);
|
|
$request->scene('putUserName')->validateResolved();
|
|
|
|
$UserService = new UserService();
|
|
$data = $UserService->putUserName();
|
|
return $this->response->json($data);
|
|
}
|
|
|
|
/**
|
|
* 退出登陆
|
|
* @return ResponseInterface
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
public function putLoginout(): ResponseInterface
|
|
{
|
|
$UserService = new UserService();
|
|
$data = $UserService->putLoginout();
|
|
return $this->response->json($data);
|
|
}
|
|
|
|
// 支付测试
|
|
public function testpay(){
|
|
// $weChat = new Wechat(1);
|
|
//
|
|
// $wx_info_data = $weChat->codeToSession("0219AIFa1ROoUE0e4lIa1bO27I29AIF9");
|
|
// dump($wx_info_data);die;
|
|
|
|
// 发起支付
|
|
// $out_trade_no = $this->request->input('out_trade_no');
|
|
// $generator = $this->container->get(IdGeneratorInterface::class);
|
|
//
|
|
// $WechatPay = new WechatPay(1);
|
|
//
|
|
// // 获取预支付交易会话标识
|
|
// $total = 0.01 * 100;
|
|
// $prepay = $WechatPay->getJsapiPrepayId($out_trade_no,$total,"omgU35DlE-rxTAGgcBjOuc4xdcX8");
|
|
// if (empty($prepay)){
|
|
// return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
|
// }
|
|
//
|
|
// // 获取小程序支付配置
|
|
// $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']);
|
|
// return $this->response->json($pay_config);
|
|
|
|
// 发起退款
|
|
$WechatPay = new WechatPay(1);
|
|
|
|
$params = array();
|
|
$params['order_inquiry_id'] = 1;
|
|
$order_inquiry = OrderInquiry::getOne($params);
|
|
|
|
|
|
$options = array();
|
|
$options['transaction_id'] = $order_inquiry['escrow_trade_no'];
|
|
$options['out_refund_no'] = $order_inquiry['inquiry_refund_no'];
|
|
$options['reason'] = "退款原因";
|
|
$options['amount'] = [
|
|
'refund' => (int)1,
|
|
'total' => (int)1,
|
|
'currency' => "CNY",
|
|
];
|
|
|
|
$result = $WechatPay->refund($options);
|
|
dump($result);
|
|
}
|
|
} |