SeckillActive.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace app\controller\merchant\store\seckill;
  3. use app\common\repositories\store\StoreSeckillActiveRepository;
  4. use crmeb\basic\BaseController;
  5. use think\App;
  6. /**
  7. * 秒杀活动
  8. */
  9. class SeckillActive extends BaseController
  10. {
  11. protected $repository;
  12. /**
  13. * SeckillActive constructor.
  14. * @param App $app
  15. * @param StoreSeckillActiveRepository $repository
  16. */
  17. public function __construct(App $app ,StoreSeckillActiveRepository $repository)
  18. {
  19. parent::__construct($app);
  20. $this->repository = $repository;
  21. }
  22. /**
  23. * 获取秒杀活动列表
  24. * FerryZhao 2024/4/16
  25. */
  26. public function list()
  27. {
  28. $where = $this->request->params([
  29. 'name',
  30. 'seckill_active_status',
  31. 'date',
  32. 'active_status'
  33. ]);
  34. [$page, $limit] = $this->getPage();
  35. $append = ['status_text', 'seckill_time_text_arr','atmosphere_pic','border_pic'];
  36. $list = $this->repository->getList($where, $page, $limit, $append);
  37. return app('json')->success($list);
  38. }
  39. /**
  40. * 返回所有列表数据-下拉
  41. * FerryZhao 2024/4/16
  42. */
  43. public function select()
  44. {
  45. return app('json')->success('获取成功',$this->repository->getActiveAll());
  46. }
  47. /**
  48. * 获取秒杀活动详情
  49. * @return void
  50. * FerryZhao 2024/4/16
  51. */
  52. public function detail($id)
  53. {
  54. if (!$id) {
  55. return app('json')->fail('参数异常');
  56. }
  57. $exists = $this->repository->exists($id);
  58. if(!$exists)
  59. return app('json')->fail('数据不存在');
  60. $info = $this->repository->get($id)->append(['status_text', 'seckill_time_text_arr','atmosphere_pic','border_pic']) ?? [];
  61. return app('json')->success('获取成功', $info);
  62. }
  63. /**
  64. * 活动统计-面板
  65. * @return array[]|void
  66. * FerryZhao 2024/4/23
  67. */
  68. public function chart_panel($id)
  69. {
  70. if( !$id ) {
  71. return app('json')->fail('参数错误');
  72. }
  73. $exists = $this->repository->exists($id);
  74. if(!$exists)
  75. return app('json')->fail('活动不存在');
  76. return app('json')->success($this->repository->chartPanel($id,$this->request->merId()));
  77. }
  78. /**
  79. * 活动参与人统计列表
  80. * @param $id
  81. * FerryZhao 2024/4/22
  82. */
  83. public function chart_people($id)
  84. {
  85. if(!$id){
  86. return app('json')->fail('参数异常');
  87. }
  88. $exists = $this->repository->exists($id);
  89. if (!$exists)
  90. return app('json')->fail('活动不存在');
  91. [$page, $limit] = $this->getPage();
  92. $where = $this->request->params(['keyword','date']);
  93. $merId = $this->request->merId();
  94. return app('json')->success($this->repository->chartPeople($id,$merId,$where,$page,$limit));
  95. }
  96. /**
  97. * 活动订单统计列表
  98. * @param $id
  99. * FerryZhao 2024/4/28
  100. */
  101. public function chart_order($id)
  102. {
  103. if(!$id){
  104. return app('json')->fail('参数异常');
  105. }
  106. $exists = $this->repository->exists($id);
  107. if (!$exists)
  108. return app('json')->fail('活动不存在');
  109. [$page, $limit] = $this->getPage();
  110. $where = $this->request->params(['keyword','status','mer_id','date']);
  111. $merId = $this->request->merId();
  112. return app('json')->success($this->repository->chartOrder($id,$merId,$where,$page,$limit));
  113. }
  114. /**
  115. * 活动商品统计列表
  116. * @param $id
  117. * FerryZhao 2024/4/28
  118. */
  119. public function chart_product($id)
  120. {
  121. if (!$id) {
  122. return app('json')->fail('参数异常');
  123. }
  124. $exists = $this->repository->exists($id);
  125. if (!$exists)
  126. return app('json')->fail('活动不存在');
  127. [$page, $limit] = $this->getPage();
  128. $where = $this->request->params(['keyword']);
  129. $merId = $this->request->merId();
  130. return app('json')->success($this->repository->chartProduct($id,$merId,$where,$page,$limit));
  131. }
  132. }