删除多余的文件

This commit is contained in:
Jack 2025-03-06 17:04:57 +08:00
parent 15def95223
commit caef74d791
10 changed files with 352 additions and 405 deletions

View File

@ -1615,8 +1615,12 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
String user_intl = "";
logger.debug("### 注册参数:{}###", JSONUtil.toJsonStr(userInfo));
// todo 支持国外手机号 isMobile() 方法
String currency_id = "+" + getParameter("currency_id", "");
org.apache.commons.lang3.StringUtils.isBlank("");
if (StrUtil.isNotBlank(user_mobile) || (CheckUtil.isMobile(user_account, currency_id) && StrUtil.equals(user_account, user_mobile))) {
// 是否为手机号码的注册
// 拆分手机号码为intl + code
@ -1637,6 +1641,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
// 判断connect绑定操作
AccountUserBindConnect bind_check_row = bindConnectService.get(user_mobile);
if (bind_check_row != null && CheckUtil.isNotEmpty(bind_check_row.getBind_active())) {
logger.error("##手机号:{}##", user_mobile);
throw new ApiException(_("手机号已经绑定过,不可以使用此手机号注册"));
}
}
@ -1668,6 +1673,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
String user_email = (String) userInfo.get("user_email");
Integer bind_type = getParameter("bind_type", 0);
if (StrUtil.isNotBlank(user_email) || (CheckUtil.isEmail(user_account) && StrUtil.equals(user_account, user_email)) || bind_type.equals(2)) {
// 是否为邮箱注册

View File

@ -111,7 +111,9 @@ public class CheckUtil {
* @return 是否属于三大运营商号段范围
*/
public static boolean isMobile(String phone, String diallingCode) {
if (StrUtil.isBlank(phone) || phone.length() <= 3) return false;
if (StrUtil.isBlank(phone) || phone.length() <= 3) {
return false;
}
String mobile = StrUtil.removePrefix(phone, diallingCode);
String regex = "^((13[0-9])|(14[5-9])|(15([0-3]|[5-9]))|(16[6-7])|(17[1-8])|(18[0-9])|(19[1|3])|(19[5|6])|(19[8|9]))\\d{8}$";
Pattern p = Pattern.compile(regex);
@ -213,7 +215,7 @@ public class CheckUtil {
strSql.append("FIND_IN_SET ( ('" + CheckUtil.addslashes(params.get(i).toString()) + "'), " + fieldName + ") or ");
}
column_row.apply("(" + strSql.toString() + ")", params);
column_row.apply("(" + strSql + ")", params);
}
public static int bkdrHash(String str) {
@ -267,11 +269,7 @@ public class CheckUtil {
}
try {
long time = DateUtil.parse(date_string).getTime();
if (time > 0) {
return true;
} else {
return false;
}
return time > 0;
// DateUtils.parseDate(date_string, parsePatterns);
} catch (Exception e) {
return false;

View File

@ -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;
}

View File

@ -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");
}
}

View File

@ -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);
/**
* 根据注册手机号禁用合同
*

View File

@ -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);
}

View File

@ -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<EsignContractFillingFileMapper, EsignContractFillingFile> 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<String, Object>() {{
put("componentKey", "mch_addr");
put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》");
}});
for (int i = 1; i <= 3; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_name" + finalI);
put("componentValue", legalPersonName);
}});
}
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_id_number");
put("componentValue", shopMerchEntry.getLegal_person_id_number());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_mobile");
put("componentValue", shopMerchEntry.getLegal_person_mobile());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_mobile2");
put("componentValue", shopMerchEntry.getLegal_person_mobile());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_mobile");
put("componentValue", finalEsignPlatformInfo.getLegal_person_mobile());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_email");
put("componentValue", finalEsignPlatformInfo.getEmail());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_sign_date");
put("componentValue", today);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_sign_date");
put("componentValue", today);
}});
for (int i = 1; i <= 14; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name" + finalI);
put("componentValue", mchCompany);
}});
}
fillJson.put("components", list);
} else if (seq == 2) {
// 小发同城服务费结算
JSONArray list = new JSONArray();
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_store_name");
put("componentValue", shopMerchEntry.getStore_name());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name15");
put("componentValue", mchCompany);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_sign_date2");
put("componentValue", today);
}});
fillJson.put("components", list);
} else if (seq == 3) {
JSONArray list = new JSONArray();
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_name1");
put("componentValue", platCompany + "和代理商");
}});
for (int i = 2; i <= 3; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_name" + finalI);
put("componentValue", platCompany);
}});
}
list.add(new HashMap<String, Object>() {{
put("componentKey", "contracts");
put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》");
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "rule_no");
put("componentValue", 3);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name16");
put("componentValue", "本商户");
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name17");
put("componentValue", mchCompany);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_ratio");
put("componentValue", shopMerchEntry.getSplit_ratio());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "settlement_method");
put("componentValue", shopMerchEntry.getSettlement_method());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_choice");
put("componentValue", true);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_name4");
put("componentValue", shopMerchEntry.getLegal_person_name());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_sign_date3");
put("componentValue", today);
}});
fillJson.put("components", list);
}
String jsonParma = fillJson.toString();
//生成签名鉴权方式的的header
Map<String, String> 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;
}
/**
* 根据注册手机号禁用合同
*

View File

@ -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<String, Object>() {{
put("componentKey", "mch_addr");
put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》");
}});
for (int i = 1; i <= 3; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_name" + finalI);
put("componentValue", legalPersonName);
}});
}
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_id_number");
put("componentValue", shopMerchEntry.getLegal_person_id_number());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_mobile");
put("componentValue", shopMerchEntry.getLegal_person_mobile());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_mobile2");
put("componentValue", shopMerchEntry.getLegal_person_mobile());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_mobile");
put("componentValue", finalEsignPlatformInfo.getLegal_person_mobile());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_email");
put("componentValue", finalEsignPlatformInfo.getEmail());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_sign_date");
put("componentValue", today);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_sign_date");
put("componentValue", today);
}});
for (int i = 1; i <= 14; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name" + finalI);
put("componentValue", mchCompany);
}});
}
fillJson.put("components", list);
} else if (seq == 2) {
// 小发同城服务费结算
JSONArray list = new JSONArray();
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_store_name");
put("componentValue", shopMerchEntry.getStore_name());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name15");
put("componentValue", mchCompany);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_sign_date2");
put("componentValue", today);
}});
fillJson.put("components", list);
} else if (seq == 3) {
JSONArray list = new JSONArray();
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_name1");
put("componentValue", platCompany + "和代理商");
}});
for (int i = 2; i <= 3; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_name" + finalI);
put("componentValue", platCompany);
}});
}
list.add(new HashMap<String, Object>() {{
put("componentKey", "contracts");
put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》");
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "rule_no");
put("componentValue", 3);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name16");
put("componentValue", "本商户");
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_name17");
put("componentValue", mchCompany);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_ratio");
put("componentValue", shopMerchEntry.getSplit_ratio());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "settlement_method");
put("componentValue", shopMerchEntry.getSettlement_method());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_choice");
put("componentValue", true);
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "legal_person_name4");
put("componentValue", shopMerchEntry.getLegal_person_name());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_sign_date3");
put("componentValue", today);
}});
fillJson.put("components", list);
}
String jsonParma = fillJson.toString();
//生成签名鉴权方式的的header
Map<String, String> 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<String, String> 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);
}
}
}

View File

@ -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) {

View File

@ -202,11 +202,23 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
// }
// userId = user.getId().toString();
// 参数校验流程
if (shopMerchEntryJSON == null || ObjectUtil.isEmpty(shopMerchEntryJSON.get("id"))) {
return CommonResult.failed("缺少必要参数!");
}
// 验证合同签署状态如果已经签署不能再次申请
ShopMerchEntry oldRecord = getById(shopMerchEntryJSON.getInt("id"));
if (oldRecord == null) {
return CommonResult.failed("未找到入驻记录!");
}
if (oldRecord.getSigned_status() > 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<ShopMerchEntryMap
record.setUpdated_by(userId);
record.setUpdated_at(new Date());
record.setStatus(CommonConstant.Enable);
record.setSigned_status(CommonConstant.Disable); // 重置合同签署状态
if (!updateById(record)) {
return CommonResult.failed("重新申请入驻提交失败!");
}
// 尊敬的管理员商家 ${name}提交了入驻我们平台的申请请及时对相关资质材料予以审核以便推进后续流程
// 获取平台方的手机号码发送短信通知
Pair<String, String> mobileAndLicenseNumber = esignPlatformInfoService.getEsignPlatformMobileAndLicenseNumber();
if (mobileAndLicenseNumber != null) {
String mchName = StrUtil.isBlank(record.getBiz_license_company()) ? "重新修正" : record.getBiz_license_company();
Map<String, Object> tmplArgs = new HashMap<>(1);
tmplArgs.put("name", "重新修正再"); // 商家公司名称
// 所有店铺管理员的发送邮件 提醒商家您有一笔新的订单 ${order_id}请及时处理
tmplArgs.put("name", mchName); // 商家公司名称
// 尊敬的管理员商家 ${name}提交了入驻我们平台的申请请及时对相关资质材料予以审核以便推进后续流程
shopMessageTemplateService.aliyunSmsSend(mobileAndLicenseNumber.getFirst(), "SMS_479760276", tmplArgs);
}