|
@@ -2,6 +2,7 @@ package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.text.DateFormat;
|
|
import java.text.DateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@@ -81,7 +82,7 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
-
|
|
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
|
|
private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
|
|
|
|
|
|
@@ -116,7 +117,7 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
private String contractBaseDir;
|
|
private String contractBaseDir;
|
|
|
|
|
|
private DateFormat dateFormatOss = new SimpleDateFormat("yyyy/MM/dd");
|
|
private DateFormat dateFormatOss = new SimpleDateFormat("yyyy/MM/dd");
|
|
-
|
|
|
|
|
|
+
|
|
private DateFormat dateFormat1 = new SimpleDateFormat("yyMMddHHmmSS");
|
|
private DateFormat dateFormat1 = new SimpleDateFormat("yyMMddHHmmSS");
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -215,8 +216,7 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
// 生成借款协议PDF
|
|
// 生成借款协议PDF
|
|
try {
|
|
try {
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath,
|
|
|
|
- "simsun.ttc");
|
|
|
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("生成pdf协议失败", e);
|
|
throw new BizException("生成pdf协议失败", e);
|
|
}
|
|
}
|
|
@@ -267,8 +267,9 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
result = FileUtils.readFileToString(srcFile);
|
|
result = FileUtils.readFileToString(srcFile);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("读取注册协议出错", e);
|
|
throw new BizException("读取注册协议出错", e);
|
|
|
|
+ } finally {
|
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
}
|
|
}
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -348,22 +349,21 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
// 生成借款协议PDF
|
|
// 生成借款协议PDF
|
|
try {
|
|
try {
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath,
|
|
|
|
- "simsun.ttc");
|
|
|
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("生成pdf协议失败", e);
|
|
throw new BizException("生成pdf协议失败", e);
|
|
}
|
|
}
|
|
String organCode = "";
|
|
String organCode = "";
|
|
- if(musicGroup.getOwnershipType() == OwnershipType.OWN){
|
|
|
|
|
|
+ if (musicGroup.getOwnershipType() == OwnershipType.OWN) {
|
|
organCode = "91440300326364429H";
|
|
organCode = "91440300326364429H";
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
organCode = "91420106333619290A";
|
|
organCode = "91420106333619290A";
|
|
}
|
|
}
|
|
SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
- if(organTsign == null){
|
|
|
|
|
|
+ if (organTsign == null) {
|
|
throw new BizException("甲方未创建签章");
|
|
throw new BizException("甲方未创建签章");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
|
|
@@ -454,8 +454,9 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
result = FileUtils.readFileToString(srcFile);
|
|
result = FileUtils.readFileToString(srcFile);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("读取课程协议出错", e);
|
|
throw new BizException("读取课程协议出错", e);
|
|
|
|
+ } finally {
|
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
}
|
|
}
|
|
- FileUtils.deleteQuietly(new File(srcPdfPath));
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -513,17 +514,16 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
// 生成借款协议PDF
|
|
// 生成借款协议PDF
|
|
try {
|
|
try {
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath,
|
|
|
|
- "simsun.ttc");
|
|
|
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("生成pdf协议失败", e);
|
|
throw new BizException("生成pdf协议失败", e);
|
|
}
|
|
}
|
|
String organCode = "91440300326364429H";
|
|
String organCode = "91440300326364429H";
|
|
SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
- if(organTsign == null){
|
|
|
|
|
|
+ if (organTsign == null) {
|
|
throw new BizException("甲方未创建签章");
|
|
throw new BizException("甲方未创建签章");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
@@ -591,8 +591,9 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
result = FileUtils.readFileToString(srcFile);
|
|
result = FileUtils.readFileToString(srcFile);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("读取课程协议出错", e);
|
|
throw new BizException("读取课程协议出错", e);
|
|
|
|
+ } finally {
|
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
}
|
|
}
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -673,22 +674,21 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
// 生成借款协议PDF
|
|
// 生成借款协议PDF
|
|
try {
|
|
try {
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath,
|
|
|
|
- "simsun.ttc");
|
|
|
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("生成pdf协议失败", e);
|
|
throw new BizException("生成pdf协议失败", e);
|
|
}
|
|
}
|
|
String organCode = "";
|
|
String organCode = "";
|
|
- if(musicGroup.getOwnershipType() == OwnershipType.OWN){
|
|
|
|
|
|
+ if (musicGroup.getOwnershipType() == OwnershipType.OWN) {
|
|
organCode = "91440300326364429H";
|
|
organCode = "91440300326364429H";
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
organCode = "91420106333619290A";
|
|
organCode = "91420106333619290A";
|
|
}
|
|
}
|
|
SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
- if(organTsign == null){
|
|
|
|
|
|
+ if (organTsign == null) {
|
|
throw new BizException("甲方未创建签章");
|
|
throw new BizException("甲方未创建签章");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
@@ -781,10 +781,115 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
result = FileUtils.readFileToString(srcFile);
|
|
result = FileUtils.readFileToString(srcFile);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new BizException("读取商品协议出错", e);
|
|
throw new BizException("读取商品协议出错", e);
|
|
|
|
+ } finally {
|
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
}
|
|
}
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String queryPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
|
+ // 合成freemarker
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/practice/" + userId + ".pdf";
|
|
|
|
+
|
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
+
|
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
|
+ if (!debtFile.exists()) {
|
|
|
|
+ debtFile.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
+
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+ params.put("courseSectionNum", courseSectionNum);
|
|
|
|
+ params.put("startDate", startDate);
|
|
|
|
+ params.put("endDate", endDate);
|
|
|
|
+ params.put("fee", fee);
|
|
|
|
+
|
|
|
|
+ templateEngine.render(params, "practice.ftl", srcFile);
|
|
|
|
+
|
|
|
|
+ String result = "";
|
|
|
|
+ try {
|
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BizException("读取陪练课购买协议出错", e);
|
|
|
|
+ } finally {
|
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean transferPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
+
|
|
|
|
+ if (sysUserTsign == null) {
|
|
|
|
+ SysUser user = sysUserFeignService.queryUserById(userId);
|
|
|
|
+ if (user == null) {
|
|
|
|
+ throw new BizException("用户信息查询失败");
|
|
|
|
+ }
|
|
|
|
+ sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Date date = new Date();
|
|
|
|
+
|
|
|
|
+ // 合成freemarker
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/practice/" + userId + ".pdf";
|
|
|
|
+
|
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
+
|
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
|
+ if (!debtFile.exists()) {
|
|
|
|
+ debtFile.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
+
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+ params.put("courseSectionNum", courseSectionNum);
|
|
|
|
+ params.put("startDate", startDate);
|
|
|
|
+ params.put("endDate", endDate);
|
|
|
|
+ params.put("fee", fee);
|
|
|
|
+
|
|
|
|
+ templateEngine.render(params, "practice.ftl", srcFile);
|
|
|
|
+
|
|
|
|
+ // 生成借款协议PDF
|
|
|
|
+ try {
|
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BizException("生成pdf协议失败", e);
|
|
|
|
+ }
|
|
|
|
+ String organCode = "91440300326364429H";
|
|
|
|
+ SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
|
+ if (organTsign == null) {
|
|
|
|
+ throw new BizException("甲方未创建签章");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
+
|
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
+
|
|
|
|
+ // 上传到oss
|
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
|
+ dateStrOss = "practice/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
|
+ String pdfFilePath = storagePlugin.uploadFile(dateStrOss, srcFile);
|
|
|
|
+
|
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
|
+ sysUserContracts.setType(ContractType.REGISTER);
|
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
+
|
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
+
|
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|