分店异步通知增加关键日志

This commit is contained in:
Jack 2025-12-27 00:04:51 +08:00
parent 50872500b3
commit 3e3a8a32a3
4 changed files with 137 additions and 4 deletions

View File

@ -789,8 +789,10 @@ public class LklTkServiceImpl {
*/ */
public JSONObject updateMerchantNotify(HttpServletRequest request) { public JSONObject updateMerchantNotify(HttpServletRequest request) {
try { try {
logger.info("开始处理拉卡拉商户增终异步通知");
// 解密请求参数 // 解密请求参数
String requestBody = LakalaUtil.getBody(request); String requestBody = LakalaUtil.getBody(request);
logger.info("拉卡拉商户增终异步通知返回加密数据:{}", requestBody);
if (StrUtil.isBlank(requestBody)) { if (StrUtil.isBlank(requestBody)) {
return new JSONObject().set("code", "400").set("message", "返回参数为空"); return new JSONObject().set("code", "400").set("message", "返回参数为空");
@ -812,6 +814,7 @@ public class LklTkServiceImpl {
if (StrUtil.isBlank(lklNotifyResp)) { if (StrUtil.isBlank(lklNotifyResp)) {
return new JSONObject().set("code", "400").set("message", "数据解密出错!"); return new JSONObject().set("code", "400").set("message", "数据解密出错!");
} }
logger.info("拉卡拉商户增终异步通知返回明文数据:{}", lklNotifyResp);
// 逻辑处理 // 逻辑处理
JSONObject dataJSON = JSONUtil.parseObj(lklNotifyResp); JSONObject dataJSON = JSONUtil.parseObj(lklNotifyResp);
@ -827,10 +830,32 @@ public class LklTkServiceImpl {
StrUtil.isBlank(merCupNo) || StrUtil.isBlank(merCupNo) ||
StrUtil.isBlank(reviewRelatedId) || StrUtil.isBlank(reviewRelatedId) ||
StrUtil.isBlank(termNo)) { StrUtil.isBlank(termNo)) {
return new JSONObject().set("code", "500").set("message", "参数解析出错"); return new JSONObject().set("code", "500").set("message", "返回参数缺少关键数据");
} }
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据 // 更新商户分店入驻表
// status 状态1-已成功2-审核未通过3-未处理4-待审核
Integer status = 4;
switch (reviewPass) {
case "PASS":
status = CommonConstant.Enable;
break;
case "UNPASS":
status = CommonConstant.Disable2;
break;
case "PASSING":
status = 3;
break;
case "PREPARE":
status = 4;
break;
default:
status = 4;
}
shopMchEntryBranchService.updateByReviewRelatedId(reviewRelatedId, status, lklNotifyResp);
// 给商家总店入驻表增加拉卡拉的商户号和拉卡拉返回的数据
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo); ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo);
if (shopMchEntry == null) { if (shopMchEntry == null) {
return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在"); return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在");

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
* Vestibulum commodo. Ut rhoncus gravida arcu.
*/
package com.suisung.mall.shop.store.controller.admin;
import cn.hutool.json.JSONObject;
import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.pojo.dto.MainStoreBranchReqDTO;
import com.suisung.mall.common.service.impl.BaseControllerImpl;
import com.suisung.mall.shop.store.service.ShopMchEntryBranchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.util.Pair;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@Slf4j
@Api(tags = "商家入驻业务控制器")
@RestController
@RequestMapping("/admin/shop/merch/branch")
public class ShopMchEntryBranchAdminController extends BaseControllerImpl {
@Resource
private ShopMchEntryBranchService shopMchEntryBranchService;
/**
* 商家申请入驻商城平台
*
* @param mainStoreBranchReqJSON
* @return
*/
@ApiOperation(value = "后台-申请总店的分店", notes = "向拉卡拉申请总店的分店")
@RequestMapping(value = "/apply/store", method = RequestMethod.POST)
public CommonResult shopMerchEntryList(@RequestBody JSONObject mainStoreBranchReqJSON) {
MainStoreBranchReqDTO mainStoreBranchReq = mainStoreBranchReqJSON.toBean(MainStoreBranchReqDTO.class);
Pair<Boolean, String> result = shopMchEntryBranchService.applyMchEntryBranchStore(mainStoreBranchReq);
if (result.getFirst()) {
return CommonResult.success();
}
return CommonResult.failed(result.getSecond());
}
}

View File

@ -22,6 +22,17 @@ public interface ShopMchEntryBranchService {
*/ */
Boolean saveShopMchEntryBranch(ShopMchEntryBranch shopMchEntryBranch); Boolean saveShopMchEntryBranch(ShopMchEntryBranch shopMchEntryBranch);
/**
* 更新商户终端入驻申请信息
*
* @param reviewRelatedId 商户终端入驻申请ID
* @param status 商户终端入驻申请状态
* @param notifyResp 商户终端入驻申请通知响应数据
* @return 更新结果
*/
Boolean updateByReviewRelatedId(String reviewRelatedId, Integer status, String notifyResp);
/** /**
* 根据商户终端入驻申请ID查询商户终端入驻申请信息 * 根据商户终端入驻申请ID查询商户终端入驻申请信息
* *

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.suisung.mall.common.constant.CommonConstant; import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.exception.ApiException; import com.suisung.mall.common.exception.ApiException;
import com.suisung.mall.common.feignService.AccountService; import com.suisung.mall.common.feignService.AccountService;
@ -28,6 +29,7 @@ import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Objects; import java.util.Objects;
@Slf4j @Slf4j
@ -101,6 +103,45 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
} }
} }
@Override
public Boolean updateByReviewRelatedId(String reviewRelatedId, Integer status, String notifyResp) {
try {
// 参数校验
if (StrUtil.isBlank(reviewRelatedId)) {
log.warn("审核关联号不能为空,无法执行更新操作");
return false;
}
LambdaUpdateWrapper<ShopMchEntryBranch> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(ShopMchEntryBranch::getReview_related_id, reviewRelatedId).set(ShopMchEntryBranch::getUpdated_at, new Date());
// 只有当状态值有效时才更新状态字段
if (CheckUtil.isNotEmpty(status)) {
updateWrapper.set(ShopMchEntryBranch::getStatus, status);
log.debug("更新状态字段为: {}", status);
}
// 更新通知响应内容
if (StrUtil.isNotBlank(notifyResp)) { // 允许空字符串但不能为null
updateWrapper.set(ShopMchEntryBranch::getLkl_notify_reps, notifyResp);
}
boolean result = update(updateWrapper);
if (result) {
log.info("成功更新分店入驻申请记录,审核关联号: {}", reviewRelatedId);
} else {
log.warn("更新分店入驻申请记录失败,审核关联号: {}", reviewRelatedId);
}
return result;
} catch (Exception e) {
log.error("更新分店入驻申请记录时发生异常,审核关联号: {}", reviewRelatedId, e);
return false;
}
}
/** /**
* 根据商户终端入驻申请ID查询商户终端入驻申请信息 * 根据商户终端入驻申请ID查询商户终端入驻申请信息
* *
@ -159,8 +200,8 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
log.debug("检查主店信息是否存在主店ID: {}", mainStoreBranchReq.getParent_store_id()); log.debug("检查主店信息是否存在主店ID: {}", mainStoreBranchReq.getParent_store_id());
LambdaQueryWrapper<ShopMchEntry> entryQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<ShopMchEntry> entryQueryWrapper = new LambdaQueryWrapper<>();
entryQueryWrapper.eq(ShopMchEntry::getStore_id, mainStoreBranchReq.getParent_store_id()) entryQueryWrapper.eq(ShopMchEntry::getStore_id, mainStoreBranchReq.getParent_store_id())
.eq(ShopMchEntry::getApproval_status, CommonConstant.Enable) .eq(ShopMchEntry::getApproval_status, CommonConstant.MCH_APPR_STA_PASS)
.eq(ShopMchEntry::getParent_id, 0L); .eq(ShopMchEntry::getParent_id, 0L); // 总店记录
ShopMchEntry mchEntry = shopMchEntryService.findOneByLambdaQueryWrapper(entryQueryWrapper); ShopMchEntry mchEntry = shopMchEntryService.findOneByLambdaQueryWrapper(entryQueryWrapper);
if (mchEntry == null) { if (mchEntry == null) {