火点重构-完善防火季订阅

This commit is contained in:
liuchengqian 2023-04-13 12:00:37 +08:00
parent b58d06d680
commit 2632d73c42
3 changed files with 90 additions and 9 deletions

View File

@ -109,6 +109,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(0); sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("街道级"); sysUserEntity.setAccountType("街道级");
sysUserEntity.setDayNum(7L);
} else if ("0000".equals(countyCode.substring(2))) { } else if ("0000".equals(countyCode.substring(2))) {
List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode); List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode);
if (proCodeList == null || proCodeList.size() == 0) { if (proCodeList == null || proCodeList.size() == 0) {
@ -120,6 +121,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(1); sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("省级"); sysUserEntity.setAccountType("省级");
sysUserEntity.setDayNum(5L);
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) { } else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode); List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode);
if (cityCodeList == null || cityCodeList.size() == 0) { if (cityCodeList == null || cityCodeList.size() == 0) {
@ -131,6 +133,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(1); sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("市级"); sysUserEntity.setAccountType("市级");
sysUserEntity.setDayNum(5L);
} else { } else {
List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode); List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode);
if (countyCodeList == null || countyCodeList.isEmpty()) { if (countyCodeList == null || countyCodeList.isEmpty()) {
@ -142,11 +145,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(0); sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("县级"); sysUserEntity.setAccountType("县级");
}
if (9 == countyCode.length()) {//街道账号7天后过期
sysUserEntity.setDayNum(7L); sysUserEntity.setDayNum(7L);
} else {//省市区县账号5天后过期
sysUserEntity.setDayNum(5L);
} }
sysUserEntity.setVipTimeRangeJson(""); sysUserEntity.setVipTimeRangeJson("");
sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now())); sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now()));
@ -211,6 +210,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(0); sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("街道级"); sysUserEntity.setAccountType("街道级");
sysUserEntity.setDayNum(7L);
} else if ("0000".equals(countyCode.substring(2))) { } else if ("0000".equals(countyCode.substring(2))) {
List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode); List<StreetEntity> proCodeList = streetDao.findByProCode(countyCode);
if (proCodeList == null || proCodeList.size() == 0) { if (proCodeList == null || proCodeList.size() == 0) {
@ -222,6 +222,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(1); sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("省级"); sysUserEntity.setAccountType("省级");
sysUserEntity.setDayNum(5L);
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) { } else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode); List<StreetEntity> cityCodeList = streetDao.findByCityCode(countyCode);
if (cityCodeList == null || cityCodeList.size() == 0) { if (cityCodeList == null || cityCodeList.size() == 0) {
@ -233,6 +234,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(1); sysUserEntity.setActiveFlag(1);
sysUserEntity.setAccountType("市级"); sysUserEntity.setAccountType("市级");
sysUserEntity.setDayNum(5L);
} else { } else {
List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode); List<StreetEntity> countyCodeList = streetDao.findByCountyCode(countyCode);
if (countyCodeList == null || countyCodeList.isEmpty()) { if (countyCodeList == null || countyCodeList.isEmpty()) {
@ -244,11 +246,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
sysUserEntity.setActiveFlag(0); sysUserEntity.setActiveFlag(0);
sysUserEntity.setAccountType("县级"); sysUserEntity.setAccountType("县级");
}
if (9 == countyCode.length()) {//街道账号7天后过期
sysUserEntity.setDayNum(7L); sysUserEntity.setDayNum(7L);
} else {//省市区县账号5天后过期
sysUserEntity.setDayNum(5L);
} }
sysUserEntity.setVipTimeRangeJson(""); sysUserEntity.setVipTimeRangeJson("");
sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now())); sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now()));

View File

@ -0,0 +1,83 @@
package com.xkrs.utilsnew;
import com.xkrs.model.bean.DataWrapper2;
import com.xkrs.model.bean.VipTimeRangeBean;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
public class TimeRangeUtils {
private TimeRangeUtils() {
}
/**
* 检查VIP是否有效
*/
public static boolean checkIfVipValid(String vipTimeRangeJson) {
LocalDateTime now = LocalDateTime.now();
List<DataWrapper2<LocalDateTime, LocalDateTime>> vipRangeList = getVipRangeList(vipTimeRangeJson);
return false;
}
/**
* 检查VIP是否过期(OK)
*/
public static boolean checkIfVipExpired(String vipTimeRangeJson) {
return !checkIfVipValid(vipTimeRangeJson);
}
/**
* 获取VIP范围列表(OK)
*/
public static List<DataWrapper2<LocalDateTime, LocalDateTime>> getVipRangeList(String vipTimeRangeJson) {
List<DataWrapper2<LocalDateTime, LocalDateTime>> vipRangeList = new ArrayList<>();//VIP范围结果列表
List<VipTimeRangeBean.VipTimeRangeItemBean> list = new ArrayList<>();//Json解析的VIP范围列表
try {
VipTimeRangeBean vipTimeRangeBean = JsonUtils.deserialize(vipTimeRangeJson, VipTimeRangeBean.class);
if (vipTimeRangeBean.getList() == null || vipTimeRangeBean.getList().size() == 0) {
throw new RuntimeException("VipTimeRangeJson Error");
}
list.addAll(vipTimeRangeBean.getList());
} catch (Exception e) {
e.printStackTrace();
}
for (VipTimeRangeBean.VipTimeRangeItemBean item : list) {
DateTimeUtils.checkDateTimeFormat(item.getStartTime());
DateTimeUtils.checkDateTimeFormat(item.getEndTime());
LocalDateTime start = DateTimeUtils.formatToLocalDateTime(item.getStartTime());
LocalDateTime end = DateTimeUtils.formatToLocalDateTime(item.getEndTime());
vipRangeList.add(new DataWrapper2<>(start, end));
}
return vipRangeList;
}
/**
* 检查试用期是否有效
*/
public static boolean checkIfProbationValid(String addTime, Long dayNum) {
LocalDateTime now = LocalDateTime.now();
DataWrapper2<LocalDateTime, LocalDateTime> probationRange = getProbationRange(addTime, dayNum);
return false;
}
/**
* 检查试用期是否过期(OK)
*/
public static boolean checkIfProbationExpired(String addTime, Long dayNum) {
return !checkIfProbationValid(addTime, dayNum);
}
/**
* 获取试用期范围(OK)
*/
public static DataWrapper2<LocalDateTime, LocalDateTime> getProbationRange(String addTime, Long dayNum) {
DateTimeUtils.checkDateTimeFormat(addTime);
LocalDateTime start = DateTimeUtils.formatToLocalDateTime(addTime);
LocalDateTime end = start.plusDays(dayNum);
return new DataWrapper2<>(start, end);
}
}

View File

@ -43,7 +43,7 @@ public class VipTimeRangeUtils {
} }
private static LocalDateTime obtainLastOverTime(String oldVipTimeRangeJson) { private static LocalDateTime obtainLastOverTime(String oldVipTimeRangeJson) {
//oldVipTimeRangeJson不为空说明不是新注册用户解析该用户的VIP时间范围 //只有付费签约的用户VipTimeRangeJson字段才不为空注册试用的用户由DayNum字段设置的天数决定试用时长
if (TextUtils.isEmpty(oldVipTimeRangeJson)) { if (TextUtils.isEmpty(oldVipTimeRangeJson)) {
return null; return null;
} }