Ver Fonte

分类再优化

shish há 6 anos atrás
pai
commit
1d476a4d20

+ 16 - 0
app/client/controllers/CategoryController.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace client\controllers;
+
+use biz\goods\services\CategoryService;
+use Yii;
+use yii\web\Controller;
+use common\components\util;
+
+class CategoryController extends BaseController
+{
+	public function actionMenu()
+	{
+	
+	}
+}

+ 14 - 2
app/client/controllers/MainController.php

@@ -2,18 +2,30 @@
 
 namespace client\controllers;
 
+use biz\goods\services\CategoryService;
 use Yii;
 use yii\web\Controller;
 use common\components\util;
 
 class MainController extends BaseController
 {
-
+	//首页 shish 2019.12.2
 	public function actionIndex()
 	{
-		$ad = ['']
+		$ad = [
+			['adImg' => 'http://img.fjglhs.com/images/glhs/glhs_banner1.jpg', 'url' => 'http://www.baidu.com'],
+			['adImg' => 'http://img.fjglhs.com/images/glhs/glhs_banner2.jpg', 'url' => 'http://www.baidu.com'],
+			['adImg' => 'http://img.fjglhs.com/images/glhs/glhs_banner3.jpg', 'url' => 'http://www.baidu.com'],
+		];
 		$data = [];
 		util::success($data);
 	}
 
+	//取分类 shish 2019.12.2
+	public function actionGetCategory()
+	{
+		$menu = CategoryService::getMenu();
+		util::success($menu);
+	}
+
 }

+ 17 - 1
biz/goods/classes/GoodsClass.php

@@ -6,7 +6,23 @@ use biz\base\classes\BaseClass;
 
 class GoodsClass extends BaseClass
 {
-	
+
 	public static $baseFile = '\biz\goods\models\Goods';
 
+	//获取商品列表完全信息 shish 2019.12.2
+	public static function getGoodsInfoList($list)
+	{
+	
+	}
+	
+	public static function groupByInfoList($list)
+	{
+	
+	}
+	
+	public static function getInfo($id)
+	{
+	
+	}
+
 }

+ 15 - 3
biz/goods/services/CategoryService.php

@@ -1,17 +1,29 @@
 <?php
+
 namespace biz\goods\services;
+
 use biz\base\services\BaseService;
+use biz\goods\classes\CategoryClass;
 use Yii;
 use linslin\yii2\curl;
+
 class CategoryService extends BaseService
 {
 	
 	public static $baseFile = '\biz\goods\classes\CategoryClass';
 	
-	//取出平台所有的分类 shish 2019.8.30
-	public static function getAllCategory()
+	//取出要在首页显示的所有分类
+	public static function getIndexShow()
 	{
-		return self::getAllByCondition(['parentId'=>0],'inTurn desc','*','id');
+		$merchantId = Yii::$app->params['merchantId'];
+		$all = CategoryClass::getAllByCondition(['merchantId' => $merchantId, 'indexShow' => 1]);
 	}
 
+	//取菜单分类 shish 2019.12.2
+	public static function getMenu()
+	{
+		$merchantId = Yii::$app->params['merchantId'];
+		return CategoryClass::getAllByCondition(['merchantId' => $merchantId, 'menuShow' => 1]);
+	}
+	
 }

+ 17 - 12
biz/goods/services/GoodsCategoryService.php

@@ -4,6 +4,7 @@ namespace biz\goods\services;
 
 use biz\base\services\BaseService;
 
+use biz\goods\classes\GoodsCategoryClass;
 use Yii;
 use linslin\yii2\curl;
 
@@ -11,7 +12,7 @@ class GoodsCategoryService extends BaseService
 {
 	
 	public static $baseFile = '\biz\goods\classes\GoodsCategoryClass';
-
+	
 	//分页取分类下的商品,包括商品明细 shish 2019.8.28
 	public static function getGoodsList($categoryId)
 	{
@@ -25,11 +26,7 @@ class GoodsCategoryService extends BaseService
 		$goodsList = [];
 		if (!empty($ids)) {
 			$goodsList = GoodsService::getByIds($ids);
-			//$lazyShow 0 显示默认图 1显示原图
-			$lazyShow = Yii::$app->params['page'] == 1 ? 1 : 0;
 			foreach ($goodsList as $key => $val) {
-				//图片懒加载参数,看不见的页面显示默认图片
-				$goodsList[$key]['lazyShow'] = $lazyShow;
 				//取出较小的封面图 shish 2019.8.3
 				$url = $val['cover'];
 				$pos = strrpos($url, '.');
@@ -42,14 +39,22 @@ class GoodsCategoryService extends BaseService
 		$return['list'] = $goodsList;
 		return $return;
 	}
-	
-	//取分类的名称和商品列表 shish 2019.7.9
-	public static function getCategoryAndList($id)
+
+	//取出商家分类下的商品id
+	public static function getCategoryIdList()
 	{
-		$category = CategoryRelateService::getById($id);
-		Yii::$app->params['pageSize'] = 100;
-		$goodsList = self::getGoodsList($id);
-		return ['category' => $category, 'goodsList' => $goodsList['list']];
+		$merchantId = Yii::$app->params['merchantId'];
+		$all = GoodsCategoryClass::getAllByCondition(['merchantId' => $merchantId], 'inTurn DESC');
+		if (empty($all)) {
+			return [];
+		}
+		$ids = [];
+		foreach ($all as $category) {
+			$cId = $category['cId'];
+			$gId = $category['gId'];
+			$ids[$cId][] = $gId;
+		}
+		return $ids;
 	}
 
 }

+ 6 - 0
sql.txt

@@ -6,6 +6,12 @@ ALTER TABLE xhCategory ADD INDEX indexShow(merchantId,indexShow);
 ALTER TABLE xhCategory ADD INDEX menuShow(merchantId,menuShow);
 ALTER TABLE xhAd ADD adImg VARCHAR(800) NOT NULL DEFAULT '' COMMENT '广告图' AFTER adName;
 ALTER TABLE xhAd MODIFY endTime INT NOT NULL DEFAULT 0 COMMENT '结束时间;方便查询,永不过期情况,使用 开始值0 结束值4102416000即2100-01-01 00:00:00';
+ALTER TABLE xhGoodsCategory MODIFY `cId` INT NOT NULL DEFAULT 0 COMMENT '分类id';
+ALTER TABLE xhGoods DROP COLUMN `categoryId`;
+ALTER TABLE xhGoodsCategory ADD INDEX merchantId(merchantId);
+ALTER TABLE xhCategory DROP COLUMN `indexShow`;
+ALTER TABLE xhCategory DROP COLUMN `menuShow`;
+ALTER TABLE xhCategory ADD `status` TINYINT NOT NULL DEFAULT 0 COMMENT '状态 0停用1启用';
 
 2019.12.2 13:00 shish 广告管理
 DROP TABLE IF EXISTS xhAd;