|
@@ -1,22 +1,84 @@
|
|
|
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.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+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.dao.EmployeeDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
|
|
|
+import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
|
|
|
+import com.ym.mec.biz.dal.dao.SysUserContractsDao;
|
|
|
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.*;
|
|
|
+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.StudentRegistration;
|
|
|
+import com.ym.mec.biz.dal.entity.Subject;
|
|
|
+import com.ym.mec.biz.dal.entity.SysUserContracts;
|
|
|
import com.ym.mec.biz.dal.entity.SysUserContracts.ContractType;
|
|
|
+import com.ym.mec.biz.dal.entity.SysUserTsign;
|
|
|
+import com.ym.mec.biz.dal.entity.TenantConfig;
|
|
|
+import com.ym.mec.biz.dal.entity.TenantContractTemplate;
|
|
|
+import com.ym.mec.biz.dal.entity.TenantInfo;
|
|
|
+import com.ym.mec.biz.dal.entity.VipGroup;
|
|
|
import com.ym.mec.biz.dal.enums.CourseViewTypeEnum;
|
|
|
import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
|
|
|
-import com.ym.mec.biz.service.*;
|
|
|
+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.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.TenantConfigService;
|
|
|
+import com.ym.mec.biz.service.TenantContractTemplateService;
|
|
|
+import com.ym.mec.biz.service.TenantInfoService;
|
|
|
+import com.ym.mec.biz.service.VipGroupService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
-import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import com.ym.mec.thirdparty.eseal.ESealPlugin;
|
|
|
import com.ym.mec.thirdparty.storage.StoragePluginContext;
|
|
|
import com.ym.mec.thirdparty.storage.provider.KS3StoragePlugin;
|
|
@@ -27,33 +89,6 @@ 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.nio.charset.Charset;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
@Service
|
|
|
public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
@@ -157,25 +192,48 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
* 校验企业营业信息,不存在则添加一个
|
|
|
*/
|
|
|
@Override
|
|
|
- public void addTsign(Integer userId, String organCode, String orgName, Integer tenantId) {
|
|
|
- Optional.ofNullable(organCode).orElseThrow(() -> new BizException("营业执照编号不能为空!"));
|
|
|
- Optional.ofNullable(orgName).orElseThrow(() -> new BizException("营业名称不能为空"));
|
|
|
+ public void addTsign(Integer userId, String organCode, String orgName, Integer tenantId) {
|
|
|
+ Optional.ofNullable(organCode).orElseThrow(() -> new BizException("营业执照编号不能为空!"));
|
|
|
+ Optional.ofNullable(orgName).orElseThrow(() -> new BizException("营业名称不能为空"));
|
|
|
|
|
|
- String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
|
|
|
- if (StringUtils.isBlank(accountId)) {
|
|
|
- throw new BizException("创建企业电子存证账户失败");
|
|
|
- }
|
|
|
+ SysUserTsign sysUserTsign = null;
|
|
|
|
|
|
- String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
|
|
|
- if (StringUtils.isBlank(sealData)) {
|
|
|
- throw new BizException("创建电子存证印章失败");
|
|
|
- }
|
|
|
+ SysUserTsign orignSysUserTsign = sysUserTsignService.get(-userId);
|
|
|
|
|
|
- SysUserTsign sysUserTsign = new SysUserTsign(-userId, accountId, sealData, orgName, organCode, tenantId);
|
|
|
- sysUserTsignService.insert(sysUserTsign);
|
|
|
- }
|
|
|
+ if (orignSysUserTsign == null || !StringUtils.equals(orignSysUserTsign.getCardNo(), organCode)) {
|
|
|
|
|
|
- @Override
|
|
|
+ String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
|
|
|
+ if (StringUtils.isBlank(accountId)) {
|
|
|
+ throw new BizException("创建企业电子存证账户失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
|
|
|
+ if (StringUtils.isBlank(sealData)) {
|
|
|
+ throw new BizException("创建电子存证印章失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ sysUserTsign = new SysUserTsign(-userId, accountId, sealData, orgName, organCode, tenantId);
|
|
|
+
|
|
|
+ if (orignSysUserTsign == null) {
|
|
|
+ sysUserTsignService.insert(sysUserTsign);
|
|
|
+ } else {
|
|
|
+ orignSysUserTsign.setAccountId(accountId);
|
|
|
+ orignSysUserTsign.setSealData(sealData);
|
|
|
+ orignSysUserTsign.setName(orgName);
|
|
|
+ orignSysUserTsign.setCardNo(organCode);
|
|
|
+ sysUserTsignService.update(orignSysUserTsign);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (!StringUtils.equals(orignSysUserTsign.getName(), orgName)) {
|
|
|
+ if (eSealPlugin.updateOrganAccount(orignSysUserTsign.getAccountId(), orgName, organCode)) {
|
|
|
+ orignSysUserTsign.setName(orgName);
|
|
|
+ sysUserTsignService.update(orignSysUserTsign);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo) {
|
|
|
|
|
|
if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCardNo) || StringUtils.isBlank(mobileNo)) {
|
|
@@ -944,8 +1002,8 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
if (studentInfo.getTenantId() == 1) {
|
|
|
if (OwnershipType.OWN.name().equals(params.get("ownershipType"))) {
|
|
|
- params.put("companyName", "深圳大雅乐盟网络教育股份有限公司");
|
|
|
- params.put("sealPicture", "https://daya-online.oss-cn-beijing.aliyuncs.com/website/cachet.png");
|
|
|
+ //params.put("companyName", "深圳大雅乐盟网络教育股份有限公司");
|
|
|
+ //params.put("sealPicture", "https://daya-online.oss-cn-beijing.aliyuncs.com/website/cachet.png");
|
|
|
} else {
|
|
|
params.put("companyName", "武汉长乐长风乐器销售有限公司");
|
|
|
params.put("sealPicture", "https://daya-online.oss-cn-beijing.aliyuncs.com/website/clcf.png");
|
|
@@ -1153,8 +1211,22 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
params.put("isShowVisualSeal", false);
|
|
|
|
|
|
- CourseViewTypeEnum courseViewType = CourseViewTypeEnum.COURSE_FEE;
|
|
|
params.put("ownershipType", "OWN");
|
|
|
+
|
|
|
+ // 查询最新协议模板
|
|
|
+ TenantContractTemplate tenantContractTemplate = tenantContractTemplateService.queryLatestContractTemplate(user.getTenantId(), null, null);
|
|
|
+ if(tenantContractTemplate == null){
|
|
|
+ logger.error("最新协议模板查询失败");
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
+ String mainContent = tenantContractTemplate.getContractTemplateContent();
|
|
|
+ params.put("contractMainContent", mainContent);
|
|
|
+
|
|
|
+ // 查询是否已生成协议
|
|
|
+ List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, tenantContractTemplate.getVersion());
|
|
|
+ if (!CollectionUtils.isEmpty(userContracts)) {
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
|
|
|
TenantInfo tenantInfo = tenantInfoService.get(studentInfo.getTenantId());
|
|
|
if(tenantInfo == null){
|
|
@@ -1179,12 +1251,7 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, 2);
|
|
|
- if (!CollectionUtils.isEmpty(userContracts)) {
|
|
|
- return BaseController.succeed();
|
|
|
- }
|
|
|
-
|
|
|
- templateEngine.render(params, "product2.ftl", srcFile);
|
|
|
+ templateEngine.render(params, "latest_contract_template.ftl", srcFile);
|
|
|
|
|
|
// 生成借款协议PDF
|
|
|
try {
|
|
@@ -1228,6 +1295,7 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
sysUserContracts.setUrl(pdfFilePath);
|
|
|
sysUserContracts.setUserId(userId);
|
|
|
sysUserContracts.setVersion(2);
|
|
|
+ sysUserContracts.setTenantId(user.getTenantId());
|
|
|
|
|
|
sysUserContractsService.insert(sysUserContracts);
|
|
|
|