火点重构-完善防火季订阅
This commit is contained in:
parent
83e87fab0f
commit
5bee4ddf83
@ -25,7 +25,7 @@ public class SysUserConvertUtils {
|
|||||||
sysUserVo.setReceiveSms(entity.getReceiveSms());
|
sysUserVo.setReceiveSms(entity.getReceiveSms());
|
||||||
sysUserVo.setReceiveSmsCount(entity.getReceiveSmsCount());
|
sysUserVo.setReceiveSmsCount(entity.getReceiveSmsCount());
|
||||||
sysUserVo.setRemark(entity.getRemark());
|
sysUserVo.setRemark(entity.getRemark());
|
||||||
sysUserVo.setOverTime(VipTimeRangeUtils.obtainOverTime(entity.getVipTimeRangeJson(), entity.getAddTime(), entity.getDayNum()));
|
sysUserVo.setOverTime(TimeRangeUtils.getSysUserOverTime(entity));
|
||||||
return sysUserVo;
|
return sysUserVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ public class TimeRangeUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkIfAllExpired(SysUserEntity sysUserEntity) {
|
public static boolean checkIfAllExpired(SysUserEntity sysUserEntity) {
|
||||||
boolean probationExpired = checkIfProbationExpired(sysUserEntity.getAddTime(), sysUserEntity.getDayNum());//试用期是否过期
|
|
||||||
boolean vipExpired = checkIfVipExpired(sysUserEntity.getVipTimeRangeJson());//VIP是否过期
|
boolean vipExpired = checkIfVipExpired(sysUserEntity.getVipTimeRangeJson());//VIP是否过期
|
||||||
return probationExpired && vipExpired;
|
boolean probationExpired = checkIfProbationExpired(sysUserEntity.getAddTime(), sysUserEntity.getDayNum());//试用期是否过期
|
||||||
|
return vipExpired && probationExpired;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,4 +101,38 @@ public class TimeRangeUtils {
|
|||||||
return rangeStart.isBefore(test) && rangeEnd.isAfter(test);
|
return rangeStart.isBefore(test) && rangeEnd.isAfter(test);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统用户的过期时间-VIP范围列表和试用期范围中最晚的那个时间
|
||||||
|
*/
|
||||||
|
public static String getSysUserOverTime(SysUserEntity sysUserEntity) {
|
||||||
|
List<LocalDateTime> timeList = new ArrayList<>();
|
||||||
|
List<DataWrapper2<LocalDateTime, LocalDateTime>> vipRangeList = getVipRangeList(sysUserEntity.getVipTimeRangeJson());
|
||||||
|
DataWrapper2<LocalDateTime, LocalDateTime> probationRange = getProbationRange(sysUserEntity.getAddTime(), sysUserEntity.getDayNum());
|
||||||
|
for (DataWrapper2<LocalDateTime, LocalDateTime> vipRange : vipRangeList) {
|
||||||
|
timeList.add(vipRange.getData2());
|
||||||
|
}
|
||||||
|
timeList.add(probationRange.getData2());
|
||||||
|
LocalDateTime lastDateTime = getLastDateTime(timeList);
|
||||||
|
return DateTimeUtils.localDateTimeToString(lastDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取list中最晚的LocalDateTime
|
||||||
|
*/
|
||||||
|
public static LocalDateTime getLastDateTime(List<LocalDateTime> list) {
|
||||||
|
if (list == null || list.size() == 0) {
|
||||||
|
throw new RuntimeException("GetLastDateTime Error");
|
||||||
|
}
|
||||||
|
LocalDateTime lastDateTime = list.get(0);
|
||||||
|
for (LocalDateTime item : list) {
|
||||||
|
if (lastDateTime == item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.isAfter(lastDateTime)) {
|
||||||
|
lastDateTime = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lastDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,74 +16,6 @@ public class VipTimeRangeUtils {
|
|||||||
private VipTimeRangeUtils() {
|
private VipTimeRangeUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取用户的过期时间
|
|
||||||
*/
|
|
||||||
public static String obtainOverTime(String oldVipTimeRangeJson, String addTime, Long dayNum) {
|
|
||||||
// 试用期结束时间
|
|
||||||
LocalDateTime lastTryTime = obtainLastTryTime(addTime, dayNum);
|
|
||||||
// VIP过期时间
|
|
||||||
LocalDateTime lastOverTime = obtainLastOverTime(oldVipTimeRangeJson);
|
|
||||||
// 如果没有设置过VIP时间范围,那就将试用期结束时间返回
|
|
||||||
if (lastOverTime == null) {
|
|
||||||
return DateTimeUtils.localDateTimeToString(lastTryTime);
|
|
||||||
}
|
|
||||||
//如果VIP时间范围对应的结束时间更晚,那就将VIP时间范围的结束时间返回
|
|
||||||
if (lastOverTime.isAfter(lastTryTime)) {
|
|
||||||
return DateTimeUtils.localDateTimeToString(lastOverTime);
|
|
||||||
}
|
|
||||||
//否则就返回试用期的结束时间
|
|
||||||
return DateTimeUtils.localDateTimeToString(lastTryTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LocalDateTime obtainLastTryTime(String addTime, Long dayNum) {
|
|
||||||
return LocalDateTime.parse(addTime, DateTimeUtils.DATE_TIME_FORMATTER_1).plusDays(dayNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LocalDateTime obtainLastOverTime(String oldVipTimeRangeJson) {
|
|
||||||
//只有付费签约的用户VipTimeRangeJson字段才不为空,注册试用的用户由DayNum字段设置的天数决定试用时长
|
|
||||||
if (TextUtils.isEmpty(oldVipTimeRangeJson)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
VipTimeRangeBean vipTimeRangeBean = JsonUtils.deserialize(oldVipTimeRangeJson, VipTimeRangeBean.class);
|
|
||||||
if (vipTimeRangeBean == null || vipTimeRangeBean.getList() == null || vipTimeRangeBean.getList().size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<VipTimeRangeBean.VipTimeRangeItemBean> list = vipTimeRangeBean.getList();
|
|
||||||
if (list == null || list.size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//校验数据合法性
|
|
||||||
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemBeanA : list) {
|
|
||||||
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemBeanB : list) {
|
|
||||||
if (vipTimeRangeItemBeanA != vipTimeRangeItemBeanB) {
|
|
||||||
LocalDateTime startLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemBeanA.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
|
||||||
LocalDateTime endLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemBeanA.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
|
||||||
LocalDateTime startLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemBeanB.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
|
||||||
LocalDateTime endLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemBeanB.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
|
||||||
if (startLocalDateTimeB.isBefore(startLocalDateTimeA) && endLocalDateTimeB.isAfter(startLocalDateTimeA)) {
|
|
||||||
throw new RuntimeException("VIP开始结束时间存在交叉现象1,系统数据错误");
|
|
||||||
}
|
|
||||||
if (startLocalDateTimeB.isBefore(endLocalDateTimeA) && endLocalDateTimeB.isAfter(endLocalDateTimeA)) {
|
|
||||||
throw new RuntimeException("VIP开始结束时间存在交叉现象2,系统数据错误");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//获取结束时间最大的那个Pair
|
|
||||||
VipTimeRangeBean.VipTimeRangeItemBean lastVipTimeRangeItemBean = list.get(0);
|
|
||||||
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemBean : list) {
|
|
||||||
if (lastVipTimeRangeItemBean != vipTimeRangeItemBean) {
|
|
||||||
LocalDateTime endLocalDateTime = LocalDateTime.parse(vipTimeRangeItemBean.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
|
||||||
LocalDateTime lastEndLocalDateTime = LocalDateTime.parse(lastVipTimeRangeItemBean.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
|
||||||
if (endLocalDateTime.isAfter(lastEndLocalDateTime)) {
|
|
||||||
lastVipTimeRangeItemBean = vipTimeRangeItemBean;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return LocalDateTime.parse(lastVipTimeRangeItemBean.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成一个新的 VipTimeRangeJson
|
* 生成一个新的 VipTimeRangeJson
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user