分店逻辑增加,逻辑编写,拉卡拉增终,收到通知,创建分店,分店周边信息、账号、入驻信息等2

This commit is contained in:
Jack 2025-12-26 00:07:27 +08:00
parent 2ff93df44b
commit f8ca35d20c
8 changed files with 45 additions and 36 deletions

View File

@ -319,6 +319,6 @@ public interface AccountService {
/**
* 服务间注册商家账号项目之间远程调用
*/
@RequestMapping(value = "/merchant/inner-register", method = RequestMethod.POST)
@RequestMapping(value = "/admin/account/account-user-base/merchant/inner-register", method = RequestMethod.POST)
Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile);
}

View File

@ -141,6 +141,9 @@ public class ShopStoreBase implements Serializable {
@ApiModelProperty(value = "店铺统一的打包费, 0-10元范围")
private BigDecimal packing_fee;
@ApiModelProperty(value = "分店所属总店 Id一般分店有值总店为0")
private Integer parent_id;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "新增时间")

View File

@ -788,50 +788,38 @@ public class LklTkServiceImpl {
* @return
*/
public JSONObject updateMerchantNotify(HttpServletRequest request) {
logger.info("开始处理拉卡拉增终异步通知");
try {
// 解密请求参数
String requestBody = LakalaUtil.getBody(request);
logger.debug("拉卡拉增终异步通知原始参数:{}", requestBody);
if (StrUtil.isBlank(requestBody)) {
logger.warn("拉卡拉增终异步通知参数为空");
return new JSONObject().set("code", "400").set("message", "返回参数为空");
}
JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody);
if (reqBodyJSON.isEmpty() || reqBodyJSON.get("data") == null) {
logger.warn("拉卡拉增终异步通知参数格式有误,无法解析: {}", requestBody);
return new JSONObject().set("code", "400").set("message", "参数格式有误,无法解析");
}
String srcData = reqBodyJSON.getStr("data");
if (StrUtil.isBlank(srcData)) {
logger.warn("拉卡拉增终异步通知关键参数为空值");
return new JSONObject().set("code", "400").set("message", "关键参数为空值");
}
// 公钥解密出来的数据
logger.debug("开始解密拉卡拉通知数据");
String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath, false, false);
String data = LakalaUtil.decryptNotifyData(notifyPubKey, srcData);
if (StrUtil.isBlank(data)) {
logger.error("拉卡拉增终异步通知数据解密失败");
String lklNotifyResp = LakalaUtil.decryptNotifyData(notifyPubKey, srcData);
if (StrUtil.isBlank(lklNotifyResp)) {
return new JSONObject().set("code", "400").set("message", "数据解密出错!");
}
logger.info("拉卡拉进件异步通知数据解密成功,开始处理业务逻辑");
// 逻辑处理
JSONObject dataJSON = JSONUtil.parseObj(data);
JSONObject dataJSON = JSONUtil.parseObj(lklNotifyResp);
String reviewPass = dataJSON.getStr("reviewPass");
String merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
String termNo = dataJSON.getStr("termNo"); //拉卡拉分配的业务终端号
String reviewRelatedId = dataJSON.getStr("reviewRelatedId"); //拉卡拉分配的业务终端号
logger.debug("解析通知数据完成 - 审核状态: {},外部商户号: {},内部商户号: {},终端号: {}",
reviewPass, merCupNo, merInnerNo, termNo);
// 合并参数校验
if (dataJSON.isEmpty() ||
@ -839,36 +827,24 @@ public class LklTkServiceImpl {
StrUtil.isBlank(merCupNo) ||
StrUtil.isBlank(reviewRelatedId) ||
StrUtil.isBlank(termNo)) {
logger.warn("拉卡拉改进异步通知参数解析出错,数据: {}", data);
return new JSONObject().set("code", "500").set("message", "参数解析出错");
}
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据
logger.debug("开始查询商户入驻信息,内部商户号: {}", merInnerNo);
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo);
if (shopMchEntry == null) {
logger.error("拉卡拉增终异步通知:{}内部商户号入驻信息不存在!", merInnerNo);
return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在");
}
Long mchId = shopMchEntry.getId();
logger.info("找到商户入驻信息商户ID: {}", mchId);
// 校验审核状态: PREPARE:待提交; PASS:通过; UNPASS:未通过; PASSING:审核中;
logger.debug("校验审核状态: {}", reviewPass);
if (!"PASS".equals(reviewPass)) {
String reviewResult = dataJSON.getStr("reviewResult");
logger.warn("拉卡拉增终审核未通过,审核状态: {},备注: {}", reviewPass, reviewResult);
shopMchEntryService.updateMerchEntryApprovalByMchId(mchId, CommonConstant.MCH_APPR_STA_LKL_NOPASS, "增终失败:" + reviewResult);
return new JSONObject().set("code", "FAIL").set("message", "返回审核状态有误");
return new JSONObject().set("code", "FAIL").set("message", "审核未通过:" + reviewResult);
}
logger.info("拉卡拉增终审核通过商户ID: {},开始更新商户信息", mchId);
// RMK 拉卡拉增终成功, 创建分店入驻记录创建商家账号创建店铺和周边信息
shopMchEntryBranchService.createMchEntryBranchStore(reviewRelatedId, termNo, data);
shopMchEntryBranchService.createMchEntryBranchStore(reviewRelatedId, termNo, lklNotifyResp);
logger.info("拉卡拉进件异步通知处理完成商户ID: {}", mchId);
return new JSONObject().set("code", "200").set("message", "处理成功");
} catch (Exception e) {
@ -877,6 +853,7 @@ public class LklTkServiceImpl {
}
}
public JSONObject openMerchantAddTerm(String externalCustomerNo) {
logger.debug("开始获取拉卡拉商户信息externalCustomerNo={}", externalCustomerNo);

View File

@ -166,6 +166,17 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
*/
Pair<Integer, String> covMerchEntryInfo2StoreInfo(Long mchId, Boolean allowThrown);
/**
* (重要入驻审批通过并且合同盖章完结之后把商家入驻信息转换成店铺信息正式生成店铺所需的数据
*
* @param mchId 入驻编号
* @param parentStoreId 总店店铺Id
* @param allowThrown 是否允许抛出异常
* @return
*/
Pair<Integer, String> covMerchEntryInfo2StoreInfo(Long mchId, Integer parentStoreId, Boolean allowThrown);
/**
* 根据店铺名称判断店铺是否存在
*

View File

@ -1,5 +1,6 @@
package com.suisung.mall.shop.store.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
@ -288,13 +289,16 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
throw new ApiException("解析分店入驻请求数据失败");
}
// 5. 获取店入驻信息
// 5. 获取店入驻信息
ShopMchEntry parentShopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(shopMchEntryBranch.getLkl_mer_cup_no());
if (parentShopMchEntry == null) {
log.error("店入驻信息不存在,拉卡拉商户号: {}", shopMchEntryBranch.getLkl_mer_cup_no());
log.error("店入驻信息不存在,拉卡拉商户号: {}", shopMchEntryBranch.getLkl_mer_cup_no());
throw new ApiException("主店入驻信息不存在");
}
// 总店店铺 Id
Integer parentStoreId = Convert.toInt(parentShopMchEntry.getStore_id(), 0);
// 6. 构建分店入驻信息
ShopMchEntry shopMchEntry = new ShopMchEntry();
// 拷贝主店基础信息
@ -302,7 +306,7 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
// 设置分店特有信息
shopMchEntry.setLkl_term_no(termNo);
shopMchEntry.setLogin_mobile(mainStoreBranchReq.getLogin_mobile());
shopMchEntry.setParent_id(parentShopMchEntry.getId()); // 设置主店ID为父ID
shopMchEntry.setParent_id(parentShopMchEntry.getId()); // 设置主店入驻ID为父ID
shopMchEntry.setStore_name(mainStoreBranchReq.getStore_name());
shopMchEntry.setContact_name(mainStoreBranchReq.getContact_name());
@ -340,7 +344,7 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
log.debug("分店商户注册账号成功,手机号: {}", mainStoreBranchReq.getLogin_mobile());
// 9. 创建分店店铺信息创建分店店铺周边信息公司员工权限等
Pair<Integer, String> storeResult = shopStoreBaseService.covMerchEntryInfo2StoreInfo(shopMchEntry.getId(), true);
Pair<Integer, String> storeResult = shopStoreBaseService.covMerchEntryInfo2StoreInfo(shopMchEntry.getId(), parentStoreId, true);
if (storeResult == null || storeResult.getFirst() <= 0) {
log.error("创建分店店铺信息失败分店入驻ID: {},错误信息: {}", shopMchEntry.getId(),
storeResult != null ? storeResult.getSecond() : "返回结果为空");

View File

@ -1325,7 +1325,10 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
}
LambdaQueryWrapper<ShopMchEntry> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ShopMchEntry::getLkl_mer_cup_no, merCupNo).eq(ShopMchEntry::getStatus, CommonConstant.Enable).orderByAsc(ShopMchEntry::getId);
queryWrapper.eq(ShopMchEntry::getLkl_mer_cup_no, merCupNo)
.eq(ShopMchEntry::getParent_id, 0L) // 总店
.eq(ShopMchEntry::getStatus, CommonConstant.Enable)
.orderByAsc(ShopMchEntry::getId);
ShopMchEntry record = findOne(queryWrapper);
if (ObjectUtil.isEmpty(record)) {
return null;

View File

@ -3251,6 +3251,11 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
@Override
public Pair<Integer, String> covMerchEntryInfo2StoreInfo(Long mchId, Boolean allowThrown) {
return covMerchEntryInfo2StoreInfo(mchId, 0, allowThrown);
}
@Override
public Pair<Integer, String> covMerchEntryInfo2StoreInfo(Long mchId, Integer parentStoreId, Boolean allowThrown) {
// 参数校验
if (ObjectUtil.isEmpty(mchId)) {
logger.error("生成店铺入驻商家自增Id不能为空");
@ -3299,6 +3304,12 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
shopStoreBase.setUser_id(userId);
shopStoreBase.setStore_name(shopMchEntry.getStore_name());
if (CheckUtil.isNotEmpty(parentStoreId)) {
shopStoreBase.setParent_id(parentStoreId);
} else {
shopStoreBase.setParent_id(0);
}
// 店铺二级分类
if (CheckUtil.isEmpty(shopStoreBase.getStore_category_id())) {
shopStoreBase.setStore_category_id(shopMchEntry.getBiz_category());

View File

@ -9,7 +9,7 @@
store_biz_state, store_biz_opening_date, ringtone_is_enable, shop_parent_id, store_2nd_category_id,
store_category_id, store_state_id, store_time, store_end_time, product_category_ids, store_o2o_tags,
store_o2o_flag, store_o2o_merchant_id, store_circle, subsite_id, lkl_merchant_no, lkl_term_no, wx_qrcode,
split_ratio, packing_fee, created_at, updated_at
split_ratio, packing_fee,parent_id,created_at, updated_at
</sql>
<select id="statisticState" resultType="java.util.Map">