12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\common\service;
- use app\common\model\UserVitality;
- use think\cache\driver\Redis;
- /**
- * 会员身综合管理
- * Class UserIdentity
- */
- class UserSynth
- {
- // 会员活跃度
- public static function vitality($user_id,$type)
- {
- if($type === false) return false;
- $type++;
- $redis = new Redis();
- $check_key = date('Y-m-d').'_'.$user_id;
- // 当天是否登录
- if(!$redis->get($check_key)) {
- $redis->set($check_key,86400);
- $year = date('Y');
- $month = date('m');
- $day = date('d');
- $vitality_info= [
- 'user_id'=>$user_id,
- 'year'=>$year,
- 'month'=>$month,
- 'day'=>$day,
- 'day_time'=>date('Y-m-d'),
- 'create_at'=>date('Y-m-d H:i:s'),
- 'type'=>$type
- ];
- UserVitality::create($vitality_info);
- }
- }
- }
|