CategoryController.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace mall\controllers;
  3. use bizMall\goods\services\CategoryService;
  4. use bizMall\goods\services\GoodsCategoryService;
  5. use Yii;
  6. use yii\web\Controller;
  7. use common\components\util;
  8. class CategoryController extends BaseController
  9. {
  10. //获取分类 ssh 2019.12.2
  11. public function actionList()
  12. {
  13. $return = CategoryService::getEnableList($this->mainId);
  14. util::success($return);
  15. }
  16. //取分类下商品 ssh 2019.12.2
  17. public function actionGoodsList()
  18. {
  19. $categoryId = Yii::$app->request->get('categoryId');
  20. if (empty($categoryId)) {
  21. util::fail('没有找到分类');
  22. }
  23. $where = [];
  24. $where['mainId'] = $this->mainId;
  25. $where['cId'] = $categoryId;
  26. $where['delStatus'] = 0;
  27. $where['status'] = 1;
  28. $shop = $this->shop;
  29. $stockModel = $shop->stockModel ?? 0;
  30. if ($stockModel == 1) {
  31. //管到支的,查看所有上架并且花材数量设置好的商品
  32. $where['setItemNum'] = 1;
  33. }
  34. $data = GoodsCategoryService::getGoodsList($where);
  35. util::success($data);
  36. }
  37. }