GoodsController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\lists\FirmGoodLists;
  4. use app\api\lists\GoodsLists;
  5. use app\api\logic\GoodsLogic;
  6. use app\api\validate\GoodsValidate;
  7. /**
  8. * 用户控制器
  9. * Class UserController
  10. * @package app\api\controller
  11. */
  12. class GoodsController extends BaseApiController
  13. {
  14. public array $notNeedLogin = ['lists','hotData','categoryDetail','goodsDetail','categoryCouponList'];
  15. public function lists()
  16. {
  17. return $this->dataLists(new GoodsLists());
  18. }
  19. public function hotData(){
  20. $result = GoodsLogic::getHotData();
  21. return $this->data($result);
  22. }
  23. public function categoryDetail()
  24. {
  25. $params = (new GoodsValidate())->goCheck('category');
  26. $result = GoodsLogic::detail($params['goods_category_id'],'category');
  27. return $this->data($result);
  28. }
  29. public function goodsDetail()
  30. {
  31. $params = (new GoodsValidate())->goCheck('goods');
  32. $result = GoodsLogic::detail($params['id'],'goods');
  33. return $this->data($result);
  34. }
  35. public function firmGoodLists()
  36. {
  37. return $this->dataLists(new FirmGoodLists());
  38. }
  39. public function firmGoodDetail(){
  40. $params = (new GoodsValidate())->get()->goCheck('goods',[
  41. 'user_id'=>$this->userId
  42. ]);
  43. $result = GoodsLogic::firmGoodsDetail($params);
  44. if (false !== $result) {
  45. return $this->data($result);
  46. }
  47. return $this->fail(GoodsLogic::getError());
  48. }
  49. public function submitFirmGood()
  50. {
  51. $params = (new GoodsValidate())->post()->goCheck('submitGood');
  52. $result = GoodsLogic::sync($params,$this->userId);
  53. if (true === $result) {
  54. return $this->success('已提交', [], 1, 1);
  55. }
  56. return $this->fail(GoodsLogic::getError());
  57. }
  58. }