Kaynağa Gözat

商城显示花材

shish 4 yıl önce
ebeveyn
işleme
96c137fda6

+ 6 - 1
app-mall/controllers/BaseController.php

@@ -7,6 +7,7 @@ use biz\sj\classes\SjClass;
 use bizHd\custom\classes\CustomClass;
 use bizMall\merchant\services\MerchantExtendService;
 use bizMall\merchant\services\MerchantService;
+use bizMall\shop\classes\MainClass;
 use bizMall\user\classes\UserClass;
 use bizMall\user\services\UserService;
 use common\components\dict;
@@ -22,7 +23,7 @@ class BaseController extends PublicController
     public $validate = true;
     public $guestAccess = [];
     public $userId = 0, $user, $shopId, $shop;
-    public $sjId, $sj, $sjExtend, $customId = 0, $custom = [];
+    public $sjId, $sj, $sjExtend, $customId = 0, $custom = [], $mainId = 0, $main = [];
     public $isWx;
 
     public function beforeAction($action)
@@ -35,6 +36,10 @@ class BaseController extends PublicController
         if (!empty($shopId)) {
             $shop = ShopClass::getById($shopId, true);
             if (!empty($shop)) {
+                $mainId = $shop->mainId ?? 0;
+                $main = MainClass::getById($mainId, true);
+                $this->main = $main;
+                $this->mainId = $mainId;
                 $this->shop = $shop;
                 $sjId = $shop->sjId ?? 0;
                 $this->sjId = $sjId;

+ 22 - 22
app-mall/controllers/CategoryController.php

@@ -10,26 +10,26 @@ use common\components\util;
 
 class CategoryController extends BaseController
 {
-	
-	//获取分类 ssh 2019.12.2
-	public function actionList()
-	{
-		$return = CategoryService::getEnableList($this->sjId);
-		util::success($return);
-	}
-	
-	//取分类下商品 ssh 2019.12.2
-	public function actionGoodsList()
-	{
-		$categoryId = Yii::$app->request->get('categoryId');
-		//没有分类默认取商家第一个分类
-		$categoryId = !empty($categoryId) ? $categoryId : CategoryService::getTopCategoryId($this->sjId);
-		$where = [];
-		$where['sjId'] = $this->sjId;
-		$where['cId'] = $categoryId;
-		$where['delStatus'] = 0;
-		$data = GoodsCategoryService::getGoodsList($where);
-		util::success($data);
-	}
-	
+
+    //获取分类 ssh 2019.12.2
+    public function actionList()
+    {
+        $return = CategoryService::getEnableList($this->mainId);
+        util::success($return);
+    }
+
+    //取分类下商品 ssh 2019.12.2
+    public function actionGoodsList()
+    {
+        $categoryId = Yii::$app->request->get('categoryId');
+        //没有分类默认取商家第一个分类
+        $categoryId = !empty($categoryId) ? $categoryId : CategoryService::getTopCategoryId($this->mainId);
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        $where['cId'] = $categoryId;
+        $where['delStatus'] = 0;
+        $data = GoodsCategoryService::getGoodsList($where);
+        util::success($data);
+    }
+
 }

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

@@ -13,7 +13,7 @@ class MainController extends BaseController
     //首页 ssh 2019.12.2
     public function actionIndex()
     {
-        $where = ['sjId' => $this->sjId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
+        $where = ['mainId' => $this->mainId, 'type' => 0, 'status' => 1, 'delStatus' => 0];
         $adRespond = AdService::getAdList($where);
         $ad = [];
         if (isset($adRespond['list']) && !empty($adRespond['list'])) {
@@ -21,7 +21,7 @@ class MainController extends BaseController
                 $ad[] = ['adImg' => $single['adImgUrl'], 'url' => ''];
             }
         }
-        $category = CategoryService::getTopThreeCategory($this->sjId);
+        $category = CategoryService::getTopThreeCategory($this->mainId);
         $categoryList = !empty($category) ? GoodsCategoryService::getAppointCategoryList($category) : [];
         $sj = $this->sj->attributes;
         $data = [

+ 6 - 6
biz-mall/goods/services/CategoryService.php

@@ -30,9 +30,9 @@ class CategoryService extends BaseService
     }
 
     //取出可用的分类 ssh 2019.12.2
-    public static function getEnableList($sjId)
+    public static function getEnableList($mainId)
     {
-        $cat = CategoryClass::getAllByCondition(['sjId' => $sjId, 'delStatus' => 0, 'status' => 1], 'inTurn DESC', '*');
+        $cat = CategoryClass::getAllByCondition(['mainId' => $mainId, 'delStatus' => 0, 'status' => 1], 'inTurn DESC', '*');
         if (empty($cat)) {
             return [];
         }
@@ -59,17 +59,17 @@ class CategoryService extends BaseService
 
 
     //获取商家最靠前的分类id ssh 2019.12.2
-    public static function getTopCategoryId($sjId)
+    public static function getTopCategoryId($mainId)
     {
-        $cat = CategoryClass::getByCondition(['sjId' => $sjId, 'delStatus' => 0, 'status' => 1], false, 'inTurn DESC');
+        $cat = CategoryClass::getByCondition(['mainId' => $mainId, 'delStatus' => 0, 'status' => 1], false, 'inTurn DESC');
         $id = isset($cat['id']) ? $cat['id'] : 0;
         return $id;
     }
 
     //获取前三个分类信息 ssh 2019.12.2
-    public static function getTopThreeCategory($sjId)
+    public static function getTopThreeCategory($mainId)
     {
-        $cat = CategoryClass::getLimitList('id,categoryName', ['sjId' => $sjId, 'delStatus' => 0, 'status' => 1], 3, 'inTurn DESC');
+        $cat = CategoryClass::getLimitList('id,categoryName', ['mainId' => $mainId, 'delStatus' => 0, 'status' => 1], 3, 'inTurn DESC');
         if (empty($cat)) {
             return [];
         }

+ 18 - 0
biz-mall/shop/classes/MainClass.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace bizMall\shop\classes;
+
+use bizMall\base\classes\BaseClass;
+
+class MainClass extends BaseClass
+{
+
+    public static $baseFile = '\bizMall\shop\models\Main';
+
+    //创建main
+    public static function addMain()
+    {
+        return self::add(['id' => null], true);
+    }
+
+}

+ 13 - 0
biz-mall/shop/classes/ShopClass.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizMall\shop\classes;
+
+use Yii;
+use bizMall\base\classes\BaseClass;
+
+class ShopClass extends BaseClass
+{
+
+    public static $baseFile = '\bizMall\shop\models\Shop';
+
+}

+ 13 - 0
biz-mall/shop/models/Main.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizMall\shop\models;
+use bizMall\base\models\Base;
+
+class Main extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhMain';
+    }
+
+}

+ 13 - 0
biz-mall/shop/models/Shop.php

@@ -0,0 +1,13 @@
+<?php
+namespace bizMall\shop\models;
+use bizMall\base\models\Base;
+
+class Shop extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhShop';
+    }
+
+}

+ 13 - 0
biz-mall/shop/services/MainService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizMall\stat\services;
+
+use bizMall\base\services\BaseService;
+use Yii;
+
+class MainService extends BaseService
+{
+
+    public static $baseFile = '\bizMall\shop\classes\MainClass';
+
+}

+ 13 - 0
biz-mall/shop/services/ShopService.php

@@ -0,0 +1,13 @@
+<?php
+
+namespace bizMall\stat\services;
+
+use bizMall\base\services\BaseService;
+use Yii;
+
+class ShopService extends BaseService
+{
+
+    public static $baseFile = '\bizMall\shop\classes\ShopClass';
+
+}