|
@@ -10,11 +10,13 @@ import com.ym.mec.auth.api.entity.SysRole;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.auth.api.enums.SysUserType;
|
|
import com.ym.mec.auth.api.enums.SysUserType;
|
|
import com.ym.mec.biz.dal.dao.OrganizationDao;
|
|
import com.ym.mec.biz.dal.dao.OrganizationDao;
|
|
|
|
+import com.ym.mec.biz.dal.dao.TenantContractTemplateDao;
|
|
import com.ym.mec.biz.dal.dao.TenantInfoDao;
|
|
import com.ym.mec.biz.dal.dao.TenantInfoDao;
|
|
import com.ym.mec.biz.dal.dto.TenantConfigDto;
|
|
import com.ym.mec.biz.dal.dto.TenantConfigDto;
|
|
import com.ym.mec.biz.dal.dto.TenantInfoDto;
|
|
import com.ym.mec.biz.dal.dto.TenantInfoDto;
|
|
import com.ym.mec.biz.dal.dto.TenantProductInfoDto;
|
|
import com.ym.mec.biz.dal.dto.TenantProductInfoDto;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
|
+import com.ym.mec.biz.dal.entity.TenantContractTemplate;
|
|
import com.ym.mec.biz.dal.entity.TenantContractRecord.TenantContractRecordEnum;
|
|
import com.ym.mec.biz.dal.entity.TenantContractRecord.TenantContractRecordEnum;
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
import com.ym.mec.biz.dal.enums.*;
|
|
import com.ym.mec.biz.dal.vo.PlatformServePageVo;
|
|
import com.ym.mec.biz.dal.vo.PlatformServePageVo;
|
|
@@ -108,6 +110,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
@Autowired
|
|
@Autowired
|
|
@Lazy
|
|
@Lazy
|
|
private ContractService contractService;
|
|
private ContractService contractService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private SysAreaService sysAreaService;
|
|
private SysAreaService sysAreaService;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -116,6 +119,8 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
private TenantPreJoinService tenantPreJoinService;
|
|
private TenantPreJoinService tenantPreJoinService;
|
|
@Autowired
|
|
@Autowired
|
|
private TenantContractRecordService tenantContractRecordService;
|
|
private TenantContractRecordService tenantContractRecordService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private TenantContractTemplateDao tenantContractTemplateDao;
|
|
|
|
|
|
@Value("${contract.baseDir:/var/pdf}")
|
|
@Value("${contract.baseDir:/var/pdf}")
|
|
private String contractBaseDir;
|
|
private String contractBaseDir;
|
|
@@ -173,7 +178,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
setIdByApply(tenantId, dto.getConfig(), dto.getConfig()::setTenantId, tenantConfigService::addConfig);
|
|
setIdByApply(tenantId, dto.getConfig(), dto.getConfig()::setTenantId, tenantConfigService::addConfig);
|
|
//查询机构入驻表如果公司全称和联系电话相同则把入驻表修改为已入驻
|
|
//查询机构入驻表如果公司全称和联系电话相同则把入驻表修改为已入驻
|
|
TenantPreJoin preJoin = tenantPreJoinService.getOne(new QueryWrapper<TenantPreJoin>()
|
|
TenantPreJoin preJoin = tenantPreJoinService.getOne(new QueryWrapper<TenantPreJoin>()
|
|
- .eq("phone_", dto.getPhone())
|
|
|
|
|
|
+ .eq("tsign_code_", dto.getTsignCode())
|
|
.eq("state_", 0));
|
|
.eq("state_", 0));
|
|
if (Objects.nonNull(preJoin)) {
|
|
if (Objects.nonNull(preJoin)) {
|
|
preJoin.setState(1);
|
|
preJoin.setState(1);
|
|
@@ -189,11 +194,32 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public void updateTenantInfo(TenantInfoDto dto) {
|
|
public void updateTenantInfo(TenantInfoDto dto) {
|
|
|
|
+
|
|
//查询机构信息
|
|
//查询机构信息
|
|
TenantInfo tenantInfo = Optional.ofNullable(dto)
|
|
TenantInfo tenantInfo = Optional.ofNullable(dto)
|
|
.map(TenantInfoDto::getId)
|
|
.map(TenantInfoDto::getId)
|
|
.map(this::getById)
|
|
.map(this::getById)
|
|
.orElseThrow(() -> new BizException("未找到该机构信息,机构信息不能为空!"));
|
|
.orElseThrow(() -> new BizException("未找到该机构信息,机构信息不能为空!"));
|
|
|
|
+
|
|
|
|
+ Integer tenantId = tenantInfo.getId();
|
|
|
|
+
|
|
|
|
+ //是否修改了机构名称或机构编码
|
|
|
|
+ if(!StringUtils.equals(dto.getTsignName(), tenantInfo.getTsignName()) || !StringUtils.equals(dto.getTsignCode(), tenantInfo.getTsignCode())){
|
|
|
|
+ //升级机构协议版本号
|
|
|
|
+ TenantContractTemplate tenantContractTemplate = tenantContractTemplateDao.queryLatestContractTemplate(null, null, tenantId);
|
|
|
|
+ if(tenantContractTemplate != null){
|
|
|
|
+ baseMapper.getLocked(tenantId);
|
|
|
|
+
|
|
|
|
+ Integer maxVersion = tenantContractTemplateDao.queryMaxVersion();
|
|
|
|
+ int version = maxVersion == null ? 1 : maxVersion + 1;
|
|
|
|
+
|
|
|
|
+ tenantContractTemplate.setVersion(version);
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ tenantContractTemplate.setUpdateTime(date);
|
|
|
|
+
|
|
|
|
+ tenantContractTemplateDao.update(tenantContractTemplate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//机构状态 1已缴费,并且 机构注册的手机号与本次修改后的手机号不同,就证明本次修改了手机号 则需要修改机构的账号信息
|
|
//机构状态 1已缴费,并且 机构注册的手机号与本次修改后的手机号不同,就证明本次修改了手机号 则需要修改机构的账号信息
|
|
if (1 == tenantInfo.getPayState() && !Objects.equals(tenantInfo.getPhone(), dto.getPhone())) {
|
|
if (1 == tenantInfo.getPayState() && !Objects.equals(tenantInfo.getPhone(), dto.getPhone())) {
|
|
@@ -535,7 +561,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
throw new BizException("读取产品协议出错");
|
|
throw new BizException("读取产品协议出错");
|
|
} finally {
|
|
} finally {
|
|
//删除文件
|
|
//删除文件
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
+// FileUtils.deleteQuietly(srcFile);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -544,12 +570,16 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
*/
|
|
*/
|
|
private Map<String, Object> getContractParam(TenantInfoInfoPageVo tenantInfo, Date now) {
|
|
private Map<String, Object> getContractParam(TenantInfoInfoPageVo tenantInfo, Date now) {
|
|
//将数据转换为Map
|
|
//将数据转换为Map
|
|
- Map<String, Object> param = toMap(tenantInfo);
|
|
|
|
|
|
+ Map<String, Object> param = WrapperUtil.toMap(tenantInfo);
|
|
|
|
+ //当前时间
|
|
param.put("nowDate", DateUtils.formatDate(now, "yyyy年MM月dd日"));
|
|
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("expireDate", DateUtils.formatDate(getExpiryDate(tenantInfo.getExpiryCount(), tenantInfo.getExpiryUnit(), now), "yyyy年MM月dd日"));
|
|
|
|
+ //购买服务的时长单位
|
|
param.put("expiryUnit", TenantProductInfo.MONTH.equals(tenantInfo.getExpiryUnit()) ? "月" : "年");
|
|
param.put("expiryUnit", TenantProductInfo.MONTH.equals(tenantInfo.getExpiryUnit()) ? "月" : "年");
|
|
|
|
+ //乙方公章
|
|
param.put("officialSealB", "https://daya.ks3-cn-beijing.ksyun.com/202202/Sx6rzWm.png");
|
|
param.put("officialSealB", "https://daya.ks3-cn-beijing.ksyun.com/202202/Sx6rzWm.png");
|
|
- //写入产品名称
|
|
|
|
|
|
+ //获取产品名称
|
|
opsContractData(tenantInfo.getServeId(), platformServeService::queryProductNameById,
|
|
opsContractData(tenantInfo.getServeId(), platformServeService::queryProductNameById,
|
|
"未查询到产品信息!",
|
|
"未查询到产品信息!",
|
|
param::put, "productName", PlatformServePageVo::getProductName);
|
|
param::put, "productName", PlatformServePageVo::getProductName);
|
|
@@ -565,13 +595,15 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
TenantConfig tenantConfig = opsContractData(tenantInfo.getId(), tenantConfigService::queryByTenantId,
|
|
TenantConfig tenantConfig = opsContractData(tenantInfo.getId(), tenantConfigService::queryByTenantId,
|
|
"未查询到机构配置信息!",
|
|
"未查询到机构配置信息!",
|
|
param::put, "chargeRate", TenantConfig::getChargeRate);
|
|
param::put, "chargeRate", TenantConfig::getChargeRate);
|
|
|
|
+ //甲方企业公章
|
|
|
|
+ param.put("officialSealA", tenantConfig.getCorporateChops());
|
|
//获取云教室规则 String人数 BigDecimal每分钟扣费标准
|
|
//获取云教室规则 String人数 BigDecimal每分钟扣费标准
|
|
Map<String, BigDecimal> rule = opsContractData(tenantConfig.getConfig(), tenantConfigService::getCloudRoomRule,
|
|
Map<String, BigDecimal> rule = opsContractData(tenantConfig.getConfig(), tenantConfigService::getCloudRoomRule,
|
|
"未查询到云教室的价格配置!",
|
|
"未查询到云教室的价格配置!",
|
|
param::put, "rowspan", Map::size);
|
|
param::put, "rowspan", Map::size);
|
|
|
|
|
|
AtomicReference<String> rowspanData = new AtomicReference<>("");
|
|
AtomicReference<String> rowspanData = new AtomicReference<>("");
|
|
- //生成默认云教室数据
|
|
|
|
|
|
+ //生成云教室扣费的样式
|
|
rule.forEach((k, v) -> {
|
|
rule.forEach((k, v) -> {
|
|
//人数
|
|
//人数
|
|
int count = Integer.parseInt(k) - 1;
|
|
int count = Integer.parseInt(k) - 1;
|
|
@@ -585,13 +617,6 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
return param;
|
|
return param;
|
|
}
|
|
}
|
|
|
|
|
|
- private Map toMap(TenantInfoInfoPageVo tenantInfo) {
|
|
|
|
- return Optional.ofNullable(tenantInfo)
|
|
|
|
- .map(JSONObject::toJSON)
|
|
|
|
- .map(o -> JSONObject.toJavaObject((JSONObject) o, Map.class))
|
|
|
|
- .orElse(null);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private static <O, T, S> T opsContractData(O param, Function<O, T> fun, String msg,
|
|
private static <O, T, S> T opsContractData(O param, Function<O, T> fun, String msg,
|
|
BiConsumer<String, Object> putC, String key, Function<T, S> val) {
|
|
BiConsumer<String, Object> putC, String key, Function<T, S> val) {
|
|
Optional<T> optional = Optional.ofNullable(fun.apply(param));
|
|
Optional<T> optional = Optional.ofNullable(fun.apply(param));
|
|
@@ -620,7 +645,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
*/
|
|
*/
|
|
public String getContractAndUpLoad(Integer tenantId) {
|
|
public String getContractAndUpLoad(Integer tenantId) {
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
- //创建地址
|
|
|
|
|
|
+ //创建PDF本次缓存地址
|
|
String srcPdfPath = contractBaseDir + lexiaoyaContract + DateUtils.formatDate(now, "yyyyMMddHHmmss") + "/" + tenantId + "_" + java.time.LocalDateTime.now().getSecond() + ".pdf";
|
|
String srcPdfPath = contractBaseDir + lexiaoyaContract + DateUtils.formatDate(now, "yyyyMMddHHmmss") + "/" + tenantId + "_" + java.time.LocalDateTime.now().getSecond() + ".pdf";
|
|
//生成文件
|
|
//生成文件
|
|
File srcFile = new File(srcPdfPath);
|
|
File srcFile = new File(srcPdfPath);
|
|
@@ -640,7 +665,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
|
|
String dateStrOss = DateUtils.formatDate(now, "yyyy/MM/dd");
|
|
String dateStrOss = DateUtils.formatDate(now, "yyyy/MM/dd");
|
|
dateStrOss = "oa/" + dateStrOss + "/" + DateUtil.getHour(now);
|
|
dateStrOss = "oa/" + dateStrOss + "/" + DateUtil.getHour(now);
|
|
String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
- //删除生成的文件
|
|
|
|
|
|
+ //删除本次PDF生成的文件缓存
|
|
FileUtils.deleteQuietly(srcFile);
|
|
FileUtils.deleteQuietly(srcFile);
|
|
return pdfFilePath;
|
|
return pdfFilePath;
|
|
}
|
|
}
|