This commit is contained in:
wushumin
2026-04-16 13:04:15 +08:00
parent 11ff03d0ea
commit 99173639c9
7 changed files with 199 additions and 5 deletions

View File

@@ -58,16 +58,28 @@ class OrderFlowService
*/
public static function userShip(Order $order, string $expressCompany, string $expressNo)
{
if ($order->status !== 'shipping') {
throw new Exception("当前状态不允许发货");
if ($order->status !== 'shipping' && $order->status !== 'wait_receive') {
throw new Exception("当前状态不允许修改发货信息");
}
if ($order->status === 'wait_receive') {
if ($order->express_modify_count >= 1) {
throw new Exception("运单号仅允许修改1次");
}
$order->express_modify_count += 1;
$actionType = 'user_ship_modify';
$title = '修改物流信息';
} else {
$order->status = 'wait_receive'; // 等待平台收件
$actionType = 'user_ship';
$title = '物品已寄出';
}
$order->express_company = $expressCompany;
$order->express_no = $expressNo;
$order->status = 'wait_receive'; // 等待平台收件(可复用为在途)
$order->save();
self::addLog($order->id, 'user_ship', '物品已寄出', "物流公司: {$expressCompany}, 单号: {$expressNo}", 'user', $order->user_id);
self::addLog($order->id, $actionType, $title, "物流公司: {$expressCompany}, 单号: {$expressNo}", 'user', $order->user_id);
return $order;
}