From 60e40199001868d98d0e947245b64e5200beb7d2 Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Wed, 28 May 2025 00:10:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E6=9D=A1=E5=BC=82=E6=AD=A5=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=9B=9E=E8=B0=83=E7=9A=84=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/LakalaApiServiceImpl.java | 8 ++-- .../lakala/service/impl/LklTkServiceImpl.java | 41 ++++++++++--------- .../mall/shop/lakala/utils/LakalaUtil.java | 10 ++++- .../impl/ShopStoreBaseServiceImpl.java | 3 +- 4 files changed, 37 insertions(+), 25 deletions(-) diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java index bb10e897..c22dac37 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java @@ -803,7 +803,7 @@ public class LakalaApiServiceImpl implements LakalaApiService { log.debug("商户入网电子合同申请回调通知开始"); // 验签 - Pair checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); + Pair checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false); if (!checkResult.getFirst()) { return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond()); } @@ -1043,7 +1043,7 @@ public class LakalaApiServiceImpl implements LakalaApiService { log.debug("商户分账业务申请异步回调通知开始"); // 验签 - Pair checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); + Pair checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false); if (!checkResult.getFirst()) { return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond()); } @@ -1427,7 +1427,7 @@ public class LakalaApiServiceImpl implements LakalaApiService { try { // 1. 验签操作:验证拉卡拉回调签名是否合法 - Pair checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); + Pair checkResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false); if (!checkResult.getFirst()) { log.warn("验签失败: {}", checkResult.getSecond()); return JSONUtil.createObj().set("code", "FAIL").set("retMsg", checkResult.getSecond()); @@ -1968,7 +1968,7 @@ public class LakalaApiServiceImpl implements LakalaApiService { log.debug("分账结果通知异步回调开始"); // 1. 验签处理 - Pair signCheckResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath); + Pair signCheckResult = LakalaUtil.chkLklApiNotifySign(request, lklNotifyCerPath, false); if (!signCheckResult.getFirst()) { log.warn("分账通知验签失败: {}", signCheckResult.getSecond()); return JSONUtil.createObj() diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java index ba3c3dc0..c4f7e15f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java @@ -627,25 +627,28 @@ public class LklTkServiceImpl { // TODO 新建一个正式的已审核通过的店铺, 新建之前判断是否已经新建过了? // 新建一个正式的已审核通过的店铺,不要抛异常,使用补偿机制,可以独立初始化店铺 ShopMchEntry shopEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo); -// if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) { -// String mchMobile = shopEntry.getLogin_mobile(); -// // 禁止往外抛异常,如果失败使用补偿机制,创建新店 -// Pair retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, false); -// -// if (retPair.getFirst() > 0) { -// // 2025-05-17暂停e签宝电子合同生成流程 -// // 更改合同记录表的店铺id -// // esignContractService.updateContractStoreId(mchMobile, retPair.getFirst()); -// // 填充合同模版表的店铺Id -// // esignContractFillingFileService.updateContractFillingStoreId(mchMobile, retPair.getFirst()); -// // 店铺创建状态已完成 -// shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable); -// logger.info("商家进件:初始化店铺成功!"); -// } else { -// logger.error("商家进件:初始化店铺失败!"); -// // throw new ApiException("商家进件:初始化店铺失败!"); -// } -// } + if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) { + String mchMobile = shopEntry.getLogin_mobile(); + + try { + Pair retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, false); + + if (retPair.getFirst() > 0) { + boolean updateSuccess = shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable); + if (!updateSuccess) { + logger.warn("更新店铺状态失败: mchMobile={}", mchMobile); + } else { + logger.info("商家进件:初始化店铺成功!mchMobile={}", mchMobile); + } + } else { + logger.warn("初始化店铺失败: mchMobile={}, reason={}", mchMobile, retPair.getSecond()); + } + + } catch (Exception e) { + // 捕获所有异常,防止事务中断 + logger.error("初始化店铺时发生异常", e); + } + } // 1、(电子合同)给商家申请分账功能使用;务必检查是否申请过?申请过忽略 // 下一步等待拉卡拉审核通过,再绑定接收方和商家的关系 diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/utils/LakalaUtil.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/utils/LakalaUtil.java index 7956777f..72adda7f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/utils/LakalaUtil.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/utils/LakalaUtil.java @@ -410,9 +410,17 @@ public class LakalaUtil { * * @param request * @param lklNotifyCerPath + * @param passVerifySign 是否通过验签 * @return 验签成功,返回解密后的json字符串,验签失败,返回错误信息 */ - public static Pair chkLklApiNotifySign(HttpServletRequest request, String lklNotifyCerPath) { + public static Pair 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 requestBody = getBody(request); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java index 7767ed28..ac712462 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java @@ -73,6 +73,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -2994,7 +2995,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl merchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown) { if (StrUtil.isBlank(mchMobile)) {