拉卡拉联调 bug 修复
This commit is contained in:
parent
d1c6630ef5
commit
b377244cb4
@ -13,6 +13,7 @@ import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
|
||||
import com.suisung.mall.shop.esign.service.EsignContractService;
|
||||
import com.suisung.mall.shop.esign.service.EsignPlatformInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -36,11 +37,14 @@ public class EsignController extends BaseControllerImpl {
|
||||
@Resource
|
||||
private EsignContractService esignContractService;
|
||||
|
||||
@Resource
|
||||
private EsignPlatformInfoService esignPlatformInfoService;
|
||||
|
||||
@ApiOperation(value = "测试填充模版控件", notes = "测试填充模版控件")
|
||||
@RequestMapping(value = "/testcase", method = RequestMethod.POST)
|
||||
public Object testCase() {
|
||||
//return esignContractFillingFileService.fillDocTemplate("13128997057", "91450881MADEQ92533");
|
||||
return esignContractService.getSignedContractFileUrl("27e8dad5491d4d9ab4bc6f8154ae8ff5");
|
||||
return esignPlatformInfoService.getDistributorAndPlatformByIds(1L);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "管理员发起签署电子合同流程", notes = "基于文件发起签署电子合同")
|
||||
|
||||
@ -32,7 +32,7 @@ public interface EsignPlatformInfoService {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<EsignPlatformInfo> getDistributorInfoByIds(Long... ids);
|
||||
List<EsignPlatformInfo> getDistributorAndPlatformByIds(Long... ids);
|
||||
|
||||
/**
|
||||
* 根据分类和营业执照号获取平台方信息
|
||||
|
||||
@ -220,8 +220,8 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
|
||||
Integer code = jsonObject.getInt("code");
|
||||
String signFlowId = (String) jsonObject.getByPath("data.signFlowId");
|
||||
if (code == null || code != 0 || StrUtil.isBlank(signFlowId)) {
|
||||
log.error("e签宝请求失败,返回状态码:{}", createByDocTemplate.getStatus());
|
||||
return Pair.of(false, "e签宝请求失败,状态码:" + createByDocTemplate.getStatus());
|
||||
log.error("e签宝请求失败,返回status码:{}", code);
|
||||
return Pair.of(false, "e签宝请求失败!");
|
||||
}
|
||||
|
||||
//合同签署状态:-1:预备数据阶段;0-等待签署;1-已部分签署;2-已完成(所有签署方完成签署)3-已撤销(发起方撤销签署任务)5-已过期(签署截止日到期后触发)7-已拒签(签署方拒绝签署)
|
||||
|
||||
@ -33,28 +33,44 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
||||
*/
|
||||
@Override
|
||||
public EsignPlatformInfo getDistributorInfoById(Long id) {
|
||||
List<EsignPlatformInfo> list = getDistributorInfoByIds(id);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
if (id == null || id <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
QueryWrapper<EsignPlatformInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", id)
|
||||
.gt("level", 0)
|
||||
.eq("status", CommonConstant.Enable).orderByAsc("level");
|
||||
|
||||
List<EsignPlatformInfo> esignPlatformInfos = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(esignPlatformInfos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return esignPlatformInfos.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取代理商信息
|
||||
* 根据一个或多个代理商自增ID获取代理商和平台记录,无论怎么都要获取一条平台方的记录
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<EsignPlatformInfo> getDistributorInfoByIds(Long... ids) {
|
||||
if (ids == null || ids.length == 0) {
|
||||
return null;
|
||||
public List<EsignPlatformInfo> getDistributorAndPlatformByIds(Long... ids) {
|
||||
QueryWrapper<EsignPlatformInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("status", CommonConstant.Enable).orderByAsc("level");
|
||||
if (ids != null && ids.length > 0) {
|
||||
queryWrapper.and(wrapper -> {
|
||||
wrapper.in("id", ids).gt("level", 0);
|
||||
wrapper.or(wrapperOr -> {
|
||||
wrapperOr.eq("level", 0);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
queryWrapper.eq("level", 0);
|
||||
}
|
||||
|
||||
QueryWrapper<EsignPlatformInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("id", ids).eq("status", CommonConstant.Enable);
|
||||
List<EsignPlatformInfo> esignPlatformInfos = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(esignPlatformInfos)) {
|
||||
return null;
|
||||
|
||||
@ -135,11 +135,10 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
@Override
|
||||
public JSONArray buildApplyLedgerReceiverReqParams(Long platformId) {
|
||||
List<Long> ids = new ArrayList<>();
|
||||
ids.add(0L);
|
||||
if (ObjectUtil.isNotEmpty(platformId)) {
|
||||
if (platformId != null && platformId > 0) {
|
||||
ids.add(platformId);
|
||||
}
|
||||
List<EsignPlatformInfo> esignPlatformInfoList = esignPlatformInfoService.getDistributorInfoByIds(ids.toArray(new Long[0]));
|
||||
List<EsignPlatformInfo> esignPlatformInfoList = esignPlatformInfoService.getDistributorAndPlatformByIds(ids.toArray(new Long[0]));
|
||||
if (CollectionUtil.isEmpty(esignPlatformInfoList)) {
|
||||
return null;
|
||||
}
|
||||
@ -167,6 +166,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
|
||||
reqParam.put("acctOpenBankName", esignPlatformInfo.getRec_acc_bank_name());
|
||||
reqParam.put("acctClearBankCode", esignPlatformInfo.getRec_acc_clear_bank_no());
|
||||
|
||||
//文件类型参考:https://o.lakala.com/#/home/document/detail?id=90
|
||||
JSONArray attachList = new JSONArray();
|
||||
if (StrUtil.isNotBlank(esignPlatformInfo.getLicense_image())) {
|
||||
JSONObject BUSINESS_LICENCE = new JSONObject();
|
||||
|
||||
@ -110,9 +110,6 @@ public class LklTkServiceImpl {
|
||||
public static String encryptNotifyData(String priKey, String data) {
|
||||
ByteArrayOutputStream out = null;
|
||||
try {
|
||||
// pubKey 去掉 空格、制表符(\t)、换行符(\n)、回车符(\r)
|
||||
priKey = priKey.replaceAll("\\s+", "");
|
||||
|
||||
logger.debug("拉卡拉tk加密私钥:{}", priKey);
|
||||
logger.debug("拉卡拉tk待加密data数据:{}", data);
|
||||
|
||||
@ -138,7 +135,6 @@ public class LklTkServiceImpl {
|
||||
|
||||
// 编码为Base64字符串
|
||||
String encryptDataStr = Base64.getEncoder().encodeToString(out.toByteArray());
|
||||
|
||||
logger.debug("拉卡拉tk数据加密结果:{}", encryptDataStr);
|
||||
return encryptDataStr;
|
||||
} catch (Exception e) {
|
||||
@ -173,8 +169,6 @@ public class LklTkServiceImpl {
|
||||
try {
|
||||
logger.debug("拉卡拉tk解密公钥:{}", pubKey);
|
||||
logger.debug("拉卡拉tk待解密data数据:{}", data);
|
||||
// pubKey 去掉 空格、制表符(\t)、换行符(\n)、回车符(\r)
|
||||
pubKey = pubKey.replaceAll("\\s+", "");
|
||||
Base64.Decoder decoder = Base64.getDecoder();
|
||||
byte[] keyBytes = decoder.decode(pubKey.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] dataBytes = decoder.decode(data.getBytes(StandardCharsets.UTF_8));
|
||||
@ -522,6 +516,12 @@ public class LklTkServiceImpl {
|
||||
if (SETTLE_ID_CARD_BEHIND != null) {
|
||||
attachments.put(SETTLE_ID_CARD_BEHIND); // 法人身份证国徽面
|
||||
}
|
||||
|
||||
JSONObject BUSINESS_LICENCE = updatePhoto(shopMchEntry.getBiz_license_image(), "BUSINESS_LICENCE", false);
|
||||
if (BUSINESS_LICENCE != null) {
|
||||
attachments.put(BUSINESS_LICENCE); // 营业执照
|
||||
}
|
||||
|
||||
} else {
|
||||
JSONObject ID_CARD_FRONT = updatePhoto(shopMchEntry.getIndividual_id_images(), "ID_CARD_FRONT", false);
|
||||
if (ID_CARD_FRONT != null) {
|
||||
@ -534,10 +534,6 @@ public class LklTkServiceImpl {
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject BUSINESS_LICENCE = updatePhoto(shopMchEntry.getBiz_license_image(), "BUSINESS_LICENCE", false);
|
||||
if (BUSINESS_LICENCE != null) {
|
||||
attachments.put(BUSINESS_LICENCE); // 营业执照
|
||||
}
|
||||
|
||||
JSONObject SHOP_OUTSIDE_IMG = updatePhoto(shopMchEntry.getFront_facade_image(), "SHOP_OUTSIDE_IMG", false);
|
||||
if (SHOP_OUTSIDE_IMG != null) {
|
||||
@ -614,7 +610,7 @@ public class LklTkServiceImpl {
|
||||
}
|
||||
|
||||
// 公钥解密出来的数据
|
||||
String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath);
|
||||
String notifyPubKey = LakalaUtil.getResourceFileWithEndSeq(notifyPubKeyPath, false);
|
||||
String data = decryptNotifyData(notifyPubKey, srcData);
|
||||
if (StrUtil.isBlank(data)) {
|
||||
return new JSONObject().set("code", "500").set("message", "密文解密出错!");
|
||||
@ -631,10 +627,10 @@ public class LklTkServiceImpl {
|
||||
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据
|
||||
String merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
|
||||
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo);
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo);
|
||||
if (ObjectUtil.isEmpty(shopMchEntry)) {
|
||||
logger.error("拉卡拉进件异步通知:返回的外部商户号:{} 入驻信息不存在!", merCupNo);
|
||||
return new JSONObject().set("code", "500").set("message", "外部商户号:" + merCupNo + " 入驻信息不存在");
|
||||
logger.error("拉卡拉进件异步通知:返回的内部商户号:{} 入驻信息不存在!", merInnerNo);
|
||||
return new JSONObject().set("code", "500").set("message", "内部商户号:" + merInnerNo + " 入驻信息不存在");
|
||||
}
|
||||
|
||||
Boolean success = shopMchEntryService.updateMerchEntryLklAuditStatusByLklMerCupNo(merInnerNo, merCupNo, CommonConstant.Enable, data);
|
||||
|
||||
@ -52,22 +52,26 @@ public class LakalaUtil {
|
||||
|
||||
/**
|
||||
* 读取证书文件内容
|
||||
* 末尾会有换行符
|
||||
*
|
||||
* @param fileName recource 文件夹下的路径,如:palyKey/wx/lakala_public_key.cer
|
||||
* @return
|
||||
*/
|
||||
public static String getResourceFile(String fileName) {
|
||||
return getResourceFileWithEndSeq(fileName, true);
|
||||
}
|
||||
|
||||
public static String getResourceFileWithEndSeq(String fileName, boolean keepLineBreaks) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
try (InputStream inputStream = new ClassPathResource(fileName).getInputStream();
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
|
||||
BufferedReader bufferedReader = new BufferedReader(inputStreamReader)) {
|
||||
String line;
|
||||
String endSeq = keepLineBreaks ? "\n" : "";
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
stringBuilder.append(line).append("\n");
|
||||
stringBuilder.append(line).append(endSeq);
|
||||
}
|
||||
String content = stringBuilder.toString();
|
||||
// log.info("证书内容:{}", content);
|
||||
return content;
|
||||
return stringBuilder.toString();
|
||||
} catch (IOException e) {
|
||||
// 记录异常信息
|
||||
log.error(e.getMessage());
|
||||
|
||||
@ -117,6 +117,14 @@ public interface ShopMchEntryService {
|
||||
*/
|
||||
ShopMchEntry getShopMerchEntryByMerCupNo(String merCupNo);
|
||||
|
||||
/**
|
||||
* 根据拉卡拉内部商户号获取有效的商家入驻申请记录
|
||||
*
|
||||
* @param merInnerNo
|
||||
* @return
|
||||
*/
|
||||
ShopMchEntry getShopMerchEntryByMerInnerNo(String merInnerNo);
|
||||
|
||||
/**
|
||||
* 根据商家注册的手机号,更新合同签署状态和合同下载地址
|
||||
*
|
||||
|
||||
@ -689,6 +689,22 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
return recordList.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopMchEntry getShopMerchEntryByMerInnerNo(String merInnerNo) {
|
||||
if (StrUtil.isBlank(merInnerNo)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
QueryWrapper<ShopMchEntry> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("lkl_mer_inner_no", merInnerNo).eq("status", CommonConstant.Enable).orderByAsc("id");
|
||||
List<ShopMchEntry> recordList = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(recordList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return recordList.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商家注册的手机号,更新合同签署状态和合同下载地址
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user