UserSign.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 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. public function lst()
  32. {
  33. [$page,$limit] = $this->getPage();
  34. $where = ['uid' => $this->request->uid()];
  35. $data = $this->repository->getList($where,$page,$limit);
  36. return app('json')->success($data);
  37. }
  38. public function create()
  39. {
  40. $uid = $this->request->uid();
  41. $day = date('Y-m-d',time());
  42. if($this->repository->getSign($uid,$day))
  43. return app('json')->fail('您今日已签到');
  44. $data = $this->repository->create($uid);
  45. return app('json')->success($data);
  46. }
  47. public function info()
  48. {
  49. $uid = $this->request->uid();
  50. $data = $this->repository->info($uid);
  51. return app('json')->success($data);
  52. }
  53. public function month()
  54. {
  55. $where = ['uid' => $this->request->uid()];
  56. return app('json')->success($this->repository->month($where));
  57. }
  58. }