StoreSpu.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\store\product;
  12. use app\common\repositories\user\UserHistoryRepository;
  13. use think\App;
  14. use crmeb\basic\BaseController;
  15. use app\common\repositories\store\product\SpuRepository;
  16. class StoreSpu extends BaseController
  17. {
  18. protected $userInfo;
  19. protected $repository;
  20. public function __construct(App $app, SpuRepository $repository)
  21. {
  22. parent::__construct($app);
  23. $this->repository = $repository;
  24. $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null;
  25. }
  26. /**
  27. * TODO 商品搜索列表
  28. * @return mixed
  29. * @author Qinii
  30. * @day 12/24/20
  31. */
  32. public function lst()
  33. {
  34. [$page, $limit] = $this->getPage();
  35. $where = $this->request->params([
  36. 'keyword', 'cate_id', 'cate_pid', 'order', 'price_on', 'price_off', 'brand_id', 'pid','mer_cate_id','product_type','action', 'common'
  37. ]);
  38. $where['is_gift_bag'] = 0;
  39. $where['order'] = $where['order'] ? $where['order'] : 'star';
  40. $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
  41. return app('json')->success($data);
  42. }
  43. /**
  44. * TODO 商户的商品搜索列表
  45. * @param $id
  46. * @return mixed
  47. * @author Qinii
  48. * @day 12/24/20
  49. */
  50. public function merProductLst($id)
  51. {
  52. [$page, $limit] = $this->getPage();
  53. $where = $this->request->params([
  54. 'keyword', 'cate_id','order', 'price_on', 'price_off', 'brand_id', 'pid','mer_cate_id','product_type','action','common'
  55. ]);
  56. $where['mer_id'] = $id;
  57. $where['is_gift_bag'] = 0;
  58. $where['order'] = $where['order'] ? $where['order'] : 'sort';
  59. $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
  60. return app('json')->success($data);
  61. }
  62. /**
  63. * TODO 推荐列表
  64. * @return mixed
  65. * @author Qinii
  66. * @day 12/24/20
  67. */
  68. public function recommend()
  69. {
  70. [$page, $limit] = $this->getPage();
  71. $where = $this->request->params(['common']);
  72. $where['order'] = 'sales';
  73. $where['is_gift_bag'] = 0;
  74. if (!is_null( $this->userInfo)) {
  75. $where['cate_id'] = app()->make(UserHistoryRepository::class)->getRecommend($this->userInfo->uid);
  76. }
  77. $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
  78. return app('json')->success($data);
  79. }
  80. /**
  81. * TODO 热门列表
  82. * @return mixed
  83. * @author Qinii
  84. * @day 12/24/20
  85. */
  86. public function hot($type)
  87. {
  88. [$page, $limit] = $this->getPage();
  89. $where = $this->request->params(['common']);
  90. $where['hot_type'] = $type;
  91. $where['is_gift_bag'] = 0;
  92. $where['order'] = 'star';
  93. $data = $this->repository->getApiSearch($where, $page, $limit, null);
  94. return app('json')->success($data);
  95. }
  96. /**
  97. * TODO 礼包列表
  98. * @return mixed
  99. * @author Qinii
  100. * @day 12/24/20
  101. */
  102. public function bag()
  103. {
  104. [$page, $limit] = $this->getPage();
  105. $where['is_gift_bag'] = 1;
  106. $where['order'] = 'rank';
  107. $data = $this->repository->getApiSearch($where, $page, $limit,null);
  108. return app('json')->success($data);
  109. }
  110. /**
  111. * TODO 礼包推荐列表
  112. * @return mixed
  113. * @author Qinii
  114. * @day 12/24/20
  115. */
  116. public function bagRecommend()
  117. {
  118. [$page, $limit] = $this->getPage();
  119. $where['is_gift_bag'] = 1;
  120. $where['hot_type'] = 'best';
  121. $data = $this->repository->getApiSearch($where, $page, $limit,null);
  122. return app('json')->success($data);
  123. }
  124. /**
  125. * TODO 活动分类
  126. * @param $type
  127. * @return \think\response\Json
  128. * @author Qinii
  129. * @day 1/12/21
  130. */
  131. public function activeCategory($type)
  132. {
  133. $data = $this->repository->getActiveCaategory($type);
  134. return app('json')->success($data);
  135. }
  136. }