|
|
@@ -33,7 +33,7 @@ class AlibabaNotify
|
|
33
|
33
|
// 获取原始POST数据
|
|
34
|
34
|
$postData = request()->post();
|
|
35
|
35
|
|
|
36
|
|
- Log::channel('alibaba')->info('[订阅消息通知] 收到请求', ['data' => json_encode($postData, JSON_UNESCAPED_UNICODE)]);
|
|
|
36
|
+ Log::channel('alibaba')->info('[订阅消息通知] 收到请求, data:' . json_encode($postData, JSON_UNESCAPED_UNICODE));
|
|
37
|
37
|
|
|
38
|
38
|
if (empty($postData['message'])) {
|
|
39
|
39
|
Log::channel('alibaba')->error('[订阅消息通知] message参数为空');
|
|
|
@@ -43,28 +43,28 @@ class AlibabaNotify
|
|
43
|
43
|
// 解析message
|
|
44
|
44
|
$message = json_decode($postData['message'], true);
|
|
45
|
45
|
if (json_last_error() !== JSON_ERROR_NONE) {
|
|
46
|
|
- Log::channel('alibaba')->error('[订阅消息通知] message JSON解析失败', ['message' => $postData['message']]);
|
|
|
46
|
+ Log::channel('alibaba')->error('[订阅消息通知] message JSON解析失败, message:' . $postData['message']);
|
|
47
|
47
|
return response('fail: message json decode error');
|
|
48
|
48
|
}
|
|
49
|
49
|
|
|
50
|
50
|
$type = $message['type'] ?? '';
|
|
51
|
|
- Log::channel('alibaba')->info('[订阅消息通知] 消息类型', ['type' => $type, 'message' => $message]);
|
|
|
51
|
+ Log::channel('alibaba')->info('[订阅消息通知] 消息类型:' . $type . ', message:' . json_encode($message, JSON_UNESCAPED_UNICODE));
|
|
52
|
52
|
|
|
53
|
53
|
try {
|
|
54
|
54
|
switch ($type) {
|
|
55
|
55
|
case 'ORDER_BUYER_VIEW_ANNOUNCE_SENDGOODS':
|
|
56
|
56
|
return $this->handleOrderSendGoods($message);
|
|
57
|
57
|
default:
|
|
58
|
|
- Log::channel('alibaba')->warning('[订阅消息通知] 未知消息类型', ['type' => $type]);
|
|
|
58
|
+ Log::channel('alibaba')->warning('[订阅消息通知] 未知消息类型, type:' . $type);
|
|
59
|
59
|
return response('success: unknown type');
|
|
60
|
60
|
}
|
|
61
|
61
|
} catch (\Throwable $e) {
|
|
62
|
|
- Log::channel('alibaba')->error('[订阅消息通知] 处理异常', [
|
|
63
|
|
- 'type' => $type,
|
|
64
|
|
- 'error' => $e->getMessage(),
|
|
65
|
|
- 'trace' => $e->getTraceAsString(),
|
|
66
|
|
- ]);
|
|
67
|
|
- return response('fail: exception - ' . $e->getMessage());
|
|
|
62
|
+ $errorMsg = $e->getMessage();
|
|
|
63
|
+ $traceStr = $e->getTraceAsString();
|
|
|
64
|
+ Log::channel('alibaba')->error('[订阅消息通知] 处理异常, type:' . $type . ', error:' . $errorMsg . ', file:' . $e->getFile() . ':' . $e->getLine() . ', trace:' . $traceStr);
|
|
|
65
|
+ // 同时记录到默认日志,防止渠道日志配置问题
|
|
|
66
|
+ Log::error('[AlibabaNotify] 处理异常: ' . $errorMsg . ' | file: ' . $e->getFile() . ':' . $e->getLine());
|
|
|
67
|
+ return response('fail: exception - ' . $errorMsg);
|
|
68
|
68
|
}
|
|
69
|
69
|
}
|
|
70
|
70
|
|
|
|
@@ -104,15 +104,11 @@ class AlibabaNotify
|
|
104
|
104
|
$orderId = $data['orderId'] ?? 0;
|
|
105
|
105
|
|
|
106
|
106
|
if (empty($orderId)) {
|
|
107
|
|
- Log::channel('alibaba')->error('[发货通知] data.orderId为空', ['message' => $message]);
|
|
|
107
|
+ Log::channel('alibaba')->error('[发货通知] data.orderId为空, message:' . json_encode($message, JSON_UNESCAPED_UNICODE));
|
|
108
|
108
|
return response('fail: orderId is empty');
|
|
109
|
109
|
}
|
|
110
|
110
|
|
|
111
|
|
- Log::channel('alibaba')->info('[发货通知] 开始处理', [
|
|
112
|
|
- 'alibaba_order_id' => $orderId,
|
|
113
|
|
- 'currentStatus' => $data['currentStatus'] ?? '',
|
|
114
|
|
- 'msgSendTime' => $data['msgSendTime'] ?? '',
|
|
115
|
|
- ]);
|
|
|
111
|
+ Log::channel('alibaba')->info('[发货通知] 开始处理, alibaba_order_id:' . $orderId . ', currentStatus:' . ($data['currentStatus'] ?? '') . ', msgSendTime:' . ($data['msgSendTime'] ?? ''));
|
|
116
|
112
|
|
|
117
|
113
|
// 1. 根据1688订单号查询本地订单
|
|
118
|
114
|
$storeOrder = Db::name('store_order')
|
|
|
@@ -120,22 +116,15 @@ class AlibabaNotify
|
|
120
|
116
|
->find();
|
|
121
|
117
|
|
|
122
|
118
|
if (empty($storeOrder)) {
|
|
123
|
|
- Log::channel('alibaba')->warning('[发货通知] 未找到匹配的本地订单', ['alibaba_order_id' => $orderId]);
|
|
|
119
|
+ Log::channel('alibaba')->warning('[发货通知] 未找到匹配的本地订单, alibaba_order_id:' . $orderId);
|
|
124
|
120
|
return response('success: order not found locally');
|
|
125
|
121
|
}
|
|
126
|
122
|
|
|
127
|
|
- Log::channel('alibaba')->info('[发货通知] 找到本地订单', [
|
|
128
|
|
- 'order_id' => $storeOrder['order_id'],
|
|
129
|
|
- 'order_sn' => $storeOrder['order_sn'],
|
|
130
|
|
- ]);
|
|
|
123
|
+ Log::channel('alibaba')->info('[发货通知] 找到本地订单, order_id:' . $storeOrder['order_id'] . ', order_sn:' . $storeOrder['order_sn']);
|
|
131
|
124
|
|
|
132
|
125
|
// 2. 如果已有物流信息,跳过
|
|
133
|
126
|
if (!empty($storeOrder['delivery_name']) && !empty($storeOrder['delivery_id'])) {
|
|
134
|
|
- Log::channel('alibaba')->info('[发货通知] 订单已有物流信息,跳过更新', [
|
|
135
|
|
- 'order_id' => $storeOrder['order_id'],
|
|
136
|
|
- 'delivery_name' => $storeOrder['delivery_name'],
|
|
137
|
|
- 'delivery_id' => $storeOrder['delivery_id'],
|
|
138
|
|
- ]);
|
|
|
127
|
+ Log::channel('alibaba')->info('[发货通知] 订单已有物流信息,跳过更新, order_id:' . $storeOrder['order_id'] . ', delivery_name:' . $storeOrder['delivery_name'] . ', delivery_id:' . $storeOrder['delivery_id']);
|
|
139
|
128
|
return response('success: already has logistics info');
|
|
140
|
129
|
}
|
|
141
|
130
|
|
|
|
@@ -146,10 +135,7 @@ class AlibabaNotify
|
|
146
|
135
|
]);
|
|
147
|
136
|
|
|
148
|
137
|
if ($logisticsResult === false || empty($logisticsResult['logisticsItems'])) {
|
|
149
|
|
- Log::channel('alibaba')->warning('[发货通知] 获取物流信息失败或物流信息为空', [
|
|
150
|
|
- 'alibaba_order_id' => $orderId,
|
|
151
|
|
- 'result' => $logisticsResult,
|
|
152
|
|
- ]);
|
|
|
138
|
+ Log::channel('alibaba')->warning('[发货通知] 获取物流信息失败或物流信息为空, alibaba_order_id:' . $orderId . ', result:' . json_encode($logisticsResult, JSON_UNESCAPED_UNICODE));
|
|
153
|
139
|
return response('success: no logistics info yet');
|
|
154
|
140
|
}
|
|
155
|
141
|
|
|
|
@@ -159,7 +145,7 @@ class AlibabaNotify
|
|
159
|
145
|
$deliveryId = $firstLogistics['logisticsCode'] ?? '';
|
|
160
|
146
|
|
|
161
|
147
|
if (empty($deliveryName) || empty($deliveryId)) {
|
|
162
|
|
- Log::channel('alibaba')->warning('[发货通知] 物流信息不完整', ['logistics' => $firstLogistics]);
|
|
|
148
|
+ Log::channel('alibaba')->warning('[发货通知] 物流信息不完整, logistics:' . json_encode($firstLogistics, JSON_UNESCAPED_UNICODE));
|
|
163
|
149
|
return response('success: logistics info incomplete');
|
|
164
|
150
|
}
|
|
165
|
151
|
|
|
|
@@ -177,12 +163,7 @@ class AlibabaNotify
|
|
177
|
163
|
|
|
178
|
164
|
app()->make(StoreOrderStatusRepository::class)->status($storeOrder['order_id'], 'delivery_0', '订单以配送【快递名称】:' . $deliveryName . '; 【快递单号】:' . $deliveryId);
|
|
179
|
165
|
|
|
180
|
|
- Log::channel('alibaba')->info('[发货通知] 物流信息更新成功', [
|
|
181
|
|
- 'order_id' => $storeOrder['order_id'],
|
|
182
|
|
- 'order_sn' => $storeOrder['order_sn'],
|
|
183
|
|
- 'delivery_name' => $deliveryName,
|
|
184
|
|
- 'delivery_id' => $deliveryId,
|
|
185
|
|
- ]);
|
|
|
166
|
+ Log::channel('alibaba')->info('[发货通知] 物流信息更新成功, order_id:' . $storeOrder['order_id'] . ', order_sn:' . $storeOrder['order_sn'] . ', delivery_name:' . $deliveryName . ', delivery_id:' . $deliveryId);
|
|
186
|
167
|
|
|
187
|
168
|
return response('success');
|
|
188
|
169
|
}
|