|
|
@@ -7,109 +7,125 @@ use common\components\util;
|
|
|
|
|
|
class OrderSendClass extends BaseClass
|
|
|
{
|
|
|
-
|
|
|
- public static $baseFile = '\bizGhs\order\models\OrderSend';
|
|
|
-
|
|
|
- //流程键名与ID关系
|
|
|
- const ACTION_RELATION = ['placeOrder' => 10, 'deliver' => 30, 'reach' => 40];
|
|
|
- const ACTION_LIST = [
|
|
|
- 10 => ['name' => '下单', 'sign' => 'placeOrder'],
|
|
|
- 30 => ['name' => '发货', 'sign' => 'deliver'],
|
|
|
- 40 => ['name' => '送达', 'sign' => 'reach']
|
|
|
- ];
|
|
|
-
|
|
|
- //自己送和本店送 shish 2021.3.4
|
|
|
- public static function selfSend($order)
|
|
|
- {
|
|
|
- $orderSn = $order['orderSn'];
|
|
|
- $action_data = self::ACTION_RELATION;
|
|
|
- $currentId = $relation['deliver'] ?? 0;
|
|
|
- if (empty($currentId)) {
|
|
|
- util::fail('没有找到流程ID');
|
|
|
- }
|
|
|
- $send = self::getByCondition(['orderSn' => $orderSn, 'actionId' => $currentId], true);
|
|
|
- if (empty($send)) {
|
|
|
- util::fail('配送信息错误');
|
|
|
- }
|
|
|
- //0没有选择 1本店送 2发快递
|
|
|
- $send->option = 1;
|
|
|
- $send->save();
|
|
|
- }
|
|
|
-
|
|
|
- //下单操作完成 shish 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('没有找到流程ID');
|
|
|
- }
|
|
|
- $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);
|
|
|
- }
|
|
|
-
|
|
|
- //当前待执行的动作 shish 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;
|
|
|
- }
|
|
|
-
|
|
|
- //送达 shish 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('没有找到流程ID');
|
|
|
- }
|
|
|
- $currentName = $actionList[$currentId]['name'] ?? '';
|
|
|
- $has = OrderSendClass::getByCondition(['orderSn' => $orderSn, 'actionId' => $currentId]);
|
|
|
- if ($has) {
|
|
|
- util::fail('已经确认送达');
|
|
|
- }
|
|
|
-
|
|
|
- $preId = $relation['deliver'] ?? 0;
|
|
|
- $preActionId = $relation['deliver'] ?? 0;
|
|
|
- $preInfo = OrderSendClass::getByCondition(['orderSn' => $orderSn, 'actionId' => $preActionId], true);
|
|
|
- if (empty($preInfo)) {
|
|
|
- util::fail('配送信息错误,没有找到前面个流程');
|
|
|
- }
|
|
|
- $preInfo->status = 1;
|
|
|
- $preInfo->save();
|
|
|
-
|
|
|
- $sendData = ['actionId' => $currentId, 'actionName' => $currentName, 'orderSn' => $orderSn, 'finishTime' => $time, 'inTurn' => $currentId, 'status' => 1];
|
|
|
- OrderSendClass::add($sendData);
|
|
|
- }
|
|
|
-
|
|
|
- //免发货和自取流程处理 shish 2021.1.24
|
|
|
- public static function withoutSend($info)
|
|
|
- {
|
|
|
- $orderSn = $info['orderSn'];
|
|
|
- self::deleteByCondition(['orderSn' => $orderSn]);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ public static $baseFile = '\bizGhs\order\models\OrderSend';
|
|
|
+
|
|
|
+ //流程键名与ID关系
|
|
|
+ const ACTION_RELATION = ['placeOrder' => 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)) {
|
|
|
+ util::fail('配送信息错误');
|
|
|
+ }
|
|
|
+ //0没有选择 1本店送 2发快递
|
|
|
+ $send->option = 2;
|
|
|
+ $send->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ //本店送 shish 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)) {
|
|
|
+ util::fail('配送信息错误');
|
|
|
+ }
|
|
|
+ //0没有选择 1本店送 2发快递
|
|
|
+ $send->option = 1;
|
|
|
+ $send->save();
|
|
|
+ }
|
|
|
+
|
|
|
+ //下单操作完成 shish 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ //当前待执行的动作 shish 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ //送达 shish 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)) {
|
|
|
+ util::fail('配送信息错误,没有找到前面个流程');
|
|
|
+ }
|
|
|
+ $preInfo->status = 1;
|
|
|
+ $preInfo->save();
|
|
|
+
|
|
|
+ $sendData = ['actionId' => $currentId, 'actionName' => $currentName, 'orderSn' => $orderSn, 'finishTime' => $time, 'inTurn' => $currentId, 'status' => 1];
|
|
|
+ OrderSendClass::add($sendData);
|
|
|
+ }
|
|
|
+
|
|
|
+ //免发货和自取流程处理 shish 2021.1.24
|
|
|
+ public static function withoutSend($info)
|
|
|
+ {
|
|
|
+ $orderSn = $info['orderSn'];
|
|
|
+ self::deleteByCondition(['orderSn' => $orderSn]);
|
|
|
+ }
|
|
|
+
|
|
|
}
|