CategoryController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\custom\classes\CustomClass;
  4. use bizHd\goods\classes\GoodsCategoryClass;
  5. use bizMall\goods\services\CategoryService;
  6. use bizMall\goods\services\GoodsCategoryService;
  7. use Yii;
  8. use common\components\util;
  9. class CategoryController extends BaseController
  10. {
  11. public $guestAccess = ['list']; // 'goods-list' ---- 为什么不用认证
  12. //获取分类 ssh 2019.12.2
  13. public function actionList()
  14. {
  15. $user = $this->user;
  16. if (empty($user)) {
  17. util::success([]);
  18. }
  19. //普莲花艺、叶上花、丰行、小武鲜花、九江云朵、源花汇、紫荆不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
  20. $mainId = $this->mainId;
  21. if (getenv('YII_ENV') == 'production') {
  22. if (in_array($mainId, [40057, 7779, 42940, 26374, 10536, 65381])) {
  23. util::fail('暂无商品哦,编号25395');
  24. }
  25. } else {
  26. if (in_array($mainId, [0, 1])) {
  27. util::fail('暂无商品哦!编号639942');
  28. }
  29. }
  30. //建立客户关系
  31. CustomClass::buildRelation($this->shop, $this->user);
  32. $mainId = $this->mainId ?? 0;
  33. $where = ['mainId' => $mainId, 'delStatus' => 0, 'status' => 1];
  34. //默认列出正常分类,美团等第三方分类不列表
  35. $where['style'] = 0;
  36. $return = CategoryService::getAllCategory($where);
  37. util::success($return);
  38. }
  39. //取分类下商品 ssh 2019.12.2
  40. public function actionGoodsList()
  41. {
  42. $user = $this->user;
  43. if (empty($user)) {
  44. util::success(['list' => []]);
  45. }
  46. $get = Yii::$app->request->get();
  47. $shop = $this->shop;
  48. $custom = $this->custom;
  49. $params = [];
  50. //调用花店端的方法,后面再分离
  51. $data = GoodsCategoryClass::getGoodsList($get, $shop, $custom, $params);
  52. util::success($data);
  53. }
  54. }