SignRewards.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. /**
  12. * @author: 吴汐
  13. * @email: 442384644@qq.com
  14. * @date: 2023/7/31
  15. */
  16. namespace app\adminapi\controller\v1\marketing;
  17. use app\adminapi\controller\AuthController;
  18. use app\services\system\SystemSignRewardServices;
  19. use think\facade\App;
  20. class SignRewards extends AuthController
  21. {
  22. /**
  23. * @param App $app
  24. * @param SystemSignRewardServices $services
  25. */
  26. public function __construct(App $app, SystemSignRewardServices $services)
  27. {
  28. parent::__construct($app);
  29. $this->services = $services;
  30. }
  31. /**
  32. * 签到奖励列表
  33. * @return \think\Response
  34. * @throws \ReflectionException
  35. * @throws \think\db\exception\DataNotFoundException
  36. * @throws \think\db\exception\DbException
  37. * @throws \think\db\exception\ModelNotFoundException
  38. * @author: 吴汐
  39. * @email: 442384644@qq.com
  40. * @date: 2023/7/31
  41. */
  42. public function index()
  43. {
  44. [$type] = $this->request->getMore([
  45. ['type', 0]
  46. ], true);
  47. $data = $this->services->getList($type);
  48. return app('json')->success($data);
  49. }
  50. /**
  51. * 新增签到奖励
  52. * @return \think\Response
  53. * @throws \FormBuilder\Exception\FormBuilderException
  54. * @throws \think\db\exception\DataNotFoundException
  55. * @throws \think\db\exception\DbException
  56. * @throws \think\db\exception\ModelNotFoundException
  57. * @author: 吴汐
  58. * @email: 442384644@qq.com
  59. * @date: 2023/7/31
  60. */
  61. public function addRewards()
  62. {
  63. [$type] = $this->request->getMore([
  64. ['type', 0]
  65. ], true);
  66. $data = $this->services->rewardsForm(0, $type);
  67. return app('json')->success($data);
  68. }
  69. /**
  70. * 修改签到奖励
  71. * @param $id
  72. * @return \think\Response
  73. * @throws \FormBuilder\Exception\FormBuilderException
  74. * @throws \think\db\exception\DataNotFoundException
  75. * @throws \think\db\exception\DbException
  76. * @throws \think\db\exception\ModelNotFoundException
  77. * @author: 吴汐
  78. * @email: 442384644@qq.com
  79. * @date: 2023/7/31
  80. */
  81. public function editRewards($id)
  82. {
  83. $data = $this->services->rewardsForm($id);
  84. return app('json')->success($data);
  85. }
  86. /**
  87. * 保存签到奖励
  88. * @param $id
  89. * @return \think\Response
  90. * @author: 吴汐
  91. * @email: 442384644@qq.com
  92. * @date: 2023/7/31
  93. */
  94. public function saveRewards($id)
  95. {
  96. $data = $this->request->postMore([
  97. ['type', 0],
  98. ['days', 0],
  99. ['point', 0],
  100. ['exp', 0]
  101. ]);
  102. $this->services->saveRewards($id, $data);
  103. return app('json')->success('保存成功');
  104. }
  105. /**
  106. * 删除签到奖励
  107. * @param $id
  108. * @return \think\Response
  109. * @author: 吴汐
  110. * @email: 442384644@qq.com
  111. * @date: 2023/7/31
  112. */
  113. public function delRewards($id)
  114. {
  115. $this->services->delete($id);
  116. return app('json')->success('删除成功');
  117. }
  118. }