UserSign.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\user;
  12. use crmeb\basic\BaseController;
  13. use app\common\repositories\user\UserSignRepository;
  14. use think\App;
  15. class UserSign extends BaseController
  16. {
  17. /**
  18. * @var repository
  19. */
  20. protected $repository;
  21. /**
  22. * UserSign constructor.
  23. * @param App $app
  24. * @param UserSignRepository $repository
  25. */
  26. public function __construct(App $app, UserSignRepository $repository)
  27. {
  28. parent::__construct($app);
  29. $this->repository = $repository;
  30. }
  31. /**
  32. * 用户签到记录
  33. * @return \think\response\Json
  34. * @author wuhaotian
  35. * @email 442384644@qq.com
  36. * @date 2024/7/10
  37. */
  38. public function lst()
  39. {
  40. [$page,$limit] = $this->getPage();
  41. $where = ['uid' => $this->request->uid()];
  42. $data = $this->repository->getList($where,$page,$limit);
  43. return app('json')->success($data);
  44. }
  45. /**
  46. * 用户签到
  47. * @return \think\response\Json
  48. * @author wuhaotian
  49. * @email 442384644@qq.com
  50. * @date 2024/7/10
  51. */
  52. public function create()
  53. {
  54. $uid = $this->request->uid();
  55. $day = date('Y-m-d',time());
  56. if($this->repository->getSign($uid,$day))
  57. return app('json')->fail('您今日已签到');
  58. $data = $this->repository->create($uid);
  59. return app('json')->success($data);
  60. }
  61. /**
  62. * 签到数据
  63. * @return \think\response\Json
  64. * @author wuhaotian
  65. * @email 442384644@qq.com
  66. * @date 2024/7/10
  67. */
  68. public function info()
  69. {
  70. $uid = $this->request->uid();
  71. $data = $this->repository->info($uid);
  72. return app('json')->success($data);
  73. }
  74. /**
  75. * 按月显示签到记录
  76. * @return \think\response\Json
  77. * @author wuhaotian
  78. * @email 442384644@qq.com
  79. * @date 2024/7/10
  80. */
  81. public function month()
  82. {
  83. $where = ['uid' => $this->request->uid()];
  84. return app('json')->success($this->repository->month($where));
  85. }
  86. }