Browse Source

全部里调支付方式

Gorden 6 months ago
parent
commit
989a53d6af
1 changed files with 9 additions and 5 deletions
  1. 9 5
      app/admin/service/order/OrderService.php

+ 9 - 5
app/admin/service/order/OrderService.php

@@ -13,6 +13,7 @@ use support\Db;
 use support\exception\BusinessException;
 use support\Log as SupportLog;
 use support\Redis;
+use Yansongda\Pay\Exceptions\GatewayException;
 use Yansongda\Pay\Log;
 use Yansongda\Pay\Pay;
 
@@ -221,9 +222,11 @@ class OrderService
             ];
             try {
                 $config = config('payment.wxpay');
-                $config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN').'/notify/orderPay/wxpay';
+                $config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN') . '/notify/orderPay/wxpay';
                 Pay::wechat($config)->pos($payData);
                 $result = self::findWxpay($params['orderGroupId'], 0);
+            }catch (GatewayException $g){
+                $result = self::findWxpay($params['orderGroupId'], 0);
             } catch (\Exception $e) {
                 $log->error("WXPAY", ['msg' => $e->getMessage()]);
                 throw new BusinessException("支付失败");
@@ -245,6 +248,8 @@ class OrderService
                 $config['notify_url'] = getenv('NOTIFY_DOMAIN_ADMIN').'/notify/orderPay/alipay';
                 Pay::alipay($config)->pos($payData);
                 $result = self::findAlipay($params['orderGroupId'], 0);
+            } catch (GatewayException $g){
+                $result = self::findAlipay($params['orderGroupId'], 0);
             } catch (\Exception $e) {
                 $log->error("ALIPAY", ['msg' => $e->getMessage()]);
                 throw new BusinessException("支付失败");
@@ -279,8 +284,7 @@ class OrderService
             $result = Pay::wechat(config('payment.wxpay'))->find($orderId, 'pos');
             $result = json_decode(json_encode($result), true);
         } catch (\Exception $e) {
-            SupportLog::channel('pay')->error("WXPAY", ['msg' => $e->getMessage()]);
-            throw new BusinessException("订单查询失败");
+            SupportLog::channel('pay')->error("FIND_WXPAY", ['msg' => $e->getMessage()]);
         }
 
         if (!empty($result['return_code']) && $result['return_code'] == 'SUCCESS' && !empty($result['result_code']) && $result['result_code'] == 'SUCCESS') {
@@ -310,8 +314,8 @@ class OrderService
             $result = Pay::alipay(config('payment.alipay'))->find($orderId);
             $result = json_decode(json_encode($result), true);
         } catch (\Exception $e) {
-            SupportLog::channel('pay')->error("ALIPAY", ['msg' => $e->getMessage()]);
-            throw new BusinessException("订单查询失败");
+            SupportLog::channel('pay')->error("FIND_ALIPAY", ['msg' => $e->getMessage()]);
+//            throw new BusinessException("订单查询失败");
         }
 
         if (!empty($result['code']) && $result['code'] == '10000' && !empty($result['trade_status']) && $result['trade_status'] == 'TRADE_SUCCESS') {