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 * @author 段誉 * @date 2023/2/28 14:21 */ public function prepay() { $params = (new PayValidate())->post()->goCheck(); $user_id = $this->userId; //订单信息 $order = PaymentLogic::getPayOrderInfo($params,$user_id); if (false === $order) { return $this->fail(PaymentLogic::getError(), $params); } //支付流程 $result = PaymentLogic::createPay($params, $order, $user_id); if($params['order_type'] == 1){ if($order['order_amount'] == 0){ $d['pay'] = $result; $d['pay_type'] = 1; return $this->success('', $d); } } if($params['from'] == "wx" || $params['from'] == "recharge"){ $redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; $result = PaymentLogic::pay($params['order_type'],$params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl); } if (false === $result) { return $this->fail(PaymentLogic::getError(), $params); } $d['pay'] = $result; return $this->success('', $d); } /** * @notes 预支付 * @return \think\response\Json * @author 段誉 * @date 2023/2/28 14:21 */ public function newprepay() { $params = (new PayValidate())->post()->goCheck(); $user_id = $this->userId; //订单信息 $order = PaymentLogic::getPayInfo($params,$user_id); if (false === $order) { return $this->fail(PaymentLogic::getError(), $params); } //支付流程 if($params['from'] == "wx" || $params['from'] == "recharge"){ $redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; $result = PaymentLogic::pay($params['order_type'],$params['pay_way'], $params['from'], $order, $this->userInfo['terminal'], $redirectUrl); }else{ $result =PaymentLogic::balancePay($order,$params); } if (false === $result) { return $this->fail(PaymentLogic::getError()); } return $this->success('', $result); } /** * @notes 获取支付状态 * @return \think\response\Json * @author 段誉 * @date 2023/3/1 16:23 */ 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 * @author 段誉 * @date 2023/2/28 14:21 */ public function notifyMnp() { return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify(); } public function notifyRefundMnp() { return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notifyRefundMnp(); } /** * @notes 公众号支付回调 * @return \Psr\Http\Message\ResponseInterface * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException * @throws \EasyWeChat\Kernel\Exceptions\RuntimeException * @throws \ReflectionException * @throws \Throwable * @author 段誉 * @date 2023/2/28 14:21 */ public function notifyOa() { return (new WeChatPayService(UserTerminalEnum::WECHAT_OA))->notify(); } /** * @notes 支付宝回调 * @author mjf * @date 2024/3/18 16:50 */ public function aliNotify() { $params = $this->request->post(); $result = (new AliPayService())->notify($params); if (true === $result) { echo 'success'; } else { echo 'fail'; } } /** * @notes 余额支付 * @author 胥聪 * @date 2025/11/3 11:30 */ public function yuePay() { $data = $this->request->post(); $user_id = $this->userId; $result = PayLogic::yuePay($data,$user_id); if ($result === false) { return $this->fail(PayLogic::getError()); } return $this->success('操作成功', [], 1, 1); } /** * @notes 用户提交退款申请 * @author 胥聪 * @date 2025/12/21 15:37 */ public function refund() { $data = $this->request->post(); $user_id = $this->userId; $result = PayLogic::refund($data,$user_id); if ($result === false) { return $this->fail(PayLogic::getError()); } return $this->success('操作成功', [], 1, 1); } }