diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java index 2d529a85..e19a484e 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java @@ -1615,8 +1615,12 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl 0) { - return true; - } else { - return false; - } + return time > 0; // DateUtils.parseDate(date_string, parsePatterns); } catch (Exception e) { return false; diff --git a/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java b/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java index 3b9e40d7..9ba1504d 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java +++ b/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java @@ -56,6 +56,13 @@ public class PhoneNumberUtils { * @return */ public static String convZhPhoneNumber(String phoneNumber) { + if (StrUtil.isBlank(phoneNumber) + || phoneNumber.equalsIgnoreCase("null") + || phoneNumber.equalsIgnoreCase("none") + || phoneNumber.equalsIgnoreCase("nil") + || phoneNumber.equalsIgnoreCase("undefined")) { + return ""; + } return StrUtil.startWith(phoneNumber, "+") ? phoneNumber : CommonConstant.IDD_ZH_CN + phoneNumber; } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignController.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignController.java index 124db7bf..abd1b5e3 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignController.java @@ -9,7 +9,7 @@ package com.suisung.mall.shop.esign.controller.admin; import com.suisung.mall.common.service.impl.BaseControllerImpl; -import com.suisung.mall.shop.esign.service.FileAndTemplateService; +import com.suisung.mall.shop.esign.service.EsignContractFillingFileService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.RequestMapping; @@ -24,11 +24,17 @@ import javax.annotation.Resource; public class EsignController extends BaseControllerImpl { @Resource - private FileAndTemplateService fileAndTemplateService; + private EsignContractFillingFileService esignContractFillingFileService; @ApiOperation(value = "店铺基础信息表-查找所有店铺编号和名称", notes = "店铺基础信息表-查找所有店铺编号和名称") @RequestMapping(value = "/testcase", method = RequestMethod.POST) public Object testCase() { - return fileAndTemplateService.fillDocTemplate("11", "11"); + return esignContractFillingFileService.fillDocTemplate("11", "11"); + } + + @ApiOperation(value = "基于文件发起签署电子合同", notes = "基于文件发起签署电子合同") + @RequestMapping(value = "/sign-flow/create-by-file", method = RequestMethod.POST) + public Object signFlowCreateByFile() { + return esignContractFillingFileService.fillDocTemplate("11", "11"); } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java index 2bb49213..0a10b95e 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java @@ -12,6 +12,15 @@ import com.suisung.mall.common.modules.esign.EsignContractFillingFile; public interface EsignContractFillingFileService { + /** + * 填充合同模版,生成合同文件地址 + * + * @param mchLicenseNumber 入驻商家的营业执照号 + * @param platLicenseNumber 平台方(代理商方)营业执照号 + * @return + */ + Boolean fillDocTemplate(String mchLicenseNumber, String platLicenseNumber); + /** * 根据注册手机号禁用合同 * diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/FileAndTemplateService.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/FileAndTemplateService.java deleted file mode 100644 index bf55ddaa..00000000 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/FileAndTemplateService.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. - * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. - * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. - * Vestibulum commodo. Ut rhoncus gravida arcu. - */ - -package com.suisung.mall.shop.esign.service; - -public interface FileAndTemplateService { - - /** - * 填充合同模版,生成合同文件地址 - * - * @param mchLicenseNumber 入驻商家的营业执照号 - * @param platLicenseNumber 平台方(代理商方)营业执照号 - * @return - */ - Boolean fillDocTemplate(String mchLicenseNumber, String platLicenseNumber); -} diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java index 33b84833..92bfc584 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java @@ -9,21 +9,318 @@ package com.suisung.mall.shop.esign.service.impl; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.suisung.mall.common.constant.CommonConstant; import com.suisung.mall.common.modules.esign.EsignContractFillingFile; +import com.suisung.mall.common.modules.esign.EsignPlatformInfo; +import com.suisung.mall.common.modules.merch.ShopMerchEntry; +import com.suisung.mall.common.utils.StringUtils; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.shop.esign.mapper.EsignContractFillingFileMapper; import com.suisung.mall.shop.esign.service.EsignContractFillingFileService; +import com.suisung.mall.shop.esign.service.EsignPlatformInfoService; +import com.suisung.mall.shop.esign.utils.comm.EsignHttpHelper; +import com.suisung.mall.shop.esign.utils.comm.EsignHttpResponse; +import com.suisung.mall.shop.esign.utils.enums.EsignRequestType; +import com.suisung.mall.shop.esign.utils.exception.EsignDemoException; +import com.suisung.mall.shop.page.service.OssService; +import com.suisung.mall.shop.store.service.ShopMerchEntryService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; +@Slf4j @Service public class EsignContractFillingFileServiceImpl extends BaseServiceImpl implements EsignContractFillingFileService { + + @Value("${esign.server_url}") + private String serverUrl; + + @Value("${esign.app_id}") + private String appId; + + @Value("${esign.app_secret}") + private String appSecret; + + @Value("#{accountBaseConfigService.getConfig('tengxun_default_dir')}") + private String TENGXUN_DEFAULT_DIR; + + @Resource + private EsignPlatformInfoService esignPlatformInfoService; + + @Resource + private ShopMerchEntryService shopMerchEntryService; + + @Resource + private EsignContractFillingFileService esignContractFillingFileService; + + @Resource + private OssService ossService; + + /** + * 填充合同模版,生成合同文件地址 + * + * @param mchLicenseNumber 入驻商家(甲方)的营业执照号 + * @param platLicenseNumber 平台方(代理商方)(乙方)营业执照号 + * @return + */ + @Override + public Boolean fillDocTemplate(String mchLicenseNumber, String platLicenseNumber) { + // 获取平台方的信息 + EsignPlatformInfo esignPlatformInfo = new EsignPlatformInfo(); + if (StrUtil.isNotEmpty(platLicenseNumber)) { + esignPlatformInfo = esignPlatformInfoService.getEsignPlatformInfo(null, platLicenseNumber); + } + if (ObjectUtils.isEmpty(esignPlatformInfo)) { + esignPlatformInfo = esignPlatformInfoService.getEsignPlatformInfo(0, ""); + } + + if (ObjectUtils.isEmpty(esignPlatformInfo)) { + log.error("缺少平台方(代理商方)信息"); + return null; + } + + // 获取入驻商家(审批通过的)的信息 + ShopMerchEntry shopMerchEntry = shopMerchEntryService.getShopMerchEntryByLicenseNumber("", mchLicenseNumber, CommonConstant.MCH_APPR_STA_PASS); + if (shopMerchEntry == null) { + log.error("缺少商家入驻信息"); + return null; + } + + String apiaddr = "/v3/files/create-by-doc-template"; + EsignRequestType requestType = EsignRequestType.POST; + + // 获取平台方(代理商方)合同模版信息 + JSONArray templates = JSONUtil.parseArray(esignPlatformInfo.getDoc_template()); + if (ObjectUtils.isEmpty(templates) || templates.size() != 3) { + log.error("缺少平台方(代理商方)合同模版信息"); + return null; + } + + String today = DateUtil.format(new Date(), "yyyy年MM月dd日"); + String mchCompany = shopMerchEntry.getBiz_license_company(); + String platCompany = esignPlatformInfo.getLicense_company(); + String legalPersonName = shopMerchEntry.getLegal_person_name(); + String mchMobile = shopMerchEntry.getLogin_mobile(); + + String contractNumber = StringUtils.genLklOrderNo(4); + + int successCnt = 0; + + // 模版文件里有三份合同,顺序排列的: 1.平台商户入驻服务框架协议 2.小发同城服务费结算 3.结算授权委托书 + for (Object template : templates) { + // 从商家信息里获取模版的信息 + JSONObject templateJson = (JSONObject) template; + String templateId = templateJson.getStr("template_id"); + String fileName = templateJson.getStr("template_name"); + int seq = templateJson.getInt("seq"); + + // 获取填充模版的数据 + JSONObject fillJson = new JSONObject(); + fillJson.put("docTemplateId", templateId) + .put("fileName", fileName); + + + if (seq == 1) { + JSONArray list = new JSONArray(); + EsignPlatformInfo finalEsignPlatformInfo = esignPlatformInfo; + + list.add(new HashMap() {{ + put("componentKey", "mch_addr"); + put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》"); + }}); + + for (int i = 1; i <= 3; i++) { + int finalI = i; + list.add(new HashMap() {{ + put("componentKey", "legal_person_name" + finalI); + put("componentValue", legalPersonName); + }}); + } + + list.add(new HashMap() {{ + put("componentKey", "legal_person_id_number"); + put("componentValue", shopMerchEntry.getLegal_person_id_number()); + }}); + + list.add(new HashMap() {{ + put("componentKey", "legal_person_mobile"); + put("componentValue", shopMerchEntry.getLegal_person_mobile()); + }}); + list.add(new HashMap() {{ + put("componentKey", "legal_person_mobile2"); + put("componentValue", shopMerchEntry.getLegal_person_mobile()); + }}); + + list.add(new HashMap() {{ + put("componentKey", "plat_mobile"); + put("componentValue", finalEsignPlatformInfo.getLegal_person_mobile()); + }}); + + list.add(new HashMap() {{ + put("componentKey", "plat_email"); + put("componentValue", finalEsignPlatformInfo.getEmail()); + }}); + + list.add(new HashMap() {{ + put("componentKey", "mch_sign_date"); + put("componentValue", today); + }}); + + list.add(new HashMap() {{ + put("componentKey", "plat_sign_date"); + put("componentValue", today); + }}); + + for (int i = 1; i <= 14; i++) { + int finalI = i; + list.add(new HashMap() {{ + put("componentKey", "mch_name" + finalI); + put("componentValue", mchCompany); + }}); + } + + fillJson.put("components", list); + } else if (seq == 2) { + // 小发同城服务费结算 + JSONArray list = new JSONArray(); + list.add(new HashMap() {{ + put("componentKey", "mch_store_name"); + put("componentValue", shopMerchEntry.getStore_name()); + }}); + list.add(new HashMap() {{ + put("componentKey", "mch_name15"); + put("componentValue", mchCompany); + }}); + list.add(new HashMap() {{ + put("componentKey", "mch_sign_date2"); + put("componentValue", today); + }}); + + fillJson.put("components", list); + } else if (seq == 3) { + JSONArray list = new JSONArray(); + + list.add(new HashMap() {{ + put("componentKey", "plat_name1"); + put("componentValue", platCompany + "和代理商"); + }}); + for (int i = 2; i <= 3; i++) { + int finalI = i; + list.add(new HashMap() {{ + put("componentKey", "plat_name" + finalI); + put("componentValue", platCompany); + }}); + } + + list.add(new HashMap() {{ + put("componentKey", "contracts"); + put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》"); + }}); + list.add(new HashMap() {{ + put("componentKey", "rule_no"); + put("componentValue", 3); + }}); + list.add(new HashMap() {{ + put("componentKey", "mch_name16"); + put("componentValue", "本商户"); + }}); + + list.add(new HashMap() {{ + put("componentKey", "mch_name17"); + put("componentValue", mchCompany); + }}); + + list.add(new HashMap() {{ + put("componentKey", "mch_ratio"); + put("componentValue", shopMerchEntry.getSplit_ratio()); + }}); + + list.add(new HashMap() {{ + put("componentKey", "settlement_method"); + put("componentValue", shopMerchEntry.getSettlement_method()); + }}); + + list.add(new HashMap() {{ + put("componentKey", "plat_choice"); + put("componentValue", true); + }}); + + + list.add(new HashMap() {{ + put("componentKey", "legal_person_name4"); + put("componentValue", shopMerchEntry.getLegal_person_name()); + }}); + + list.add(new HashMap() {{ + put("componentKey", "mch_sign_date3"); + put("componentValue", today); + }}); + + fillJson.put("components", list); + } + String jsonParma = fillJson.toString(); + + //生成签名鉴权方式的的header + Map header = null; + try { + header = EsignHttpHelper.signAndBuildSignAndJsonHeader(appId, appSecret, jsonParma, requestType.name(), apiaddr, true); + //发起接口请求 + EsignHttpResponse createByDocTemplate = EsignHttpHelper.doCommHttp(serverUrl, apiaddr, requestType, jsonParma, header, true); + log.info("合同生成数据:{}", createByDocTemplate); + if (createByDocTemplate.getStatus() != 200) { + return false; + } + + EsignContractFillingFile esignContractFillingFile = new EsignContractFillingFile(); + + JSONObject jsonObject = JSONUtil.parseObj(createByDocTemplate.getBody()).getJSONObject("data"); + esignContractFillingFile.setUnsigned_contract_url(jsonObject.getStr("fileDownloadUrl")); + + // 把合同文件 url 上传到cos服务器 + String cosFileName = TENGXUN_DEFAULT_DIR.concat("/").concat("contract") + .concat("/").concat(mchLicenseNumber).concat("/") + .concat(jsonObject.getStr("fileId")).concat(".pdf"); + // 上传到cos服务器 + String localFileUrl = ossService.uploadObject4OSS(esignContractFillingFile.getUnsigned_contract_url(), cosFileName); + esignContractFillingFile.setUnsigned_contract_local_url(localFileUrl); + + esignContractFillingFile.setDoc_template_id(templateId); + esignContractFillingFile.setContract_number(contractNumber + seq); + esignContractFillingFile.setContract_name(fileName); + esignContractFillingFile.setStore_id(contractNumber); + esignContractFillingFile.setMobile(mchMobile); + esignContractFillingFile.setDoc_template_filling_values(jsonParma); + esignContractFillingFile.setSeq(seq); + esignContractFillingFile.setStatus(CommonConstant.Enable); + + if (esignContractFillingFileService.trySaveRecord(esignContractFillingFile)) { + successCnt += 1; + } + + } catch (EsignDemoException e) { + throw new RuntimeException(e); + } + } + + return successCnt == 3; + } + /** * 根据注册手机号禁用合同 * diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/FileAndTemplateServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/FileAndTemplateServiceImpl.java deleted file mode 100644 index 79071f5b..00000000 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/FileAndTemplateServiceImpl.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit. - * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. - * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. - * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. - * Vestibulum commodo. Ut rhoncus gravida arcu. - */ - -package com.suisung.mall.shop.esign.service.impl; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONArray; -import cn.hutool.json.JSONObject; -import cn.hutool.json.JSONUtil; -import com.suisung.mall.common.constant.CommonConstant; -import com.suisung.mall.common.modules.esign.EsignContractFillingFile; -import com.suisung.mall.common.modules.esign.EsignPlatformInfo; -import com.suisung.mall.common.modules.merch.ShopMerchEntry; -import com.suisung.mall.common.utils.StringUtils; -import com.suisung.mall.shop.esign.service.EsignContractFillingFileService; -import com.suisung.mall.shop.esign.service.EsignPlatformInfoService; -import com.suisung.mall.shop.esign.service.FileAndTemplateService; -import com.suisung.mall.shop.esign.utils.comm.EsignHttpHelper; -import com.suisung.mall.shop.esign.utils.comm.EsignHttpResponse; -import com.suisung.mall.shop.esign.utils.enums.EsignRequestType; -import com.suisung.mall.shop.esign.utils.exception.EsignDemoException; -import com.suisung.mall.shop.page.service.OssService; -import com.suisung.mall.shop.store.service.ShopMerchEntryService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; - -import javax.annotation.Resource; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -@Slf4j -@Service -public class FileAndTemplateServiceImpl implements FileAndTemplateService { - @Value("${esign.server_url}") - private String serverUrl; - - @Value("${esign.app_id}") - private String appId; - - @Value("${esign.app_secret}") - private String appSecret; - - @Value("#{accountBaseConfigService.getConfig('tengxun_default_dir')}") - private String TENGXUN_DEFAULT_DIR; - - @Resource - private EsignPlatformInfoService esignPlatformInfoService; - - @Resource - private ShopMerchEntryService shopMerchEntryService; - - @Resource - private EsignContractFillingFileService esignContractFillingFileService; - - @Resource - private OssService ossService; - - /** - * 填充合同模版,生成合同文件地址 - * - * @param mchLicenseNumber 入驻商家(甲方)的营业执照号 - * @param platLicenseNumber 平台方(代理商方)(乙方)营业执照号 - * @return - */ - @Override - public Boolean fillDocTemplate(String mchLicenseNumber, String platLicenseNumber) { - // 获取平台方的信息 - EsignPlatformInfo esignPlatformInfo = new EsignPlatformInfo(); - if (StrUtil.isNotEmpty(platLicenseNumber)) { - esignPlatformInfo = esignPlatformInfoService.getEsignPlatformInfo(null, platLicenseNumber); - } - if (ObjectUtils.isEmpty(esignPlatformInfo)) { - esignPlatformInfo = esignPlatformInfoService.getEsignPlatformInfo(0, ""); - } - - if (ObjectUtils.isEmpty(esignPlatformInfo)) { - log.error("缺少平台方(代理商方)信息"); - return null; - } - - // 获取入驻商家(审批通过的)的信息 - ShopMerchEntry shopMerchEntry = shopMerchEntryService.getShopMerchEntryByLicenseNumber("", mchLicenseNumber, CommonConstant.MCH_APPR_STA_PASS); - if (shopMerchEntry == null) { - log.error("缺少商家入驻信息"); - return null; - } - - String apiaddr = "/v3/files/create-by-doc-template"; - EsignRequestType requestType = EsignRequestType.POST; - - // 获取平台方(代理商方)合同模版信息 - JSONArray templates = JSONUtil.parseArray(esignPlatformInfo.getDoc_template()); - if (ObjectUtils.isEmpty(templates) || templates.size() != 3) { - log.error("缺少平台方(代理商方)合同模版信息"); - return null; - } - - String today = DateUtil.format(new Date(), "yyyy年MM月dd日"); - String mchCompany = shopMerchEntry.getBiz_license_company(); - String platCompany = esignPlatformInfo.getLicense_company(); - String legalPersonName = shopMerchEntry.getLegal_person_name(); - String mchMobile = shopMerchEntry.getLogin_mobile(); - - String contractNumber = StringUtils.genLklOrderNo(4); - - int successCnt = 0; - - // 模版文件里有三份合同,顺序排列的: 1.平台商户入驻服务框架协议 2.小发同城服务费结算 3.结算授权委托书 - for (Object template : templates) { - // 从商家信息里获取模版的信息 - JSONObject templateJson = (JSONObject) template; - String templateId = templateJson.getStr("template_id"); - String fileName = templateJson.getStr("template_name"); - int seq = templateJson.getInt("seq"); - - // 获取填充模版的数据 - JSONObject fillJson = new JSONObject(); - fillJson.put("docTemplateId", templateId) - .put("fileName", fileName); - - - if (seq == 1) { - JSONArray list = new JSONArray(); - EsignPlatformInfo finalEsignPlatformInfo = esignPlatformInfo; - - list.add(new HashMap() {{ - put("componentKey", "mch_addr"); - put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》"); - }}); - - for (int i = 1; i <= 3; i++) { - int finalI = i; - list.add(new HashMap() {{ - put("componentKey", "legal_person_name" + finalI); - put("componentValue", legalPersonName); - }}); - } - - list.add(new HashMap() {{ - put("componentKey", "legal_person_id_number"); - put("componentValue", shopMerchEntry.getLegal_person_id_number()); - }}); - - list.add(new HashMap() {{ - put("componentKey", "legal_person_mobile"); - put("componentValue", shopMerchEntry.getLegal_person_mobile()); - }}); - list.add(new HashMap() {{ - put("componentKey", "legal_person_mobile2"); - put("componentValue", shopMerchEntry.getLegal_person_mobile()); - }}); - - list.add(new HashMap() {{ - put("componentKey", "plat_mobile"); - put("componentValue", finalEsignPlatformInfo.getLegal_person_mobile()); - }}); - - list.add(new HashMap() {{ - put("componentKey", "plat_email"); - put("componentValue", finalEsignPlatformInfo.getEmail()); - }}); - - list.add(new HashMap() {{ - put("componentKey", "mch_sign_date"); - put("componentValue", today); - }}); - - list.add(new HashMap() {{ - put("componentKey", "plat_sign_date"); - put("componentValue", today); - }}); - - for (int i = 1; i <= 14; i++) { - int finalI = i; - list.add(new HashMap() {{ - put("componentKey", "mch_name" + finalI); - put("componentValue", mchCompany); - }}); - } - - fillJson.put("components", list); - } else if (seq == 2) { - // 小发同城服务费结算 - JSONArray list = new JSONArray(); - list.add(new HashMap() {{ - put("componentKey", "mch_store_name"); - put("componentValue", shopMerchEntry.getStore_name()); - }}); - list.add(new HashMap() {{ - put("componentKey", "mch_name15"); - put("componentValue", mchCompany); - }}); - list.add(new HashMap() {{ - put("componentKey", "mch_sign_date2"); - put("componentValue", today); - }}); - - fillJson.put("components", list); - } else if (seq == 3) { - JSONArray list = new JSONArray(); - - list.add(new HashMap() {{ - put("componentKey", "plat_name1"); - put("componentValue", platCompany + "和代理商"); - }}); - for (int i = 2; i <= 3; i++) { - int finalI = i; - list.add(new HashMap() {{ - put("componentKey", "plat_name" + finalI); - put("componentValue", platCompany); - }}); - } - - list.add(new HashMap() {{ - put("componentKey", "contracts"); - put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》"); - }}); - list.add(new HashMap() {{ - put("componentKey", "rule_no"); - put("componentValue", 3); - }}); - list.add(new HashMap() {{ - put("componentKey", "mch_name16"); - put("componentValue", "本商户"); - }}); - - list.add(new HashMap() {{ - put("componentKey", "mch_name17"); - put("componentValue", mchCompany); - }}); - - list.add(new HashMap() {{ - put("componentKey", "mch_ratio"); - put("componentValue", shopMerchEntry.getSplit_ratio()); - }}); - - list.add(new HashMap() {{ - put("componentKey", "settlement_method"); - put("componentValue", shopMerchEntry.getSettlement_method()); - }}); - - list.add(new HashMap() {{ - put("componentKey", "plat_choice"); - put("componentValue", true); - }}); - - - list.add(new HashMap() {{ - put("componentKey", "legal_person_name4"); - put("componentValue", shopMerchEntry.getLegal_person_name()); - }}); - - list.add(new HashMap() {{ - put("componentKey", "mch_sign_date3"); - put("componentValue", today); - }}); - - fillJson.put("components", list); - } - String jsonParma = fillJson.toString(); - - //生成签名鉴权方式的的header - Map header = null; - try { - header = EsignHttpHelper.signAndBuildSignAndJsonHeader(appId, appSecret, jsonParma, requestType.name(), apiaddr, true); - //发起接口请求 - EsignHttpResponse createByDocTemplate = EsignHttpHelper.doCommHttp(serverUrl, apiaddr, requestType, jsonParma, header, true); - log.info("合同生成数据:{}", createByDocTemplate); - if (createByDocTemplate.getStatus() != 200) { - return false; - } - - EsignContractFillingFile esignContractFillingFile = new EsignContractFillingFile(); - - JSONObject jsonObject = JSONUtil.parseObj(createByDocTemplate.getBody()).getJSONObject("data"); - esignContractFillingFile.setUnsigned_contract_url(jsonObject.getStr("fileDownloadUrl")); - - // 把合同文件 url 上传到cos服务器 - String cosFileName = TENGXUN_DEFAULT_DIR.concat("/").concat("contract") - .concat("/").concat(mchLicenseNumber).concat("/") - .concat(jsonObject.getStr("fileId")).concat(".pdf"); - // 上传到cos服务器 - String localFileUrl = ossService.uploadObject4OSS(esignContractFillingFile.getUnsigned_contract_url(), cosFileName); - esignContractFillingFile.setUnsigned_contract_local_url(localFileUrl); - - esignContractFillingFile.setDoc_template_id(templateId); - esignContractFillingFile.setContract_number(contractNumber + seq); - esignContractFillingFile.setContract_name(fileName); - esignContractFillingFile.setStore_id(contractNumber); - esignContractFillingFile.setMobile(mchMobile); - esignContractFillingFile.setDoc_template_filling_values(jsonParma); - esignContractFillingFile.setSeq(seq); - esignContractFillingFile.setStatus(CommonConstant.Enable); - - if (esignContractFillingFileService.trySaveRecord(esignContractFillingFile)) { - successCnt += 1; - } - - } catch (EsignDemoException e) { - throw new RuntimeException(e); - } - } - - return successCnt == 3; - } - - /** - * 填充合同模版,生成合同文件地址 - * - * @param mchLicenseNumber 入驻商家的营业执照号 - * @param platLicenseNumber 平台方(代理商方)营业执照号 - * @return - */ - // @Override - public EsignContractFillingFile fillDocTemplate1(String mchLicenseNumber, String platLicenseNumber) { - // 获取模版文件 - String templateId = "b411907d8f4640a1af593bea98c6b6c1"; - String apiaddr = "/v3/files/create-by-doc-template"; - - // 获取填充模版的数据 - JSONObject fillJson = new JSONObject(); - fillJson.put("docTemplateId", templateId) - .put("fileName", "小发同城入驻协议测试"); - - String componentJson = "[{'componentKey':'yf_company','componentValue':'桂平厚德贸易有限公司'},{'componentKey':'sign_date','componentValue':'2025-02-20'}]"; - fillJson.put("components", JSONUtil.parseArray(componentJson)); - - String jsonParma = fillJson.toString(); - - // 填充模版操作 - /* 填写模板生成文件*/ - - //请求方法 - EsignRequestType requestType = EsignRequestType.POST; - //生成签名鉴权方式的的header - Map header = null; - try { - header = EsignHttpHelper.signAndBuildSignAndJsonHeader(appId, appSecret, jsonParma, requestType.name(), apiaddr, true); - //发起接口请求 - EsignHttpResponse createByDocTemplate = EsignHttpHelper.doCommHttp(serverUrl, apiaddr, requestType, jsonParma, header, true); - - log.info("{}", createByDocTemplate); - - EsignContractFillingFile esignContractFillingFile = new EsignContractFillingFile(); - esignContractFillingFile.setDoc_template_id("docTemplateId"); - esignContractFillingFile.setStore_id("storeId"); - esignContractFillingFile.setDoc_template_filling_values(jsonParma); - esignContractFillingFile.setUnsigned_contract_url(createByDocTemplate.getBody()); - esignContractFillingFile.setUnsigned_contract_local_url(createByDocTemplate.getBody()); - esignContractFillingFile.setStatus(1); - return esignContractFillingFile; - - } catch (EsignDemoException e) { - throw new RuntimeException(e); - } - } -} diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/ShopMerchEntryController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/ShopMerchEntryController.java index e2e684bb..1a8c2e17 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/ShopMerchEntryController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/ShopMerchEntryController.java @@ -12,7 +12,7 @@ import cn.hutool.json.JSONObject; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.merch.ShopMerchEntry; import com.suisung.mall.common.service.impl.BaseControllerImpl; -import com.suisung.mall.shop.esign.service.FileAndTemplateService; +import com.suisung.mall.shop.esign.service.EsignContractFillingFileService; import com.suisung.mall.shop.store.service.ShopMerchEntryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -34,22 +34,20 @@ public class ShopMerchEntryController extends BaseControllerImpl { private ShopMerchEntryService shopMerchEntryService; @Resource - private FileAndTemplateService fileAndTemplateService; + private EsignContractFillingFileService esignContractFillingFileService; @ApiOperation(value = "测试", notes = "测试") @RequestMapping(value = "/gencon", method = RequestMethod.POST) public Object fillDocTemplate() { - return fileAndTemplateService.fillDocTemplate("yyzz787654566543", "91450881MADEQ92533"); + return esignContractFillingFileService.fillDocTemplate("yyzz787654566543", "91450881MADEQ92533"); } - @ApiOperation(value = "店铺主营分类(类目)", notes = "店铺主营分类(类目)") @RequestMapping(value = "/business/category", method = RequestMethod.POST) public CommonResult shopStoreBusinessCategoryList() { return shopMerchEntryService.storeBusinessCategoryList(); } - @ApiOperation(value = "商家申请入驻商城平台", notes = "商家申请入驻商城平台") @RequestMapping(value = "/apply", method = RequestMethod.POST) public CommonResult shopMerchEntryApply(@RequestBody JSONObject shopMerchEntryJSON) { diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMerchEntryServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMerchEntryServiceImpl.java index 2d02f964..f6019da3 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMerchEntryServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMerchEntryServiceImpl.java @@ -202,11 +202,23 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl 0) { + return CommonResult.failed("已经签署合同,不能再次申请!"); + } + + ShopMerchEntry record = JSONUtil.toBean(shopMerchEntryJSON, ShopMerchEntry.class); if (record == null) { log.error("###商家入驻参数转换失败###"); @@ -238,17 +250,18 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl mobileAndLicenseNumber = esignPlatformInfoService.getEsignPlatformMobileAndLicenseNumber(); if (mobileAndLicenseNumber != null) { + String mchName = StrUtil.isBlank(record.getBiz_license_company()) ? "重新修正" : record.getBiz_license_company(); Map tmplArgs = new HashMap<>(1); - tmplArgs.put("name", "重新修正再"); // 商家公司名称 - // 所有店铺管理员的发送邮件, 提醒商家:您有一笔新的订单 ${order_id},请及时处理。 + tmplArgs.put("name", mchName); // 商家公司名称 + // 尊敬的管理员,商家 ${name},提交了入驻我们平台的申请,请及时对相关资质材料予以审核,以便推进后续流程。 shopMessageTemplateService.aliyunSmsSend(mobileAndLicenseNumber.getFirst(), "SMS_479760276", tmplArgs); }