123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace app\common\model;
- use think\Model;
- class UserLevelRank extends Model
- {
-
- public static function getUserVip($user_id)
- {
- $user_info = User::where('id',$user_id)->field('id,account_type,group_id,is_first,group_first')->find();
-
- if($user_info['account_type'] == 2 || ($user_info['account_type'] == 1 && $user_info['is_first'] == 1)) {
- return static::where([['user_id','=',$user_id],['end_time','>',time()]])->max('level_id');
- }
-
- if($user_info['account_type'] == 1) {
- return static::where([['user_id','=',$user_info['group_first']],['end_time','>',time()]])->max('level_id');
- }
- return 0;
- }
-
- public static function getUserVipInfo($user_id)
- {
- $user_info = User::where('id',$user_id)->field('id,account_type,group_id,is_first,group_first')->find();
-
- if($user_info['account_type'] == 2 || ($user_info['account_type'] == 1 && $user_info['is_first'] == 1)) {
- $vip_info = static::where([['user_id','=',$user_id],['end_time','>',time()]])->find();
- }
-
- if($user_info['account_type'] == 1) {
- $vip_info = static::where([['user_id','=',$user_info['group_first']],['end_time','>',time()]])->find();
- }
- return empty($vip_info) ? [] : $vip_info->toArray();
- }
- }
|