goCheck('payway'); $result = PaymentLogic::getPayWay($this->userId, $this->userInfo['terminal'], $params); if ($result === false) { return $this->fail(PaymentLogic::getError()); } return $this->data($result); } /** * @notes 预支付 * @return \think\response\Json */ public function prepay() { $params = (new PayValidate())->post()->goCheck(); //订单信息 if ($params['from'] == 'retention_money') { $order = PaymentLogic::getPayRetentionMoneyOrderInfo($params);//质保金缴费单 } else { $order = PaymentLogic::getPayOrderInfo($params); } if (false === $order) { return $this->fail(PaymentLogic::getError(), $params); } //支付流程 $redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; if ($params['pay_way'] == PayEnum::WECHAT_NATIVE_PAY) { //微信二维码预支付 $result = PaymentLogic::pay(2, $params['from'], $order, 4, $redirectUrl); } else { $result = PaymentLogic::pay($params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl); } if (false === $result) { return $this->fail(PaymentLogic::getError(), $params); } $result['sn'] = $order['sn']; $result['order_id'] = $order['id']; return $this->success('', $result); } /** * @notes 获取支付状态 * @return \think\response\Json */ public function payStatus() { $params = (new PayValidate())->goCheck('status', ['user_id' => $this->userId]); $result = PaymentLogic::getPayStatus($params); if ($result === false) { return $this->fail(PaymentLogic::getError()); } return $this->data($result); } /** * @notes 小程序支付回调 * @return \Psr\Http\Message\ResponseInterface * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException * @throws \ReflectionException * @throws \Throwable */ public function notifyMnp() { Log::write(json_encode($this->request->param(), JSON_UNESCAPED_UNICODE)); return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify(); } /** * @notes 公众号支付回调 * @return \Psr\Http\Message\ResponseInterface * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException * @throws \ReflectionException * @throws \Throwable */ public function notifyOa() { return (new WeChatPayService(UserTerminalEnum::WECHAT_OA))->notify(); } /** * @notes 支付宝回调 * @author mjf */ public function aliNotify() { $params = $this->request->post(); $result = (new AliPayService())->notify($params); if (true === $result) { echo 'success'; } else { echo 'fail'; } } /** * @notes 工单分享代付 * @return \think\response\Json */ public function sharePrepay() { $params = (new PayValidate())->post()->goCheck(); //订单信息 $order = PaymentLogic::getPayOrderInfo($params); if (false === $order) { return $this->fail(PaymentLogic::getError(), $params); } //支付流程 $redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; $result = PaymentLogic::userSharePay($params['pay_way'], $params['from'], $order, ['openid'=>$params['openid']??''], $redirectUrl); if (false === $result) { return $this->fail(PaymentLogic::getError(), $params); } $result['sn'] = $order['sn']; return $this->success('', $result); } }