Prechádzať zdrojové kódy

用户支付-测试

whitefang 1 rok pred
rodič
commit
bd485762f7

+ 6 - 3
app/common/logic/PaymentLogic.php

@@ -22,6 +22,7 @@ use app\common\model\recharge\RechargeOrder;
 use app\common\model\user\User;
 use app\common\service\pay\AliPayService;
 use app\common\service\pay\WeChatPayService;
+use think\Exception;
 
 
 /**
@@ -143,17 +144,19 @@ class PaymentLogic extends BaseLogic
         try {
             $order = RechargeOrder::findOrEmpty($params['order_id']);
             if ($order->isEmpty()) {
-                throw new \Exception('订单不存在');
+                throw new Exception('订单不存在');
             }
-
             //判断订单类型.服务订单尾款处理
             if($order['order_type'] == 0 and $order['pay_status'] == PayEnum::ISPAID)//服务工单
             {
                 $order = RechargeOrder::where(['work_id'=>$order['work_id'],'pay_status'=>0])->findOrEmpty();
+                if($order->isEmpty()){
+                    throw new Exception('订单已支付');
+                }
             }
 
             if ($order['pay_status'] == PayEnum::ISPAID) {
-                throw new \Exception('订单已支付');
+                throw new Exception('订单已支付');
             }
             return $order;
         } catch (\Exception $e) {

+ 2 - 0
app/common/service/pay/WeChatPayService.php

@@ -24,6 +24,7 @@ use app\common\model\user\UserAuth;
 use app\common\service\wechat\WeChatConfigService;
 use EasyWeChat\Pay\Application;
 use EasyWeChat\Pay\Message;
+use think\facade\Log;
 
 
 /**
@@ -371,6 +372,7 @@ class WeChatPayService extends BasePayService
         $server = $this->app->getServer();
         // 支付通知
         $server->handlePaid(function (Message $message) {
+            Log::write(json_encode($message, JSON_UNESCAPED_UNICODE));
             if ($message['trade_state'] === 'SUCCESS') {
                 $extra['transaction_id'] = $message['transaction_id'];
                 $attach = $message['attach'];