|
@@ -6,6 +6,7 @@ import java.text.DateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
@@ -16,10 +17,15 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
|
+import com.ym.mec.biz.dal.dto.StudentInfo;
|
|
|
|
+import com.ym.mec.biz.dal.entity.Goods;
|
|
import com.ym.mec.biz.dal.entity.SysUserContracts;
|
|
import com.ym.mec.biz.dal.entity.SysUserContracts;
|
|
import com.ym.mec.biz.dal.entity.SysUserContracts.ContractType;
|
|
import com.ym.mec.biz.dal.entity.SysUserContracts.ContractType;
|
|
import com.ym.mec.biz.dal.entity.SysUserTsign;
|
|
import com.ym.mec.biz.dal.entity.SysUserTsign;
|
|
|
|
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
import com.ym.mec.biz.service.ContractService;
|
|
import com.ym.mec.biz.service.ContractService;
|
|
|
|
+import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
|
+import com.ym.mec.biz.service.StudentRegistrationService;
|
|
import com.ym.mec.biz.service.SysUserContractsService;
|
|
import com.ym.mec.biz.service.SysUserContractsService;
|
|
import com.ym.mec.biz.service.SysUserTsignService;
|
|
import com.ym.mec.biz.service.SysUserTsignService;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
@@ -39,6 +45,12 @@ public class ContractServiceImpl implements ContractService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SysUserContractsService sysUserContractsService;
|
|
private SysUserContractsService sysUserContractsService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentRegistrationService studentRegistrationService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ESealPlugin eSealPlugin;
|
|
private ESealPlugin eSealPlugin;
|
|
@@ -162,7 +174,7 @@ public class ContractServiceImpl implements ContractService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean transferCoursesContract(Integer userId, Integer musicGroupId) {
|
|
|
|
|
|
+ public boolean transferMusicGroupCoursesContract(Integer userId, Integer musicGroupId) {
|
|
SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
|
|
if (sysUserTsign == null) {
|
|
if (sysUserTsign == null) {
|
|
@@ -182,7 +194,8 @@ public class ContractServiceImpl implements ContractService {
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
//查询参数信息
|
|
//查询参数信息
|
|
-
|
|
|
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
templateEngine.render(params, "courses.ftl", new File(srcPdfPath));
|
|
templateEngine.render(params, "courses.ftl", new File(srcPdfPath));
|
|
|
|
|
|
@@ -215,7 +228,7 @@ public class ContractServiceImpl implements ContractService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String queryCoursesContract(Integer userId, Integer musicGroupId) {
|
|
|
|
|
|
+ public String queryMusicGroupCoursesContract(Integer userId, Integer musicGroupId) {
|
|
|
|
|
|
// 合成freemarker
|
|
// 合成freemarker
|
|
String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
@@ -228,6 +241,9 @@ public class ContractServiceImpl implements ContractService {
|
|
templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+
|
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
templateEngine.render(params, "courses.ftl", new File(srcPdfPath));
|
|
templateEngine.render(params, "courses.ftl", new File(srcPdfPath));
|
|
|
|
|
|
@@ -242,4 +258,95 @@ public class ContractServiceImpl implements ContractService {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean transferGoodsContract(Integer userId, Integer musicGroupId) {
|
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
+
|
|
|
|
+ if (sysUserTsign == null) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 合成freemarker
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/goods/" + userId + ".pdf";
|
|
|
|
+ File debtFile = new File(contractBaseDir);
|
|
|
|
+ if (!debtFile.exists()) {
|
|
|
|
+ debtFile.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
+
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+
|
|
|
|
+ //查询参数信息
|
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
+
|
|
|
|
+ List<Goods> goodsList = studentPaymentOrderService.queryApplyGoodsList(musicGroupId, OrderDetailTypeEnum.MUSICAL);
|
|
|
|
+ params.put("goodsList", goodsList);
|
|
|
|
+
|
|
|
|
+ templateEngine.render(params, "goods.ftl", new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ // 生成借款协议PDF
|
|
|
|
+ try {
|
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(new File(srcPdfPath)), srcPdfPath,
|
|
|
|
+ "config/fonts/simsun.ttc");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BizException("生成pdf协议失败", e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
+
|
|
|
|
+ Date date = new Date();
|
|
|
|
+ // 上传到oss
|
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
|
+ String pdfFilePath = storagePlugin.uploadFile(dateStrOss, new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
|
+ sysUserContracts.setType(ContractType.REGISTER);
|
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
+
|
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
+
|
|
|
|
+ FileUtils.deleteQuietly(new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String queryGoodsContract(Integer userId, Integer musicGroupId) {
|
|
|
|
+
|
|
|
|
+ // 合成freemarker
|
|
|
|
+ String srcPdfPath = contractBaseDir + "/goods/" + userId + ".pdf";
|
|
|
|
+ File debtFile = new File(contractBaseDir);
|
|
|
|
+ if (!debtFile.exists()) {
|
|
|
|
+ debtFile.mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
+
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+
|
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
+
|
|
|
|
+ List<Goods> goodsList = studentPaymentOrderService.queryApplyGoodsList(musicGroupId, OrderDetailTypeEnum.MUSICAL);
|
|
|
|
+ params.put("goodsList", goodsList);
|
|
|
|
+
|
|
|
|
+ templateEngine.render(params, "goods.ftl", new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ String result = "";
|
|
|
|
+ try {
|
|
|
|
+ result = FileUtils.readFileToString(new File(srcPdfPath));
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new BizException("读取商品协议出错", e);
|
|
|
|
+ }
|
|
|
|
+ FileUtils.deleteQuietly(new File(srcPdfPath));
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|