UserSignController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\api\controller\v1\user;
  12. use app\Request;
  13. use app\services\user\UserSignServices;
  14. /**
  15. * 用户签到
  16. * Class UserController
  17. * @package app\api\controller\v1\user
  18. */
  19. class UserSignController
  20. {
  21. protected $services = NUll;
  22. /**
  23. * UserController constructor.
  24. * @param UserSignServices $services
  25. */
  26. public function __construct(UserSignServices $services)
  27. {
  28. $this->services = $services;
  29. }
  30. /**
  31. * 签到 配置
  32. * @return mixed
  33. * @throws \think\db\exception\DataNotFoundException
  34. * @throws \think\db\exception\DbException
  35. * @throws \think\db\exception\ModelNotFoundException
  36. */
  37. public function sign_config(Request $request)
  38. {
  39. $uid = (int)$request->uid();
  40. return app('json')->success($this->services->signConfig($uid));
  41. }
  42. /**
  43. * 签到 列表
  44. * @param Request $request
  45. * @return mixed
  46. * @throws \think\db\exception\DataNotFoundException
  47. * @throws \think\db\exception\DbException
  48. * @throws \think\db\exception\ModelNotFoundException
  49. */
  50. public function sign_list(Request $request)
  51. {
  52. list($page, $limit) = $request->getMore([
  53. ['page', 0],
  54. ['limit', 0]
  55. ], true);
  56. if (!$limit) return app('json')->success([]);
  57. $uid = (int)$request->uid();
  58. return app('json')->success($this->services->getUserSignList($uid));
  59. }
  60. /**
  61. * 签到
  62. * @param Request $request
  63. * @return mixed
  64. * @throws \think\db\exception\DataNotFoundException
  65. * @throws \think\db\exception\DbException
  66. * @throws \think\db\exception\ModelNotFoundException
  67. */
  68. public function sign_integral(Request $request)
  69. {
  70. if (sys_config('sign_status') == 0) {
  71. return app('json')->fail('签到功能未开启');
  72. }
  73. $uid = (int)$request->uid();
  74. $integral = $this->services->sign($uid);
  75. return app('json')->success(410127, ['integral' => $integral], ['integral' => $integral]);
  76. }
  77. /**
  78. * 签到用户信息
  79. * @param Request $request
  80. * @return mixed
  81. */
  82. public function sign_user(Request $request)
  83. {
  84. list($sign, $integral, $all) = $request->postMore([
  85. ['sign', 0],
  86. ['integral', 0],
  87. ['all', 0],
  88. ], true);
  89. $uid = (int)$request->uid();
  90. return app('json')->success($this->services->signUser($uid, $sign, $integral, $all));
  91. }
  92. /**
  93. * 签到列表(年月)
  94. * @param Request $request
  95. * @return mixed
  96. */
  97. public function sign_month(Request $request)
  98. {
  99. $uid = (int)$request->uid();
  100. return app('json')->success($this->services->getSignMonthList($uid));
  101. }
  102. /**
  103. * 用户设置签到提醒
  104. * @param Request $request
  105. * @param $status
  106. * @return \think\Response
  107. * @author: 吴汐
  108. * @email: 442384644@qq.com
  109. * @date: 2023/8/9
  110. */
  111. public function sign_remind(Request $request, $status)
  112. {
  113. $uid = (int)$request->uid();
  114. $this->services->setSignRemind($uid, $status);
  115. return app('json')->success(100014);
  116. }
  117. }