StoreProductGroup.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace app\controller\api\store\product;
  3. use app\common\repositories\store\product\ProductGroupBuyingRepository;
  4. use app\common\repositories\store\product\ProductGroupUserRepository;
  5. use ln\jobs\ChangeSpuStatusJob;
  6. use think\App;
  7. use ln\basic\BaseController;
  8. use app\common\repositories\store\product\ProductGroupRepository;
  9. class StoreProductGroup extends BaseController
  10. {
  11. protected $repository;
  12. protected $userInfo;
  13. /**
  14. * StoreProductPresell constructor.
  15. * @param App $app
  16. * @param repository $repository
  17. */
  18. public function __construct(App $app, ProductGroupRepository $repository)
  19. {
  20. parent::__construct($app);
  21. $this->repository = $repository;
  22. $this->userInfo = $this->request->isLogin() ? $this->request->userInfo() : null;
  23. }
  24. public function lst()
  25. {
  26. [$page, $limit] = $this->getPage();
  27. $where = $this->request->params([['active_type',1],'store_category_id','star']);
  28. return app('json')->success($this->repository->getApiList($where,$page, $limit));
  29. }
  30. public function detail($id)
  31. {
  32. $data = $this->repository->apiDetail($id, $this->userInfo);
  33. return app('json')->success($data);
  34. }
  35. public function groupBuying($id)
  36. {
  37. $make = app()->make(ProductGroupBuyingRepository::class);
  38. $data = $make->detail($id,$this->userInfo);
  39. if(!$data) return app('json')->fail('数据丢失');
  40. return app('json')->success($data);
  41. }
  42. public function userCount()
  43. {
  44. [$page, $limit] = $this->getPage();
  45. $data = app()->make(ProductGroupUserRepository::class)->getApiList([],$page,$limit);
  46. return app('json')->success($data);
  47. }
  48. public function category()
  49. {
  50. return app('json')->success($this->repository->getCategory());
  51. }
  52. /**
  53. * TODO 取消参团
  54. * @author Qinii
  55. * @day 1/13/21
  56. */
  57. public function cancel()
  58. {
  59. $data = (int)$this->request->param('group_buying_id');
  60. $make = app()->make(ProductGroupBuyingRepository::class);
  61. $make->cancelGroup($data,$this->userInfo);
  62. return app('json')->success('取消成功,订单金额将会原路退回');
  63. }
  64. }