CategoryController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\custom\classes\CustomClass;
  4. use bizMall\goods\services\CategoryService;
  5. use bizMall\goods\services\GoodsCategoryService;
  6. use bizMall\user\classes\UserClass;
  7. use Yii;
  8. use yii\web\Controller;
  9. use common\components\util;
  10. class CategoryController extends BaseController
  11. {
  12. //获取分类 ssh 2019.12.2
  13. public function actionList()
  14. {
  15. //建立客户关系
  16. CustomClass::buildRelation($this->shop, $this->user);
  17. $mainId = $this->mainId ?? 0;
  18. $where = ['mainId' => $mainId, 'delStatus' => 0, 'status' => 1];
  19. //默认列出正常分类,美团等第三方分类不列表
  20. $where['style'] = 0;
  21. $return = CategoryService::getAllCategory($where);
  22. util::success($return);
  23. }
  24. //取分类下商品 ssh 2019.12.2
  25. public function actionGoodsList()
  26. {
  27. $categoryId = Yii::$app->request->get('categoryId');
  28. if (empty($categoryId)) {
  29. util::fail('没有找到分类');
  30. }
  31. $where = [];
  32. $where['mainId'] = $this->mainId;
  33. $where['cId'] = $categoryId;
  34. $where['delStatus'] = 0;
  35. $where['status'] = 1;
  36. $shop = $this->shop;
  37. $stockModel = $shop->stockModel ?? 0;
  38. if ($stockModel == 1) {
  39. //管到支的,查看所有上架并且花材数量设置好的商品
  40. $where['setItemNum'] = 1;
  41. }
  42. $data = GoodsCategoryService::getGoodsList($where);
  43. util::success($data);
  44. }
  45. }