|
@@ -8,9 +8,11 @@ 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.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.enums.CourseViewTypeEnum;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
@@ -76,1183 +78,1282 @@ import com.ym.mec.util.pdf.PDFUtil;
|
|
|
@Service
|
|
|
public class ContractServiceImpl implements ContractService, InitializingBean {
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysUserTsignService sysUserTsignService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserTsignService sysUserTsignService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysUserFeignService sysUserFeignService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserFeignService sysUserFeignService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysUserContractsService sysUserContractsService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserContractsService sysUserContractsService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysUserContractsDao sysUserContractsDao;
|
|
|
+ @Autowired
|
|
|
+ private SysUserContractsDao sysUserContractsDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentRegistrationService studentRegistrationService;
|
|
|
+ @Autowired
|
|
|
+ private StudentRegistrationService studentRegistrationService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentRegistrationDao studentRegistrationDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentRegistrationDao studentRegistrationDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- @Lazy
|
|
|
- private VipGroupService vipGroupService;
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private VipGroupService vipGroupService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SubjectService subjectService;
|
|
|
+ @Autowired
|
|
|
+ private SubjectService subjectService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ESealPlugin eSealPlugin;
|
|
|
+ @Autowired
|
|
|
+ private ESealPlugin eSealPlugin;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StoragePluginContext storagePluginContext;
|
|
|
+ @Autowired
|
|
|
+ private StoragePluginContext storagePluginContext;
|
|
|
|
|
|
- @Autowired
|
|
|
- private GoodsService goodsService;
|
|
|
+ @Autowired
|
|
|
+ private GoodsService goodsService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MusicGroupService musicGroupService;
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupService musicGroupService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
|
|
|
- @Value("${contract.baseDir:/var/pdf}")
|
|
|
- private String contractBaseDir;
|
|
|
+ @Autowired
|
|
|
+ private EmployeeDao employeeDao;
|
|
|
|
|
|
- @Value("${message.debugMode}")
|
|
|
- private boolean debugMode;
|
|
|
+ @Value("${contract.baseDir:/var/pdf}")
|
|
|
+ private String contractBaseDir;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RealnameAuthenticationPluginContext realnameAuthenticationPluginContext;
|
|
|
+ @Value("${message.debugMode}")
|
|
|
+ private boolean debugMode;
|
|
|
|
|
|
- private DateFormat dateFormatOss = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
+ @Autowired
|
|
|
+ private RealnameAuthenticationPluginContext realnameAuthenticationPluginContext;
|
|
|
|
|
|
- private DateFormat dateFormat1 = new SimpleDateFormat("yyMMddHHmmSS");
|
|
|
+ private DateFormat dateFormatOss = new SimpleDateFormat("yyyy/MM/dd");
|
|
|
|
|
|
- private final Logger logger = LoggerFactory.getLogger(ContractService.class);
|
|
|
+ private DateFormat dateFormat1 = new SimpleDateFormat("yyMMddHHmmSS");
|
|
|
|
|
|
- @Override
|
|
|
- public void afterPropertiesSet() throws Exception {
|
|
|
- // 注册企业账户
|
|
|
- Map<String, String> organList = new HashMap<String, String>();
|
|
|
- organList.put("91420106333619290A", "武汉长乐长风乐器销售有限公司");
|
|
|
- organList.put("91440300326364429H", "深圳大雅乐盟网络教育股份有限公司");
|
|
|
+ private final Logger logger = LoggerFactory.getLogger(ContractService.class);
|
|
|
|
|
|
- for (Entry<String, String> organ : organList.entrySet()) {
|
|
|
+ @Override
|
|
|
+ public void afterPropertiesSet() throws Exception {
|
|
|
+ // 注册企业账户
|
|
|
+ Map<String, String> organList = new HashMap<String, String>();
|
|
|
+ organList.put("91420106333619290A", "武汉长乐长风乐器销售有限公司");
|
|
|
+ organList.put("91440300326364429H", "深圳大雅乐盟网络教育股份有限公司");
|
|
|
|
|
|
- String organCode = organ.getKey();
|
|
|
- String orgName = organ.getValue();
|
|
|
+ for (Entry<String, String> organ : organList.entrySet()) {
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
+ String organCode = organ.getKey();
|
|
|
+ String orgName = organ.getValue();
|
|
|
|
|
|
- if (sysUserTsign == null) {
|
|
|
- String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.queryByCardNo(organCode);
|
|
|
|
|
|
- if (StringUtils.isBlank(accountId)) {
|
|
|
- throw new BizException("创建企业电子存证账户失败");
|
|
|
- }
|
|
|
+ if (sysUserTsign == null) {
|
|
|
+ String accountId = eSealPlugin.createOrganAccount(orgName, organCode);
|
|
|
|
|
|
- String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
|
|
|
+ if (StringUtils.isBlank(accountId)) {
|
|
|
+ throw new BizException("创建企业电子存证账户失败");
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(sealData)) {
|
|
|
- throw new BizException("创建电子存证印章失败");
|
|
|
- }
|
|
|
+ String sealData = eSealPlugin.createOrganSeal(accountId, "", "");
|
|
|
|
|
|
- sysUserTsign = new SysUserTsign(-1, accountId, sealData, orgName, organCode);
|
|
|
+ if (StringUtils.isBlank(sealData)) {
|
|
|
+ throw new BizException("创建电子存证印章失败");
|
|
|
+ }
|
|
|
|
|
|
- sysUserTsignService.insert(sysUserTsign);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ sysUserTsign = new SysUserTsign(-1, accountId, sealData, orgName, organCode);
|
|
|
|
|
|
- @Override
|
|
|
- public SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo) {
|
|
|
+ sysUserTsignService.insert(sysUserTsign);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCardNo) || StringUtils.isBlank(mobileNo)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public SysUserTsign register(Integer userId, String realName, String idCardNo, String mobileNo) {
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
- if (sysUserTsign == null) {
|
|
|
+ if (StringUtils.isBlank(realName) || StringUtils.isBlank(idCardNo) || StringUtils.isBlank(mobileNo)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- String accountId = "";
|
|
|
- String sealData = "";
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ if (sysUserTsign == null) {
|
|
|
|
|
|
- SysUser user = studentDao.getUser(userId);
|
|
|
- if (user == null) {
|
|
|
- throw new BizException("用户信息查询失败");
|
|
|
- }
|
|
|
+ String accountId = "";
|
|
|
+ String sealData = "";
|
|
|
|
|
|
- if(CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())){
|
|
|
- if(!debugMode){
|
|
|
- realnameAuthenticationPluginContext.getRealnameAuthenticationPlugin(LinkfaceRealnameAuthenticationPlugin.getName()).verify(realName, idCardNo);
|
|
|
- }
|
|
|
+ SysUser user = studentDao.getUser(userId);
|
|
|
+ if (user == null) {
|
|
|
+ throw new BizException("用户信息查询失败");
|
|
|
+ }
|
|
|
|
|
|
- accountId = eSealPlugin.createUserAccount(realName, idCardNo, mobileNo);
|
|
|
+ if (CertificateTypeEnum.IDENTITY.getCode().equals(user.getCertificateType())) {
|
|
|
+ if (!debugMode) {
|
|
|
+ realnameAuthenticationPluginContext.getRealnameAuthenticationPlugin(LinkfaceRealnameAuthenticationPlugin.getName()).verify(realName, idCardNo);
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(accountId)) {
|
|
|
- throw new BizException("创建电子存证账户失败");
|
|
|
- }
|
|
|
+ accountId = eSealPlugin.createUserAccount(realName, idCardNo, mobileNo);
|
|
|
|
|
|
- sealData = eSealPlugin.createUserSeal(accountId);
|
|
|
+ if (StringUtils.isBlank(accountId)) {
|
|
|
+ throw new BizException("创建电子存证账户失败");
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isBlank(sealData)) {
|
|
|
- throw new BizException("创建电子存证印章失败");
|
|
|
- }
|
|
|
- }
|
|
|
+ sealData = eSealPlugin.createUserSeal(accountId);
|
|
|
|
|
|
- sysUserTsign = new SysUserTsign(userId, accountId, sealData, realName, idCardNo);
|
|
|
+ if (StringUtils.isBlank(sealData)) {
|
|
|
+ throw new BizException("创建电子存证印章失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- sysUserTsignService.insert(sysUserTsign);
|
|
|
+ sysUserTsign = new SysUserTsign(userId, accountId, sealData, realName, idCardNo);
|
|
|
|
|
|
- return sysUserTsign;
|
|
|
- }
|
|
|
+ sysUserTsignService.insert(sysUserTsign);
|
|
|
|
|
|
- return null;
|
|
|
- }
|
|
|
+ return sysUserTsign;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public boolean transferRegisterContract(Integer userId) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ @Override
|
|
|
+ public boolean transferRegisterContract(Integer userId) {
|
|
|
|
|
|
- if (sysUserTsign == null) {
|
|
|
- SysUser user = sysUserFeignService.queryUserById(userId);
|
|
|
- if (user == null) {
|
|
|
- throw new BizException("用户信息查询失败");
|
|
|
- }
|
|
|
- sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
- }
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/register/" + userId + ".pdf";
|
|
|
+ if (sysUserTsign == null) {
|
|
|
+ SysUser user = sysUserFeignService.queryUserById(userId);
|
|
|
+ if (user == null) {
|
|
|
+ throw new BizException("用户信息查询失败");
|
|
|
+ }
|
|
|
+ sysUserTsign = register(userId, user.getRealName(), user.getIdCardNo(), user.getPhone());
|
|
|
+ }
|
|
|
|
|
|
- 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>();
|
|
|
|
|
|
- // 生成借款协议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);
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取注册协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public boolean transferMusicGroupCoursesContract(Integer userId, String musicGroupId) {
|
|
|
- if(true){
|
|
|
- return transferProduceContract(userId, musicGroupId);
|
|
|
- }
|
|
|
- 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);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- 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());
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public boolean transferMusicGroupCoursesContract(Integer userId, String musicGroupId) {
|
|
|
+ if (true) {
|
|
|
+ return transferProduceContract(userId, musicGroupId);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
|
|
|
- // 收费形式
|
|
|
- List<MusicGroupPaymentCalender> calenders = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
|
|
|
+ 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", "一次性");
|
|
|
} else {
|
|
|
params.put("paymentcalender", calenders.stream().map(cal -> cal.getPaymentMonth().toString()).collect(Collectors.joining("月,")) + "月");
|
|
|
}*/
|
|
|
-
|
|
|
- params.put("paymentcalender", "一次性");
|
|
|
-
|
|
|
- params.put("isShowVisualSeal", true);
|
|
|
-
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- throw new BizException("乐团信息没找到");
|
|
|
- }
|
|
|
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+ params.put("paymentcalender", "一次性");
|
|
|
|
|
|
- templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
+ params.put("isShowVisualSeal", true);
|
|
|
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取课程协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团信息没找到");
|
|
|
+ }
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
|
|
|
- @Override
|
|
|
- public boolean transferVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
- if(true){
|
|
|
- return transferProduceContract(userId, null);
|
|
|
- }
|
|
|
+ templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取课程协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- 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();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/vipCourses/" + dateFormat1.format(date) + "/" + userId + ".pdf";
|
|
|
+ @Override
|
|
|
+ public boolean transferVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
+ if (true) {
|
|
|
+ return transferProduceContract(userId, null);
|
|
|
+ }
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ 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();
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/vipCourses/" + dateFormat1.format(date) + "/" + userId + ".pdf";
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- // 查询参数信息
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- // 课程类型
|
|
|
- params.put("classesType", "VIP课");
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
- // 课程费用
|
|
|
- VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
- if (vipGroup == null) {
|
|
|
- throw new BizException("VIP课找不到");
|
|
|
- }
|
|
|
- params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
- // 收费形式
|
|
|
- params.put("paymentcalender", "一次性");
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
+ // 课程类型
|
|
|
+ params.put("classesType", "VIP课");
|
|
|
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
+ // 课程费用
|
|
|
+ VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
+ if (vipGroup == null) {
|
|
|
+ throw new BizException("VIP课找不到");
|
|
|
+ }
|
|
|
+ params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
|
|
|
- templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
+ // 收费形式
|
|
|
+ params.put("paymentcalender", "一次性");
|
|
|
|
|
|
- // 生成借款协议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("甲方未创建签章");
|
|
|
- }
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
|
|
|
- eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
|
|
|
- if (sysUserTsign != null) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
+ templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "vipCourses/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, 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("甲方未创建签章");
|
|
|
+ }
|
|
|
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.VIP_COURSES);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
+ eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
+ if (sysUserTsign != null) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "vipCourses/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
|
|
|
- return true;
|
|
|
- }
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.VIP_COURSES);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
|
|
- @Override
|
|
|
- public String queryVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public String queryVipGroupCoursesContract(Integer userId, Long vipGroupId) {
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/courses/" + userId + ".pdf";
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- // 课程类型
|
|
|
- params.put("classesType", "VIP课");
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
- // 课程费用
|
|
|
- VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
- if (vipGroup == null) {
|
|
|
- throw new BizException("VIP课找不到");
|
|
|
- }
|
|
|
- params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
- // 收费形式
|
|
|
- params.put("paymentcalender", "一次性");
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
- params.put("isShowVisualSeal", true);
|
|
|
+ // 课程类型
|
|
|
+ params.put("classesType", "VIP课");
|
|
|
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
+ // 课程费用
|
|
|
+ VipGroup vipGroup = vipGroupService.get(vipGroupId);
|
|
|
+ if (vipGroup == null) {
|
|
|
+ throw new BizException("VIP课找不到");
|
|
|
+ }
|
|
|
+ params.put("courseFee", vipGroup.getTotalPrice().doubleValue());
|
|
|
|
|
|
- templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
+ // 收费形式
|
|
|
+ params.put("paymentcalender", "一次性");
|
|
|
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取课程协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
+ params.put("isShowVisualSeal", true);
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
|
|
|
- @Override
|
|
|
- public boolean transferGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
- if(true){
|
|
|
- return transferProduceContract(userId, musicGroupId);
|
|
|
- }
|
|
|
+ templateEngine.render(params, "courses.ftl", srcFile);
|
|
|
|
|
|
- SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取课程协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- 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();
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/goods/" + dateFormat1.format(date) + "/" + userId + ".pdf";
|
|
|
+ @Override
|
|
|
+ public boolean transferGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
+ if (true) {
|
|
|
+ return transferProduceContract(userId, musicGroupId);
|
|
|
+ }
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ SysUserTsign sysUserTsign = sysUserTsignService.get(userId);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ 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();
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/goods/" + dateFormat1.format(date) + "/" + userId + ".pdf";
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- // 查询参数信息
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- int subjectId = studentInfo.getSubject().getId();
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
- Subject subject = subjectService.get(subjectId);
|
|
|
- studentInfo.setSubject(subject);
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
|
|
|
- List<Goods> goodsList = goodsService.findGoodsByIds(goodsIds);
|
|
|
- params.put("goodsList", goodsList);
|
|
|
+ int subjectId = studentInfo.getSubject().getId();
|
|
|
|
|
|
- double depositFee = 0d;
|
|
|
- if (kitGroupPurchaseTypeEnum == KitGroupPurchaseTypeEnum.LEASE) {
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.SUCCESS);
|
|
|
+ Subject subject = subjectService.get(subjectId);
|
|
|
+ studentInfo.setSubject(subject);
|
|
|
|
|
|
- if (studentPaymentOrder == null) {
|
|
|
- MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
|
|
|
- if (musicGroupSubjectPlan != null) {
|
|
|
- depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
|
|
|
- }
|
|
|
- } else {
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
|
|
|
- List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
- for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
- if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
- depositFee = detail.getPrice().doubleValue();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- params.put("depositFee", depositFee);
|
|
|
- params.put("depositFeeFmt", MoneyUtil.toChinese(depositFee + ""));
|
|
|
-
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
+ List<Goods> goodsList = goodsService.findGoodsByIds(goodsIds);
|
|
|
+ params.put("goodsList", goodsList);
|
|
|
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- throw new BizException("乐团信息没找到");
|
|
|
- }
|
|
|
-
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
-
|
|
|
- templateEngine.render(params, "goods.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("甲方未创建签章");
|
|
|
- }
|
|
|
+ double depositFee = 0d;
|
|
|
+ if (kitGroupPurchaseTypeEnum == KitGroupPurchaseTypeEnum.LEASE) {
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.SUCCESS);
|
|
|
|
|
|
- eSealPlugin.organSign(organTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ if (studentPaymentOrder == null) {
|
|
|
+ MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
|
|
|
+ if (musicGroupSubjectPlan != null) {
|
|
|
+ depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
|
|
|
- if (sysUserTsign != null) {
|
|
|
- eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
- }
|
|
|
+ List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
+ for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
+ depositFee = detail.getPrice().doubleValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ params.put("depositFee", depositFee);
|
|
|
+ params.put("depositFeeFmt", MoneyUtil.toChinese(depositFee + ""));
|
|
|
|
|
|
- // 上传到oss
|
|
|
- String dateStrOss = dateFormatOss.format(date);
|
|
|
- dateStrOss = "goods/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
- String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
|
|
|
- SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
- sysUserContracts.setCreateTime(date);
|
|
|
- sysUserContracts.setType(ContractType.INSTRUMENT);
|
|
|
- sysUserContracts.setUrl(pdfFilePath);
|
|
|
- sysUserContracts.setUserId(userId);
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团信息没找到");
|
|
|
+ }
|
|
|
+
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
|
|
|
- sysUserContractsService.insert(sysUserContracts);
|
|
|
+ templateEngine.render(params, "goods.ftl", srcFile);
|
|
|
|
|
|
- FileUtils.deleteQuietly(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);
|
|
|
|
|
|
- return true;
|
|
|
- }
|
|
|
+ if (sysUserTsign != null) {
|
|
|
+ eSealPlugin.userSign(sysUserTsign.getAccountId(), sysUserTsign.getSealData(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "goods/" + dateStrOss + "/" + DateUtil.getHour(date);
|
|
|
+ String pdfFilePath = storagePluginContext.uploadFile(KS3StoragePlugin.PLUGIN_NAME, dateStrOss, srcFile);
|
|
|
|
|
|
- @Override
|
|
|
- public String queryGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
+ SysUserContracts sysUserContracts = new SysUserContracts();
|
|
|
+ sysUserContracts.setCreateTime(date);
|
|
|
+ sysUserContracts.setType(ContractType.INSTRUMENT);
|
|
|
+ sysUserContracts.setUrl(pdfFilePath);
|
|
|
+ sysUserContracts.setUserId(userId);
|
|
|
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/goods/" + userId + ".pdf";
|
|
|
+ sysUserContractsService.insert(sysUserContracts);
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ @Override
|
|
|
+ public String queryGoodsContract(Integer userId, String musicGroupId, String goodsIds, KitGroupPurchaseTypeEnum kitGroupPurchaseTypeEnum) {
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/goods/" + userId + ".pdf";
|
|
|
|
|
|
- // 查询参数信息
|
|
|
- StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- int subjectId = studentInfo.getSubject().getId();
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- Subject subject = subjectService.get(subjectId);
|
|
|
- studentInfo.setSubject(subject);
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
- params.put("studentInfo", studentInfo);
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+
|
|
|
+ // 查询参数信息
|
|
|
+ StudentInfo studentInfo = studentRegistrationService.queryStudentInfo(userId);
|
|
|
+
|
|
|
+ int subjectId = studentInfo.getSubject().getId();
|
|
|
+
|
|
|
+ Subject subject = subjectService.get(subjectId);
|
|
|
+ studentInfo.setSubject(subject);
|
|
|
+
|
|
|
+ params.put("studentInfo", studentInfo);
|
|
|
+
|
|
|
+ List<Goods> goodsList = goodsService.findGoodsByIds(goodsIds);
|
|
|
+ params.put("goodsList", goodsList);
|
|
|
+
|
|
|
+ double depositFee = 0d;
|
|
|
+ if (kitGroupPurchaseTypeEnum == KitGroupPurchaseTypeEnum.LEASE) {
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService
|
|
|
+ .findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.WAIT_PAY);
|
|
|
+
|
|
|
+ if (studentPaymentOrder == null) {
|
|
|
+ MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
|
|
|
+ if (musicGroupSubjectPlan != null) {
|
|
|
+ depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
+ for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
+ if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
+ depositFee = detail.getPrice().doubleValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ params.put("depositFee", depositFee);
|
|
|
+ params.put("depositFeeFmt", MoneyUtil.toChinese(depositFee + ""));
|
|
|
|
|
|
- List<Goods> goodsList = goodsService.findGoodsByIds(goodsIds);
|
|
|
- params.put("goodsList", goodsList);
|
|
|
+ params.put("isShowVisualSeal", true);
|
|
|
|
|
|
- double depositFee = 0d;
|
|
|
- if (kitGroupPurchaseTypeEnum == KitGroupPurchaseTypeEnum.LEASE) {
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService
|
|
|
- .findMusicGroupApplyOrderByStatus(userId, musicGroupId, DealStatusEnum.WAIT_PAY);
|
|
|
+ MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
+ if (musicGroup == null) {
|
|
|
+ throw new BizException("乐团信息没找到");
|
|
|
+ }
|
|
|
|
|
|
- if (studentPaymentOrder == null) {
|
|
|
- MusicGroupSubjectGoodsGroup musicGroupSubjectPlan = musicGroupSubjectGoodsGroupService.query(musicGroupId, subjectId, goodsIds);
|
|
|
- if (musicGroupSubjectPlan != null) {
|
|
|
- depositFee = musicGroupSubjectPlan.getDepositFee().doubleValue();
|
|
|
- }
|
|
|
- } else {
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
|
|
|
- List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
|
|
|
- for (StudentPaymentOrderDetail detail : orderDetailList) {
|
|
|
- if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
|
|
|
- depositFee = detail.getPrice().doubleValue();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- params.put("depositFee", depositFee);
|
|
|
- params.put("depositFeeFmt", MoneyUtil.toChinese(depositFee + ""));
|
|
|
+ templateEngine.render(params, "goods.ftl", srcFile);
|
|
|
|
|
|
- params.put("isShowVisualSeal", true);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取商品协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- MusicGroup musicGroup = musicGroupService.get(musicGroupId);
|
|
|
- if (musicGroup == null) {
|
|
|
- throw new BizException("乐团信息没找到");
|
|
|
- }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+ @Override
|
|
|
+ public String queryPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
+ // 合成freemarker
|
|
|
+ String srcPdfPath = contractBaseDir + "/practice/" + userId + ".pdf";
|
|
|
|
|
|
- templateEngine.render(params, "goods.ftl", srcFile);
|
|
|
+ File srcFile = new File(srcPdfPath);
|
|
|
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取商品协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
+ File debtFile = new File(srcFile.getParent());
|
|
|
+ if (!debtFile.exists()) {
|
|
|
+ debtFile.mkdirs();
|
|
|
+ }
|
|
|
|
|
|
- return result;
|
|
|
- }
|
|
|
+ FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
+ templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
|
|
|
- @Override
|
|
|
- public String queryPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
- // 合成freemarker
|
|
|
- String srcPdfPath = contractBaseDir + "/practice/" + userId + ".pdf";
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ params.put("courseSectionNum", courseSectionNum);
|
|
|
+ params.put("startDate", startDate);
|
|
|
+ params.put("endDate", endDate);
|
|
|
+ params.put("fee", fee);
|
|
|
|
|
|
- File srcFile = new File(srcPdfPath);
|
|
|
+ params.put("isShowVisualSeal", false);
|
|
|
|
|
|
- File debtFile = new File(srcFile.getParent());
|
|
|
- if (!debtFile.exists()) {
|
|
|
- debtFile.mkdirs();
|
|
|
- }
|
|
|
+ params.put("ownershipType", "OWN");
|
|
|
|
|
|
- FreemarkerTemplateEngine templateEngine = FreemarkerTemplateEngine.getInstance();
|
|
|
- templateEngine.setClassForTemplateLoading(ContractServiceImpl.class, "/config/contracts/");
|
|
|
+ templateEngine.render(params, "practice.ftl", srcFile);
|
|
|
|
|
|
- Map<String, Object> params = new HashMap<String, Object>();
|
|
|
- params.put("courseSectionNum", courseSectionNum);
|
|
|
- params.put("startDate", startDate);
|
|
|
- params.put("endDate", endDate);
|
|
|
- params.put("fee", fee);
|
|
|
+ String result = "";
|
|
|
+ try {
|
|
|
+ result = FileUtils.readFileToString(srcFile);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BizException("读取网管课购买协议出错", e);
|
|
|
+ } finally {
|
|
|
+ FileUtils.deleteQuietly(srcFile);
|
|
|
+ }
|
|
|
|
|
|
- params.put("isShowVisualSeal", false);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean transferPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
+ if (true) {
|
|
|
+ return transferProduceContract(userId, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW)
|
|
|
+ public boolean transferProduceContract(Integer userId, String musicGroupId) {
|
|
|
+ SysUser user = studentDao.lockUserReturnInfo(userId);
|
|
|
+
|
|
|
+ if (user == null) {
|
|
|
+ logger.error("用户不存在({})", userId);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(user.getRealName()) || StringUtils.isBlank(user.getIdCardNo())) {
|
|
|
+ logger.error("身份信息缺失({})", userId);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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_lIST;
|
|
|
+
|
|
|
+ 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 false;
|
|
|
+ }
|
|
|
+ params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
+ ownershipType = musicGroup.getCourseViewType();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, ownershipType.getContractVersion());
|
|
|
+ if (!CollectionUtils.isEmpty(userContracts)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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 false;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(isolation = Isolation.READ_COMMITTED)
|
|
|
+ public Map<String, Object> queryProductContract(Integer userId, String musicGroupId) {
|
|
|
+ // 合成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_lIST);
|
|
|
+ CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_lIST;
|
|
|
+
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ 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_lIST;
|
|
|
+ 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(List<CirculationUser> circulationUsers, List<CirculationUser> executors) {
|
|
|
+ List<Integer> circulationUserIds = circulationUsers.stream().map(CirculationUser::getUserId).collect(Collectors.toList());
|
|
|
+ List<Integer> executorIds = executors.stream().map(CirculationUser::getUserId).collect(Collectors.toList());
|
|
|
+ circulationUserIds.addAll(executorIds);
|
|
|
+ List<SysUser> users = employeeDao.getUsers(circulationUserIds);
|
|
|
+
|
|
|
+ Integer workOrderId = null;
|
|
|
+ for (SysUser user : users) {
|
|
|
+ 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);
|
|
|
+ throw new BizException(user.getRealName() + "电子签章注册失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (CirculationUser circulationUser : circulationUsers) {
|
|
|
+ if (workOrderId == null) {
|
|
|
+ workOrderId = circulationUser.getWorkOrderId();
|
|
|
+ }
|
|
|
+ if (!circulationUser.getUserId().equals(user.getId())) continue;
|
|
|
+ circulationUser.setRealName(user.getRealName());
|
|
|
+ circulationUser.setIdCard(user.getIdCardNo());
|
|
|
+ circulationUser.setPhone(user.getPhone());
|
|
|
+ circulationUser.setSysUserTsign(sysUserTsign);
|
|
|
+ }
|
|
|
+ for (CirculationUser executor : executors) {
|
|
|
+ if (!executor.getUserId().equals(user.getId())) continue;
|
|
|
+ executor.setRealName(user.getRealName());
|
|
|
+ executor.setIdCard(user.getIdCardNo());
|
|
|
+ executor.setPhone(user.getPhone());
|
|
|
+ executor.setSysUserTsign(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("circulationUsers", circulationUsers);
|
|
|
+ params.put("executors", executors);
|
|
|
+
|
|
|
+ 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 (CirculationUser circulationUser : circulationUsers) {
|
|
|
+ eSealPlugin.userSign(circulationUser.getSysUserTsign().getAccountId(), circulationUser.getSysUserTsign().getSealData(),circulationUser.getRealName(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (CirculationUser executor : executors) {
|
|
|
+ eSealPlugin.userSign(executor.getSysUserTsign().getAccountId(), executor.getSysUserTsign().getSealData(),executor.getRealName(), srcPdfPath, srcPdfPath);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传到oss
|
|
|
+ String dateStrOss = dateFormatOss.format(date);
|
|
|
+ dateStrOss = "oa/" + 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 pdfFilePath;
|
|
|
+ }
|
|
|
|
|
|
- params.put("ownershipType", "OWN");
|
|
|
-
|
|
|
- templateEngine.render(params, "practice.ftl", srcFile);
|
|
|
-
|
|
|
- String result = "";
|
|
|
- try {
|
|
|
- result = FileUtils.readFileToString(srcFile);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BizException("读取网管课购买协议出错", e);
|
|
|
- } finally {
|
|
|
- FileUtils.deleteQuietly(srcFile);
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean transferPracticeCoursesContract(Integer userId, int courseSectionNum, Date startDate, Date endDate, BigDecimal fee) {
|
|
|
- if(true){
|
|
|
- return transferProduceContract(userId, null);
|
|
|
- }
|
|
|
-
|
|
|
- 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
|
|
|
- @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRES_NEW)
|
|
|
- public boolean transferProduceContract(Integer userId,String musicGroupId) {
|
|
|
- SysUser user = studentDao.lockUserReturnInfo(userId);
|
|
|
-
|
|
|
- if (user == null) {
|
|
|
- logger.error("用户不存在({})", userId);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if(StringUtils.isBlank(user.getRealName())||StringUtils.isBlank(user.getIdCardNo())){
|
|
|
- logger.error("身份信息缺失({})", userId);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- 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 false;
|
|
|
- }
|
|
|
- }
|
|
|
- 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_lIST;
|
|
|
-
|
|
|
- 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 false;
|
|
|
- }
|
|
|
- params.put("ownershipType", musicGroup.getOwnershipType().name());
|
|
|
- ownershipType = musicGroup.getCourseViewType();
|
|
|
- }
|
|
|
-
|
|
|
- List<SysUserContracts> userContracts = sysUserContractsService.getUserContractWithType(userId, ContractType.PRODUCT, ownershipType.getContractVersion());
|
|
|
- if(!CollectionUtils.isEmpty(userContracts)){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- 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 false;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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 false;
|
|
|
- }
|
|
|
-
|
|
|
- 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);
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(isolation = Isolation.READ_COMMITTED)
|
|
|
- public Map<String, Object> queryProductContract(Integer userId,String musicGroupId) {
|
|
|
- // 合成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_lIST);
|
|
|
- CourseViewTypeEnum ownershipType = CourseViewTypeEnum.COURSE_lIST;
|
|
|
-
|
|
|
- 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();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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_lIST;
|
|
|
- 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();
|
|
|
- }
|
|
|
}
|