UserVisitDayDao.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @package merchant
  4. *
  5. * @author xaboy
  6. * @day 2020/5/27
  7. *
  8. *
  9. */
  10. namespace app\common\dao\user;
  11. use app\common\dao\BaseDao;
  12. use app\common\model\user\UserVisitDay;
  13. use think\facade\Db;
  14. use think\Model;
  15. /**
  16. * Class UserVisitDayDao
  17. * @package app\common\dao\user
  18. * @author xaboy
  19. * @day 2020/5/27
  20. */
  21. class UserVisitDayDao extends BaseDao
  22. {
  23. /**
  24. * @return string
  25. * @author xaboy
  26. * @day 2020/5/27
  27. */
  28. protected function getModel(): string
  29. {
  30. return UserVisitDay::class;
  31. }
  32. public function incrUserVisitDay($day,$number=1)
  33. {
  34. if (empty(Db::name('user_visit_day')->where('day', $day)->find())) {
  35. Db::name('user_visit_day')->insert([
  36. 'day' => $day,
  37. 'number' => 0,
  38. ]);
  39. }
  40. return Db::name('user_visit_day')->where('day', $day)->inc('number',$number)->update();
  41. }
  42. public function dateVisitUserNum($date): int
  43. {
  44. return (int)UserVisitDay::getDB()->when($date, function ($query, $date) {
  45. getModelTime($query, $date, 'create_time');
  46. })->value('number');
  47. }
  48. }