|
|
@@ -7,6 +7,7 @@ use bizHd\express\classes\HdDeliveryOrderClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
use bizHd\order\classes\OrderClass as HdOrderClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
+use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -46,7 +47,7 @@ class CallBackHandler
|
|
|
{
|
|
|
$orderSn = $data['order_id']; // 对应 orderSn
|
|
|
$dadaStatus = $data['order_status'];
|
|
|
- $clientId = isset($data['client_id']) ? $data['client_id'] : '';
|
|
|
+ $clientId = isset($data['client_id']) ? $data['client_id'] : ''; //达达物流订单号
|
|
|
|
|
|
// 查找主订单
|
|
|
$order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
@@ -69,10 +70,10 @@ class CallBackHandler
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 更新 client_id (达达运单号)
|
|
|
+ // 更新 client_id (达达物流订单号)
|
|
|
if (!empty($clientId) && empty($deliveryOrder->orderId)) {
|
|
|
- $deliveryOrder->orderId = $clientId;
|
|
|
- $deliveryOrder->save();
|
|
|
+ // $deliveryOrder->orderId = $clientId;
|
|
|
+ // $deliveryOrder->save();
|
|
|
}
|
|
|
|
|
|
$sendStatus = $this->convertOrderSendStatus($dadaStatus);
|
|
|
@@ -84,18 +85,12 @@ class CallBackHandler
|
|
|
|
|
|
// 更新配送订单状态
|
|
|
$deliveryOrder->orderStatus = $sendStatus;
|
|
|
- if (isset($data['dm_name'])) {
|
|
|
- $deliveryOrder->riderName = $data['dm_name'];
|
|
|
- }
|
|
|
- if (isset($data['dm_mobile'])) {
|
|
|
- $deliveryOrder->riderPhone = $data['dm_mobile'];
|
|
|
- }
|
|
|
$deliveryOrder->save();
|
|
|
|
|
|
// 更新主订单
|
|
|
if ($isGhs) {
|
|
|
util::checkRepeatCommit('ghs_pt_' . $order->id . '_' . $sendStatus, 2);
|
|
|
- $order = OrderClass::getById($order->id, true, 'id,sendType,sendStatus,deliveryId,purchaseId,customId,status');
|
|
|
+ //$order = OrderClass::getById($order->id, true, 'id,sendType,sendStatus,deliveryId,purchaseId,customId,status');
|
|
|
|
|
|
if ($order) {
|
|
|
// 已送达
|
|
|
@@ -122,7 +117,7 @@ class CallBackHandler
|
|
|
} else {
|
|
|
// 零售订单处理
|
|
|
util::checkRepeatCommit('hd_pt_' . $order->id . '_' . $sendStatus, 2);
|
|
|
- $order = HdOrderClass::getById($order->id, true, 'id,sendType,sendStatus,deliveryId,customId,status');
|
|
|
+ //$order = HdOrderClass::getById($order->id, true, 'id,sendType,sendStatus,deliveryId,customId,status');
|
|
|
if ($order) {
|
|
|
$order->sendStatus = $sendStatus;
|
|
|
if ($orderStatus !== null) {
|
|
|
@@ -161,15 +156,31 @@ class CallBackHandler
|
|
|
private function getDeliveryOrder($order, $isGhs)
|
|
|
{
|
|
|
if ($isGhs) {
|
|
|
- return GhsDeliveryOrderClass::getByCondition([
|
|
|
+ $gdos = GhsDeliveryOrderClass::getAllByCondition([
|
|
|
'deliveryId' => 'dada',
|
|
|
- 'ghsOrderId' => $order->id
|
|
|
- ], true);
|
|
|
+ 'ghsOrderId' => $order->id,
|
|
|
+ 'orderStatus!=' => -1
|
|
|
+ ], 'id DESC', '*', null, true);
|
|
|
+ if(count($gdos)>=2){
|
|
|
+ noticeUtil::push("xhGhsDeliveryOrder ghsOrderId={$order->id} 有两笔以上是在配送中");
|
|
|
+ $gdo = $gdos[0];
|
|
|
+ }else{
|
|
|
+ $gdo = $gdos[0];
|
|
|
+ }
|
|
|
+ return $gdo;
|
|
|
} else {
|
|
|
- return HdDeliveryOrderClass::getByCondition([
|
|
|
+ $hdos = HdDeliveryOrderClass::getAllByCondition([
|
|
|
'deliveryId' => 'dada',
|
|
|
- 'hdOrderId' => $order->id
|
|
|
- ], true);
|
|
|
+ 'hdOrderId' => $order->id,
|
|
|
+ 'orderStatus!=' => -1
|
|
|
+ ], 'id DESC', '*', null, true);
|
|
|
+ if(count($hdos)>=2){
|
|
|
+ noticeUtil::push("xhHdDeliveryOrder hdOrderId={$order->id} 有两笔以上是在配送中");
|
|
|
+ $hdo = $hdos[0];
|
|
|
+ }else{
|
|
|
+ $hdo = $hdos[0];
|
|
|
+ }
|
|
|
+ return $hdo;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -193,10 +204,11 @@ class CallBackHandler
|
|
|
private function convertOrderStatus($dadaStatus)
|
|
|
{
|
|
|
$map = [
|
|
|
- 2 => 3, // 待取货 -> 配送中
|
|
|
- 3 => 3, // 配送中 -> 配送中
|
|
|
- 4 => 4, // 已完成 -> 已完成
|
|
|
- 100 => 3, // 到店 -> 配送中
|
|
|
+ 1 => 3, // 待接单 -> 配送中
|
|
|
+ 2 => 3, // 待取货 -> 配送中
|
|
|
+ 3 => 3, // 配送中 -> 配送中
|
|
|
+ 4 => 4, // 已完成 -> 已完成
|
|
|
+ 100 => 3, // 到店 -> 配送中
|
|
|
];
|
|
|
return $map[$dadaStatus] ?? null;
|
|
|
}
|