|  | @@ -331,7 +331,24 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
 | 
	
		
			
				|  |  |                      userVip.setVipType(EVipType.VIP);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  Optional<VipCardRecord> max = vipList.stream().max(Comparator.comparing(VipCardRecord::getEndTime));
 | 
	
		
			
				|  |  | +                Optional<VipCardRecord> min = vipList.stream().min(Comparator.comparing(VipCardRecord::getStartTime));
 | 
	
		
			
				|  |  |                  max.ifPresent(vipCardRecord -> userVip.setVipEndDate(vipCardRecord.getEndTime()));
 | 
	
		
			
				|  |  | +                Date minDate = null;
 | 
	
		
			
				|  |  | +                if (min.isPresent()) {
 | 
	
		
			
				|  |  | +                    minDate = min.get().getStartTime();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                // 设置VIP剩余天数
 | 
	
		
			
				|  |  | +                if (userVip.getVipEndDate() != null) {
 | 
	
		
			
				|  |  | +                    int num;
 | 
	
		
			
				|  |  | +                    if (userVip.getSvipEndDate() != null && userVip.getSvipEndDate().after(new Date())) {
 | 
	
		
			
				|  |  | +                        num = DateUtil.daysBetween(userVip.getSvipEndDate(), userVip.getVipEndDate());
 | 
	
		
			
				|  |  | +                    } else if (minDate != null && minDate.after(new Date())){
 | 
	
		
			
				|  |  | +                        num = DateUtil.daysBetween(minDate, userVip.getVipEndDate());
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        num = DateUtil.daysBetween(new Date(), userVip.getVipEndDate()) +1;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    userVip.setVipEndDays(Math.max(num, 0));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  Integer vipCount = this.lambdaQuery()
 | 
	
		
			
				|  |  |                      .eq(VipCardRecord::getUserId, userId)
 | 
	
	
		
			
				|  | @@ -345,16 +362,6 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        // 设置剩余天数
 | 
	
		
			
				|  |  | -        if (userVip.getVipEndDate() != null) {
 | 
	
		
			
				|  |  | -            int num;
 | 
	
		
			
				|  |  | -            if (userVip.getSvipEndDate() != null && userVip.getSvipEndDate().after(new Date())) {
 | 
	
		
			
				|  |  | -                num = DateUtil.daysBetween(userVip.getSvipEndDate(), userVip.getVipEndDate());
 | 
	
		
			
				|  |  | -            } else {
 | 
	
		
			
				|  |  | -                num = DateUtil.daysBetween(new Date(), userVip.getVipEndDate()) + 1;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            userVip.setVipEndDays(Math.max(num, 0));
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |          if (userVip.getSvipEndDate() != null) {
 | 
	
		
			
				|  |  |              int num = DateUtil.daysBetween(new Date(), userVip.getSvipEndDate()) +1;
 | 
	
		
			
				|  |  |              userVip.setSvipEndDays(Math.max(num, 0));
 |