-- 废弃订单状态 received(已收货):入库后直接进 pendingAllocation / pendingPayment,不再停留 received -- 历史数据:已入库的归待排货;若已有应付且未支付则归待支付 UPDATE `t_order` SET `OrderStatus` = CASE WHEN IFNULL(`IsPaid`, 0) > 0 THEN 'pendingShip' WHEN IFNULL(`PayableAmount`, 0) > 0 AND (`AllocationPendingReason` IS NULL OR TRIM(`AllocationPendingReason`) = '') THEN 'pendingPayment' ELSE 'pendingAllocation' END, `UpdateTime` = NOW() WHERE `OrderStatus` = 'received';