Переглянути джерело

fix: 直接支付返回的status字符串还原

joe 4 роки тому
батько
коміт
c0e8875675
1 змінених файлів з 26 додано та 16 видалено
  1. 26 16
      app/api/controller/order/StoreOrderController.php

+ 26 - 16
app/api/controller/order/StoreOrderController.php

@@ -26,7 +26,7 @@ use app\models\system\SystemStore;
 use app\models\user\UserAddress;
 use app\models\user\UserLevel;
 use app\Request;
-use think\facade\Cache;
+use think\facade\{Cache, Log};
 use crmeb\services\{
     CacheService,
     ExpressService,
@@ -272,17 +272,17 @@ class StoreOrderController
                                 $jsConfig = OrderRepository::wxPay($orderId);
                             }
                         } catch (\Exception $e) {
+                            Log::error("weixin pay error:" . $e->getMessage());
                             return app('json')->status('pay_error', $e->getMessage(), $info);
                         }
                         $info['jsConfig'] = $jsConfig;
-                        return app('json')->status($payType . '_' . $from, '订单创建成功', $info);
-                        // if ($from == 'weixinh5') {
-                        //     return app('json')->status('wechat_h5_pay', '订单创建成功', $info);
-                        // } elseif ($from == 'app') {
-                        //     return app('json')->status('wechat_app_pay', '订单创建成功', $info);
-                        // } else {
-                        //     return app('json')->status('wechat_pay', '订单创建成功', $info);
-                        // }
+                        $status = 'wechat_pay'; // routine
+                        if ($from == 'weixinh5') {
+                            $status = 'wechat_h5_pay';
+                        } elseif ($from == 'app') {
+                            $status = 'wechat_app_pay';
+                        }
+                        return app('json')->status($status, '订单创建成功', $info);
                     }
                     break;
                 case 'yue':
@@ -466,15 +466,17 @@ class StoreOrderController
                                 $jsConfig = OrderRepository::wxPayBatch($porderId);
                             }
                         } catch (\Exception $e) {
+                            Log::error("weixin pay error:" . $e->getMessage());
                             return app('json')->status('pay_error', $e->getMessage(), $info);
                         }
                         $info['jsConfig'] = $jsConfig;
-                        return app('json')->status($payType . '_' . $from, '订单创建成功', $info);
-                        // if ($from == 'weixinh5') {
-                        //     return app('json')->status('wechat_h5_pay', '订单创建成功', $info);
-                        // } else {
-                        //     return app('json')->status('wechat_pay', '订单创建成功', $info);
-                        // }
+                        $status = 'wechat_pay'; // routine
+                        if ($from == 'weixinh5') {
+                            $status = 'wechat_h5_pay';
+                        } elseif ($from == 'app') {
+                            $status = 'wechat_app_pay';
+                        }
+                        return app('json')->status($status, '订单创建成功', $info);
                     }
                     break;
                 case 'yue':
@@ -584,11 +586,19 @@ class StoreOrderController
                         $jsConfig = OrderRepository::wxPay($order);
                     }
                 } catch (\Exception $e) {
+                    Log::error('weixin pay error:' . $e->getMessage());
                     return app('json')->fail($e->getMessage());
                 }
 
-                return app('json')->status($paytype . '_' . $from, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
+                // return app('json')->status($paytype . '_' . $from, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
 
+                $status = 'wechat_pay'; // routine
+                if ($from == 'weixinh5') {
+                    $status = 'wechat_h5_pay';
+                } elseif ($from == 'app') {
+                    $status = 'wechat_app_pay';
+                }
+                return app('json')->status($status, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
                 // if ($from == 'weixinh5') {
                 //     return app('json')->status('wechat_h5_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
                 // } else {