SignRewards.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * @author: 吴汐
  4. * @email: 442384644@qq.com
  5. * @date: 2023/7/31
  6. */
  7. namespace app\adminapi\controller\v1\marketing;
  8. use app\adminapi\controller\AuthController;
  9. use app\services\system\SystemSignRewardServices;
  10. use think\facade\App;
  11. class SignRewards extends AuthController
  12. {
  13. /**
  14. * @param App $app
  15. * @param SystemSignRewardServices $services
  16. */
  17. public function __construct(App $app, SystemSignRewardServices $services)
  18. {
  19. parent::__construct($app);
  20. $this->services = $services;
  21. }
  22. /**
  23. * 签到奖励列表
  24. * @return \think\Response
  25. * @throws \ReflectionException
  26. * @throws \think\db\exception\DataNotFoundException
  27. * @throws \think\db\exception\DbException
  28. * @throws \think\db\exception\ModelNotFoundException
  29. * @author: 吴汐
  30. * @email: 442384644@qq.com
  31. * @date: 2023/7/31
  32. */
  33. public function index()
  34. {
  35. [$type] = $this->request->getMore([
  36. ['type', 0]
  37. ], true);
  38. $data = $this->services->getList($type);
  39. return app('json')->success($data);
  40. }
  41. /**
  42. * 新增签到奖励
  43. * @return \think\Response
  44. * @throws \FormBuilder\Exception\FormBuilderException
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. * @author: 吴汐
  49. * @email: 442384644@qq.com
  50. * @date: 2023/7/31
  51. */
  52. public function addRewards()
  53. {
  54. [$type] = $this->request->getMore([
  55. ['type', 0]
  56. ], true);
  57. $data = $this->services->rewardsForm(0, $type);
  58. return app('json')->success($data);
  59. }
  60. /**
  61. * 修改签到奖励
  62. * @param $id
  63. * @return \think\Response
  64. * @throws \FormBuilder\Exception\FormBuilderException
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\DbException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. * @author: 吴汐
  69. * @email: 442384644@qq.com
  70. * @date: 2023/7/31
  71. */
  72. public function editRewards($id)
  73. {
  74. $data = $this->services->rewardsForm($id);
  75. return app('json')->success($data);
  76. }
  77. /**
  78. * 保存签到奖励
  79. * @param $id
  80. * @return \think\Response
  81. * @author: 吴汐
  82. * @email: 442384644@qq.com
  83. * @date: 2023/7/31
  84. */
  85. public function saveRewards($id)
  86. {
  87. $data = $this->request->postMore([
  88. ['type', 0],
  89. ['days', 0],
  90. ['point', 0],
  91. ['exp', 0]
  92. ]);
  93. $this->services->saveRewards($id, $data);
  94. return app('json')->success(100000);
  95. }
  96. /**
  97. * 删除签到奖励
  98. * @param $id
  99. * @return \think\Response
  100. * @author: 吴汐
  101. * @email: 442384644@qq.com
  102. * @date: 2023/7/31
  103. */
  104. public function delRewards($id)
  105. {
  106. $this->services->delete($id);
  107. return app('json')->success(100002);
  108. }
  109. }