Эх сурвалжийг харах

新增花材控制器 ItemController

shizhongqi 4 жил өмнө
parent
commit
593d77efa7

+ 46 - 0
app-mall/controllers/ItemController.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace mall\controllers;
+
+use bizGhs\item\classes\ItemClassClass;
+use bizGhs\product\classes\ProductClass;
+use bizGhs\product\services\ProductService;
+use common\components\util;
+use Yii;
+
+class ItemController extends BaseController
+{
+    public function actionIndex()
+    {
+        $py = Yii::$app->request->get('py', '');
+        //默认显示上架商品
+        $status = Yii::$app->request->get('status', 1);
+        //默认显示未删除商品
+        $delStatus = Yii::$app->request->get('delStatus', 0);
+
+        //获取所有当前供应商的分类 (全部、常用)
+        //根据分类组装分类下的花材信息
+        //中央ID
+        $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
+
+        $where['mainId'] = $this->mainId;
+        if ($py) {
+            $pyName = strtolower($py);
+            $where['py'] = $pyName;
+        }
+
+
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        $where['delStatus'] = $delStatus;
+
+        $level = 0;
+        $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
+        $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
+
+        $data = ProductService::assembleData($classIds, $itemInfoData, true);
+
+        util::success($data);
+    }
+}