e签宝模版填充修改,单文件

This commit is contained in:
Jack 2025-03-09 00:08:05 +08:00
parent 673761800f
commit fd04445418
5 changed files with 234 additions and 9 deletions

View File

@ -15,6 +15,7 @@ import cn.hutool.json.JSONUtil;
import com.suisung.mall.common.pojo.dto.GpsDTO;
import com.suisung.mall.common.pojo.res.BaiduMapLbsRes;
import com.suisung.mall.common.utils.RestTemplateHttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -27,6 +28,7 @@ import java.net.URLConnection;
/**
* 百度坐标系转换类
*/
@Slf4j
@Service
public class BaiduMapServiceImpl {
@ -141,7 +143,9 @@ public class BaiduMapServiceImpl {
}
if (city_limit != null) {
apiUrl.append("&city_limit").append(city_limit);
apiUrl.append("&city_limit=").append(city_limit);
} else {
apiUrl.append("&city_limit=false");
}
if (StrUtil.isNotBlank(coord_type)) {
@ -151,8 +155,11 @@ public class BaiduMapServiceImpl {
if (StrUtil.isNotBlank(ret_coordtype)) {
apiUrl.append("&ret_coordtype=").append(ret_coordtype);
}
String reqUrl = apiUrl.toString();
log.debug("apiUrl: {}", reqUrl);
String respJson = RestTemplateHttpUtil.sendGet(apiUrl.toString(), String.class);
String respJson = RestTemplateHttpUtil.sendGet(reqUrl, String.class);
return JSONUtil.parseObj(respJson);
}
}

View File

@ -33,7 +33,7 @@ public class EsignController extends BaseControllerImpl {
@ApiOperation(value = "店铺基础信息表-查找所有店铺编号和名称", notes = "店铺基础信息表-查找所有店铺编号和名称")
@RequestMapping(value = "/testcase", method = RequestMethod.POST)
public Object testCase() {
return esignContractFillingFileService.fillDocTemplate("11", "11");
return esignContractFillingFileService.fillDocTemplate("yyzz787654566543", "91450881MADEQ92533");
}
@ApiOperation(value = "基于文件发起签署电子合同", notes = "基于文件发起签署电子合同")

View File

@ -105,6 +105,220 @@ public class EsignContractFillingFileServiceImpl extends BaseServiceImpl<EsignCo
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() <= 0) {
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);
JSONArray list = new JSONArray();
EsignPlatformInfo finalEsignPlatformInfo = esignPlatformInfo;
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_contracts");
put("componentValue", "《平台商户入驻服务框架协议》和《小发同城服务费结算》");
}});
// 签署时间
for (int i = 1; i <= 3; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_sign_date" + finalI);
put("componentValue", today);
}});
}
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_sign_date1");
put("componentValue", today);
}});
// 甲方公司名称
for (int i = 1; i <= 16; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_company" + finalI);
put("componentValue", mchCompany);
}});
}
for (int i = 1; i <= 4; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_legal_person_name" + finalI);
put("componentValue", legalPersonName);
}});
}
for (int i = 1; i <= 2; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_legal_person_mobile" + finalI);
put("componentValue", shopMerchEntry.getLegal_person_mobile());
}});
}
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_legal_person_id_number1");
put("componentValue", shopMerchEntry.getLegal_person_id_number());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "mch_store_name1");
put("componentValue", shopMerchEntry.getStore_name());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "rule_no");
put("componentValue", 3);
}});
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", "mch_address1");
put("componentValue", shopMerchEntry.getStore_address());
}});
// 乙方公司名称
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_company1");
put("componentValue", platCompany + "和代理商");
}});
for (int i = 2; i <= 3; i++) {
int finalI = i;
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_company" + finalI);
put("componentValue", platCompany);
}});
}
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_mobile1");
put("componentValue", finalEsignPlatformInfo.getLegal_person_mobile());
}});
list.add(new HashMap<String, Object>() {{
put("componentKey", "plat_email1");
put("componentValue", finalEsignPlatformInfo.getEmail());
}});
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 > 0;
}
/**
* 更加双方营业执照号码填充合同模版生成合同文件地址
*
* @param mchLicenseNumber 入驻商家(甲方)的营业执照号
* @param platLicenseNumber 平台方代理商方乙方营业执照号
* @return
*/
public Boolean fillDocTemplate2(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) {
@ -321,6 +535,7 @@ public class EsignContractFillingFileServiceImpl extends BaseServiceImpl<EsignCo
return successCnt == 3;
}
/**
* 根据注册手机号禁用合同
*

View File

@ -8,6 +8,8 @@
package com.suisung.mall.shop.esign.service.impl;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.suisung.mall.common.modules.esign.EsignContract;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.esign.mapper.EsignContractMapper;
@ -16,13 +18,12 @@ import org.springframework.stereotype.Service;
@Service
public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMapper, EsignContract> implements EsignContractService {
/**
* @param s
* @param s1
* @return
*/
@Override
public Object signFlowCreateByFile() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("docs", new JSONArray() {
});
return null;
}
}

View File

@ -11,6 +11,7 @@ package com.suisung.mall.shop.esign.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.modules.esign.EsignPlatformInfo;
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
@ -34,7 +35,8 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
@Override
public EsignPlatformInfo getEsignPlatformInfo(Integer type, String licenseNumber) {
QueryWrapper<EsignPlatformInfo> queryWrapper = new QueryWrapper<>();
if (ObjectUtils.isEmpty(type)) {
queryWrapper.eq("status", CommonConstant.Enable);
if (!ObjectUtils.isEmpty(type)) {
queryWrapper.eq("type", type);
}