CategoryController.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\custom\classes\CustomClass;
  4. use bizMall\goods\services\CategoryService;
  5. use Yii;
  6. use common\components\util;
  7. class CategoryController extends BaseController
  8. {
  9. public $guestAccess = ['list']; // 'goods-list' ---- 为什么不用认证
  10. //获取分类 ssh 2019.12.2
  11. public function actionList()
  12. {
  13. $user = $this->user;
  14. if (empty($user)) {
  15. util::success([]);
  16. }
  17. $get = Yii::$app->request->get();
  18. $flower = $get['flower'] ?? -1;
  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. if ($flower > -1) {
  35. $where['flower'] = $flower;
  36. }
  37. //默认列出正常分类,美团等第三方分类不列表
  38. $where['style'] = 0;
  39. $return = CategoryService::getAllCategory($where);
  40. util::success($return);
  41. }
  42. //取分类下商品 ssh 2019.12.2
  43. public function actionGoodsList()
  44. {
  45. $user = $this->user;
  46. if (empty($user)) {
  47. util::success(['list' => []]);
  48. }
  49. $get = Yii::$app->request->get();
  50. $shop = $this->shop;
  51. $custom = $this->custom;
  52. $params = [];
  53. //调用花店端的方法,后面再分离 (为了代码维护可以不分离,免得一处改了,另一处没修改到。--- 所以分离好后,又还原了)
  54. $data = \bizHd\goods\classes\GoodsCategoryClass::getGoodsList($get, $shop, $custom, $params);
  55. util::success($data);
  56. }
  57. }