Browse Source

Merge branch 'dev'

sunxbiao 8 months ago
parent
commit
8d391c5ee1
2 changed files with 9 additions and 10 deletions
  1. 0 2
      app/controller/api/store/merchant/Merchant.php
  2. 9 8
      app/traits/GzcApiRequest.php

+ 0 - 2
app/controller/api/store/merchant/Merchant.php

@@ -228,8 +228,6 @@ class Merchant extends BaseController
228 228
             $hasProductMerIdList = array_column($hasProductMerIdList->toArray(), 'mer_id');
229 229
         }
230 230
         $query = Db::name('merchant')->where($where);
231
-        $page = 1;
232
-        $limit = 100;
233 231
         if (!empty($hasProductMerIdList) && is_array($hasProductMerIdList)) {
234 232
             $query->whereIn('mer_id', $hasProductMerIdList);
235 233
         }

+ 9 - 8
app/traits/GzcApiRequest.php

@@ -87,6 +87,8 @@ trait GzcApiRequest
87 87
 
88 88
         $amount = $cxbResponseData['extendData']['amount'] + $xfbResponseData['extendData']['amount'];
89 89
         return $amount;
90
+
91
+
90 92
     }
91 93
     public function getAmountFromGzc()
92 94
     {
@@ -105,18 +107,17 @@ trait GzcApiRequest
105 107
             return app('json')->fail('查询失败(第三方异常)');
106 108
         }
107 109
 
108
-        // 提取 amount(兼容多种字段位置)
109
-        $amountCents = $res['extendData']['amount'] ?? $res['data']['amount'] ?? $res['amount'] ?? null;
110
-        $amount = $amountCents === null ? 0.0 : floatval($amountCents) * 0.01;
111
-        $formatted = sprintf('%.2f', $amount);
110
+        if (!is_array($res) || ($res['code'] ?? -1) !== 0) {
111
+            return app('json')->fail($res['message'] ?? '查询失败');
112
+        }
112 113
 
113
-        // 从 checkAmount 返回的 debug(若存在)
114
-        $debug = $res['debug'] ?? null;
114
+        $amountCents = $res['extendData']['amount'] ?? $res['data']['amount'] ?? $res['amount'] ?? 0;
115
+        $amount = floatval($amountCents) * 0.01;
116
+        $formatted = sprintf('%.2f', $amount);
115 117
 
116
-        // 返回 amount 与 debug 给调用方(前端 / 调试)
117 118
         return app('json')->success([
118 119
             'amount' => $formatted,
119
-            'debug'  => $debug
120
+            'debug'  => $res['debug'] ?? null,
120 121
         ]);
121 122
     }
122 123
     /**