Ver código fonte

分类接口

shish 6 anos atrás
pai
commit
ba37478596

+ 4 - 1
app/client/controllers/BaseController.php

@@ -2,6 +2,7 @@
 
 
 namespace client\controllers;
 namespace client\controllers;
 
 
+use Yii;
 use biz\merchant\services\MerchantExtendService;
 use biz\merchant\services\MerchantExtendService;
 use biz\merchant\services\MerchantService;
 use biz\merchant\services\MerchantService;
 use biz\user\services\UserService;
 use biz\user\services\UserService;
@@ -42,7 +43,9 @@ class BaseController extends PublicController
 		$this->merchantId = $account;
 		$this->merchantId = $account;
 		$this->merchant = $merchant;
 		$this->merchant = $merchant;
 		$this->merchantExtend = MerchantExtendService::getByMerchantId($account);
 		$this->merchantExtend = MerchantExtendService::getByMerchantId($account);
-		
+		Yii::$app->params['merchantId'] = $account;
+		Yii::$app->params['merchant'] = $merchant;
+
 		$this->isWeixin = util::isWeixin();
 		$this->isWeixin = util::isWeixin();
 		
 		
 		if (empty($userId)) {
 		if (empty($userId)) {

+ 6 - 2
app/client/controllers/CategoryController.php

@@ -9,8 +9,12 @@ use common\components\util;
 
 
 class CategoryController extends BaseController
 class CategoryController extends BaseController
 {
 {
-	public function actionMenu()
+
+	//获取分类 shish 2019.12.2
+	public function actionGetList()
 	{
 	{
-	
+		$return = CategoryService::getEnableList();
+		util::success($return);
 	}
 	}
+
 }
 }

+ 12 - 10
biz/goods/services/CategoryService.php

@@ -12,18 +12,20 @@ class CategoryService extends BaseService
 	
 	
 	public static $baseFile = '\biz\goods\classes\CategoryClass';
 	public static $baseFile = '\biz\goods\classes\CategoryClass';
 	
 	
-	//取出要在首页显示的所有分类
-	public static function getIndexShow()
+	//取出可用的分类 shish 2019.12.2
+	public static function getEnableList()
 	{
 	{
 		$merchantId = Yii::$app->params['merchantId'];
 		$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]);
+		$cat = CategoryClass::getAllByCondition(['merchantId' => $merchantId], 'inTurn DESC', '*');
+		if (empty($cat)) {
+			return [];
+		}
+		//处理图片
+		$prefix = Yii::$app->params['imgUrl'];
+		foreach ($cat as $key => $info) {
+			$cat[$key]['cover'] = $prefix . $info['cover'];
+		}
+		return $cat;
 	}
 	}
 	
 	
 }
 }

+ 3 - 0
sql.txt

@@ -12,6 +12,9 @@ ALTER TABLE xhGoodsCategory ADD INDEX merchantId(merchantId);
 ALTER TABLE xhCategory DROP COLUMN `indexShow`;
 ALTER TABLE xhCategory DROP COLUMN `indexShow`;
 ALTER TABLE xhCategory DROP COLUMN `menuShow`;
 ALTER TABLE xhCategory DROP COLUMN `menuShow`;
 ALTER TABLE xhCategory ADD `status` TINYINT NOT NULL DEFAULT 0 COMMENT '状态 0停用1启用';
 ALTER TABLE xhCategory ADD `status` TINYINT NOT NULL DEFAULT 0 COMMENT '状态 0停用1启用';
+ALTER TABLE xhCategory DROP INDEX `indexShow`;
+ALTER TABLE xhCategory DROP INDEX `menuShow`;
+ALTER TABLE xhCategory ADD INDEX merchantId(merchantId,`status`);
 
 
 2019.12.2 13:00 shish 广告管理
 2019.12.2 13:00 shish 广告管理
 DROP TABLE IF EXISTS xhAd;
 DROP TABLE IF EXISTS xhAd;