Forráskód Böngészése

顺丰订单详情

shizhongqi 7 hónapja
szülő
commit
4b0048f4a7

+ 1 - 1
app-ghs/models/delivery/OrderDetailForm.php

@@ -18,7 +18,7 @@ class OrderDetailForm extends BaseForm
         return [
             [['platform', 'orderId'], 'required'],
             [['platform', 'orderId'], 'string'],
-            ['platform', 'in', 'range' => ['shansong', 'fengniao', 'huolala', 'dada']],
+            ['platform', 'in', 'range' => ['shansong', 'fengniao', 'huolala', 'dada', 'shunfeng']],
             ['orderSn', 'string'],
         ];
     }

+ 2 - 1
common/components/delivery/services/DispatchService.php

@@ -154,7 +154,8 @@ class DispatchService
         }
 
         if ($adapter instanceof ShunfengAdapter) {
-            return $adapter->selectOrder($orderId);
+            $deliveryOrder = $this->getDeliveryOrder($orderId, 'shunfeng');
+            return $adapter->selectOrder($deliveryOrder['orderId']);
         }
 
         return $adapter->selectOrder($orderId);

+ 43 - 1
common/components/delivery/services/adapter/ShunfengAdapter.php

@@ -327,10 +327,52 @@ class ShunfengAdapter extends Shunfeng implements Adapter
 
     /**
      * 查询订单状态
+     * @param array $data
+     * @return array
      */
-    public function selectOrder($data)
+    public function selectOrder($orderId)
     {
+        if (empty($orderId)) {
+            return [
+                'code' => -1,
+                'platform' => 'shunfeng',
+                'msg' => 'order_id不能为空',
+                'data' => null,
+            ];
+        }
 
+        $payload = [
+            'order_id' => $orderId,
+            'push_time' => time(),
+        ];
+
+        if (isset($data['order_type'])) {
+            $payload['order_type'] = (int)$data['order_type'];
+        }
+
+        if (!empty($data['shop_id'])) {
+            $payload['shop_id'] = $data['shop_id'];
+        }
+        if (isset($data['shop_type'])) {
+            $payload['shop_type'] = (int)$data['shop_type'];
+        }
+
+        $resp = $this->httpRequest('getorderstatus', $payload);
+
+        if (isset($resp['error_code']) && $resp['error_code'] == 0 && isset($resp['result'])) {
+            return [
+                'code' => 0,
+                'platform' => 'shunfeng',
+                'data' => $resp['result']
+            ];
+        }
+
+        return [
+            'code' => (int)($resp['error_code'] ?? -1),
+            'platform' => 'shunfeng',
+            'msg' => $resp['error_msg'] ?? '查询订单状态失败',
+            'data' => null
+        ];
     }
 
     /**