|
@@ -1,69 +1,18 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
-import java.util.Map.Entry;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import com.ym.mec.biz.dal.dao.*;
|
|
|
-import com.ym.mec.biz.dal.dto.CirculationUser;
|
|
|
-import com.ym.mec.biz.dal.dto.OAFinancialDto;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.factory.InitializingBean;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Isolation;
|
|
|
-import org.springframework.transaction.annotation.Propagation;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.auth.api.enums.CertificateTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.CirculationUser;
|
|
|
+import com.ym.mec.biz.dal.dto.OAFinancialDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentInfo;
|
|
|
import com.ym.mec.biz.dal.entity.CooperationOrgan.OwnershipType;
|
|
|
-import com.ym.mec.biz.dal.entity.Goods;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
|
|
|
-import com.ym.mec.biz.dal.entity.StudentRegistration;
|
|
|
-import com.ym.mec.biz.dal.entity.Subject;
|
|
|
-import com.ym.mec.biz.dal.entity.SysUserContracts;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.entity.SysUserContracts.ContractType;
|
|
|
-import com.ym.mec.biz.dal.entity.SysUserTsign;
|
|
|
-import com.ym.mec.biz.dal.entity.VipGroup;
|
|
|
import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
|
|
|
-import com.ym.mec.biz.service.ContractService;
|
|
|
-import com.ym.mec.biz.service.GoodsService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupSubjectGoodsGroupService;
|
|
|
-import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentRegistrationService;
|
|
|
-import com.ym.mec.biz.service.SubjectService;
|
|
|
-import com.ym.mec.biz.service.SysUserContractsService;
|
|
|
-import com.ym.mec.biz.service.SysUserTsignService;
|
|
|
-import com.ym.mec.biz.service.VipGroupService;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
@@ -76,422 +25,451 @@ import com.ym.mec.util.date.DateUtil;
|
|
|
import com.ym.mec.util.freemarker.FreemarkerTemplateEngine;
|
|
|
import com.ym.mec.util.money.MoneyUtil;
|
|
|
import com.ym.mec.util.pdf.PDFUtil;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.InitializingBean;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysUserTsignService sysUserTsignService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysUserContractsService sysUserContractsService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private SysUserContractsDao sysUserContractsDao;
|
|
|
+ @Autowired
|
|
|
+ private SysUserTsignService sysUserTsignService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentRegistrationService studentRegistrationService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentRegistrationDao studentRegistrationDao;
|
|
|
+ @Autowired
|
|
|
+ private SysUserContractsService sysUserContractsService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserContractsDao sysUserContractsDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
|
+ @Autowired
|
|
|
+ private StudentRegistrationService studentRegistrationService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
|
|
|
+ @Autowired
|
|
|
+ private StudentRegistrationDao studentRegistrationDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
|
|
|
|
|
|
- @Autowired
|
|
|
- @Lazy
|
|
|
- private VipGroupService vipGroupService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SubjectService subjectService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ESealPlugin eSealPlugin;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StoragePluginContext storagePluginContext;
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private VipGroupService vipGroupService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private GoodsService goodsService;
|
|
|
+ @Autowired
|
|
|
+ private SubjectService subjectService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupService musicGroupService;
|
|
|
+ @Autowired
|
|
|
+ private ESealPlugin eSealPlugin;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private StoragePluginContext storagePluginContext;
|
|
|
|
|
|
- @Autowired
|
|
|
- private EmployeeDao employeeDao;
|
|
|
+ @Autowired
|
|
|
+ private GoodsService goodsService;
|
|
|
|
|
|
- @Value("${contract.baseDir:/var/pdf}")
|
|
|
- private String contractBaseDir;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupService musicGroupService;
|
|
|
|
|
|
- @Value("${message.debugMode}")
|
|
|
- private boolean debugMode;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RealnameAuthenticationPluginContext realnameAuthenticationPluginContext;
|
|
|
+ @Autowired
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
|
|
|
- private DateFormat dateFormatOss = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+ @Value("${contract.baseDir:/var/pdf}")
|
|
|
+ private String contractBaseDir;
|
|
|
|
|
|
- private DateFormat dateFormat1 = new SimpleDateFormat("yyMMddHHmmSS");
|
|
|
+ @Value("${message.debugMode}")
|
|
|
+ private boolean debugMode;
|
|
|
|
|
|
- private final Logger logger = LoggerFactory.getLogger(ContractService.class);
|
|
|
+ @Autowired
|
|
|
+ private RealnameAuthenticationPluginContext realnameAuthenticationPluginContext;
|
|
|
|
|
|
- @Override
|
|
|
- public void afterPropertiesSet() throws Exception {
|
|
|
- // 注册企业账户
|
|
|
- Map<String, String> organList = new HashMap<String, String>();
|
|
|
- organList.put("91420106333619290A", "武汉长乐长风乐器销售有限公司");
|
|
|
- organList.put("91440300326364429H", "深圳大雅乐盟网络教育股份有限公司");
|
|
|
+ private DateFormat dateFormatOss = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
|
|
|
- for (Entry<String, String> organ : organList.entrySet()) {
|
|
|
+ private DateFormat dateFormat1 = new SimpleDateFormat("yyMMddHHmmSS");
|
|
|
|
|
|
- String organCode = organ.getKey();
|
|
|
- String orgName = organ.getValue();
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(ContractService.class);
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
+ @Override
|
|
|
+ public void afterPropertiesSet() throws Exception {
|
|
|
+ // 注册企业账户
|
|
|
+ Map<String, String> organList = new HashMap<String, String>();
|
|
|
+ organList.put("91420106333619290A", "武汉长乐长风乐器销售有限公司");
|
|
|
+ organList.put("91440300326364429H", "深圳大雅乐盟网络教育股份有限公司");
|
|
|
|
|
|
- if (sysUserTsign == null) {
|
|
|
- String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
|
|
|
+ organList.forEach((code, name) -> {
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.queryByCardNo(code);
|
|
|
+ if (Objects.isNull(sysUserTsign)) {
|
|
|
+ addTsign(code, name);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(accountId)) {
|
|
|
- throw new BizException("创建企业电子存证账户失败");
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 校验企业营业信息,不存在则添加一个
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void addTsign(String organCode, String orgName) {
|
|
|
+ Optional.ofNullable(organCode).orElseThrow(() -> new BizException("营业执照编号不能为空!"));
|
|
|
+ Optional.ofNullable(orgName).orElseThrow(() -> new BizException("营业名称不能为空"));
|
|
|
|
|
|
- String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
|
|
|
+ String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
|
|
|
+ if (StringUtils.isBlank(accountId)) {
|
|
|
+ throw new BizException("创建企业电子存证账户失败");
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(sealData)) {
|
|
|
- throw new BizException("创建电子存证印章失败");
|
|
|
- }
|
|
|
+ String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
|
|
|
+ if (StringUtils.isBlank(sealData)) {
|
|
|
+ throw new BizException("创建电子存证印章失败");
|
|
|
+ }
|
|
|
|
|
|
- sysUserTsign = new SysUserTsign(-1, accountId, sealData, orgName, organCode);
|
|
|
+ SysUserTsign sysUserTsign = new SysUserTsign(-1, accountId, sealData, orgName, organCode);
|
|
|
+ sysUserTsignService.insert(sysUserTsign);
|
|
|
+ }
|
|
|
|
|
|
- sysUserTsignService.insert(sysUserTsign);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo) {
|
|
|
|
|
|
- @Override
|
|
|
- public SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo) {
|
|
|
+ if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCardNo) || StringUtils.isBlank(mobileNo)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCardNo) || StringUtils.isBlank(mobileNo)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ if (sysUserTsign == null) {
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
- if (sysUserTsign == null) {
|
|
|
+ String accountId = "";
|
|
|
+ String sealData = "";
|
|
|
|
|
|
- String accountId = "";
|
|
|
- String sealData = "";
|
|
|
+ SysUser user = studentDao.getUser(userId);
|
|
|
+ if (user == null) {
|
|
|
+ throw new BizException("用户信息查询失败");
|
|
|
+ }
|
|
|
|
|
|
- SysUser user = studentDao.getUser(userId);
|
|
|
- if (user == null) {
|
|
|
- throw new BizException("用户信息查询失败");
|
|
|
- }
|
|
|
+ if (CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())) {
|
|
|
+ if (!debugMode) {
|
|
|
+ realnameAuthenticationPluginContext.getRealnameAuthenticationPlugin(LinkfaceRealnameAuthenticationPlugin.getName()).verify(realName, idCardNo);
|
|
|
+ }
|
|
|
|
|
|
- if(CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())){
|
|
|
- if(!debugMode){
|
|
|
- realnameAuthenticationPluginContext.getRealnameAuthenticationPlugin(LinkfaceRealnameAuthenticationPlugin.getName()).verify(realName, idCardNo);
|
|
|
- }
|
|
|
+ accountId = eSealPlugin.createUserAccount(realName, idCardNo, mobileNo);
|
|
|
|
|
|
- accountId = eSealPlugin.createUserAccount(realName, idCardNo, mobileNo);
|
|
|
+ if (StringUtils.isBlank(accountId)) {
|
|
|
+ throw new BizException("创建电子存证账户失败");
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(accountId)) {
|
|
|
- throw new BizException("创建电子存证账户失败");
|
|
|
- }
|
|
|
+ sealData = eSealPlugin.createUserSeal(accountId);
|
|
|
|
|
|
- sealData = eSealPlugin.createUserSeal(accountId);
|
|
|
+ if (StringUtils.isBlank(sealData)) {
|
|
|
+ throw new BizException("创建电子存证印章失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(sealData)) {
|
|
|
- throw new BizException("创建电子存证印章失败");
|
|
|
- }
|
|
|
- }
|
|
|
+ sysUserTsign = new SysUserTsign(userId, accountId, sealData, realName, idCardNo);
|
|
|
|
|
|
- sysUserTsign = new SysUserTsign(userId, accountId, sealData, realName, idCardNo);
|
|
|
+ sysUserTsignService.insert(sysUserTsign);
|
|
|
|
|
|
- sysUserTsignService.insert(sysUserTsign);
|
|
|
+ return sysUserTsign;
|
|
|
+ }
|
|
|
|
|
|
- return sysUserTsign;
|
|
|
- }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public boolean transferRegisterContract(Integer userId) {
|
|
|
|
|
|
- @Override
|
|
|
- public boolean transferRegisterContract(Integer userId) {
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
|
|
- 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());
|
|
|
+ }
|
|
|
|
|
|
- if (sysUserTsign == null) {
|
|
|
- SysUser user = sysUserFeignService.queryUserById(userId);
|
|
|
- if (user == null) {
|
|
|
- throw new BizException("用户信息查询失败");
|
|
|
- }
|
|
|
- sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
- }
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/register/" + userId + ".pdf";
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/register/" + userId + ".pdf";
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
+
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ templateEngine.render(params, "register.ftl", srcFile);
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ // 生成借款协议PDF
|
|
|
+ try {
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("生成pdf协议失败", e);
|
|
|
+ }
|
|
|
|
|
|
- templateEngine.render(params, "register.ftl", srcFile);
|
|
|
+ if (sysUserTsign != null) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
|
|
|
- // 生成借款协议PDF
|
|
|
- try {
|
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("生成pdf协议失败", e);
|
|
|
- }
|
|
|
+ Date date = new Date();
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "users/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
|
|
|
- if (sysUserTsign != null) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.REGISTER);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
|
|
- Date date = new Date();
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "users/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.REGISTER);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
+ @Override
|
|
|
+ public String queryRegisterContract(Integer userId) {
|
|
|
|
|
|
- return true;
|
|
|
- }
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/register/" + userId + ".pdf";
|
|
|
|
|
|
- @Override
|
|
|
- public String queryRegisterContract(Integer userId) {
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/register/" + userId + ".pdf";
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ templateEngine.render(params, "register.ftl", srcFile);
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取注册协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- templateEngine.render(params, "register.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 transferMusicGroupCoursesContract(Integer userId, String musicGroupId) {
|
|
|
- if(true){
|
|
|
- transferProduceContract(userId, musicGroupId, null);
|
|
|
- return true;
|
|
|
- }
|
|
|
- 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 + "/courses/" + dateFormat1.format(date) + "/" + 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>();
|
|
|
-
|
|
|
- // 查询参数信息
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
-
|
|
|
- // 课程类型
|
|
|
- params.put("classesType", "乐团团课");
|
|
|
-
|
|
|
- // 课程费用
|
|
|
- StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
- if (studentRegistration == null) {
|
|
|
- throw new BizException("用户 报名信息不存在");
|
|
|
- }
|
|
|
- MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
|
|
|
- if (musicGroupStudentFee == null) {
|
|
|
- MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId,
|
|
|
- studentRegistration.getActualSubjectId());
|
|
|
- if (musicGroupSubjectPlan == null) {
|
|
|
- throw new BizException("声部课程费用设置找不到");
|
|
|
- }
|
|
|
- params.put("courseFee", musicGroupSubjectPlan.getFee().doubleValue());
|
|
|
- } else {
|
|
|
- params.put("courseFee", musicGroupStudentFee.getTemporaryCourseFee().doubleValue() > 0 ? musicGroupStudentFee.getTemporaryCourseFee().doubleValue()
|
|
|
- : musicGroupStudentFee.getCourseFee().doubleValue());
|
|
|
- }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- // 收费形式
|
|
|
- List<MusicGroupPaymentCalender> calenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
+ @Override
|
|
|
+ public boolean transferMusicGroupCoursesContract(Integer userId, String musicGroupId) {
|
|
|
+ if (true) {
|
|
|
+ transferProduceContract(userId, musicGroupId, null);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ 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 + "/courses/" + dateFormat1.format(date) + "/" + 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>();
|
|
|
+
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
+
|
|
|
+ // 课程类型
|
|
|
+ params.put("classesType", "乐团团课");
|
|
|
+
|
|
|
+ // 课程费用
|
|
|
+ StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+ if (studentRegistration == null) {
|
|
|
+ throw new BizException("用户 报名信息不存在");
|
|
|
+ }
|
|
|
+ MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
|
|
|
+ if (musicGroupStudentFee == null) {
|
|
|
+ MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId,
|
|
|
+ studentRegistration.getActualSubjectId());
|
|
|
+ if (musicGroupSubjectPlan == null) {
|
|
|
+ throw new BizException("声部课程费用设置找不到");
|
|
|
+ }
|
|
|
+ params.put("courseFee", musicGroupSubjectPlan.getFee().doubleValue());
|
|
|
+ } else {
|
|
|
+ params.put("courseFee", musicGroupStudentFee.getTemporaryCourseFee().doubleValue() > 0 ? musicGroupStudentFee.getTemporaryCourseFee().doubleValue()
|
|
|
+ : musicGroupStudentFee.getCourseFee().doubleValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收费形式
|
|
|
+ List<MusicGroupPaymentCalender> calenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
|
|
|
/*if (calenders == null || calenders.size() == 0) {
|
|
|
|
|
|
} else {
|
|
|
params.put("paymentcalender", calenders.stream().map(cal -> cal.getPaymentMonth().toString()).collect(Collectors.joining("月,")) + "月");
|
|
|
}*/
|
|
|
- params.put("paymentcalender", "一次性");
|
|
|
-
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
-
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- throw new BizException("乐团信息没找到");
|
|
|
- }
|
|
|
-
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
-
|
|
|
- templateEngine.render(params, "courses.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 = "";
|
|
|
- if (musicGroup.getOwnershipType() == OwnershipType.OWN) {
|
|
|
- organCode = "91440300326364429H";
|
|
|
- } else {
|
|
|
- organCode = "91420106333619290A";
|
|
|
- }
|
|
|
- SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
- if (organTsign == null) {
|
|
|
- throw new BizException("甲方未创建签章");
|
|
|
- }
|
|
|
-
|
|
|
- eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- if (sysUserTsign != null) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
-
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "musicCourses/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
-
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.COURSES);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
-
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
-
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public String queryMusicGroupCoursesContract(Integer userId, String musicGroupId) {
|
|
|
-
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/courses/" + 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>();
|
|
|
-
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
-
|
|
|
- // 课程类型
|
|
|
- params.put("classesType", "乐团团课");
|
|
|
-
|
|
|
- // 课程费用
|
|
|
- StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
- if (studentRegistration == null) {
|
|
|
- throw new BizException("用户报名信息不存在");
|
|
|
- }
|
|
|
- MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
|
|
|
- if (musicGroupStudentFee == null) {
|
|
|
- MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId,
|
|
|
- studentRegistration.getActualSubjectId());
|
|
|
- if (musicGroupSubjectPlan == null) {
|
|
|
- throw new BizException("声部课程费用设置找不到");
|
|
|
- }
|
|
|
- params.put("courseFee", musicGroupSubjectPlan.getFee().doubleValue());
|
|
|
- } else {
|
|
|
- params.put(
|
|
|
- "courseFee",
|
|
|
- (musicGroupStudentFee.getTemporaryCourseFee() != null && musicGroupStudentFee.getTemporaryCourseFee().doubleValue() > 0) ? musicGroupStudentFee
|
|
|
- .getTemporaryCourseFee().doubleValue() : musicGroupStudentFee.getCourseFee().doubleValue());
|
|
|
- }
|
|
|
-
|
|
|
- // 收费形式
|
|
|
- List<MusicGroupPaymentCalender> calenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
+ params.put("paymentcalender", "一次性");
|
|
|
+
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
+
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团信息没找到");
|
|
|
+ }
|
|
|
+
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+
|
|
|
+ templateEngine.render(params, "courses.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 = "";
|
|
|
+ if (musicGroup.getOwnershipType() == OwnershipType.OWN) {
|
|
|
+ organCode = "91440300326364429H";
|
|
|
+ } else {
|
|
|
+ organCode = "91420106333619290A";
|
|
|
+ }
|
|
|
+ SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
+ if (organTsign == null) {
|
|
|
+ throw new BizException("甲方未创建签章");
|
|
|
+ }
|
|
|
+
|
|
|
+ eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ if (sysUserTsign != null) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "musicCourses/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.COURSES);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
+
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
+
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String queryMusicGroupCoursesContract(Integer userId, String musicGroupId) {
|
|
|
+
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/courses/" + 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>();
|
|
|
+
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
+
|
|
|
+ // 课程类型
|
|
|
+ params.put("classesType", "乐团团课");
|
|
|
+
|
|
|
+ // 课程费用
|
|
|
+ StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, musicGroupId);
|
|
|
+ if (studentRegistration == null) {
|
|
|
+ throw new BizException("用户报名信息不存在");
|
|
|
+ }
|
|
|
+ MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
|
|
|
+ if (musicGroupStudentFee == null) {
|
|
|
+ MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(musicGroupId,
|
|
|
+ studentRegistration.getActualSubjectId());
|
|
|
+ if (musicGroupSubjectPlan == null) {
|
|
|
+ throw new BizException("声部课程费用设置找不到");
|
|
|
+ }
|
|
|
+ params.put("courseFee", musicGroupSubjectPlan.getFee().doubleValue());
|
|
|
+ } else {
|
|
|
+ params.put(
|
|
|
+ "courseFee",
|
|
|
+ (musicGroupStudentFee.getTemporaryCourseFee() != null && musicGroupStudentFee.getTemporaryCourseFee().doubleValue() > 0) ? musicGroupStudentFee
|
|
|
+ .getTemporaryCourseFee().doubleValue() : musicGroupStudentFee.getCourseFee().doubleValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收费形式
|
|
|
+ List<MusicGroupPaymentCalender> calenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
|
|
|
/*if (calenders == null || calenders.size() == 0) {
|
|
|
params.put("paymentcalender", "一次性");
|
|
@@ -499,736 +477,736 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
params.put("paymentcalender", calenders.stream().map(cal -> cal.getPaymentMonth().toString()).collect(Collectors.joining("月,")) + "月");
|
|
|
}*/
|
|
|
|
|
|
- params.put("paymentcalender", "一次性");
|
|
|
+ params.put("paymentcalender", "一次性");
|
|
|
|
|
|
- params.put("isShowVisualSeal", true);
|
|
|
+ params.put("isShowVisualSeal", true);
|
|
|
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- throw new BizException("乐团信息没找到");
|
|
|
- }
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团信息没找到");
|
|
|
+ }
|
|
|
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
|
|
|
- templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
+ templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取课程协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取课程协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public boolean transferVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
- if(true){
|
|
|
- transferProduceContract(userId, null, null);
|
|
|
- return true;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public boolean transferVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
+ if (true) {
|
|
|
+ transferProduceContract(userId, null, null);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ 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();
|
|
|
+ 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 + "/vipCourses/" + dateFormat1.format(date) + "/" + userId + ".pdf";
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/vipCourses/" + dateFormat1.format(date) + "/" + userId + ".pdf";
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ 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);
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
- // 课程类型
|
|
|
- params.put("classesType", "VIP课");
|
|
|
+ // 课程类型
|
|
|
+ params.put("classesType", "VIP课");
|
|
|
|
|
|
- // 课程费用
|
|
|
- VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
- if (vipGroup == null) {
|
|
|
- throw new BizException("VIP课找不到");
|
|
|
- }
|
|
|
- params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
+ // 课程费用
|
|
|
+ VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
+ if (vipGroup == null) {
|
|
|
+ throw new BizException("VIP课找不到");
|
|
|
+ }
|
|
|
+ params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
|
|
|
- // 收费形式
|
|
|
- params.put("paymentcalender", "一次性");
|
|
|
+ // 收费形式
|
|
|
+ params.put("paymentcalender", "一次性");
|
|
|
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
|
|
|
- templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
+ templateEngine.render(params, "courses.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("甲方未创建签章");
|
|
|
- }
|
|
|
+ // 生成借款协议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.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
|
|
- if (sysUserTsign != null) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
+ if (sysUserTsign != null) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "vipCourses/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "vipCourses/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.VIP_COURSES);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.VIP_COURSES);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
- return true;
|
|
|
- }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public String queryVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
+ @Override
|
|
|
+ public String queryVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ 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);
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
- // 课程类型
|
|
|
- params.put("classesType", "VIP课");
|
|
|
+ // 课程类型
|
|
|
+ params.put("classesType", "VIP课");
|
|
|
|
|
|
- // 课程费用
|
|
|
- VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
- if (vipGroup == null) {
|
|
|
- throw new BizException("VIP课找不到");
|
|
|
- }
|
|
|
- params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
+ // 课程费用
|
|
|
+ VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
+ if (vipGroup == null) {
|
|
|
+ throw new BizException("VIP课找不到");
|
|
|
+ }
|
|
|
+ params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
|
|
|
- // 收费形式
|
|
|
- params.put("paymentcalender", "一次性");
|
|
|
+ // 收费形式
|
|
|
+ params.put("paymentcalender", "一次性");
|
|
|
|
|
|
- params.put("isShowVisualSeal", true);
|
|
|
+ params.put("isShowVisualSeal", true);
|
|
|
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
|
|
|
- templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
+ templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取课程协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取课程协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public boolean transferGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
+ @Override
|
|
|
+ public boolean transferGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
|
|
|
- transferProduceContract(userId, musicGroupId,null);
|
|
|
- return true;
|
|
|
- }
|
|
|
+ transferProduceContract(userId, musicGroupId, null);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public String queryGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
+ @Override
|
|
|
+ public String queryGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/goods/" + userId + ".pdf";
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/goods/" + userId + ".pdf";
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ 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);
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
|
|
|
- int subjectId = studentInfo.getSubject().getId();
|
|
|
+ int subjectId = studentInfo.getSubject().getId();
|
|
|
|
|
|
- Subject subject = subjectService.get(subjectId);
|
|
|
- studentInfo.setSubject(subject);
|
|
|
+ Subject subject = subjectService.get(subjectId);
|
|
|
+ studentInfo.setSubject(subject);
|
|
|
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
- List<Goods> goodsList = goodsService.findGoodsByIds(goodsIds);
|
|
|
- params.put("goodsList", goodsList);
|
|
|
+ List<Goods> goodsList = goodsService.findGoodsByIds(goodsIds);
|
|
|
+ params.put("goodsList", goodsList);
|
|
|
|
|
|
- double depositFee = 0d;
|
|
|
- if (kitGroupPurchaseTypeEnum == KitGroupPurchaseTypeEnum.LEASE) {
|
|
|
- MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
|
|
|
- if (musicGroupSubjectPlan != null) {
|
|
|
- depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
|
|
|
- }
|
|
|
- }
|
|
|
- params.put("depositFee", depositFee);
|
|
|
- params.put("depositFeeFmt", MoneyUtil.toChinese(depositFee + ""));
|
|
|
+ double depositFee = 0d;
|
|
|
+ if (kitGroupPurchaseTypeEnum == KitGroupPurchaseTypeEnum.LEASE) {
|
|
|
+ MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
|
|
|
+ if (musicGroupSubjectPlan != null) {
|
|
|
+ depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ params.put("depositFee", depositFee);
|
|
|
+ params.put("depositFeeFmt", MoneyUtil.toChinese(depositFee + ""));
|
|
|
|
|
|
- params.put("isShowVisualSeal", true);
|
|
|
+ params.put("isShowVisualSeal", true);
|
|
|
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- throw new BizException("乐团信息没找到");
|
|
|
- }
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团信息没找到");
|
|
|
+ }
|
|
|
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
|
|
|
- templateEngine.render(params, "goods.ftl", srcFile);
|
|
|
+ templateEngine.render(params, "goods.ftl", srcFile);
|
|
|
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取商品协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取商品协议出错", e);
|
|
|
+ } finally {
|
|
|
+ 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";
|
|
|
+ @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 srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ 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);
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ params.put("courseSectionNum", courseSectionNum);
|
|
|
+ params.put("startDate", startDate);
|
|
|
+ params.put("endDate", endDate);
|
|
|
+ params.put("fee", fee);
|
|
|
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
|
|
|
- templateEngine.render(params, "practice.ftl", srcFile);
|
|
|
+ templateEngine.render(params, "practice.ftl", srcFile);
|
|
|
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取网管课购买协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取网管课购买协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- @Async
|
|
|
- public boolean transferPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
- if(true){
|
|
|
- transferProduceContract(userId, null, null);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
-
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
-
|
|
|
- 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);
|
|
|
-
|
|
|
- if (sysUserTsign != null) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
-
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "practice/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
-
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.PRACTICE);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
-
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
-
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Async
|
|
|
- @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW)
|
|
|
- public void transferProduceContract(Integer userId,String musicGroupId, CourseViewTypeEnum courseViewType) {
|
|
|
- SysUser user = studentDao.lockUserReturnInfo(userId);
|
|
|
-
|
|
|
- if (user == null) {
|
|
|
- logger.error("用户不存在({})", userId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isBlank(user.getRealName())||StringUtils.isBlank(user.getIdCardNo())){
|
|
|
- logger.error("身份信息缺失({})", userId);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
- if (sysUserTsign == null) {
|
|
|
- try {
|
|
|
- sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("用户电子签章注册失败", e);
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- Date date = new Date();
|
|
|
-
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/product/" + dateFormat1.format(date) + "/" + userId + "_" + LocalDateTime.now().getSecond() + ".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>();
|
|
|
-
|
|
|
- // 查询参数信息
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
-
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
-
|
|
|
- CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_FEE;
|
|
|
-
|
|
|
- if(StringUtils.isBlank(musicGroupId)){
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
- MusicGroup userLastNormalMusicGroup = studentRegistrationDao.getUserLastNormalMusicGroup(userId);
|
|
|
- if(Objects.nonNull(userLastNormalMusicGroup)){
|
|
|
- ownershipType = userLastNormalMusicGroup.getCourseViewType();
|
|
|
- }
|
|
|
- }else{
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- logger.error("乐团信息没找到({})", musicGroupId);
|
|
|
- return;
|
|
|
- }
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
- ownershipType = musicGroup.getCourseViewType();
|
|
|
- }
|
|
|
-
|
|
|
- if(Objects.nonNull(courseViewType)){
|
|
|
- ownershipType = courseViewType;
|
|
|
- }
|
|
|
-
|
|
|
- List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, ownershipType.getContractVersion());
|
|
|
- if(!CollectionUtils.isEmpty(userContracts)){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- templateEngine.render(params, "product"+ownershipType.getContractVersion()+".ftl", srcFile);
|
|
|
-
|
|
|
- // 生成借款协议PDF
|
|
|
- try {
|
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
- } catch (IOException e) {
|
|
|
- logger.error("生成产品协议失败", e);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- String organCode = "";
|
|
|
- if (OwnershipType.OWN.name().equals(params.get("ownershipType"))){
|
|
|
- organCode = "91440300326364429H";
|
|
|
- } else {
|
|
|
- organCode = "91420106333619290A";
|
|
|
- }
|
|
|
- SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
- if (organTsign == null) {
|
|
|
- logger.error("甲方未创建签章");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- if (sysUserTsign != null && CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
-
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "product/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
-
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.PRODUCT);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
- sysUserContracts.setVersion(ownershipType.getContractVersion());
|
|
|
-
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
-
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(isolation = Isolation.READ_COMMITTED)
|
|
|
- public Map<String, Object> queryProductContract(Integer userId,String musicGroupId, CourseViewTypeEnum courseViewType) {
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/product/" + 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>();
|
|
|
-
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
- if(Objects.isNull(studentInfo)){
|
|
|
- studentInfo = new StudentInfo();
|
|
|
- }
|
|
|
- if(StringUtils.isEmpty(studentInfo.getCertificateType())){
|
|
|
- studentInfo.setCertificateType(CertificateTypeEnum.IDENTITY.getCode());
|
|
|
- }
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
- params.put("isShowVisualSeal", true);
|
|
|
-
|
|
|
- Map<String, Object> result = new HashMap<>();
|
|
|
- result.put("courseViewType", CourseViewTypeEnum.COURSE_FEE);
|
|
|
- CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_FEE;
|
|
|
-
|
|
|
- if(StringUtils.isBlank(musicGroupId)){
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
- MusicGroup userLastNormalMusicGroup = studentRegistrationDao.getUserLastNormalMusicGroup(userId);
|
|
|
- if(Objects.nonNull(userLastNormalMusicGroup)){
|
|
|
- result.put("courseViewType", userLastNormalMusicGroup.getCourseViewType());
|
|
|
- ownershipType = userLastNormalMusicGroup.getCourseViewType();
|
|
|
- }
|
|
|
- }else{
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- throw new BizException("乐团信息没找到");
|
|
|
- }
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
- result.put("courseViewType", musicGroup.getCourseViewType());
|
|
|
- ownershipType = musicGroup.getCourseViewType();
|
|
|
- }
|
|
|
-
|
|
|
- if(Objects.nonNull(courseViewType)){
|
|
|
- ownershipType = courseViewType;
|
|
|
- }
|
|
|
-
|
|
|
- templateEngine.render(params, "product"+ownershipType.getContractVersion()+".ftl", srcFile);
|
|
|
-
|
|
|
- String html = "";
|
|
|
- try {
|
|
|
- html = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取产品协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
-
|
|
|
- List<SysUserContracts> userContractWithType = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, ownershipType.getContractVersion());
|
|
|
-
|
|
|
- result.put("exists", !CollectionUtils.isEmpty(userContractWithType));
|
|
|
- result.put("productContract", html);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResponseResult transferProduceContractOnlyWithCourseList(Integer userId) {
|
|
|
- SysUser user = studentDao.lockUserReturnInfo(userId);
|
|
|
- if (user == null) {
|
|
|
- logger.error("用户不存在({})", userId);
|
|
|
- return BaseController.failed("用户不存在");
|
|
|
- }
|
|
|
-
|
|
|
- int validContactNum = sysUserContractsDao.countUserValidContact(userId);
|
|
|
- if(validContactNum>0){
|
|
|
- return BaseController.succeed();
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isBlank(user.getRealName())||StringUtils.isBlank(user.getIdCardNo())){
|
|
|
- return BaseController.failed(HttpStatus.PARTIAL_CONTENT, user, "");
|
|
|
- }
|
|
|
-
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
- if (sysUserTsign == null) {
|
|
|
- try {
|
|
|
- sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("用户电子签章注册失败", e);
|
|
|
- return BaseController.failed("用户电子签章注册失败");
|
|
|
- }
|
|
|
- }
|
|
|
- Date date = new Date();
|
|
|
-
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/product/" + dateFormat1.format(date) + "/" + userId + "_" + LocalDateTime.now().getSecond() + ".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>();
|
|
|
-
|
|
|
- // 查询参数信息
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
-
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
-
|
|
|
- CourseViewTypeEnum courseViewType = CourseViewTypeEnum.COURSE_FEE;
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
-
|
|
|
- List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, 2);
|
|
|
- if(!CollectionUtils.isEmpty(userContracts)){
|
|
|
- return BaseController.succeed();
|
|
|
- }
|
|
|
-
|
|
|
- templateEngine.render(params, "product2.ftl", srcFile);
|
|
|
-
|
|
|
- // 生成借款协议PDF
|
|
|
- try {
|
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
- } catch (IOException e) {
|
|
|
- logger.error("生成产品协议失败", e);
|
|
|
- return BaseController.failed("生成产品协议失败");
|
|
|
- }
|
|
|
-
|
|
|
- String organCode = "91440300326364429H";
|
|
|
-
|
|
|
- SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
- if (organTsign == null) {
|
|
|
- logger.error("甲方未创建签章");
|
|
|
- return BaseController.failed("甲方未创建签章");
|
|
|
- }
|
|
|
-
|
|
|
- eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- if (sysUserTsign != null && CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
-
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "product/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
-
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.PRODUCT);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
- sysUserContracts.setVersion(2);
|
|
|
-
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
-
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- return BaseController.succeed();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public String transferOaFinancial(OAFinancialDto financialDto) {
|
|
|
- List<Integer> circulationUserIds = financialDto.getCirculationUsers().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
|
|
|
- List<Integer> executorIds = financialDto.getExecutors().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
|
|
|
- circulationUserIds.addAll(executorIds);
|
|
|
- List<SysUser> users = employeeDao.getUsers(circulationUserIds);
|
|
|
-
|
|
|
- Integer workOrderId = null;
|
|
|
- List<SysUserTsign> sysUserTsigns = new ArrayList<>();
|
|
|
- for (SysUser user : users) {
|
|
|
- for (CirculationUser circulationUser : financialDto.getCirculationUsers()) {
|
|
|
- if (workOrderId == null) {
|
|
|
- workOrderId = circulationUser.getWorkOrder();
|
|
|
- }
|
|
|
- if (!circulationUser.getUserId().equals(user.getId())) continue;
|
|
|
- circulationUser.setRealName(user.getRealName());
|
|
|
- }
|
|
|
- for (CirculationUser executor : financialDto.getExecutors()) {
|
|
|
- if (!executor.getUserId().equals(user.getId())) continue;
|
|
|
- executor.setRealName(user.getRealName());
|
|
|
- }
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(user.getId());
|
|
|
- if (sysUserTsign == null) {
|
|
|
- try {
|
|
|
- sysUserTsign = register(user.getId(), user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("用户电子签章注册失败", e);
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- sysUserTsigns.add(sysUserTsign);
|
|
|
- }
|
|
|
-
|
|
|
- Date date = new Date();
|
|
|
-
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/oa/" + dateFormat1.format(date) + "/" + workOrderId + "_" + LocalDateTime.now().getSecond() + ".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("organName", financialDto.getOrganName());
|
|
|
- params.put("realName", financialDto.getRealName());
|
|
|
- params.put("feeType", financialDto.getFeeType());
|
|
|
- params.put("totalMoney", financialDto.getTotalMoney().setScale(2, RoundingMode.HALF_UP));
|
|
|
- params.put("hasLoan", financialDto.getHasLoan());
|
|
|
- params.put("memo", financialDto.getMemo());
|
|
|
- params.put("circulationUsers", financialDto.getCirculationUsers());
|
|
|
- params.put("executors", financialDto.getExecutors());
|
|
|
-
|
|
|
- templateEngine.render(params, "financial.ftl", srcFile);
|
|
|
-
|
|
|
- // 生成借款协议PDF
|
|
|
- try {
|
|
|
- PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
- } catch (IOException e) {
|
|
|
- logger.error("生成签章协议失败", e);
|
|
|
- }
|
|
|
-
|
|
|
- for (SysUserTsign sysUserTsign : sysUserTsigns) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), sysUserTsign.getUserId().toString(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
-
|
|
|
- //上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "oa/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
-
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
-
|
|
|
- return pdfFilePath;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public boolean transferPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
+ if (true) {
|
|
|
+ transferProduceContract(userId, null, null);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
+
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ if (sysUserTsign != null) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "practice/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.PRACTICE);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
+
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
+
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public void transferProduceContract(Integer userId, String musicGroupId, CourseViewTypeEnum courseViewType) {
|
|
|
+ SysUser user = studentDao.lockUserReturnInfo(userId);
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ logger.error("用户不存在({})", userId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(user.getRealName()) || StringUtils.isBlank(user.getIdCardNo())) {
|
|
|
+ logger.error("身份信息缺失({})", userId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ if (sysUserTsign == null) {
|
|
|
+ try {
|
|
|
+ sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("用户电子签章注册失败", e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/product/" + dateFormat1.format(date) + "/" + userId + "_" + LocalDateTime.now().getSecond() + ".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>();
|
|
|
+
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
+
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
+
|
|
|
+ CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_FEE;
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(musicGroupId)) {
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
+ MusicGroup userLastNormalMusicGroup = studentRegistrationDao.getUserLastNormalMusicGroup(userId);
|
|
|
+ if (Objects.nonNull(userLastNormalMusicGroup)) {
|
|
|
+ ownershipType = userLastNormalMusicGroup.getCourseViewType();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ logger.error("乐团信息没找到({})", musicGroupId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+ ownershipType = musicGroup.getCourseViewType();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.nonNull(courseViewType)) {
|
|
|
+ ownershipType = courseViewType;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, ownershipType.getContractVersion());
|
|
|
+ if (!CollectionUtils.isEmpty(userContracts)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ templateEngine.render(params, "product" + ownershipType.getContractVersion() + ".ftl", srcFile);
|
|
|
+
|
|
|
+ // 生成借款协议PDF
|
|
|
+ try {
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("生成产品协议失败", e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String organCode = "";
|
|
|
+ if (OwnershipType.OWN.name().equals(params.get("ownershipType"))) {
|
|
|
+ organCode = "91440300326364429H";
|
|
|
+ } else {
|
|
|
+ organCode = "91420106333619290A";
|
|
|
+ }
|
|
|
+ SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
+ if (organTsign == null) {
|
|
|
+ logger.error("甲方未创建签章");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ if (sysUserTsign != null && CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "product/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.PRODUCT);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
+ sysUserContracts.setVersion(ownershipType.getContractVersion());
|
|
|
+
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
+
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED)
|
|
|
+ public Map<String, Object> queryProductContract(Integer userId, String musicGroupId, CourseViewTypeEnum courseViewType) {
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/product/" + 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>();
|
|
|
+
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ if (Objects.isNull(studentInfo)) {
|
|
|
+ studentInfo = new StudentInfo();
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(studentInfo.getCertificateType())) {
|
|
|
+ studentInfo.setCertificateType(CertificateTypeEnum.IDENTITY.getCode());
|
|
|
+ }
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
+ params.put("isShowVisualSeal", true);
|
|
|
+
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("courseViewType", CourseViewTypeEnum.COURSE_FEE);
|
|
|
+ CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_FEE;
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(musicGroupId)) {
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
+ MusicGroup userLastNormalMusicGroup = studentRegistrationDao.getUserLastNormalMusicGroup(userId);
|
|
|
+ if (Objects.nonNull(userLastNormalMusicGroup)) {
|
|
|
+ result.put("courseViewType", userLastNormalMusicGroup.getCourseViewType());
|
|
|
+ ownershipType = userLastNormalMusicGroup.getCourseViewType();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团信息没找到");
|
|
|
+ }
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+ result.put("courseViewType", musicGroup.getCourseViewType());
|
|
|
+ ownershipType = musicGroup.getCourseViewType();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Objects.nonNull(courseViewType)) {
|
|
|
+ ownershipType = courseViewType;
|
|
|
+ }
|
|
|
+
|
|
|
+ templateEngine.render(params, "product" + ownershipType.getContractVersion() + ".ftl", srcFile);
|
|
|
+
|
|
|
+ String html = "";
|
|
|
+ try {
|
|
|
+ html = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取产品协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysUserContracts> userContractWithType = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, ownershipType.getContractVersion());
|
|
|
+
|
|
|
+ result.put("exists", !CollectionUtils.isEmpty(userContractWithType));
|
|
|
+ result.put("productContract", html);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResponseResult transferProduceContractOnlyWithCourseList(Integer userId) {
|
|
|
+ SysUser user = studentDao.lockUserReturnInfo(userId);
|
|
|
+ if (user == null) {
|
|
|
+ logger.error("用户不存在({})", userId);
|
|
|
+ return BaseController.failed("用户不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ int validContactNum = sysUserContractsDao.countUserValidContact(userId);
|
|
|
+ if (validContactNum > 0) {
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(user.getRealName()) || StringUtils.isBlank(user.getIdCardNo())) {
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT, user, "");
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ if (sysUserTsign == null) {
|
|
|
+ try {
|
|
|
+ sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("用户电子签章注册失败", e);
|
|
|
+ return BaseController.failed("用户电子签章注册失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/product/" + dateFormat1.format(date) + "/" + userId + "_" + LocalDateTime.now().getSecond() + ".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>();
|
|
|
+
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
+
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
+
|
|
|
+ CourseViewTypeEnum courseViewType = CourseViewTypeEnum.COURSE_FEE;
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
+
|
|
|
+ List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, 2);
|
|
|
+ if (!CollectionUtils.isEmpty(userContracts)) {
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ templateEngine.render(params, "product2.ftl", srcFile);
|
|
|
+
|
|
|
+ // 生成借款协议PDF
|
|
|
+ try {
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("生成产品协议失败", e);
|
|
|
+ return BaseController.failed("生成产品协议失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ String organCode = "91440300326364429H";
|
|
|
+
|
|
|
+ SysUserTsign organTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
+ if (organTsign == null) {
|
|
|
+ logger.error("甲方未创建签章");
|
|
|
+ return BaseController.failed("甲方未创建签章");
|
|
|
+ }
|
|
|
+
|
|
|
+ eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ if (sysUserTsign != null && CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "product/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.PRODUCT);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
+ sysUserContracts.setVersion(2);
|
|
|
+
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
+
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String transferOaFinancial(OAFinancialDto financialDto) {
|
|
|
+ List<Integer> circulationUserIds = financialDto.getCirculationUsers().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
|
|
|
+ List<Integer> executorIds = financialDto.getExecutors().stream().map(CirculationUser::getUserId).collect(Collectors.toList());
|
|
|
+ circulationUserIds.addAll(executorIds);
|
|
|
+ List<SysUser> users = employeeDao.getUsers(circulationUserIds);
|
|
|
+
|
|
|
+ Integer workOrderId = null;
|
|
|
+ List<SysUserTsign> sysUserTsigns = new ArrayList<>();
|
|
|
+ for (SysUser user : users) {
|
|
|
+ for (CirculationUser circulationUser : financialDto.getCirculationUsers()) {
|
|
|
+ if (workOrderId == null) {
|
|
|
+ workOrderId = circulationUser.getWorkOrder();
|
|
|
+ }
|
|
|
+ if (!circulationUser.getUserId().equals(user.getId())) continue;
|
|
|
+ circulationUser.setRealName(user.getRealName());
|
|
|
+ }
|
|
|
+ for (CirculationUser executor : financialDto.getExecutors()) {
|
|
|
+ if (!executor.getUserId().equals(user.getId())) continue;
|
|
|
+ executor.setRealName(user.getRealName());
|
|
|
+ }
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(user.getId());
|
|
|
+ if (sysUserTsign == null) {
|
|
|
+ try {
|
|
|
+ sysUserTsign = register(user.getId(), user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("用户电子签章注册失败", e);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sysUserTsigns.add(sysUserTsign);
|
|
|
+ }
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/oa/" + dateFormat1.format(date) + "/" + workOrderId + "_" + LocalDateTime.now().getSecond() + ".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("organName", financialDto.getOrganName());
|
|
|
+ params.put("realName", financialDto.getRealName());
|
|
|
+ params.put("feeType", financialDto.getFeeType());
|
|
|
+ params.put("totalMoney", financialDto.getTotalMoney().setScale(2, RoundingMode.HALF_UP));
|
|
|
+ params.put("hasLoan", financialDto.getHasLoan());
|
|
|
+ params.put("memo", financialDto.getMemo());
|
|
|
+ params.put("circulationUsers", financialDto.getCirculationUsers());
|
|
|
+ params.put("executors", financialDto.getExecutors());
|
|
|
+
|
|
|
+ templateEngine.render(params, "financial.ftl", srcFile);
|
|
|
+
|
|
|
+ // 生成借款协议PDF
|
|
|
+ try {
|
|
|
+ PDFUtil.renderToPDFByData(ContractServiceImpl.class.getResource("/").getFile(), FileUtils.readFileToString(srcFile), srcPdfPath, "simsun.ttc");
|
|
|
+ } catch (IOException e) {
|
|
|
+ logger.error("生成签章协议失败", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (SysUserTsign sysUserTsign : sysUserTsigns) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), sysUserTsign.getUserId().toString(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "oa/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+
|
|
|
+ return pdfFilePath;
|
|
|
+ }
|
|
|
}
|