Просмотр исходного кода

【程序目录】处理退款错误提示

evoxwht 2 лет назад
Родитель
Сommit
87809fce93
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      crmeb/crmeb/services/pay/storage/WechatPay.php

+ 7 - 5
crmeb/crmeb/services/pay/storage/WechatPay.php

@@ -111,18 +111,20 @@ class WechatPay extends BasePay implements PayInterface
         $refundAccount = $opt['refund_account'] ?? 'REFUND_SOURCE_UNSETTLED_FUNDS';
         if (isset($opt['wechat'])) {
             $result = WechatService::refund($outTradeNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundReason, $type, $refundAccount);
-            if(isset($result['return_code']) && $result['return_code'] != 'SUCCESS') throw new AdminException($result['return_msg']);
-            if(isset($result['status']) && $result['status'] != 'SUCCESS') throw new AdminException($result['status']);
         } else {
             if ($opt['pay_new_weixin_open']) {
                 $result = MiniProgramService::miniRefund($outTradeNo, $totalFee, $refundFee, $opt);
-                if ($result['errcode'] != 0) throw new AdminException($result['errmsg']);
             } else {
                 $result = MiniProgramService::refund($outTradeNo, $refundNo, $totalFee, $refundFee, $opUserId, $refundReason, $type, $refundAccount);
-                if(isset($result['return_code']) && $result['return_code'] != 'SUCCESS') throw new AdminException($result['return_msg']);
-                if(isset($result['status']) && $result['status'] != 'SUCCESS') throw new AdminException($result['status']);
             }
         }
+        if ($opt['pay_new_weixin_open']) {
+            if ($result['errcode'] != 0) throw new AdminException($result['errmsg']);
+        } else {
+            if (isset($result['return_code']) && $result['return_code'] != 'SUCCESS') throw new AdminException($result['return_msg']);
+            if (isset($result['result_code']) && $result['result_code'] != 'SUCCESS') throw new AdminException($result['err_code_des']);
+            if (isset($result['status']) && $result['status'] != 'SUCCESS') throw new AdminException($result['status']);
+        }
     }
 
     /**