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;
- }
- // 获取vip 详情
- 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();
- }
- }
|