Browse Source

成品开单(花材列表)

林琦海 5 years ago
parent
commit
55e8263895
1 changed files with 52 additions and 1 deletions
  1. 52 1
      app-hd/controllers/ProductController.php

+ 52 - 1
app-hd/controllers/ProductController.php

@@ -6,8 +6,59 @@
 
 namespace hd\controllers;
 
-
+use bizGhs\admin\classes\AdminClass;
+use bizGhs\item\classes\ItemClass;
+use bizGhs\item\classes\ItemClassClass;
+use bizGhs\product\classes\ProductClass;
+use bizGhs\product\services\ProductService;
+use bizGhs\item\services\ItemService;
+use common\components\noticeUtil;
+use common\components\util;
+use Yii;
 class ProductController extends BaseController
 {
 
+    public function actionIndex()
+    {
+        $py = Yii::$app->request->get('py', '');
+        $type = Yii::$app->request->get('type', '');
+
+        //访问店铺时用户增加最近访问的店铺 ssh 2021.3.1
+        AdminClass::addRecentShop($this->shopId, $this->admin);
+
+        //获取所有当前供应商的分类 (全部、常用)
+        //根据分类组装分类下的花材信息
+        $classIds = ItemClassClass::getGhsItemClassAll($this->sjId);
+
+        $where['merchantId'] = $this->sjId;
+        if ($py) {
+            $pyName = strtolower($py);
+            $where['py'] = $pyName;
+        }
+        $shopId = $this->shopId;
+
+        //库存预警
+        if ($type == 'waring') {
+            //shopId 改为可以前端传,默认是当前shopId linqh  2021.1.26
+            $shopId = Yii::$app->request->get('shopId', 0);
+            if (!$shopId) {
+                $shopId = $this->shopId;
+            }
+        }
+        $where['shopId'] = $shopId;
+
+        $itemInfoData = ProductClass::getAllByCondition($where,null,"*");
+        $itemInfoData = ProductClass::groupProductInfo($itemInfoData);
+        //常用的itemIds
+        $oftenItemIds = ProductClass::getOftenItemIds($shopId);
+        //获取供应商下所有花材ID (itemIds)
+        $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
+
+        //dd($itemInfoData);
+        //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
+        $data = ProductService::assembleData($classIds, $itemIdsInfo,$itemInfoData, $oftenItemIds, $type);
+
+        util::success($data);
+    }
+
 }