```
feat(shopro_wechat_trade): 添加自提订单准备功能 - 在ConfirmOrders命令中添加prepareSelfetchOrder方法,用于处理自提订单的发货逻辑 - 当订单项为自提类型且未发货时,调用checkDispatchAndSend进行发货操作 - 添加异常处理机制,确保自提订单处理失败时不会中断整体流程 - 增加dry-run模式支持,便于测试验证 - 添加日志输出,提供详细的执行状态反馈 ```
这个提交包含在:
@@ -66,6 +66,14 @@ class ConfirmOrders extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->prepareSelfetchOrder($orderModel, $order, $dryRun, $output);
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(' [FAIL] 自提准备: ' . $e->getMessage());
|
||||
$fail++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$skipMall) {
|
||||
try {
|
||||
$this->mallConfirmItems($orderModel, $order, $dryRun, $output);
|
||||
@@ -161,6 +169,38 @@ class ConfirmOrders extends Command
|
||||
return array_values(array_unique($ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 自提/到店:未发货时先走 selfetchSendItem,便于 upload_shipping_info(logistics_type=4)
|
||||
*/
|
||||
protected function prepareSelfetchOrder(Order $orderModel, &$order, $dryRun, Output $output)
|
||||
{
|
||||
$needsShip = false;
|
||||
foreach ($order->item ?? [] as $item) {
|
||||
$itemArr = is_object($item) && method_exists($item, 'toArray') ? $item->toArray() : (array) $item;
|
||||
if (($itemArr['dispatch_type'] ?? '') !== 'selfetch') {
|
||||
continue;
|
||||
}
|
||||
if (intval($itemArr['dispatch_status'] ?? 0) < OrderItem::DISPATCH_STATUS_SENDED) {
|
||||
$needsShip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$needsShip) {
|
||||
return;
|
||||
}
|
||||
if ($dryRun) {
|
||||
$output->writeln(' [dry-run] 自提发货 checkDispatchAndSend');
|
||||
return;
|
||||
}
|
||||
$orderModel->checkDispatchAndSend($order, []);
|
||||
$order = Order::with('item')->where('id', $order['id'])->find();
|
||||
if (!$order) {
|
||||
throw new \RuntimeException('自提发货后订单不存在');
|
||||
}
|
||||
$output->writeln(' [OK] 自提已发货(待同步微信 upload_shipping_info)');
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
protected function mallConfirmItems(Order $orderModel, $order, $dryRun, Output $output)
|
||||
{
|
||||
$items = $order->item ?? [];
|
||||
|
||||
在新工单中引用
屏蔽一个用户