Browse Source

所有花材

shish 4 years ago
parent
commit
244137002f
2 changed files with 43 additions and 31 deletions
  1. 43 22
      app-ghs/controllers/ProductController.php
  2. 0 9
      biz-ghs/product/classes/ProductClass.php

+ 43 - 22
app-ghs/controllers/ProductController.php

@@ -23,8 +23,7 @@ class ProductController extends BaseController
 
     public $guestAccess = ['index'];
 
-    //开单时获取所有的分类花材信息
-    //库存预警
+    //按分类列出所有花材
     public function actionIndex()
     {
         $py = Yii::$app->request->get('py', '');
@@ -76,7 +75,7 @@ class ProductController extends BaseController
         util::success($data);
     }
 
-    //当前门店所有花材
+    //所有花材分页和不分页
     public function actionList()
     {
         $where = [];
@@ -143,33 +142,55 @@ class ProductController extends BaseController
             $respond['list'] = ProductClass::groupProductInfo($respond['list'], $level);
             $respond['list'] = ProductClass::groupClassName($this->sjId, $respond['list']);
             util::success($respond);
-        }
-        if ($type == 'waring') {
-            //库存预警 按库存从小到大排序
-            $data = ProductClass::getAllByCondition($where, ['stock' => SORT_ASC, 'inTurn' => SORT_DESC], "*");
         } else {
-            if (!empty($productIds)) {
-                //优先按 $productIds 排序 "FIELD(`id`,4,5,6)"=>true
-                $data = ProductClass::getAllByCondition($where, ["FIELD(`id`,$productIds)" => true, 'inTurn' => SORT_DESC], "*");
+            if ($type == 'waring') {
+                //库存预警 按库存从小到大排序
+                $data = ProductClass::getAllByCondition($where, ['stock' => SORT_ASC, 'inTurn' => SORT_DESC], "*");
             } else {
-                $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
-            }
+                if (!empty($productIds)) {
+                    //优先按 $productIds 排序 "FIELD(`id`,4,5,6)"=>true
+                    $data = ProductClass::getAllByCondition($where, ["FIELD(`id`,$productIds)" => true, 'inTurn' => SORT_DESC], "*");
+                } else {
+                    $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
+                }
 
-        }
+            }
 
-        $data = ProductClass::groupProductInfo($data, $level);
-        $data = ProductClass::groupClassName($this->sjId, $data);
+            $data = ProductClass::groupProductInfo($data, $level);
+            $data = ProductClass::groupClassName($this->sjId, $data);
 
-        if ($type == 'waring') {
-            //库存预警
-            $newData = [];
-            foreach ($data as $v) {
-                if ($v['stock'] <= $v['stockWarning']) {
-                    $newData[] = $v;
+            if ($type == 'waring') {
+                //库存预警
+                $newData = [];
+                foreach ($data as $v) {
+                    if ($v['stock'] <= $v['stockWarning']) {
+                        $newData[] = $v;
+                    }
                 }
+                util::success(['list' => $newData]);
             }
-            util::success(['list' => $newData]);
+            util::success(['list' => $data]);
         }
+    }
+
+    //所有花材
+    public function actionAll()
+    {
+        $where = [];
+        $where['sjId'] = $this->sjId;
+        $where['shopId'] = $this->shopId;
+        $status = Yii::$app->request->get('status', 0);
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        $delStatus = Yii::$app->request->get('delStatus', 0);
+        if ($delStatus != 2) {
+            $where['delStatus'] = $delStatus;
+        }
+        //输出标准会员价,即花店价,默认显示的是花店价
+        $level = 1;
+        $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
+        $data = ProductClass::groupProductInfo($data, $level);
         util::success(['list' => $data]);
     }
 

+ 0 - 9
biz-ghs/product/classes/ProductClass.php

@@ -950,21 +950,12 @@ class ProductClass extends BaseClass
     //补className
     public static function groupClassName($sjId, $data)
     {
-        //补className
-        //获取当前商家下所有itemId=>classId
-//        $itemInfo = ItemClass::getGhsItemAll($sjId, "itemId,classId");
-//        $itemClassMap = [];
-//        foreach ($itemInfo as $v) {
-//            $itemClassMap[$v['itemId']] = $v['classId'];
-//        }
-        //获取classId=>name
         $itemClassInfo = ItemClassClass::getAll($sjId, "id,name");
         $classNameMap = [];
         foreach ($itemClassInfo as $v) {
             $classNameMap[$v['id']] = $v['name'];
         }
         foreach ($data as $k => $v) {
-            //$itemId = $v['itemId'];
             $classId = $v['classId'];
             $className = $classNameMap[$classId] ?? '';
             $v['className'] = $className;