| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * Created by PhpStorm.
- * User: shish <shish@zhhinc.com>
- * Date: 2019/6/29
- * Time: 14:27
- */
- namespace mini\controllers;
- use biz\goods\services\CategoryRelateService;
- use biz\goods\services\GoodsCategoryService;
- use biz\goods\services\GoodsUsageService;
- use common\components\util;
- use common\services\xhGoodsService;
- use common\services\xhRecommendService;
- use Yii;
- use yii\helpers\Json;
- class GoodsController extends BaseController
- {
-
- public $withoutLogin = ['get-index-data'];
-
- public function actionGetLimitGoods()
- {
- $list = xhGoodsService::getLimitGoods($this->merchantId);
- util::sendJson($list);
- }
-
- public function actionGetIndexData()
- {
- $slide = xhRecommendService::getSlide($this->merchantId);
- $list = xhGoodsService::getLimitGoods($this->merchantId);
- $categoryData = CategoryRelateService::getShowList(8);
- $chunkData = array_chunk($categoryData, 4);
- $category1 = $chunkData[0];
- $category2 = $chunkData[1];
- //首页第一个分类列表的名称 shish 2019.8.3
- $firstCategoryName = '掌柜推荐';
- //是否显示第一个分类列表的名称 shish 2019.8.3
- $showFirstCategory = 1;
- $data = ['goods' => $list, 'slide' => $slide, 'category1' => $category1,
- 'category2' => $category2, 'firstCategoryName' => $firstCategoryName, 'showFirstCategory' => $showFirstCategory];
- util::sendJson($data);
- }
-
- public function actionGetById()
- {
- $id = Yii::$app->request->get('id', 0);
- $info = xhGoodsService::getById($id);
- $info['shopImg'] = json_decode($info['shopImg'], true);
- util::sendJson($info);
- }
-
- //根据分类取商品列表 shish 2019.7.3
- public function actionGetListByCategory()
- {
- $id = Yii::$app->request->get('categoryId', 0);
- $type = Yii::$app->request->get('type', 'category');
- if ($type == 'category') {
- $return = GoodsCategoryService::getGoodsList($id);
- } else {
- $return = GoodsUsageService::getGoodsData($id);
- }
- util::sendJson($return);
- }
- }
|