|
|
@@ -253,7 +253,7 @@ class DispatchService
|
|
|
|
|
|
// 格式化返回结果
|
|
|
return [
|
|
|
- 'quotes' => array_values($results['success'] ?? []),
|
|
|
+ 'quotes' => $results['success'] ?? [],
|
|
|
'failed' => $results['failed'] ?? [],
|
|
|
];
|
|
|
}
|
|
|
@@ -302,7 +302,13 @@ class DispatchService
|
|
|
// 准备顺丰订单数据
|
|
|
if (isset($this->adapters['shunfeng'])) {
|
|
|
try {
|
|
|
- $preparedData['shunfeng'] = $this->prepareShunfengData($order, $shop);
|
|
|
+ //$customSettings = $this->adapters['shunfeng']->getCustomSettings();
|
|
|
+ $customSettings = [];//自定义用户设置:默认不专人直送
|
|
|
+ $preparedData['shunfeng'] = $this->prepareShunfengData($order, $shop, $customSettings);
|
|
|
+
|
|
|
+ //添加专人直送的订单数据
|
|
|
+ $customSettings = ['isPersonDirect' => 1];//自定义用户设置:专人直送
|
|
|
+ $preparedData['shunfeng_1v1'] = $this->prepareShunfengData($order, $shop, $customSettings);
|
|
|
} catch (\Exception $e) {
|
|
|
Yii::warning("Shunfeng 数据准备失败: {$e->getMessage()}");
|
|
|
}
|
|
|
@@ -511,7 +517,7 @@ class DispatchService
|
|
|
/**
|
|
|
* 准备顺丰订单数据
|
|
|
*/
|
|
|
- private function prepareShunfengData($order, $shop)
|
|
|
+ private function prepareShunfengData($order, $shop, $customSettings)
|
|
|
{
|
|
|
// 获取订单商品信息
|
|
|
// $itemInfos = OrderItemClass::getAllByCondition(['orderSn' => $order['orderSn']], null, 'id, name, unitPrice, num, unitWeight');
|
|
|
@@ -556,7 +562,7 @@ class DispatchService
|
|
|
'shop_expect_time' => 0, // TODO 商家期望送达时间 -- 格式为:{timestamp},
|
|
|
'lbs_type' => 2, // 坐标类型(2:高德坐标)
|
|
|
'is_insured' => 0, // 是否保价(0:非保价)
|
|
|
- 'is_person_direct' => 0, // 是否专人直送(0:否)
|
|
|
+ 'is_person_direct' => $customSettings['isPersonDirect'] ?? 0, // 是否专人直送(0:否)
|
|
|
'vehicle' => 0, // 配送交通工具(0:否)
|
|
|
//'four_wheeler_type' => 0, // 车型 -- 只有vehicle = 2,⻋型字段才有效。
|
|
|
//'declared_value' => 0, // 保价金额(单位:分)
|
|
|
@@ -658,12 +664,18 @@ class DispatchService
|
|
|
|
|
|
foreach ($preparedData as $platform => $data) {
|
|
|
try {
|
|
|
+ $adapterKey = $platform; //由于要支持特殊逻辑处理,把 $this->adapters[xxx] 的 xxx 单独取变量
|
|
|
+
|
|
|
if (!isset($this->adapters[$platform])) {
|
|
|
- $results['failed'][$platform] = '平台适配器未初始化';
|
|
|
- continue;
|
|
|
+ if($platform == 'shunfeng_1v1'){ //特殊处理 -- 专人直送的订单,使用顺丰平台适配器
|
|
|
+ $adapterKey = 'shunfeng';
|
|
|
+ } else {
|
|
|
+ $results['failed'][$platform] = '平台适配器未初始化';
|
|
|
+ Yii::warning("[DispatchService] {$platform} 平台适配器未初始化");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- $adapter = $this->adapters[$platform];
|
|
|
+ $adapter = $this->adapters[$adapterKey];
|
|
|
|
|
|
// 根据平台类型调用相应的 buildPriceRequest(s) 方法
|
|
|
if ($platform === 'huolala') {
|
|
|
@@ -707,7 +719,11 @@ class DispatchService
|
|
|
$data = $mapping['data'];
|
|
|
|
|
|
try {
|
|
|
- $adapter = $this->adapters[$platform];
|
|
|
+ $adapterKey = $platform; //由于要支持特殊逻辑处理,把 $this->adapters[xxx] 的 xxx 单独取变量
|
|
|
+ if($platform == 'shunfeng_1v1'){ //特殊处理 -- 专人直送的订单,使用顺丰平台适配器
|
|
|
+ $adapterKey = 'shunfeng';
|
|
|
+ }
|
|
|
+ $adapter = $this->adapters[$adapterKey];
|
|
|
$quote = null;
|
|
|
|
|
|
if ($platform === 'huolala') {
|
|
|
@@ -746,7 +762,6 @@ class DispatchService
|
|
|
}
|
|
|
}
|
|
|
} catch (\Throwable $e) {
|
|
|
- $platform = $mapping['platform'];
|
|
|
$results['failed'][$platform] = "处理响应失败: {$e->getMessage()}";
|
|
|
Yii::error("[DispatchService] {$platform} 处理响应异常: {$e->getMessage()}");
|
|
|
}
|
|
|
@@ -824,7 +839,7 @@ class DispatchService
|
|
|
return $deliveryList;
|
|
|
}
|
|
|
|
|
|
- foreach ($platformQuotes['quotes'] as $item) {
|
|
|
+ foreach ($platformQuotes['quotes'] as $platformKey => $item) {
|
|
|
if(!isset($item['platform'])){
|
|
|
Yii::error(json_encode($item));
|
|
|
continue;
|
|
|
@@ -833,11 +848,11 @@ class DispatchService
|
|
|
switch ($item['platform']) {
|
|
|
case 'shunfeng':
|
|
|
$deliveryList[] = [
|
|
|
- 'name' => '顺丰',
|
|
|
+ 'name' => '顺丰' . ($platformKey == 'shunfeng_1v1' ? ' (专送)' : ''),
|
|
|
'en_name' => 'shunfeng',
|
|
|
'price' => $item['real_pay_money'],
|
|
|
'distance' => $item['distance'],
|
|
|
- 'type' => '',
|
|
|
+ 'type' => '' . ($platformKey == 'shunfeng_1v1' ? '专人直送' : ''),
|
|
|
'isAble' => true
|
|
|
];
|
|
|
break;
|
|
|
@@ -945,9 +960,11 @@ class DispatchService
|
|
|
// ---------------------------------------------
|
|
|
'deliverFee' => $item['deliverFee'],
|
|
|
'deliveryNo' => $item['deliveryNo'],
|
|
|
- 'couponName' => $item['couponName'],
|
|
|
- 'couponFee' => $item['couponFee'],
|
|
|
];
|
|
|
+ if(isset($item['couponName']) && isset($item['couponFee'])){
|
|
|
+ $deliveryList['couponName'] = $item['couponName'];
|
|
|
+ $deliveryList['couponFee'] = $item['couponFee'];
|
|
|
+ }
|
|
|
break;
|
|
|
|
|
|
case 'didi':
|