UserSignController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. $uid = (int)$request->uid();
  71. if ($integral = $this->services->sign($uid)) {
  72. return app('json')->success(410127, ['integral' => $integral], ['integral' => $integral]);
  73. }
  74. return app('json')->fail(410128);
  75. }
  76. /**
  77. * 签到用户信息
  78. * @param Request $request
  79. * @return mixed
  80. */
  81. public function sign_user(Request $request)
  82. {
  83. list($sign, $integral, $all) = $request->postMore([
  84. ['sign', 0],
  85. ['integral', 0],
  86. ['all', 0],
  87. ], true);
  88. $uid = (int)$request->uid();
  89. return app('json')->success($this->services->signUser($uid, $sign, $integral, $all));
  90. }
  91. /**
  92. * 签到列表(年月)
  93. * @param Request $request
  94. * @return mixed
  95. */
  96. public function sign_month(Request $request)
  97. {
  98. $uid = (int)$request->uid();
  99. return app('json')->success($this->services->getSignMonthList($uid));
  100. }
  101. /**
  102. * 用户设置签到提醒
  103. * @param Request $request
  104. * @param $status
  105. * @return \think\Response
  106. * @author: 吴汐
  107. * @email: 442384644@qq.com
  108. * @date: 2023/8/9
  109. */
  110. public function sign_remind(Request $request, $status)
  111. {
  112. $uid = (int)$request->uid();
  113. $this->services->setSignRemind($uid, $status);
  114. return app('json')->success(100014);
  115. }
  116. }