Przeglądaj źródła

Merge branch 'zhongqi-delivery'

shizhongqi 8 miesięcy temu
rodzic
commit
eb276d3af3

+ 11 - 15
common/components/delivery/platform/shansong/Shop.php

@@ -38,15 +38,15 @@ class Shop extends Shansong
         // 计算签名(闪送使用 MD5 签名)
         $sign = SignHelper::makeSign(
             $params, 
-            $this->appSecret, 
+            $this->appSecret,
             'md5', 
             true, 
             'shansong'
         );
         $params['sign'] = $sign;
         
-        // 发送请求
-        $response = HttpClient::post($url, $params);
+        $headers = ['Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'];
+        $response = HttpClient::post($url, $params, $headers);
         Yii::info("[ShansongUserAccount] Response: " . json_encode($response));
         
         // 检查API响应状态
@@ -105,9 +105,8 @@ class Shop extends Shansong
         // 计算签名
         $sign = SignHelper::makeSign($payload, $this->appSecret, 'md5', true, 'shansong');
         $payload['sign'] = $sign;
-        
-        // 发送请求
-        $response = HttpClient::post($url, $payload);
+        $headers = ['Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'];
+        $response = HttpClient::post($url, $payload, $headers);
         Yii::info("[ShansongAddShop] Response: " . json_encode($response));
         
         // 检查API响应状态
@@ -165,9 +164,8 @@ class Shop extends Shansong
         // 计算签名
         $sign = SignHelper::makeSign($payload, $this->appSecret, 'md5', true, 'shansong');
         $payload['sign'] = $sign;
-        
-        // 发送请求
-        $response = HttpClient::post($url, $payload);
+        $headers = ['Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'];
+        $response = HttpClient::post($url, $payload, $headers);
         Yii::info("[ShansongBatchAddShops] Response: " . json_encode($response));
         
         // 检查API响应状态
@@ -227,9 +225,8 @@ class Shop extends Shansong
         // 计算签名
         $sign = SignHelper::makeSign($payload, $this->appSecret, 'md5', true, 'shansong');
         $payload['sign'] = $sign;
-        
-        // 发送请求
-        $response = HttpClient::post($url, $payload);
+        $headers = ['Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'];
+        $response = HttpClient::post($url, $payload, $headers);
         Yii::info("[ShansongUpdateShop] Response: " . json_encode($response));
         
         // 检查API响应状态
@@ -302,9 +299,8 @@ class Shop extends Shansong
         // 计算签名
         $sign = SignHelper::makeSign($payload, $this->appSecret, 'md5', true, 'shansong');
         $payload['sign'] = $sign;
-        
-        // 发送请求
-        $response = HttpClient::post($url, $payload);
+        $headers = ['Content-Type' => 'application/x-www-form-urlencoded;charset=utf-8'];
+        $response = HttpClient::post($url, $payload, $headers);
         Yii::info("[ShansongQueryShops] Response: " . json_encode($response));
         
         // 检查API响应状态

+ 1 - 2
common/components/delivery/platform/shunfeng/Shunfeng.php

@@ -29,13 +29,12 @@ class Shunfeng
             $this->baseUrl = 'https://openic.sf-express.com/open/api/external/';
             $this->devId = 1594082399;
             $this->appSecret = '9025c4f5ad93e8e08e947f02d0cde652';
-            $this->shopId = $shopId;
         } else {
             $this->baseUrl = 'https://openic.sf-express.com/open/api/external/';
             $this->devId = 1741530942;
             $this->appSecret = '07b3f83d19a4a9f89322976c936faf92';
-            $this->shopId = $shopId;
         }
+        $this->shopId = $shopId;
 
         //保存 xhDeliveryAuthToken 表数据
         $this->deliveryAuthToken = $deliveryAuthToken;

+ 23 - 18
common/components/delivery/services/DispatchService.php

@@ -309,17 +309,21 @@ class DispatchService
                 $adapter = $this->adapters['shunfeng'];
                 // is_person_direct -- 店铺是否支持专人直送,0不支持 1支持 2只能发独享专送
                 $isPersonDirect = $adapter->getIsPersonDirect();
-                if($isPersonDirect != 2){
-                    //$customSettings = $this->adapters['shunfeng']->getCustomSettings();
-                    $customSettings = [];//自定义用户设置:默认不专人直送
-                    $preparedData['shunfeng'] = $this->prepareShunfengData($order, $shop, $customSettings);
-                }
+                 if($isPersonDirect != 2){
+                     $customSettings = [];//自定义用户设置:默认不专人直送
+                     $preparedData['shunfeng'] = $this->prepareShunfengData($order, $shop, $customSettings);
+                 }
 
                 //添加专人直送的订单数据
-                if(in_array($isPersonDirect, [1, 2])){
+                if(in_array($isPersonDirect, [1, 2])){ // 支持专人直送
                     $customSettings = ['isPersonDirect' => 1];//自定义用户设置:专人直送
                     $preparedData['shunfeng_1v1'] = $this->prepareShunfengData($order, $shop, $customSettings);
+                    Yii::info('预创建订单 shunfeng_1v1 request data: ' . json_encode($preparedData['shunfeng_1v1']));
                 }
+                // else{
+                //     $customSettings = [];//自定义用户设置:默认不专人直送
+                //     $preparedData['shunfeng'] = $this->prepareShunfengData($order, $shop, $customSettings);
+                // }
             } catch (\Exception $e) {
                 Yii::warning("Shunfeng 数据准备失败: {$e->getMessage()}");
             }
@@ -551,25 +555,26 @@ class DispatchService
             'user_lat' => (string)$order['lat'],                     // 用户地址纬度
             'user_address' => $order['fullAddress'],                 // 用户详细地址
             'weight' => $order['weight'] * 1000,                     // 物品重量(单位:克)
-            'product_type' => 4,                                     // 物品类型(4:鲜花绿植
+            'product_type' => 14,                                     // 物品类型(14:鲜花)
             'push_time' => time(),                                   // 推单时间(秒级时间戳)
-            'shop' => [                                              // 发货店铺信息
-                'shop_name' => $shop['merchantName'],                // 店铺名称
-                'shop_address' => $shop['address'],                  // 店铺地址
-                'shop_lng' => (string)$shop['long'],                 // 店铺经度
-                'shop_lat' => (string)$shop['lat'],                  // 店铺纬度
-                'shop_phone' => $shop['mobile'],                     // 店铺联系电话
-            ],
+            //shop 平台级开发者需要传入
+            // 'shop' => [                                              // 发货店铺信息
+            //     'shop_name' => $shop['merchantName'],                // 店铺名称
+            //     'shop_address' => $shop['fullAddress'],              // 店铺地址
+            //     'shop_lng' => (string)$shop['long'],                 // 店铺经度
+            //     'shop_lat' => (string)$shop['lat'],                  // 店铺纬度
+            //     'shop_phone' => $shop['mobile'],                     // 店铺联系电话
+            // ],
             //-------------------------- 非必填 -------------------------------
             'city_name' => $order['city'],                          // 发单城市
             //'order_source' => '6',                                   // 订单接入来源(6:京东秒送,可自定义)
             'source_origin_order_id' => $order['orderSn'],          // 商流订单号
             'total_price' => (int)($order['actPrice'] * 100),       // 用户订单总金额(单位:分)
             'is_appoint' => 0,                                       // 是否预约单(0:非预约单)
-            'appoint_type' => 0,                                     // TODO 预约单类型(0:立即单)
-            'expect_time' => 0,                                      // TODO 用户期望送达时间
-            //'expect_pickup_time' => 0,                             // TODO 用户期望上门时间 -- appoint_type=2时需必传,秒级时间戳
-            'shop_expect_time' => 0,                                 // TODO 商家期望送达时间 -- 格式为:{timestamp},
+            //'appoint_type' => 0,                                     // 预约单的时候传入,1:预约送达单;2:预约上门单
+            //'expect_pickup_time' => 0,                               // TODO 用户期望上门时间 -- appoint_type=2时需必传,秒级时间戳
+            //'expect_time' => 0,                                      // TODO 用户期望送达时间
+            //'shop_expect_time' => 0,                                 // TODO 商家期望送达时间 -- 格式为:{timestamp},
             'lbs_type' => 2,                                         // 坐标类型(2:高德坐标)
             'is_insured' => 0,                                       // 是否保价(0:非保价)
             'is_person_direct' => $customSettings['isPersonDirect'] ?? 0, // 是否专人直送(0:否  1:是)

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

@@ -439,7 +439,6 @@ class ShunfengAdapter extends Shunfeng implements Adapter
             'shop_id' => $this->shopId,
             'shop_type' => 1, //1:顺丰店铺ID 2:接入方店铺ID
         ];
-
         $payload = array_merge($payload, $data);
 
         // 计算签名(SignHelper 会自动递归过滤空值)