CategoryController.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. //普莲花艺、叶上花、丰行、小武鲜花、九江云朵、源花汇、紫荆不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
  16. $mainId = $this->mainId;
  17. if (getenv('YII_ENV') == 'production') {
  18. if (in_array($mainId, [40057, 7779, 42940, 26374,10536, 65381])) {
  19. util::fail('暂无商品哦,编号25395');
  20. }
  21. } else {
  22. if (in_array($mainId, [0, 1])) {
  23. util::fail('暂无商品哦!编号639942');
  24. }
  25. }
  26. //建立客户关系
  27. CustomClass::buildRelation($this->shop, $this->user);
  28. $mainId = $this->mainId ?? 0;
  29. $where = ['mainId' => $mainId, 'delStatus' => 0, 'status' => 1];
  30. //默认列出正常分类,美团等第三方分类不列表
  31. $where['style'] = 0;
  32. $return = CategoryService::getAllCategory($where);
  33. util::success($return);
  34. }
  35. //取分类下商品 ssh 2019.12.2
  36. public function actionGoodsList()
  37. {
  38. $categoryId = Yii::$app->request->get('categoryId');
  39. if (empty($categoryId)) {
  40. util::fail('没有找到分类');
  41. }
  42. $where = [];
  43. $where['mainId'] = $this->mainId;
  44. $where['cId'] = $categoryId;
  45. $where['delStatus'] = 0;
  46. $where['status'] = 1;
  47. $shop = $this->shop;
  48. $stockModel = $shop->stockModel ?? 0;
  49. if ($stockModel == 1) {
  50. //管到支的,查看所有上架并且花材数量设置好的商品
  51. $where['setItemNum'] = 1;
  52. }
  53. $data = GoodsCategoryService::getGoodsList($where);
  54. util::success($data);
  55. }
  56. }