Explorar el Código

零售端盘点

林琦海 hace 5 años
padre
commit
dd69cf52ba
Se han modificado 1 ficheros con 92 adiciones y 1 borrados
  1. 92 1
      app-hd/controllers/CheckOrderController.php

+ 92 - 1
app-hd/controllers/CheckOrderController.php

@@ -24,4 +24,95 @@ class CheckOrderController extends BaseController
         util::success($list);
     }
 
-}
+    //订单详情 2021.1.22 linqh
+    public function actionDetail()
+    {
+        $orderSn = Yii::$app->request->get('orderSn','');
+        $orderData = CheckOrderClass::getOrderDetail($orderSn,$this->shopId);
+        util::success($orderData);
+    }
+
+    //盘点确认 linqh 2021.1.22
+    public function actionCreateOrder()
+    {
+        $post = Yii::$app->request->post();
+        $post['merchantId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        //盘点是否有未处理的草稿,有的话先处理之前的草稿??
+        //todo
+        $this->saveOrder($post,false,false);
+
+    }
+
+    //盘点存草稿 linqh 2021.1.22
+    public function actionCreateDraft()
+    {
+        $post = Yii::$app->request->post();
+        $post['merchantId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+
+        $this->saveOrder($post,true,false);
+    }
+
+    //编辑草稿 ,继续保存草稿
+    public function actionUpdateDraft()
+    {
+        $post = Yii::$app->request->post();
+        $post['merchantId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        $orderSn = $post['orderSn']??'';
+        $orderData = CheckOrderClass::orderExist($orderSn,$this->shopId);
+        if($orderData['status'] != CheckOrderClass::STATUS_DRAFT){
+            util::fail("订单不存在");
+        }
+        $this->saveOrder($post,true,true);
+
+    }
+
+    //编辑草稿, 确认
+    public function actionUpdateOrder()
+    {
+        $post = Yii::$app->request->post();
+        $post['merchantId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        $orderSn = $post['orderSn']??'';
+        $orderData = CheckOrderClass::orderExist($orderSn,$this->shopId);
+        if($orderData['status'] != CheckOrderClass::STATUS_DRAFT){
+            util::fail("订单不存在");
+        }
+        $this->saveOrder($post,false,true);
+    }
+
+    protected function saveOrder($post,$draft=false,$update=false)
+    {
+        $ghsItemInfo = $post['itemInfo']??'';
+        if(empty($ghsItemInfo)){
+            util::fail('请选择花材');
+        }
+        $ghsItemInfo = json_decode($ghsItemInfo,true); // [{productId:0,bigNum:1,smallNum:0}]
+        if(!is_array($ghsItemInfo)){
+            util::fail('花材格式不正确');
+        }
+        //判断花材格式,是否属于当前门店
+        ProductClass::valid($ghsItemInfo,$this->shopId);
+        $post['itemInfo'] = $ghsItemInfo;
+        if($update===true){
+            //编辑
+            $order = CheckOrderClass::opOrder($post,$draft,$update);
+        }else{
+            $order = CheckOrderClass::opOrder($post,$draft,$update);
+        }
+
+        if($order){
+            util::success($order);
+        }else{
+            util::fail();
+        }
+    }
+
+
+}