|
@@ -539,10 +539,24 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
.filter(CollectionUtils::isNotEmpty)
|
|
|
.map(a -> a.get(0))
|
|
|
.orElseThrow(() -> new BizException("未查询到机构信息"));
|
|
|
- //如果本次协议是开通服务则直接取开通时的价格
|
|
|
+ Date now = new Date();
|
|
|
+ Date startDate = now;
|
|
|
+ Date expiryDate;
|
|
|
+ //如果本次协议是开通服务则直接取开通时的价格并在现在的时间计算到期时间
|
|
|
if (TenantContractRecordEnum.OPEN.equals(en)) {
|
|
|
tenantInfo.setContractPrice(tenantInfo.getOpenPrice());
|
|
|
+ expiryDate = getExpiryDate(val, tenantInfo.getExpiryUnit(), now);
|
|
|
} else {
|
|
|
+ //修改续费时间
|
|
|
+ if (tenantInfo.getExpireDate().compareTo(now) > 0) {
|
|
|
+ //在上一个到期时间节点上做增加时间的操作
|
|
|
+ expiryDate = getExpiryDate(val, tenantInfo.getExpiryUnit(), tenantInfo.getExpireDate());
|
|
|
+ //协议开始时间为上一个到期时间节点+1天
|
|
|
+ startDate = DateUtils.addDays(tenantInfo.getExpireDate(), 1);
|
|
|
+ } else {
|
|
|
+ //如果上一个时间已经到期则 取现在时间
|
|
|
+ expiryDate = getExpiryDate(val, tenantInfo.getExpiryUnit(), now);
|
|
|
+ }
|
|
|
//续费时 取合同价
|
|
|
BigDecimal contractAmount = tenantInfo.getContractPrice().multiply(new BigDecimal(val), new MathContext(1, RoundingMode.HALF_UP));
|
|
|
tenantInfo.setContractPrice(contractAmount);
|
|
@@ -550,6 +564,14 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
}
|
|
|
//获取协议变量参数
|
|
|
Map<String, Object> param = getContractParam(tenantInfo);
|
|
|
+ //设置协议服务开始的时间和到期时间
|
|
|
+ Function<Date, String> getStrDate = (date) -> DateUtils.formatDate(date, "yyyy年MM月dd日");
|
|
|
+ //协议中服务开始时间
|
|
|
+ param.put("startDate", getStrDate.apply(startDate));
|
|
|
+ //协议中服务过期时间
|
|
|
+ param.put("expireDate", getStrDate.apply(expiryDate));
|
|
|
+ //当前时间
|
|
|
+ param.put("nowDate", getStrDate.apply(now));
|
|
|
//生成模版
|
|
|
FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
templateEngine.setClassForTemplateLoading(TenantInfoServiceImpl.class, "/config/contracts/");
|
|
@@ -579,10 +601,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
Date now = new Date();
|
|
|
//将数据转换为Map
|
|
|
Map<String, Object> param = WrapperUtil.toMap(tenantInfo);
|
|
|
- //当前时间
|
|
|
- param.put("nowDate", DateUtils.formatDate(now, "yyyy年MM月dd日"));
|
|
|
- //服务过期时间
|
|
|
- param.put("expireDate", DateUtils.formatDate(getExpiryDate(tenantInfo.getExpiryCount(), tenantInfo.getExpiryUnit(), now), "yyyy年MM月dd日"));
|
|
|
//购买服务的时长单位
|
|
|
param.put("expiryUnit", TenantProductInfo.MONTH.equals(tenantInfo.getExpiryUnit()) ? "个月" : "年");
|
|
|
//乙方公章
|
|
@@ -685,7 +703,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
|
//删除本次PDF生成的文件缓存
|
|
|
FileUtils.deleteQuietly(srcFile);
|
|
|
//删除缓存
|
|
|
- if(en.equals(TenantContractRecordEnum.RENEW)){
|
|
|
+ if (en.equals(TenantContractRecordEnum.RENEW)) {
|
|
|
redissonClient.getBucket(key).delete();
|
|
|
}
|
|
|
return pdfFilePath;
|