分店逻辑增加,逻辑编写,拉卡拉增终,收到通知,创建分店,分店周边信息、账号、入驻信息等2
This commit is contained in:
parent
2ff93df44b
commit
f8ca35d20c
@ -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);
|
Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -141,6 +141,9 @@ public class ShopStoreBase implements Serializable {
|
|||||||
@ApiModelProperty(value = "店铺统一的打包费, 0-10元范围")
|
@ApiModelProperty(value = "店铺统一的打包费, 0-10元范围")
|
||||||
private BigDecimal packing_fee;
|
private BigDecimal packing_fee;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分店所属总店 Id,一般分店有值,总店为0")
|
||||||
|
private Integer parent_id;
|
||||||
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
@ApiModelProperty(value = "新增时间")
|
@ApiModelProperty(value = "新增时间")
|
||||||
|
|||||||
@ -788,50 +788,38 @@ public class LklTkServiceImpl {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public JSONObject updateMerchantNotify(HttpServletRequest request) {
|
public JSONObject updateMerchantNotify(HttpServletRequest request) {
|
||||||
logger.info("开始处理拉卡拉增终异步通知");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 解密请求参数
|
// 解密请求参数
|
||||||
String requestBody = LakalaUtil.getBody(request);
|
String requestBody = LakalaUtil.getBody(request);
|
||||||
logger.debug("拉卡拉增终异步通知原始参数:{}", requestBody);
|
|
||||||
|
|
||||||
if (StrUtil.isBlank(requestBody)) {
|
if (StrUtil.isBlank(requestBody)) {
|
||||||
logger.warn("拉卡拉增终异步通知参数为空");
|
|
||||||
return new JSONObject().set("code", "400").set("message", "返回参数为空");
|
return new JSONObject().set("code", "400").set("message", "返回参数为空");
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody);
|
JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody);
|
||||||
if (reqBodyJSON.isEmpty() || reqBodyJSON.get("data") == null) {
|
if (reqBodyJSON.isEmpty() || reqBodyJSON.get("data") == null) {
|
||||||
logger.warn("拉卡拉增终异步通知参数格式有误,无法解析: {}", requestBody);
|
|
||||||
return new JSONObject().set("code", "400").set("message", "参数格式有误,无法解析");
|
return new JSONObject().set("code", "400").set("message", "参数格式有误,无法解析");
|
||||||
}
|
}
|
||||||
|
|
||||||
String srcData = reqBodyJSON.getStr("data");
|
String srcData = reqBodyJSON.getStr("data");
|
||||||
if (StrUtil.isBlank(srcData)) {
|
if (StrUtil.isBlank(srcData)) {
|
||||||
logger.warn("拉卡拉增终异步通知关键参数为空值");
|
|
||||||
return new JSONObject().set("code", "400").set("message", "关键参数为空值");
|
return new JSONObject().set("code", "400").set("message", "关键参数为空值");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 公钥解密出来的数据
|
// 公钥解密出来的数据
|
||||||
logger.debug("开始解密拉卡拉通知数据");
|
|
||||||
String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath, false, false);
|
String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath, false, false);
|
||||||
String data = LakalaUtil.decryptNotifyData(notifyPubKey, srcData);
|
String lklNotifyResp = LakalaUtil.decryptNotifyData(notifyPubKey, srcData);
|
||||||
if (StrUtil.isBlank(data)) {
|
if (StrUtil.isBlank(lklNotifyResp)) {
|
||||||
logger.error("拉卡拉增终异步通知数据解密失败");
|
|
||||||
return new JSONObject().set("code", "400").set("message", "数据解密出错!");
|
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 reviewPass = dataJSON.getStr("reviewPass");
|
||||||
String merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
|
String merCupNo = dataJSON.getStr("externalCustomerNo"); //拉卡拉外部商户号
|
||||||
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
|
String merInnerNo = dataJSON.getStr("customerNo"); //拉卡拉内部商户号
|
||||||
String termNo = dataJSON.getStr("termNo"); //拉卡拉分配的业务终端号
|
String termNo = dataJSON.getStr("termNo"); //拉卡拉分配的业务终端号
|
||||||
String reviewRelatedId = dataJSON.getStr("reviewRelatedId"); //拉卡拉分配的业务终端号
|
String reviewRelatedId = dataJSON.getStr("reviewRelatedId"); //拉卡拉分配的业务终端号
|
||||||
logger.debug("解析通知数据完成 - 审核状态: {},外部商户号: {},内部商户号: {},终端号: {}",
|
|
||||||
reviewPass, merCupNo, merInnerNo, termNo);
|
|
||||||
|
|
||||||
// 合并参数校验
|
// 合并参数校验
|
||||||
if (dataJSON.isEmpty() ||
|
if (dataJSON.isEmpty() ||
|
||||||
@ -839,36 +827,24 @@ public class LklTkServiceImpl {
|
|||||||
StrUtil.isBlank(merCupNo) ||
|
StrUtil.isBlank(merCupNo) ||
|
||||||
StrUtil.isBlank(reviewRelatedId) ||
|
StrUtil.isBlank(reviewRelatedId) ||
|
||||||
StrUtil.isBlank(termNo)) {
|
StrUtil.isBlank(termNo)) {
|
||||||
logger.warn("拉卡拉改进异步通知参数解析出错,数据: {}", data);
|
|
||||||
return new JSONObject().set("code", "500").set("message", "参数解析出错");
|
return new JSONObject().set("code", "500").set("message", "参数解析出错");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据
|
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据
|
||||||
logger.debug("开始查询商户入驻信息,内部商户号: {}", merInnerNo);
|
|
||||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo);
|
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo);
|
||||||
if (shopMchEntry == null) {
|
if (shopMchEntry == null) {
|
||||||
logger.error("拉卡拉增终异步通知:{}内部商户号入驻信息不存在!", merInnerNo);
|
|
||||||
return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在");
|
return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
Long mchId = shopMchEntry.getId();
|
|
||||||
logger.info("找到商户入驻信息,商户ID: {}", mchId);
|
|
||||||
|
|
||||||
// 校验审核状态: PREPARE:待提交; PASS:通过; UNPASS:未通过; PASSING:审核中;
|
// 校验审核状态: PREPARE:待提交; PASS:通过; UNPASS:未通过; PASSING:审核中;
|
||||||
logger.debug("校验审核状态: {}", reviewPass);
|
|
||||||
if (!"PASS".equals(reviewPass)) {
|
if (!"PASS".equals(reviewPass)) {
|
||||||
String reviewResult = dataJSON.getStr("reviewResult");
|
String reviewResult = dataJSON.getStr("reviewResult");
|
||||||
logger.warn("拉卡拉增终审核未通过,审核状态: {},备注: {}", reviewPass, reviewResult);
|
return new JSONObject().set("code", "FAIL").set("message", "审核未通过:" + reviewResult);
|
||||||
shopMchEntryService.updateMerchEntryApprovalByMchId(mchId, CommonConstant.MCH_APPR_STA_LKL_NOPASS, "增终失败:" + reviewResult);
|
|
||||||
return new JSONObject().set("code", "FAIL").set("message", "返回审核状态有误");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("拉卡拉增终审核通过,商户ID: {},开始更新商户信息", mchId);
|
|
||||||
|
|
||||||
// RMK 拉卡拉增终成功, 创建分店入驻记录,创建商家账号、创建店铺和周边信息
|
// RMK 拉卡拉增终成功, 创建分店入驻记录,创建商家账号、创建店铺和周边信息
|
||||||
shopMchEntryBranchService.createMchEntryBranchStore(reviewRelatedId, termNo, data);
|
shopMchEntryBranchService.createMchEntryBranchStore(reviewRelatedId, termNo, lklNotifyResp);
|
||||||
|
|
||||||
logger.info("拉卡拉进件异步通知处理完成,商户ID: {}", mchId);
|
|
||||||
return new JSONObject().set("code", "200").set("message", "处理成功");
|
return new JSONObject().set("code", "200").set("message", "处理成功");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -877,6 +853,7 @@ public class LklTkServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public JSONObject openMerchantAddTerm(String externalCustomerNo) {
|
public JSONObject openMerchantAddTerm(String externalCustomerNo) {
|
||||||
logger.debug("开始获取拉卡拉商户信息,externalCustomerNo={}", externalCustomerNo);
|
logger.debug("开始获取拉卡拉商户信息,externalCustomerNo={}", externalCustomerNo);
|
||||||
|
|
||||||
|
|||||||
@ -166,6 +166,17 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
|
|||||||
*/
|
*/
|
||||||
Pair<Integer, String> covMerchEntryInfo2StoreInfo(Long mchId, Boolean allowThrown);
|
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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据店铺名称判断店铺是否存在
|
* 根据店铺名称判断店铺是否存在
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.suisung.mall.shop.store.service.impl;
|
package com.suisung.mall.shop.store.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.StrUtil;
|
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;
|
||||||
@ -288,13 +289,16 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
|||||||
throw new ApiException("解析分店入驻请求数据失败");
|
throw new ApiException("解析分店入驻请求数据失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 获取主店入驻信息
|
// 5. 获取总店入驻信息
|
||||||
ShopMchEntry parentShopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(shopMchEntryBranch.getLkl_mer_cup_no());
|
ShopMchEntry parentShopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(shopMchEntryBranch.getLkl_mer_cup_no());
|
||||||
if (parentShopMchEntry == null) {
|
if (parentShopMchEntry == null) {
|
||||||
log.error("主店入驻信息不存在,拉卡拉商户号: {}", shopMchEntryBranch.getLkl_mer_cup_no());
|
log.error("总店入驻信息不存在,拉卡拉商户号: {}", shopMchEntryBranch.getLkl_mer_cup_no());
|
||||||
throw new ApiException("主店入驻信息不存在");
|
throw new ApiException("主店入驻信息不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 总店店铺 Id
|
||||||
|
Integer parentStoreId = Convert.toInt(parentShopMchEntry.getStore_id(), 0);
|
||||||
|
|
||||||
// 6. 构建分店入驻信息
|
// 6. 构建分店入驻信息
|
||||||
ShopMchEntry shopMchEntry = new ShopMchEntry();
|
ShopMchEntry shopMchEntry = new ShopMchEntry();
|
||||||
// 拷贝主店基础信息
|
// 拷贝主店基础信息
|
||||||
@ -302,7 +306,7 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
|||||||
// 设置分店特有信息
|
// 设置分店特有信息
|
||||||
shopMchEntry.setLkl_term_no(termNo);
|
shopMchEntry.setLkl_term_no(termNo);
|
||||||
shopMchEntry.setLogin_mobile(mainStoreBranchReq.getLogin_mobile());
|
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.setStore_name(mainStoreBranchReq.getStore_name());
|
||||||
shopMchEntry.setContact_name(mainStoreBranchReq.getContact_name());
|
shopMchEntry.setContact_name(mainStoreBranchReq.getContact_name());
|
||||||
|
|
||||||
@ -340,7 +344,7 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
|||||||
log.debug("分店商户注册账号成功,手机号: {}", mainStoreBranchReq.getLogin_mobile());
|
log.debug("分店商户注册账号成功,手机号: {}", mainStoreBranchReq.getLogin_mobile());
|
||||||
|
|
||||||
// 9. 创建分店店铺信息,创建分店店铺周边信息(公司、员工、权限等)
|
// 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) {
|
if (storeResult == null || storeResult.getFirst() <= 0) {
|
||||||
log.error("创建分店店铺信息失败,分店入驻ID: {},错误信息: {}", shopMchEntry.getId(),
|
log.error("创建分店店铺信息失败,分店入驻ID: {},错误信息: {}", shopMchEntry.getId(),
|
||||||
storeResult != null ? storeResult.getSecond() : "返回结果为空");
|
storeResult != null ? storeResult.getSecond() : "返回结果为空");
|
||||||
|
|||||||
@ -1325,7 +1325,10 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<ShopMchEntry> queryWrapper = new LambdaQueryWrapper<>();
|
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);
|
ShopMchEntry record = findOne(queryWrapper);
|
||||||
if (ObjectUtil.isEmpty(record)) {
|
if (ObjectUtil.isEmpty(record)) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -3251,6 +3251,11 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<Integer, String> covMerchEntryInfo2StoreInfo(Long mchId, Boolean allowThrown) {
|
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)) {
|
if (ObjectUtil.isEmpty(mchId)) {
|
||||||
logger.error("生成店铺:入驻商家自增Id不能为空");
|
logger.error("生成店铺:入驻商家自增Id不能为空");
|
||||||
@ -3299,6 +3304,12 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
shopStoreBase.setUser_id(userId);
|
shopStoreBase.setUser_id(userId);
|
||||||
shopStoreBase.setStore_name(shopMchEntry.getStore_name());
|
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())) {
|
if (CheckUtil.isEmpty(shopStoreBase.getStore_category_id())) {
|
||||||
shopStoreBase.setStore_category_id(shopMchEntry.getBiz_category());
|
shopStoreBase.setStore_category_id(shopMchEntry.getBiz_category());
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
store_biz_state, store_biz_opening_date, ringtone_is_enable, shop_parent_id, store_2nd_category_id,
|
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_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,
|
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>
|
</sql>
|
||||||
|
|
||||||
<select id="statisticState" resultType="java.util.Map">
|
<select id="statisticState" resultType="java.util.Map">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user