shish преди 10 месеца
родител
ревизия
e44440cbf1

+ 1 - 19
app-ghs/controllers/GoodsController.php

@@ -23,25 +23,7 @@ class GoodsController extends BaseController
     //商品列表 ssh 2019.12.7
     public function actionList()
     {
-        $get = Yii::$app->request->get();
-        $status = isset($get['status']) ? $get['status'] : -1;
-        $name = isset($get['name']) && !empty($get['name']) ? $get['name'] : '';
-        $where = [];
-        if ($status != -1) {
-            $where['status'] = $status;
-        }
-        if (!empty($name)) {
-            $where['name'] = ['like', $name];
-        }
-        if (isset($get['cId']) && $get['cId'] != -1) {
-            $where['cId'] = $get['cId'];
-        }
-        $where['sjId'] = $this->sjId;
-        $where['delStatus'] = 0;
-        $data = GoodsService::getGoodsList($where);
-        $asset = MerchantAssetService::getBySjId($this->sjId);
-        $data['MerchantAsset'] = $asset;
-        util::success($data);
+
     }
 
     //商品排序 ssh 2020.3.11

+ 8 - 27
app-hd/controllers/GoodsController.php

@@ -114,36 +114,17 @@ class GoodsController extends BaseController
     public function actionList()
     {
         $get = Yii::$app->request->get();
-        $status = isset($get['status']) && is_numeric($get['status']) ? $get['status'] : -1;
         $cId = isset($get['cId']) ? intval($get['cId']) : 0;
-        $name = isset($get['name']) && !empty($get['name']) ? $get['name'] : '';
-        $flowerNum = isset($get['flowerNum']) && $get['flowerNum'] > 0 ? $get['flowerNum'] : 0;
-        //$flower = isset($get['flower']) ? $get['flower'] : '';
-        $hasStock = isset($get['hasStock']) ? $get['hasStock'] : 0;
-
-        $where = [];
-        if ($status != -1) {
-            $where['status'] = $status;
-        }
-        if (!empty($name)) {
-            $where['name'] = ['like', $name];
-        }
+        $shop = $this->shop;
+        $custom = $this->custom;
+        $argument = [];
         if (!empty($cId)) {
-            $where['cId'] = $cId;
+            $argument['catId'] = $cId;
         }
-        $where['mainId'] = $this->mainId;
-        $where['delStatus'] = 0;
-        if ($flowerNum > 0) {
-            $where['flowerNum'] = $flowerNum;
-        }
-        // 需求变动:不再用 flower 做区分
-        //if (is_numeric($flower)) {
-        //$where['flower'] = $flower;
-        //}
-        if ($hasStock == 1) {
-            $where['stock>'] = 0;
-        }
-        $data = GoodsService::getGoodsList($where);
+        $argument['pageSize'] = 20;
+        $argument['requestType'] = 'goodsList';
+        $data = GoodsCategoryClass::getGoodsList($argument, $shop, $custom);
+
         util::success($data);
     }
 

+ 1 - 5
app-pt/controllers/GoodsController.php

@@ -16,11 +16,7 @@ class GoodsController extends BaseController
     //商品列表 ssh 2019.12.7
     public function actionList()
     {
-        $where = [];
-        $data = GoodsService::getGoodsList($where);
-        $asset = RetailAssetService::getAsset();
-        $data['RetailAsset'] = $asset;
-        util::success($data);
+
     }
 
     //排序

+ 3 - 3
biz-hd/goods/classes/GoodsCategoryClass.php

@@ -49,7 +49,7 @@ class GoodsCategoryClass extends BaseClass
 
                 $query->andWhere(['xhGoods.delStatus' => 0]);
 
-                $priceStatus = is_numeric($askInfo['priceStatus']) ? $askInfo['priceStatus'] : -1;
+                $priceStatus = isset($askInfo['priceStatus']) && is_numeric($askInfo['priceStatus']) ? $askInfo['priceStatus'] : -1;
                 if ($priceStatus > -1) {
                     //1 有价格,2 无价格
                     if ($priceStatus == 1) {
@@ -60,7 +60,7 @@ class GoodsCategoryClass extends BaseClass
                     }
                 }
 
-                $stockStatus = is_numeric($askInfo['stockStatus']) ? $askInfo['stockStatus'] : -1;
+                $stockStatus = isset($askInfo['stockStatus']) && is_numeric($askInfo['stockStatus']) ? $askInfo['stockStatus'] : -1;
                 if ($stockStatus > -1) {
                     //1 有库存,2 无库存
                     if ($stockStatus == 1) {
@@ -71,7 +71,7 @@ class GoodsCategoryClass extends BaseClass
                     }
                 }
 
-                $flowerNum = is_numeric($askInfo['flowerNum']) ? $askInfo['flowerNum'] : 0;
+                $flowerNum = isset($askInfo['flowerNum']) && is_numeric($askInfo['flowerNum']) ? $askInfo['flowerNum'] : 0;
                 if ($flowerNum > 0) {
                     $query->andWhere(['xhGoods.flowerNum' => $flowerNum]);
                 }

+ 6 - 4
biz-hd/goods/services/GoodsService.php

@@ -16,7 +16,7 @@ class GoodsService extends BaseService
     public static $baseFile = '\bizHd\goods\classes\GoodsClass';
 
     //商品列表
-    public static function getGoodsList($where)
+    public static function getGoodsList($where, $shop)
     {
         $page = Yii::$app->request->get('page', 1);
         $pageSize = Yii::$app->request->get('pageSize', 20);
@@ -26,11 +26,13 @@ class GoodsService extends BaseService
             return self::getCategoryGoodsList($where, $page, $pageSize);
         } else {
             $data = GoodsClass::getList('*', $where, 'updateTime DESC');
-            $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+            $list = !empty($data['list']) ? $data['list'] : [];
             if (empty($list)) {
                 return $data;
             }
-            $data['list'] = GoodsClass::groupGoodsBaseInfo($list);
+            $custom = [];
+            $params = [];
+            $data['list'] = GoodsClass::groupGoodsBaseInfo($list, $shop, $custom, $params);
             return $data;
         }
     }
@@ -120,7 +122,7 @@ class GoodsService extends BaseService
     {
         // 构建基础查询
         $query = GoodsCategory::find()
-            ->joinWith(['goods' => function($query) use ($where) {
+            ->joinWith(['goods' => function ($query) use ($where) {
                 // 商品表的筛选条件
                 if (isset($where['mainId'])) {
                     $query->andWhere(['xhGoods.mainId' => $where['mainId']]);