shish пре 4 година
родитељ
комит
77b9ca6ee7

+ 0 - 17
app-hd/controllers/MainController.php

@@ -60,23 +60,6 @@ class MainController extends BaseController
         return $this->renderPartial('demo');
     }
 
-    //首页 ssh 2019.12.2
-    public function actionIndex()
-    {
-        $where = ['mainId' => $this->mainId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
-        $adRespond = AdService::getAdList($where);
-        $ad = [];
-        if (isset($adRespond['list']) && !empty($adRespond['list'])) {
-            foreach ($adRespond['list'] as $single) {
-                $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
-            }
-        }
-        $category = CategoryService::getTopThreeCategory($this->mainId);
-        $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
-        $data = ['ad' => $ad, 'category' => $categoryList, 'columnStyle' => rand(1, 2)];
-        util::success($data);
-    }
-
     //新客户 ssh 2019.12.29
     public function actionVisit()
     {

+ 2 - 1
app-mall/controllers/MainController.php

@@ -21,8 +21,9 @@ class MainController extends BaseController
                 $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
             }
         }
+        $shop = $this->shop;
         $category = CategoryService::getTopThreeCategory($this->mainId);
-        $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
+        $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category, $shop) : [];
         $sj = $this->sj->attributes;
         $data = [
             'ad' => $ad,

+ 0 - 47
biz-hd/goods/services/GoodsCategoryService.php

@@ -27,53 +27,6 @@ class GoodsCategoryService extends BaseService
         return $data;
     }
 
-    //查询指定分类下的商品,没有分页,首页使用 ssh 2019.12.2
-    public static function getAppointCategoryList($category)
-    {
-        $ids = array_column($category, 'id');
-        //取出分类下的商品id
-        $list = GoodsCategoryClass::getAllByCondition(['cId' => ['in', $ids]], 'inTurn DESC,addTime DESC', '*');
-        if (empty($list)) {
-            foreach ($category as $key => $val) {
-                $category[$key]['goodsInfoList'] = [];
-            }
-            return $category;
-        }
-        $goodsList = [];
-        $categoryGoods = [];
-        foreach ($list as $val) {
-            $goodsList[] = $val['gId'];
-            $cId = $val['cId'];
-            $categoryGoods[$cId][] = $val['gId'];
-        }
-        //查出商品信息
-        $goodsInfoList = GoodsService::getAllByCondition(['id' => ['in', $goodsList]], 'inTurn DESC', '*', 'id');
-        $goodsInfoList = GoodsClass::groupGoodsBaseInfo($goodsInfoList);
-
-        //每个分类取的商品数
-        $getNum = [6, 2, 4];
-        $showRowNum = [2, 1, 2];
-
-        foreach ($category as $key => $val) {
-            $id = $val['id'];
-            //当前分类下有哪些商品id,并组合商品信息
-            $categoryGoodsIdList = isset($categoryGoods[$id]) ? $categoryGoods[$id] : [];
-            $info = [];
-            if (!empty($categoryGoodsIdList)) {
-                $currentGetNum = isset($getNum[$key]) ? $getNum[$key] : 2;
-                $categoryGoodsIdList = array_slice($categoryGoodsIdList, 0, $currentGetNum);
-                foreach ($categoryGoodsIdList as $currentGoodsId) {
-                    if (isset($goodsInfoList[$currentGoodsId])) {
-                        $info[] = $goodsInfoList[$currentGoodsId];
-                    }
-                }
-            }
-            $category[$key]['goodsInfoList'] = $info;
-            $category[$key]['showRow'] = isset($showRowNum[$key]) ? $showRowNum[$key] : 2;
-        }
-        return $category;
-    }
-
     //获取商品所属的分类id  ssh 201917
     public static function getGoodsHasCategoryIds($goodsId)
     {

+ 11 - 2
biz-mall/goods/services/GoodsCategoryService.php

@@ -28,7 +28,7 @@ class GoodsCategoryService extends BaseService
     }
 
     //查询指定分类下的商品,没有分页,首页使用 ssh 2019.12.2
-    public static function getAppointCategoryList($category)
+    public static function getAppointCategoryList($category, $shop)
     {
         $ids = array_column($category, 'id');
 
@@ -36,8 +36,17 @@ class GoodsCategoryService extends BaseService
         $getNum = [6, 2, 4];
         $showRowNum = [2, 1, 2];
 
+        $stockModel = $shop->stockModel ?? 0;
+        if ($stockModel == 0) {
+            //管到扎的,可以查看所有上架的商品
+            $where = ['cId' => ['in', $ids], 'status' => 1];
+        } else {
+            //管到支的,查看所有上架并且花材数量设置好的商品
+            $where = ['cId' => ['in', $ids], 'status' => 1, 'setItemNum' => 1];
+        }
+
         //取出分类下的商品id
-        $list = GoodsCategoryClass::getAllByCondition(['cId' => ['in', $ids]], 'inTurn DESC,addTime DESC', '*');
+        $list = GoodsCategoryClass::getAllByCondition($where, 'inTurn DESC,addTime DESC', '*');
         if (empty($list)) {
             foreach ($category as $key => $val) {
                 $category[$key]['goodsInfoList'] = [];