GoodsController.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\lists\GoodsLists;
  4. use app\api\logic\GoodsLogic;
  5. use app\api\logic\UserCouponLogic;
  6. use app\api\validate\GoodsValidate;
  7. use app\api\validate\UserCouponValidate;
  8. /**
  9. * 用户控制器
  10. * Class UserController
  11. * @package app\api\controller
  12. */
  13. class GoodsController extends BaseApiController
  14. {
  15. public array $notNeedLogin = ['lists','hotData','categoryDetail','goodsDetail','categoryCouponList'];
  16. public function lists()
  17. {
  18. return $this->dataLists(new GoodsLists());
  19. }
  20. public function hotData(){
  21. $result = GoodsLogic::getHotData();
  22. return $this->data($result);
  23. }
  24. public function categoryDetail()
  25. {
  26. $params = (new GoodsValidate())->goCheck('category');
  27. $result = GoodsLogic::detail($params['goods_category_id'],'category');
  28. return $this->data($result);
  29. }
  30. public function goodsDetail()
  31. {
  32. $params = (new GoodsValidate())->goCheck('goods');
  33. $result = GoodsLogic::detail($params['id'],'goods');
  34. return $this->data($result);
  35. }
  36. //商品优惠卷
  37. public function categoryCouponList()
  38. {
  39. $params = (new UserCouponValidate())->goCheck('category',[
  40. 'user_id'=>$this->userId
  41. ]);
  42. $result = UserCouponLogic::categoryCouponList($params);
  43. if (false === $result) {
  44. return $this->fail(UserCouponLogic::getError());
  45. }
  46. return $this->data($result);
  47. }
  48. }