shish 3 سال پیش
والد
کامیت
beee9606b9

+ 9 - 5
app-hd/controllers/CheckOrderController.php

@@ -39,10 +39,7 @@ class CheckOrderController extends BaseController
         $post['sjId'] = $this->sjId;
         $post['shopId'] = $this->shopId;
         $post['adminId'] = $this->adminId;
-        //盘点是否有未处理的草稿,有的话先处理之前的草稿??
-        //todo
         $this->saveOrder($post, false, false);
-
     }
 
     //盘点存草稿 lqh 2021.1.22
@@ -93,12 +90,20 @@ class CheckOrderController extends BaseController
         if (empty($ghsItemInfo)) {
             util::fail('请选择花材');
         }
-        $ghsItemInfo = json_decode($ghsItemInfo, true); // [{productId:0,bigNum:1,smallNum:0}]
+        $ghsItemInfo = json_decode($ghsItemInfo, true);
         if (!is_array($ghsItemInfo)) {
             util::fail('花材格式不正确');
         }
         //判断花材格式,是否属于当前门店
         ProductClass::valid($ghsItemInfo, $this->mainId);
+
+        foreach ($ghsItemInfo as $key => $item) {
+            //如果盘点数是99999则转为0
+            if (isset($item['bigNum']) && $item['bigNum'] == 99999) {
+                $ghsItemInfo[$key]['bigNum'] = 0;
+            }
+        }
+
         $post['itemInfo'] = $ghsItemInfo;
         if ($update === true) {
             //编辑
@@ -106,7 +111,6 @@ class CheckOrderController extends BaseController
         } else {
             $order = CheckOrderClass::opOrder($post, $draft, $update);
         }
-
         if ($order) {
             util::success($order);
         } else {

+ 1 - 1
app-hd/controllers/GoodsController.php

@@ -150,7 +150,7 @@ class GoodsController extends BaseController
         $data['flower'] = $info['flower'] ?? 0;
 
         if (isset($info['spu']) && !empty($info['spu'])) {
-            util::fail('美团商品暂时不能修改,请在美团APP上修改');
+            util::fail('美团商品暂时不能修改');
         }
 
         $connection = Yii::$app->db;

+ 107 - 0
app-hd/controllers/PdGoodsController.php

@@ -0,0 +1,107 @@
+<?php
+
+namespace hd\controllers;
+
+use bizHd\pd\classes\PdGoodsClass;
+use Yii;
+use common\components\util;
+
+class PdGoodsController extends BaseController
+{
+
+    //订单列表 ssh 20230302
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $orderStatus = isset($get['status']) ? $get['status'] : '';
+        $where = [];
+        $where['shopId'] = $this->shopId;
+        if (!empty($orderStatus)) {
+            $where['status'] = $orderStatus;
+        }
+        $list = PdGoodsClass::getPdList($where);
+        util::success($list);
+    }
+
+    //订单详情
+    public function actionDetail()
+    {
+        $orderSn = Yii::$app->request->get('orderSn', '');
+        $orderData = PdGoodsClass::getOrderDetail($orderSn, $this->shopId);
+        util::success($orderData);
+    }
+
+    //盘点确认
+    public function actionCreateOrder()
+    {
+        $post = Yii::$app->request->post();
+        $post['sjId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        $this->saveOrder($post, false, false);
+    }
+
+    //盘点存草稿
+    public function actionCreateDraft()
+    {
+        $post = Yii::$app->request->post();
+        $post['sjId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+
+        $this->saveOrder($post, true, false);
+    }
+
+    //编辑草稿 ,继续保存草稿
+    public function actionUpdateDraft()
+    {
+        $post = Yii::$app->request->post();
+        $post['sjId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        $orderSn = $post['orderSn'] ?? '';
+        $orderData = PdGoodsClass::orderExist($orderSn, $this->shopId);
+        if ($orderData['status'] != PdGoodsClass::STATUS_DRAFT) {
+            util::fail("订单不存在");
+        }
+        $this->saveOrder($post, true, true);
+
+    }
+
+    //编辑草稿, 确认
+    public function actionUpdateOrder()
+    {
+        $post = Yii::$app->request->post();
+        $post['sjId'] = $this->sjId;
+        $post['shopId'] = $this->shopId;
+        $post['adminId'] = $this->adminId;
+        $orderSn = $post['orderSn'] ?? '';
+        $orderData = PdGoodsClass::orderExist($orderSn, $this->shopId);
+        if ($orderData['status'] != PdGoodsClass::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);
+        if (!is_array($ghsItemInfo)) {
+            util::fail('花材格式不正确');
+        }
+        foreach ($ghsItemInfo as $key => $item) {
+            //如果盘点数是99999则转为0
+            if (isset($item['bigNum']) && $item['bigNum'] == 99999) {
+                $ghsItemInfo[$key]['bigNum'] = 0;
+            }
+        }
+        $post['itemInfo'] = $ghsItemInfo;
+        PdGoodsClass::opOrder($post, $draft, $update);
+        util::complete();
+    }
+
+}

+ 27 - 2
biz-hd/goods/classes/GoodsClass.php

@@ -487,8 +487,33 @@ class GoodsClass extends BaseClass
         $data['cover'] = $data['shopImg'][0] ?? '';
         $data['shopImg'] = json_encode($data['shopImg']);
         $data['py'] = $py;
-        //库存不可修改
-        unset($data['stock']);
+
+        //库存可以修改
+        if (isset($data['stock']) && is_numeric($data['stock'])) {
+            $preStock = $info['stock'] ?? 0;
+            if ($data['stock'] != $preStock) {
+                if ($data['stock'] < 0) {
+                    util::fail("库存不能小于0");
+                }
+                if (floor($data['stock']) != $data['stock']) {
+                    util::fail('库存请填写整数');
+                }
+                //增加盘点记录 2021.7.27
+//                $ratio = $product->ratio ?? 0;
+//                $formNum = ProductClass::formatStock($data['stock'], $ratio);
+//                $ghsItemInfo = [['productId' => $product->id, 'bigNum' => $formNum['bigNum'], 'smallNum' => $formNum['smallNum'],]];
+//                $pdData = [];
+//                $pdData['itemInfo'] = $ghsItemInfo;
+//                $pdData['sjId'] = $sjId;
+//                $pdData['shopId'] = $shopId;
+//                $pdData['adminId'] = $data['adminId'];
+//                $pdData['mainId'] = $mainId;
+//                $pdData['staffName'] = $data['staffName'] ?? '';
+//                CheckOrderClass::opOrder($pdData, false, false);
+            }
+            unset($data['stock']);
+        }
+
         self::updateById($id, $data);
 
         $itemList = $data['itemList'] ?? '';

+ 24 - 0
biz-hd/pd/classes/PdGoodsClass.php

@@ -0,0 +1,24 @@
+<?php
+namespace bizHd\pd\classes;
+
+use bizHd\base\classes\BaseClass;
+use Yii;
+
+class PdGoodsClass extends BaseClass
+{
+
+    public static $baseFile = '\bizHd\pd\models\PdGoods';
+
+    public static function getPdList($where)
+    {
+        $data = self::getList('*', $where, 'addTime DESC');
+        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        if (empty($list)) {
+            return $data;
+        }
+        return $data;
+    }
+
+
+
+}

+ 13 - 0
biz-hd/pd/models/PdGoods.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizHd\pd\models;
+use bizHd\base\models\Base;
+
+class PdGoods extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhPdGoods';
+    }
+
+}

+ 10 - 0
biz-hd/pd/services/PdGoodsService.php

@@ -0,0 +1,10 @@
+<?php
+namespace bizHd\pd\services;
+use bizHd\base\services\BaseService;
+
+class PdGoodsService extends BaseService
+{
+
+    public static $baseFile = '\bizHd\pd\classes\PdGoodsClass';
+
+}