10, 'deliver' => 30, 'reach' => 40]; const ACTION_LIST = [ 10 => ['name' => '下单', 'sign' => 'placeOrder'], 30 => ['name' => '发货', 'sign' => 'deliver'], 40 => ['name' => '送达', 'sign' => 'reach'] ]; public static function thirdSend($order) { $orderSn = $order->orderSn; $relation = self::ACTION_RELATION; $currentId = $relation['deliver'] ?? 0; if (empty($currentId)) { util::fail('没有找到流程'); } $send = self::getByCondition(['orderSn' => $orderSn, 'actionId' => $currentId], true); if (empty($send)) { return false; util::fail('配送信息错误'); } //0没有选择 1本店送 2发快递 $send->option = 2; $send->status = 0; $send->finishTime = date("Y-m-d H:i:s"); $send->save(); } //本店送 ssh 2021.3.4 public static function selfSend($order) { $orderSn = $order->orderSn; $relation = self::ACTION_RELATION; $currentId = $relation['deliver'] ?? 0; if (empty($currentId)) { util::fail('没有找到流程'); } $send = self::getByCondition(['orderSn' => $orderSn, 'actionId' => $currentId], true); if (empty($send)) { return false; util::fail('配送信息错误'); } //0没有选择 1本店送 2发快递 $send->option = 1; $send->status = 0; $send->finishTime = date("Y-m-d H:i:s"); $send->save(); } //下单操作完成 ssh 2019.12.13 public static function placeOrder($data) { //下单完成 $orderSn = $data['orderSn']; $payTime = $data['payTime']; $relation = self::ACTION_RELATION; $actionList = self::ACTION_LIST; $currentId = $relation['placeOrder'] ?? 0; if (empty($currentId)) { util::fail('没有找到流程'); } $currentName = $actionList[$currentId]['name'] ?? ''; $data = ['actionId' => $currentId, 'actionName' => $currentName, 'orderSn' => $orderSn, 'finishTime' => $payTime, 'inTurn' => $currentId, 'status' => 1]; self::add($data); OrderClass::updateByCondition(['orderSn' => $orderSn], ['currentFlow' => 1]); //配送未开始 $nextId = $relation['deliver'] ?? 0; if (empty($nextId)) { util::fail('下单后没有找到下一步的流程ID'); } $nextName = $actionList[$nextId]['name'] ?? ''; $data = ['actionId' => $nextId, 'actionName' => $nextName, 'orderSn' => $orderSn, 'inTurn' => $nextId, 'status' => 0]; self::add($data); } //当前待执行的动作 ssh 2019.12.16 public static function toDoActionId($orderSn) { $action = self::getByCondition(['orderSn' => $orderSn], false, 'inTurn DESC'); $actionId = 0; if (empty($action['finishTime'])) { $actionId = $action['actionId']; } return $actionId; } //送达 ssh 2020.6.1 public static function reach($order) { $orderSn = $order['orderSn']; $time = date("Y-m-d H:i:s"); $relation = self::ACTION_RELATION; $actionList = self::ACTION_LIST; $currentId = $relation['reach'] ?? 0; if (empty($currentId)) { util::fail('没有找到流程'); } $currentName = $actionList[$currentId]['name'] ?? ''; $has = OrderSendClass::getByCondition(['orderSn' => $orderSn, 'actionId' => $currentId]); if ($has) { util::fail('已经确认送达'); } $preActionId = $relation['deliver'] ?? 0; $preInfo = OrderSendClass::getByCondition(['orderSn' => $orderSn, 'actionId' => $preActionId], true); if (empty($preInfo)) { return false; util::fail('配送信息错误,没有找到前面个流程'); } $preInfo->status = 1; $preInfo->save(); $sendData = ['actionId' => $currentId, 'actionName' => $currentName, 'orderSn' => $orderSn, 'finishTime' => $time, 'inTurn' => $currentId, 'status' => 1]; OrderSendClass::add($sendData); } //免发货和自取流程处理 ssh 2021.1.24 public static function withoutSend($info) { $orderSn = $info->orderSn ?? ''; if (empty($orderSn)) { util::faill('没有找到订单编号'); } self::deleteByCondition(['orderSn' => $orderSn]); } }