浏览代码

订单处理流程

shish 6 年之前
父节点
当前提交
4d46ce54a6

+ 22 - 9
app/business/controllers/OrderController.php

@@ -2,6 +2,7 @@
 
 namespace business\controllers;
 
+use biz\order\services\OrderSendService;
 use biz\order\services\OrderService;
 use Yii;
 use common\components\util;
@@ -30,14 +31,26 @@ class OrderController extends BaseController
 	}
 	
 	//发货管理 shish 2019.11.30
-	public function actionSend()
+	public function actionSendDetail()
 	{
-
+		$id = Yii::$app->request->get('id', 0);
+		$order = OrderService::getById($id);
+		OrderService::valid($order, $this->merchantId);
+		$list = OrderSendService::sendDetail($id);
+		util::success($list);
 	}
-
+	
+	//发货流程更新 shish 2019.12.15
 	public function actionSendUpdate()
 	{
-
+		$post = Yii::$app->request->post();
+		$id = isset($post['id']) ? $post['id'] : 0;
+		$actionId = isset($post['actionId']) ? $post['actionId'] : 0;
+		$option = isset($post['option']) ? $post['option'] : 0;
+		$order = OrderService::getById($id);
+		OrderService::valid($order, $this->merchantId);
+		OrderSendService::sendUpdate(['id' => $id, 'actionId' => $actionId, 'option' => $option]);
+		util::ok('操作成功');
 	}
 	
 	//向快递公司发起配送需求
@@ -52,17 +65,17 @@ class OrderController extends BaseController
 		$sendSide = 1;
 		$sendTime = '10:21';
 	}
-
+	
 	//添加小费
 	public function actionAddTip()
 	{
-
+	
 	}
-
+	
 	//结果回调通知
 	public function actionExpressCallback()
 	{
-
+	
 	}
 	
 	//快递服务提供方
@@ -71,5 +84,5 @@ class OrderController extends BaseController
 		$data = ['id' => 1, 'name' => '达达'];
 		util::success($data);
 	}
-
+	
 }

+ 3 - 3
app/client/controllers/OrderController.php

@@ -122,7 +122,7 @@ class OrderController extends BaseController
 		OrderGoodsService::add($data);//创建订单商品列表
 		util::success(['orderSn' => $orderSn, 'totalPrice' => $showPrice, 'couponId' => $couponId]);
 	}
-
+	
 	//下单要用到的相关信息 shish 2019.12.6
 	public function actionOrderRelate()
 	{
@@ -148,7 +148,7 @@ class OrderController extends BaseController
 		UserService::validPayPassword($payPassword, $this->user);
 		
 		//验证订单有效性
-		OrderService::valid($order, $this->userId);
+		OrderService::check($order, $this->userId);
 		
 		$typeList = configDict::getConfig('capitalType');
 		$capitalType = $typeList['xhOrder']['id'];
@@ -167,7 +167,7 @@ class OrderController extends BaseController
 		$order = OrderService::getByOrderSn($orderSn);
 		
 		//验证订单有效性
-		OrderService::valid($order, $this->userId);
+		OrderService::check($order, $this->userId);
 		
 		$name = isset($order['orderName']) && !empty($order['orderName']) ? $order['orderName'] : '购买商品';
 		$totalFee = $order['actPrice'];

+ 45 - 2
biz/order/classes/OrderSendClass.php

@@ -3,6 +3,7 @@
 namespace biz\order\classes;
 
 use common\components\stringUtil;
+use common\components\util;
 use common\services\xhOrderDayNumService;
 use common\services\xhOrderMonthNumService;
 use Yii;
@@ -17,6 +18,21 @@ class OrderSendClass extends BaseClass
 	public static $actionId = ['placeOrder' => 10, 'printOrder' => 20, 'deliver' => 30, 'reach' => 40, 'finish' => 50];
 	public static $actionName = [10 => '下单', 20 => '打单', 30 => '发货', 40 => '送达', 50 => '完成'];
 	
+	//发货详情 shish 2019.12.15
+	public static function sendDetail($orderId)
+	{
+		$list = self::getAllByCondition(['orderId' => $orderId], 'inTurn DESC', '*');
+		if (empty($list)) {
+			return [];
+		}
+		$nameList = self::$actionName;
+		foreach ($list as $key => $val) {
+			$actionId = $val['actionId'];
+			$list[$key]['actionName'] = isset($nameList[$actionId]) ? $nameList[$actionId] : '';
+		}
+		return $list;
+	}
+	
 	//下单操作完成 shish 2019.12.13
 	public static function placeOrder($data)
 	{
@@ -34,10 +50,37 @@ class OrderSendClass extends BaseClass
 		$data = ['actionId' => $printOrderId, 'orderId' => $orderId, 'finishTime' => 0, 'addTime' => $time, 'inTurn' => $printOrderId];
 		self::add($data);
 	}
-
+	
 	public static function printOrder()
 	{
 	
 	}
-
+	
+	//发货流程更新
+	public static function sendUpdate($data)
+	{
+		$id = $data['id'];
+		$actionId = $data['actionId'];
+		$option = $data['option'];
+		$currentId = self::onActionId($id);
+		$time = time();
+		if ($currentId != $actionId) {
+			util::fail('超期或过期操作');
+		}
+		self::updateByCondition(['orderId' => $id, 'actionId' => $actionId], ['option' => $option, 'finishTime' => $time]);
+		util::ok('操作成功');
+	}
+	
+	//当前订单待操作action shish 2019.12.16
+	public static function onActionId($id)
+	{
+		$list = self::sendDetail($id);
+		$actionId = 0;
+		if (!empty($list)) {
+			$action = current($list);
+			$actionId = $action['actionId'];
+		}
+		return $actionId;
+	}
+	
 }

+ 11 - 1
biz/order/services/OrderSendService.php

@@ -5,6 +5,7 @@ namespace biz\order\services;
 use biz\base\services\BaseService;
 use biz\merchant\services\MerchantCapitalService;
 use biz\order\classes\OrderClass;
+use biz\order\classes\OrderSendClass;
 use biz\order\models\Order;
 use biz\promote\services\CouponRightService;
 use biz\user\services\UserService;
@@ -18,6 +19,15 @@ class OrderSendService extends BaseService
 {
 	
 	public static $baseFile = '\biz\order\classes\OrderSendClass';
-
 	
+	public static function sendDetail($orderId)
+	{
+		return OrderSendClass::sendDetail($orderId);
+	}
+
+	public static function sendUpdate($data)
+	{
+		return OrderSendClass::sendUpdate($data);
+	}
+
 }

+ 14 - 3
biz/order/services/OrderService.php

@@ -60,8 +60,8 @@ class OrderService extends BaseService
 		return self::getLimitList('*', $where, $limit, $order, $with);
 	}
 	
-	//验证订单是否有效 shish 2019.12.6
-	public static function valid($order, $userId)
+	//用户验证订单是否有效 shish 2019.12.6
+	public static function check($order, $userId)
 	{
 		$now = time();
 		if (empty($order)) {
@@ -80,7 +80,18 @@ class OrderService extends BaseService
 			util::fail('订单已经付款了');
 		}
 	}
-
+	
+	//商家验证是否有效 shish 2019.12.15
+	public static function valid($order, $merchantId)
+	{
+		if (empty($order)) {
+			util::fail('订单无效');
+		}
+		if ($order['merchantId'] != $merchantId) {
+			util::fail('您没有权限操作');
+		}
+	}
+	
 	//根据编号查询 shish 2019.12.14
 	public static function getByOrderSn($orderSn)
 	{