拉卡拉 入网电子合同申请 相关业务逻辑,修改加密方法

This commit is contained in:
Jack 2025-05-16 07:04:34 +08:00
parent 8eb9cf3ce6
commit 98275e1593
7 changed files with 101 additions and 15 deletions

View File

@ -31,7 +31,7 @@ public class RSAUtil {
*/
public static String signSHA256withRSA(String data, String privateKey) {
try {
// 解码私钥
// 解码私钥 并去掉头尾的标识
byte[] keyBytes = Base64.getDecoder().decode(privateKey);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);

View File

@ -198,7 +198,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
return Pair.of(false, "请先审核商家入驻信息");
}
//"{\"docs\":[{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"fileName\":\"平台商户入驻合同协议.pdf\"}],\"signFlowConfig\":{\"signFlowTitle\":\"平台商户入驻合同协议\",\"signFlowExpireTime\":1746844718000,\"autoFinish\":true,\"notifyUrl\":\"https://mall.gpxscs.cn/asyn/notify\",\"redirectConfig\":{\"redirectUrl\":\"https://mall.gpxscs.cn/\"}},\"signers\":[{\"signConfig\":{\"signOrder\":1},\"noticeConfig\":{\"noticeTypes\":\"1\"},\"signerType\":0,\"psnSignerInfo\":{\"psnAccount\":\"13128997057\",\"psnInfo\":{\"psnName\":\"潘军杰\"}},\"signFields\":[{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":40,\"positionX\":472.3607,\"positionY\":277.19104}}},{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":5,\"positionX\":470.58798,\"positionY\":589.14496}}}]},{\"signConfig\":{\"signOrder\":2},\"noticeConfig\":{\"noticeTypes\":\"1\"},\"signerType\":1,\"orgSignerInfo\":{\"orgName\":\"桂平发发网络有限公司\",\"orgInfo\":{\"orgIDCardNum\":\"91450881MADEQ92533\",\"orgIDCardType\":\"CRED_ORG_USCC\"},\"transactorInfo\":{\"psnAccount\":\"17777525395\",\"psnInfo\":{\"psnName\":\"谢能坤\"}}},\"signFields\":[{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":2,\"positionX\":479.04996,\"positionY\":357.2327}}},{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":5,\"positionX\":255.96832,\"positionY\":588.4553}}}]}]}";
//"{\"docs\":[{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"fileName\":\"小发同城平台商户合作协议.pdf\"}],\"signFlowConfig\":{\"signFlowTitle\":\"小发同城平台商户合作协议\",\"signFlowExpireTime\":1746844718000,\"autoFinish\":true,\"notifyUrl\":\"https://mall.gpxscs.cn/asyn/notify\",\"redirectConfig\":{\"redirectUrl\":\"https://mall.gpxscs.cn/\"}},\"signers\":[{\"signConfig\":{\"signOrder\":1},\"noticeConfig\":{\"noticeTypes\":\"1\"},\"signerType\":0,\"psnSignerInfo\":{\"psnAccount\":\"13128997057\",\"psnInfo\":{\"psnName\":\"潘军杰\"}},\"signFields\":[{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":40,\"positionX\":472.3607,\"positionY\":277.19104}}},{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":5,\"positionX\":470.58798,\"positionY\":589.14496}}}]},{\"signConfig\":{\"signOrder\":2},\"noticeConfig\":{\"noticeTypes\":\"1\"},\"signerType\":1,\"orgSignerInfo\":{\"orgName\":\"桂平发发网络有限公司\",\"orgInfo\":{\"orgIDCardNum\":\"91450881MADEQ92533\",\"orgIDCardType\":\"CRED_ORG_USCC\"},\"transactorInfo\":{\"psnAccount\":\"17777525395\",\"psnInfo\":{\"psnName\":\"谢能坤\"}}},\"signFields\":[{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":2,\"positionX\":479.04996,\"positionY\":357.2327}}},{\"fileId\":\"ab30d2c5600441f4a7daf512e4d69157\",\"normalSignFieldConfig\":{\"signFieldStyle\":1,\"signFieldPosition\":{\"positionPage\":5,\"positionX\":255.96832,\"positionY\":588.4553}}}]}]}";
// esignContractService.
String jsonParams = esignContract.getReq_params();

View File

@ -52,7 +52,7 @@ public class LakalaController extends BaseControllerImpl {
@ApiOperation(value = "商户入网电子合同申请回调通知", notes = "商户入网电子合同申请回调通知")
@RequestMapping(value = "/ec/applyNotify", method = RequestMethod.POST)
public JSONObject ecApplyNotify(HttpServletRequest request) {
return lakalaPayService.applyLedgerMerNotify(request);
return lakalaPayService.applyLedgerMerEcNotify(request);
}
@ApiOperation(value = "商户分账业务开通申请", notes = "商户分账业务开通申请")

View File

@ -116,6 +116,15 @@ public interface LakalaApiService {
*/
Pair<Boolean, String> innerApplyLedgerMer(String merCupNo);
/**
* 商户入网电子合同申请回调通知
* 参考https://o.lakala.com/#/home/document/detail?id=289
*
* @param request
* @return
*/
JSONObject applyLedgerMerEcNotify(HttpServletRequest request);
/**
* 商户分账业务开通申请回调
* 参考https://o.lakala.com/#/home/document/detail?id=379

View File

@ -34,9 +34,10 @@ public interface LklLedgerEcService extends IBaseService<LklLedgerEc> {
* 根据接applyId查询记录
*
* @param applyId
* @param status
* @return
*/
LklLedgerEc getByApplyId(Long applyId);
LklLedgerEc getByApplyId(Long applyId, Integer status);
/**

View File

@ -509,13 +509,20 @@ public class LakalaApiServiceImpl implements LakalaApiService {
LocalDate today = LocalDate.now(); // 获取当前日期
String signDate = today.getYear() + "-" + today.getMonthValue() + "-" + today.getDayOfMonth();
String platformName = "桂平发发网络有限公司";
String ratioNum = "0.6";
if (isProd()) {
ratioNum = "0.25";
}
JSONObject ecParams = new JSONObject();
ecParams.put("A1", isQy ? shopMchEntry.getBiz_license_company() : shopMchEntry.getAccount_holder_name());
ecParams.put("A30", "0.6"); // 测试环境微信费率0.6
ecParams.put("A96", "D1");
ecParams.put("A97", "开通");
ecParams.put("A100", "不开通");
ecParams.put("A30", ratioNum); // 测试环境微信费率0.6
ecParams.put("A96", "1");
ecParams.put("A97", "");
ecParams.put("A100", "");
ecParams.put("A101", "中国境内");
ecParams.put("A102", platformName);
ecParams.put("A103", "小发同城");
ecParams.put("A104", today.getYear());
ecParams.put("A105", today.getMonthValue());
ecParams.put("A106", today.getDayOfMonth());
@ -523,11 +530,13 @@ public class LakalaApiServiceImpl implements LakalaApiService {
ecParams.put("A108", today.getMonthValue());
ecParams.put("A109", today.getDayOfMonth());
ecParams.put("B1", today.getYear());
ecParams.put("B3", "");
ecParams.put("B2", today.getMonthValue());
ecParams.put("B8", isQy ? shopMchEntry.getBiz_license_company() : shopMchEntry.getAccount_holder_name());
ecParams.put("B9", shopMchEntry.getSales_info());
ecParams.put("B9", StrUtil.subSufByLength(shopMchEntry.getSales_info(), 22));
ecParams.put("B10", isQy ? shopMchEntry.getBiz_license_company() : shopMchEntry.getAccount_holder_name());
ecParams.put("B14", isQy ? shopMchEntry.getBiz_license_number() : "");
ecParams.put("B16", isQy ? "" : "");
ecParams.put("B19", shopMchEntry.getOpenning_bank_code());
ecParams.put("B20", shopMchEntry.getAccount_number());
ecParams.put("B31", shopMchEntry.getStore_name());
@ -536,16 +545,16 @@ public class LakalaApiServiceImpl implements LakalaApiService {
ecParams.put("B34", shopMchEntry.getLogin_mobile());
ecParams.put("D1", shopMchEntry.getBank_name());
ecParams.put("D2", signDate);
ecParams.put("D4", "桂平发发网络有限公司");
ecParams.put("D4", platformName);
ecParams.put("D7", signDate);
ecParams.put("D9", signDate);
ecParams.put("D11", signDate);
ecParams.put("D12", signDate);
ecParams.put("E1", "桂平发发网络有限公司");
ecParams.put("E2", "商户入驻小发同城平台合同协议");
ecParams.put("E3", "0");
ecParams.put("E1", platformName);
ecParams.put("E2", "小发同城平台商户合作协议");
ecParams.put("E3", "2");
ecParams.put("E4", "70");
ecParams.put("E5", "桂平发发网络有限公司");
ecParams.put("E5", platformName);
ecParams.put("E7", signDate);
ecParams.put("E8", shopMchEntry.getAccount_holder_name());
@ -792,6 +801,69 @@ public class LakalaApiServiceImpl implements LakalaApiService {
}
}
/**
* 商户入网电子合同申请回调通知
* 参考https://o.lakala.com/#/home/document/detail?id=289
*
* @param request
* @return
*/
@Override
public JSONObject applyLedgerMerEcNotify(HttpServletRequest request) {
log.info("商户入网电子合同申请回调通知开始");
// 验签
String authorization = request.getHeader("Authorization");
String requestBody = LakalaUtil.getBody(request);
log.info("商户入网电子合同申请回调返回参数:{}", requestBody);
boolean checkSuccess = LakalaUtil.verify(authorization, requestBody, lklNotifyCerPath);
if (!checkSuccess) {
log.info("商户入网电子合同申请回调:验签失败");
return JSONUtil.createObj().set("retCode", "OP90002").set("retMsg", "验签失败!");
}
JSONObject paramsJSON = JSONUtil.parseObj(requestBody);
JSONObject respData = new JSONObject();
respData.put("retCode", "OP90003");
respData.put("retMsg", "系统处理失败!");
if (paramsJSON != null) {
Long ecApplyId = paramsJSON.getLong("ecApplyId");
String ecNo = paramsJSON.getStr("ecNo");
if (ecApplyId == null || StrUtil.isBlank(ecNo)) {
log.info("商户入网电子合同申请回调ecApplyId 为空");
respData.put("retMsg", "ecApplyId 返回空值!");
return respData;
}
if (lklLedgerEcService.getByApplyId(ecApplyId, CommonConstant.Enable) != null) {
respData.put("retCode", lklSuccessCode);
respData.put("retMsg", "操作成功!");
log.info("商户入网电子合同申请回调:已处理成功,不需再重新处理");
}
// 更改本地分账记录状态数据
LklLedgerEc updRecord = new LklLedgerEc();
updRecord.setEc_apply_id(ecApplyId);
updRecord.setEc_no(ecNo);
updRecord.setEc_name(paramsJSON.getStr("ecName"));
updRecord.setEc_status(paramsJSON.getStr("ecStatus"));
// 更新本地数据状态和合同编号合同名字
Boolean success = lklLedgerEcService.updateByApplyId(updRecord);
if (success) {
respData.put("retCode", lklSuccessCode);
respData.put("retMsg", "操作成功!");
log.info("商户入网电子合同申请回调:处理成功");
// 更新商家入驻表的合同编号合同名称
}
}
return respData;
}
/**
* 商户分账业务开通申请回调
* 参考https://o.lakala.com/#/home/document/detail?id=379

View File

@ -107,13 +107,17 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
* @return
*/
@Override
public LklLedgerEc getByApplyId(Long applyId) {
public LklLedgerEc getByApplyId(Long applyId, Integer status) {
if (ObjectUtil.isEmpty(applyId)) {
return null;
}
QueryWrapper<LklLedgerEc> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("ec_apply_id", applyId);
if (ObjectUtil.isNotEmpty(status)) {
queryWrapper.eq("status", status);
}
return getOne(queryWrapper);
}