UserLevelRank.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. // 会员等级
  5. class UserLevelRank extends Model
  6. {
  7. // 判断会员是否有会员权限
  8. public static function getUserVip($user_id)
  9. {
  10. $user_info = User::where('id',$user_id)->field('id,account_type,group_id,is_first,group_first')->find();
  11. // 非公司会员 || 公司会员主账号
  12. if($user_info['account_type'] == 2 || ($user_info['account_type'] == 1 && $user_info['is_first'] == 1)) {
  13. return static::where([['user_id','=',$user_id],['end_time','>',time()]])->max('level_id');
  14. }
  15. // 公司员工查询主账号的会员
  16. if($user_info['account_type'] == 1) {
  17. return static::where([['user_id','=',$user_info['group_first']],['end_time','>',time()]])->max('level_id');
  18. }
  19. return 0;
  20. }
  21. // 获取vip 详情
  22. public static function getUserVipInfo($user_id)
  23. {
  24. $user_info = User::where('id',$user_id)->field('id,account_type,group_id,is_first,group_first')->find();
  25. // 非公司会员 || 公司会员主账号
  26. if($user_info['account_type'] == 2 || ($user_info['account_type'] == 1 && $user_info['is_first'] == 1)) {
  27. $vip_info = static::where([['user_id','=',$user_id],['end_time','>',time()]])->find();
  28. }
  29. // 公司员工查询主账号的会员
  30. if($user_info['account_type'] == 1) {
  31. $vip_info = static::where([['user_id','=',$user_info['group_first']],['end_time','>',time()]])->find();
  32. }
  33. return empty($vip_info) ? [] : $vip_info->toArray();
  34. }
  35. }