CategoryController.php 1.3 KB

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