|
@@ -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));
|
|
@@ -815,7 +822,35 @@ public class VipCardRecordServiceImpl extends ServiceImpl<VipCardRecordDao, VipC
|
|
|
if (sysUser == null) {
|
|
|
return;
|
|
|
}
|
|
|
- MessageTypeEnum messageTypeEnum = EVipRecordStatus.ADD.equals(addVipCardRecord.getStatus()) ? MessageTypeEnum.PLATFORM_ADD_VIP : MessageTypeEnum.PLATFORM_ADD_DUDECT_VIP;
|
|
|
+ MessageTypeEnum messageTypeEnum;
|
|
|
+ EVipRecordStatus status = addVipCardRecord.getStatus();
|
|
|
+ EVipType vipType = addVipCardRecord.getVipType();
|
|
|
+ if (EVipRecordStatus.ADD.equals(status)) {
|
|
|
+ if (EVipType.VIP.equals(vipType)) {
|
|
|
+ messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_VIP;
|
|
|
+ }else {
|
|
|
+ PeriodEnum period = addVipCardRecord.getType();
|
|
|
+ if (PeriodEnum.PERPETUAL.equals(period)) {
|
|
|
+ messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_PER_SVIP;
|
|
|
+ } else {
|
|
|
+ messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_SVIP;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (EVipRecordStatus.DEDUCTION.equals(status)) {
|
|
|
+ if (EVipType.VIP.equals(vipType)) {
|
|
|
+ messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_DUDECT_VIP;
|
|
|
+ }else {
|
|
|
+ PeriodEnum period = addVipCardRecord.getType();
|
|
|
+ if (PeriodEnum.PERPETUAL.equals(period)) {
|
|
|
+ messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_DUDECT_PER_SVIP;
|
|
|
+ } else {
|
|
|
+ messageTypeEnum = MessageTypeEnum.PLATFORM_ADD_DUDECT_SVIP;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new BizException("不支持类型");
|
|
|
+ }
|
|
|
+
|
|
|
Map<Long, String> receivers = new HashMap<>();
|
|
|
receivers.put(addVipCardRecord.getUserId(), sysUser.getPhone());
|
|
|
|