LuckyDrawController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\controller;
  20. use app\common\service\JsonService;
  21. use app\shopapi\logic\LuckyDrawLogic;
  22. use app\shopapi\validate\LuckyDrawValidate;
  23. /**
  24. * 幸运抽奖
  25. */
  26. class LuckyDrawController extends BaseShopController
  27. {
  28. /**
  29. * @notes 获取活动信息
  30. * @author Tab
  31. * @date 2021/11/25 11:43
  32. */
  33. public function activity()
  34. {
  35. $params = (new LuckyDrawValidate())->goCheck('activity');
  36. $params['user_id'] = $this->userId;
  37. $result = LuckyDrawLogic::activity($params);
  38. return JsonService::data($result);
  39. }
  40. /**
  41. * @notes 抽奖
  42. * @author Tab
  43. * @date 2021/11/24 16:32
  44. */
  45. public function lottery()
  46. {
  47. $params = (new LuckyDrawValidate())->post()->goCheck('lottery', ['user_id' => $this->userId]);
  48. $result = LuckyDrawLogic::lottery($params);
  49. if ($result) {
  50. return JsonService::success('抽奖完成', $result, 1, 0);
  51. }
  52. return JsonService::fail(LuckyDrawLogic::getError());
  53. }
  54. /**
  55. * @notes 查看抽奖记录
  56. * @return \think\response\Json
  57. * @author Tab
  58. * @date 2021/11/25 10:49
  59. */
  60. public function record()
  61. {
  62. $params = (new LuckyDrawValidate())->goCheck('record');
  63. $params['page_no'] = $params['page_no'] ?? 1;
  64. $params['page_size'] = $params['page_size'] ?? 25;
  65. $params['user_id'] = $this->userId;
  66. $result = LuckyDrawLogic::record($params);
  67. return JsonService::data($result);
  68. }
  69. /**
  70. * @notes 查看中奖名单
  71. * @author Tab
  72. * @date 2021/11/25 14:13
  73. */
  74. public function winningList()
  75. {
  76. $params = (new LuckyDrawValidate())->goCheck('winningList');
  77. $params['page_no'] = $params['page_no'] ?? 1;
  78. $params['page_size'] = $params['page_size'] ?? 25;
  79. $result = LuckyDrawLogic::winningList($params);
  80. return JsonService::data($result);
  81. }
  82. }