UserSynth.php 968 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\service;
  3. use app\common\model\UserVitality;
  4. use think\cache\driver\Redis;
  5. /**
  6. * 会员身综合管理
  7. * Class UserIdentity
  8. */
  9. class UserSynth
  10. {
  11. // 会员活跃度
  12. public static function vitality($user_id,$type)
  13. {
  14. if($type === false) return false;
  15. $type++;
  16. $redis = new Redis();
  17. $check_key = date('Y-m-d').'_'.$user_id;
  18. // 当天是否登录
  19. if(!$redis->get($check_key)) {
  20. $redis->set($check_key,86400);
  21. $year = date('Y');
  22. $month = date('m');
  23. $day = date('d');
  24. $vitality_info= [
  25. 'user_id'=>$user_id,
  26. 'year'=>$year,
  27. 'month'=>$month,
  28. 'day'=>$day,
  29. 'day_time'=>date('Y-m-d'),
  30. 'create_at'=>date('Y-m-d H:i:s'),
  31. 'type'=>$type
  32. ];
  33. UserVitality::create($vitality_info);
  34. }
  35. }
  36. }