细条异步通知回调的流程

This commit is contained in:
Jack 2025-05-28 00:10:32 +08:00
parent 56daec15ea
commit 60e4019900
4 changed files with 37 additions and 25 deletions

View File

@ -803,7 +803,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
log.debug("商户入网电子合同申请回调通知开始"); log.debug("商户入网电子合同申请回调通知开始");
// 验签 // 验签
Pair<Boolean, String> checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); Pair<Boolean, String> checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false);
if (!checkResult.getFirst()) { if (!checkResult.getFirst()) {
return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond()); return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond());
} }
@ -1043,7 +1043,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
log.debug("商户分账业务申请异步回调通知开始"); log.debug("商户分账业务申请异步回调通知开始");
// 验签 // 验签
Pair<Boolean, String> checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); Pair<Boolean, String> checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false);
if (!checkResult.getFirst()) { if (!checkResult.getFirst()) {
return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond()); return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond());
} }
@ -1427,7 +1427,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
try { try {
// 1. 验签操作验证拉卡拉回调签名是否合法 // 1. 验签操作验证拉卡拉回调签名是否合法
Pair<Boolean, String> checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); Pair<Boolean, String> checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false);
if (!checkResult.getFirst()) { if (!checkResult.getFirst()) {
log.warn("验签失败: {}", checkResult.getSecond()); log.warn("验签失败: {}", checkResult.getSecond());
return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond()); return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond());
@ -1968,7 +1968,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
log.debug("分账结果通知异步回调开始"); log.debug("分账结果通知异步回调开始");
// 1. 验签处理 // 1. 验签处理
Pair<Boolean, String> signCheckResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); Pair<Boolean, String> signCheckResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false);
if (!signCheckResult.getFirst()) { if (!signCheckResult.getFirst()) {
log.warn("分账通知验签失败: {}", signCheckResult.getSecond()); log.warn("分账通知验签失败: {}", signCheckResult.getSecond());
return JSONUtil.createObj() return JSONUtil.createObj()

View File

@ -627,25 +627,28 @@ public class LklTkServiceImpl {
// TODO 新建一个正式的已审核通过的店铺 新建之前判断是否已经新建过了 // TODO 新建一个正式的已审核通过的店铺 新建之前判断是否已经新建过了
// 新建一个正式的已审核通过的店铺不要抛异常使用补偿机制可以独立初始化店铺 // 新建一个正式的已审核通过的店铺不要抛异常使用补偿机制可以独立初始化店铺
ShopMchEntry shopEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo); ShopMchEntry shopEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo);
// if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) { if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) {
// String mchMobile = shopEntry.getLogin_mobile(); String mchMobile = shopEntry.getLogin_mobile();
// // 禁止往外抛异常如果失败使用补偿机制创建新店
// Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, false); try {
// Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, false);
// if (retPair.getFirst() > 0) {
// // 2025-05-17暂停e签宝电子合同生成流程 if (retPair.getFirst() > 0) {
// // 更改合同记录表的店铺id boolean updateSuccess = shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable);
// // esignContractService.updateContractStoreId(mchMobile, retPair.getFirst()); if (!updateSuccess) {
// // 填充合同模版表的店铺Id logger.warn("更新店铺状态失败: mchMobile={}", mchMobile);
// // esignContractFillingFileService.updateContractFillingStoreId(mchMobile, retPair.getFirst()); } else {
// // 店铺创建状态已完成 logger.info("商家进件初始化店铺成功mchMobile={}", mchMobile);
// shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable); }
// logger.info("商家进件:初始化店铺成功!"); } else {
// } else { logger.warn("初始化店铺失败: mchMobile={}, reason={}", mchMobile, retPair.getSecond());
// logger.error("商家进件:初始化店铺失败!"); }
// // throw new ApiException("商家进件:初始化店铺失败!");
// } } catch (Exception e) {
// } // 捕获所有异常防止事务中断
logger.error("初始化店铺时发生异常", e);
}
}
// 1电子合同给商家申请分账功能使用务必检查是否申请过申请过忽略 // 1电子合同给商家申请分账功能使用务必检查是否申请过申请过忽略
// 下一步等待拉卡拉审核通过再绑定接收方和商家的关系 // 下一步等待拉卡拉审核通过再绑定接收方和商家的关系

View File

@ -410,9 +410,17 @@ public class LakalaUtil {
* *
* @param request * @param request
* @param lklNotifyCerPath * @param lklNotifyCerPath
* @param passVerifySign 是否通过验签
* @return 验签成功返回解密后的json字符串验签失败返回错误信息 * @return 验签成功返回解密后的json字符串验签失败返回错误信息
*/ */
public static Pair<Boolean, String> chkLklApiNotifySign(HttpServletRequest request, String lklNotifyCerPath) { public static Pair<Boolean, String> chkLklApiNotifySign(HttpServletRequest request, String lklNotifyCerPath, Boolean passVerifySign) {
if (passVerifySign) {
// 如果不需要验签直接返回请求体内容
String requestBody = getBody(request);
log.debug("{} 回调通知 requestbody 参数:{}", request.getRequestURL(), requestBody);
return Pair.of(true, requestBody);
}
// 验签 // 验签
String authorization = request.getHeader("Authorization"); String authorization = request.getHeader("Authorization");
String requestBody = getBody(request); String requestBody = getBody(request);

View File

@ -73,6 +73,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.data.util.Pair; import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
@ -2994,7 +2995,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
* @param allowThrown 是否允许抛出异常 * @param allowThrown 是否允许抛出异常
* @return 店铺Id * @return 店铺Id
*/ */
@Transactional @Transactional(propagation = Propagation.REQUIRES_NEW)
@Override @Override
public Pair<Integer, String> merchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown) { public Pair<Integer, String> merchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown) {
if (StrUtil.isBlank(mchMobile)) { if (StrUtil.isBlank(mchMobile)) {