1
0

GoodsController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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','eventGoodsDetail','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',$this->userId);
  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 eventGoodsDetail()
  36. {
  37. $params = (new GoodsValidate())->goCheck('goods');
  38. $result = GoodsLogic::eventDetail($params['id'],$this->userId);
  39. return $this->data($result);
  40. }
  41. public function firmGoodLists()
  42. {
  43. return $this->dataLists(new FirmGoodLists());
  44. }
  45. public function firmGoodDetail(){
  46. $params = (new GoodsValidate())->get()->goCheck('goods',[
  47. 'user_id'=>$this->userId
  48. ]);
  49. $result = GoodsLogic::firmGoodsDetail($params);
  50. if (false !== $result) {
  51. return $this->data($result);
  52. }
  53. return $this->fail(GoodsLogic::getError());
  54. }
  55. public function submitFirmGood()
  56. {
  57. $params = (new GoodsValidate())->post()->goCheck('submitGood');
  58. $result = GoodsLogic::sync($params,$this->userId);
  59. if (true === $result) {
  60. return $this->success('已提交', [], 1, 1);
  61. }
  62. return $this->fail(GoodsLogic::getError());
  63. }
  64. }