分店注册,增加账号密码参数
This commit is contained in:
parent
d9d9efd233
commit
7f0d3e9897
@ -233,10 +233,10 @@ public class AccountUserBaseController extends BaseControllerImpl {
|
||||
return CommonResult.success(accountUserBaseService.logout());
|
||||
}
|
||||
|
||||
@ApiOperation("服务间注册商家账号,项目之间远程调用")
|
||||
@ApiOperation("注册商家账号,项目之间远程调用")
|
||||
@RequestMapping(value = "/merchant/inner-register", method = RequestMethod.POST)
|
||||
public Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile) {
|
||||
return accountUserBaseService.merchantInnerRegister(mobile);
|
||||
public Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile, @Param("regPwd") String regPwd) {
|
||||
return accountUserBaseService.merchantInnerRegister(mobile, regPwd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -302,9 +302,10 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
* 商家内部注册(服务之间调用)
|
||||
*
|
||||
* @param mobile 商家手机号
|
||||
* @param regPwd 注册密码
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示提示信息
|
||||
*/
|
||||
Pair<Boolean, String> merchantInnerRegister(String mobile);
|
||||
Pair<Boolean, String> merchantInnerRegister(String mobile, String regPwd);
|
||||
|
||||
/**
|
||||
* 批量保存accountInfo
|
||||
|
||||
@ -1715,8 +1715,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
|
||||
|
||||
// 有手机参数,优先手机注册
|
||||
// if ((StrUtil.isNotBlank(user_mobile))
|
||||
// || (CheckUtil.isMobile(user_account, user_intl) && StrUtil.equals(user_account, user_mobile))) {
|
||||
if (StrUtil.isNotBlank(user_mobile) && CheckUtil.isMobile(user_mobile, user_intl)) {
|
||||
|
||||
if (StrUtil.isNotBlank(rand_key) && StrUtil.isNotBlank(verifyCode)) {
|
||||
@ -1801,7 +1799,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
throw new ApiException(_("绑定账号失败"));
|
||||
}
|
||||
return user_base_row;
|
||||
// throw new ApiException(_("用户已经存在,请更换用户名"));
|
||||
|
||||
} else {
|
||||
// 检测到用户尚未注册,立即新增用户基本信息和用户附加信息
|
||||
String user_nickname = Convert.toStr(userInfo.get("user_nickname"), user_account);
|
||||
@ -1816,7 +1814,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
// 密码加盐加密
|
||||
user_password = SecureUtil.md5(user_salt + SecureUtil.md5(user_password));
|
||||
user_base_reg_row.setUser_password(user_password);
|
||||
// user_base_reg_row.setUser_password((BCrypt.hashpw(user_password)));
|
||||
user_base_reg_row.setUser_nickname(user_nickname);
|
||||
user_base_reg_row.setUser_state(user_state);
|
||||
user_base_reg_row.setUser_key(user_key);
|
||||
@ -1900,16 +1897,17 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
|
||||
// 远程调用异常忽略掉
|
||||
try {
|
||||
// User_Resource初始化 用户积分
|
||||
if (!payService.initUserPoints(user_id)) {
|
||||
log.error("初始化用户积分失败");
|
||||
// throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
// 初始化用户经验表
|
||||
if (!accountUserInfoService.initUserExperience(user_id)) {
|
||||
log.error("初始化用户经验表失败");
|
||||
// throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
@ -1925,7 +1923,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
addSourceUserId(user_id, user_parent_id);
|
||||
}
|
||||
|
||||
//todo 分享券
|
||||
// 分享券活动id
|
||||
Integer activityId = Convert.toInt(getParameter("activity_id"));
|
||||
if (CheckUtil.isEmpty(activityId) && CheckUtil.isNotEmpty(activity_id)) {
|
||||
@ -1953,7 +1950,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
// 如果是商家首次注册 恭喜您,成功注册了商家账号!您的初始密码为:${password},密码可登录商家版 APP,登录后请尽快修改密码。
|
||||
Map<String, Object> smsArgs = new HashMap<>();
|
||||
smsArgs.put("password", user_password_src);
|
||||
sendSmsMessage(PhoneNumberUtils.cleanPhoneNumber(user_mobile), "SMS_496910525", smsArgs); // SMS_496910525
|
||||
sendSmsMessage(PhoneNumberUtils.cleanPhoneNumber(user_mobile), "SMS_496910525", smsArgs);
|
||||
}
|
||||
|
||||
//初次注册发送消息
|
||||
@ -3221,6 +3218,20 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
* @return
|
||||
*/
|
||||
public CommonResult doMobileBindLogin(String user_mobile, Integer userType, String cid, String osType) {
|
||||
return doMobileBindLogin(user_mobile, "", userType, cid, osType);
|
||||
}
|
||||
|
||||
/**
|
||||
* (商家版app)入驻商家手机号绑定登录
|
||||
*
|
||||
* @param user_mobile
|
||||
* @param regPwd 注册用途
|
||||
* @param userType
|
||||
* @param cid
|
||||
* @param osType
|
||||
* @return
|
||||
*/
|
||||
public CommonResult doMobileBindLogin(String user_mobile, String regPwd, Integer userType, String cid, String osType) {
|
||||
if (StrUtil.isBlank(user_mobile) || userType == null) {
|
||||
return CommonResult.failed("缺少必要参数!");
|
||||
}
|
||||
@ -3247,8 +3258,11 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
userInfo.put("user_account", user_mobile);
|
||||
userInfo.put("user_mobile", user_mobile);
|
||||
userInfo.put("user_is_admin", userType); // 商家入驻注册
|
||||
String user_password = regPwd;
|
||||
if (StrUtil.isBlank(user_password)) {
|
||||
// 随机数明文密码
|
||||
String user_password = com.suisung.mall.common.utils.StringUtils.random(6, com.suisung.mall.common.utils.StringUtils.RandomType.STRING);
|
||||
user_password = com.suisung.mall.common.utils.StringUtils.random(6, com.suisung.mall.common.utils.StringUtils.RandomType.STRING);
|
||||
}
|
||||
userInfo.put("user_password", user_password);
|
||||
userInfo.put("is_admin", userType); // 商家入驻注册
|
||||
|
||||
@ -3281,10 +3295,11 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
* 商家内部注册(服务之间调用)
|
||||
*
|
||||
* @param mobile 商家手机号
|
||||
* @param regPwd 注册明文密码
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示提示信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> merchantInnerRegister(String mobile) {
|
||||
public Pair<Boolean, String> merchantInnerRegister(String mobile, String regPwd) {
|
||||
log.info("商家内部注册开始,手机号: {}", mobile);
|
||||
|
||||
// 1. 参数校验
|
||||
@ -3305,7 +3320,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
}
|
||||
|
||||
// 4. 执行手机号绑定登录(注册商家账号)
|
||||
CommonResult result = doMobileBindLogin(convertedMobile, CommonConstant.USER_TYPE_MCH, null, null);
|
||||
CommonResult result = doMobileBindLogin(convertedMobile, regPwd, CommonConstant.USER_TYPE_MCH, null, null);
|
||||
|
||||
// 5. 检查注册结果
|
||||
if (result == null || result.getCode() != ResultCode.SUCCESS.getCode()) {
|
||||
|
||||
@ -329,5 +329,6 @@ public interface AccountService {
|
||||
* 服务间注册商家账号,项目之间远程调用
|
||||
*/
|
||||
@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, @Param("regPwd") String regPwd);
|
||||
|
||||
}
|
||||
|
||||
@ -789,22 +789,24 @@ public class LklTkServiceImpl {
|
||||
*/
|
||||
public JSONObject updateMerchantNotify(HttpServletRequest request) {
|
||||
try {
|
||||
logger.info("开始处理拉卡拉商户增终异步通知");
|
||||
// 解密请求参数
|
||||
String requestBody = LakalaUtil.getBody(request);
|
||||
logger.info("拉卡拉商户增终异步通知返回加密数据:{}", requestBody);
|
||||
logger.info("拉卡拉商户增终异步通知 - 接收原始数据: {}", 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", "关键参数为空值");
|
||||
}
|
||||
|
||||
@ -812,64 +814,56 @@ public class LklTkServiceImpl {
|
||||
String notifyPubKey = LakalaUtil.getResourceFile(notifyPubKeyPath, false, false);
|
||||
String lklNotifyResp = LakalaUtil.decryptNotifyData(notifyPubKey, srcData);
|
||||
if (StrUtil.isBlank(lklNotifyResp)) {
|
||||
logger.error("拉卡拉商户增终异步通知 - 数据解密失败,加密数据: {}", srcData);
|
||||
return new JSONObject().set("code", "400").set("message", "数据解密出错!");
|
||||
}
|
||||
logger.info("拉卡拉商户增终异步通知返回明文数据:{}", lklNotifyResp);
|
||||
logger.info("拉卡拉商户增终异步通知 - 解密后数据: {}", lklNotifyResp);
|
||||
|
||||
// 逻辑处理
|
||||
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.info("拉卡拉商户增终异步通知 - 解析数据完成 - 审核状态: {}, 外部商户号: {}, 终端号: {}, 审核关联ID: {}",
|
||||
reviewPass, merCupNo, termNo, reviewRelatedId);
|
||||
|
||||
// 合并参数校验
|
||||
if (dataJSON.isEmpty() ||
|
||||
StrUtil.isBlank(reviewPass) ||
|
||||
StrUtil.isBlank(merCupNo) ||
|
||||
StrUtil.isBlank(reviewRelatedId) ||
|
||||
StrUtil.isBlank(termNo)) {
|
||||
logger.warn("拉卡拉商户增终异步通知 - 参数解析出错,解密数据: {}", lklNotifyResp);
|
||||
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;
|
||||
|
||||
}
|
||||
Integer status = "PASS".equals(reviewPass) ? CommonConstant.Enable :
|
||||
"UNPASS".equals(reviewPass) ? CommonConstant.Disable2 :
|
||||
"PASSING".equals(reviewPass) ? 3 : 4;
|
||||
logger.info("拉卡拉商户增终异步通知 - 更新分店入驻表,审核关联ID: {}, 状态: {}, 通知响应: {}", reviewRelatedId, status, lklNotifyResp);
|
||||
shopMchEntryBranchService.updateByReviewRelatedId(reviewRelatedId, status, lklNotifyResp);
|
||||
|
||||
// 给商家总店入驻表增加拉卡拉的商户号和拉卡拉返回的数据
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerInnerNo(merInnerNo);
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(merCupNo, 0L);
|
||||
if (shopMchEntry == null) {
|
||||
return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在");
|
||||
logger.error("拉卡拉商户增终异步通知 - 商户号入驻信息不存在: {}", merCupNo);
|
||||
return new JSONObject().put("code", "500").put("message", merCupNo + "商户号入驻信息不存在");
|
||||
}
|
||||
|
||||
// 校验审核状态: PREPARE:待提交; PASS:通过; UNPASS:未通过; PASSING:审核中;
|
||||
if (!"PASS".equals(reviewPass)) {
|
||||
String reviewResult = dataJSON.getStr("reviewResult");
|
||||
return new JSONObject().set("code", "FAIL").set("message", "审核未通过:" + reviewResult);
|
||||
logger.info("拉卡拉商户增终异步通知 - 审核未通过,状态: {}, 结果: {}", reviewPass, dataJSON.getStr("reviewResult"));
|
||||
return new JSONObject().set("code", "500").set("message", "忽略处理,因审核未通过:" + dataJSON.getStr("reviewResult"));
|
||||
}
|
||||
|
||||
logger.info("拉卡拉商户增终异步通知 - 审核通过,开始创建分店入驻记录,审核关联ID: {}, 终端号: {}", reviewRelatedId, termNo);
|
||||
// RMK 拉卡拉增终成功, 创建分店入驻记录,创建商家账号、创建店铺和周边信息
|
||||
shopMchEntryBranchService.createMchEntryBranchStore(reviewRelatedId, termNo, lklNotifyResp);
|
||||
|
||||
logger.info("拉卡拉商户增终异步通知 - 处理完成,审核关联ID: {}", reviewRelatedId);
|
||||
return new JSONObject().set("code", "200").set("message", "处理成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -138,6 +138,15 @@ public interface ShopMchEntryService {
|
||||
ShopMchEntry getShopMerchEntryByCondition(String loginMobile, String bizLicenseNumber, Integer... approvalStatusList);
|
||||
|
||||
|
||||
/**
|
||||
* 根据拉卡拉商户号获取有效的商家入驻申请记录
|
||||
*
|
||||
* @param merCupNo
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
ShopMchEntry getShopMerchEntryByMerCupNo(String merCupNo, Long parentId);
|
||||
|
||||
/**
|
||||
* 根据拉卡拉外部商户号获取有效的商家入驻申请记录
|
||||
*
|
||||
@ -386,4 +395,12 @@ public interface ShopMchEntryService {
|
||||
ShopMchEntry getLklContractStatusUrl(Integer storeId);
|
||||
|
||||
ShopMchEntry findOneByLambdaQueryWrapper(LambdaQueryWrapper<ShopMchEntry> query);
|
||||
|
||||
/**
|
||||
* 根据商户入驻Id删除商户入驻记录
|
||||
*
|
||||
* @param mchId 商户入驻Id
|
||||
* @return 删除结果,true为成功,false为失败
|
||||
*/
|
||||
Boolean removeByMchId(Long mchId);
|
||||
}
|
||||
@ -191,13 +191,27 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
return Pair.of(false, "分店入驻信息不能为空");
|
||||
}
|
||||
|
||||
// 必填参数校验
|
||||
if (mainStoreBranchReq.getParent_store_id() == null) {
|
||||
log.warn("主店ID不能为空");
|
||||
return Pair.of(false, "主店ID不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getLogin_mobile())) {
|
||||
return Pair.of(false, "登录手机号不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getStore_name())) {
|
||||
return Pair.of(false, "分店名称不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getStore_address())) {
|
||||
return Pair.of(false, "分店地址不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getStore_longitude())) {
|
||||
return Pair.of(false, "分店经度不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getStore_latitude())) {
|
||||
return Pair.of(false, "分店纬度不能为空");
|
||||
}
|
||||
|
||||
// 2. 检查主店信息是否存在及入驻状态
|
||||
log.debug("检查主店信息是否存在,主店ID: {}", mainStoreBranchReq.getParent_store_id());
|
||||
LambdaQueryWrapper<ShopMchEntry> entryQueryWrapper = new LambdaQueryWrapper<>();
|
||||
entryQueryWrapper.eq(ShopMchEntry::getStore_id, mainStoreBranchReq.getParent_store_id())
|
||||
.eq(ShopMchEntry::getApproval_status, CommonConstant.MCH_APPR_STA_PASS)
|
||||
@ -205,79 +219,57 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
ShopMchEntry mchEntry = shopMchEntryService.findOneByLambdaQueryWrapper(entryQueryWrapper);
|
||||
|
||||
if (mchEntry == null) {
|
||||
log.warn("主店商户入驻信息不存在,主店ID: {}", mainStoreBranchReq.getParent_store_id());
|
||||
return Pair.of(false, "主店商户入驻信息不存在");
|
||||
}
|
||||
|
||||
if (!Objects.equals(mchEntry.getLkl_tk_audit_status(), CommonConstant.Enable)) {
|
||||
log.warn("主店入驻状态未完成,当前状态: {},无法创建分店", mchEntry.getLkl_tk_audit_status());
|
||||
return Pair.of(false, "主店入驻状态未完成,无法创建分店");
|
||||
}
|
||||
log.debug("主店信息检查通过,拉卡拉商户号: {}", mchEntry.getLkl_mer_cup_no());
|
||||
|
||||
// 3. 检查店铺名称是否已经存在
|
||||
log.debug("检查店铺名称是否已存在: {}", mainStoreBranchReq.getStore_name());
|
||||
LambdaQueryWrapper<ShopStoreBase> nameQueryWrapper = new LambdaQueryWrapper<>();
|
||||
nameQueryWrapper.eq(ShopStoreBase::getStore_name, mainStoreBranchReq.getStore_name());
|
||||
ShopStoreBase existingStore = shopStoreBaseService.getOne(nameQueryWrapper);
|
||||
if (existingStore != null) {
|
||||
log.warn("店铺名称已存在: {}", mainStoreBranchReq.getStore_name());
|
||||
if (shopStoreBaseService.getOne(nameQueryWrapper) != null) {
|
||||
return Pair.of(false, "店铺名称已存在");
|
||||
}
|
||||
log.debug("店铺名称检查通过");
|
||||
|
||||
// 4. 检查分店登录手机号是否已经注册过商户
|
||||
log.debug("检查手机号是否已注册商户: {}", mainStoreBranchReq.getLogin_mobile());
|
||||
Integer status = accountService.isMerchantExists(mainStoreBranchReq.getLogin_mobile());
|
||||
if (CheckUtil.isEmpty(status)) {
|
||||
log.error("调用账户服务检查商户信息失败,手机号: {}", mainStoreBranchReq.getLogin_mobile());
|
||||
return Pair.of(false, "检查商户信息失败!");
|
||||
}
|
||||
|
||||
if (CommonConstant.Enable.equals(status)) {
|
||||
log.warn("手机号商户已被注册: {}", mainStoreBranchReq.getLogin_mobile());
|
||||
return Pair.of(false, "手机号商户已被注册");
|
||||
return Pair.of(false, "手机号已被其他商家注册");
|
||||
}
|
||||
log.debug("手机号检查通过");
|
||||
|
||||
// 5. 检查分店终端号是否已经申请或申请中
|
||||
log.debug("检查分店终端号是否已申请或申请中,拉卡拉内部商户号: {}", mchEntry.getLkl_mer_inner_no());
|
||||
LambdaQueryWrapper<ShopMchEntryBranch> branchQueryWrapper = new LambdaQueryWrapper<>();
|
||||
branchQueryWrapper.eq(ShopMchEntryBranch::getLkl_mer_cup_no, mchEntry.getLkl_mer_inner_no())
|
||||
.in(ShopMchEntryBranch::getStatus, Arrays.asList(1, 3)); // 1-申请中,3-可能的其他状态
|
||||
long existingBranchCount = count(branchQueryWrapper);
|
||||
if (existingBranchCount > 0) {
|
||||
log.info("分店终端号已申请或申请中,拉卡拉内部商户号: {},已存在申请数量: {}",
|
||||
mchEntry.getLkl_mer_inner_no(), existingBranchCount);
|
||||
if (count(branchQueryWrapper) > 0) {
|
||||
return Pair.of(false, "分店终端号已申请或申请中,请等待审核");
|
||||
}
|
||||
log.debug("终端号检查通过");
|
||||
|
||||
// 6. 调用拉卡拉接口创建商户终端
|
||||
log.info("调用拉卡拉接口创建商户终端,主店拉卡拉商户号: {}", mchEntry.getLkl_mer_cup_no());
|
||||
JSONObject lklResp = lklTkService.openMerchantAddTerm(mchEntry.getLkl_mer_cup_no());
|
||||
if (lklResp == null || StrUtil.isBlank(lklResp.getStr("reviewRelatedId"))) {
|
||||
log.error("调用拉卡拉接口创建商户终端失败,主店拉卡拉商户号: {}", mchEntry.getLkl_mer_cup_no());
|
||||
return Pair.of(false, "分店提交申请失败");
|
||||
}
|
||||
String reviewRelatedId = lklResp.getStr("reviewRelatedId");
|
||||
log.info("拉卡拉接口调用成功,审核关联号: {}", reviewRelatedId);
|
||||
|
||||
// 7. 保存商户入驻申请信息
|
||||
log.debug("开始保存商户入驻申请信息");
|
||||
ShopMchEntryBranch shopMchEntryBranch = new ShopMchEntryBranch();
|
||||
shopMchEntryBranch.setLkl_mer_cup_no(mchEntry.getLkl_mer_cup_no());
|
||||
shopMchEntryBranch.setReview_related_id(reviewRelatedId);
|
||||
shopMchEntryBranch.setReview_related_id(lklResp.getStr("reviewRelatedId"));
|
||||
shopMchEntryBranch.setLkl_req(JSONUtil.toJsonStr(mainStoreBranchReq));
|
||||
shopMchEntryBranch.setLkl_reps(JSONUtil.toJsonStr(lklResp));
|
||||
|
||||
Boolean isSuccess = saveShopMchEntryBranch(shopMchEntryBranch);
|
||||
if (!isSuccess) {
|
||||
log.error("保存商户入驻申请信息失败,审核关联号: {}", reviewRelatedId);
|
||||
if (!saveShopMchEntryBranch(shopMchEntryBranch)) {
|
||||
return Pair.of(false, "分店提交申请失败");
|
||||
}
|
||||
log.info("分店商户入驻申请创建成功,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
|
||||
|
||||
log.info("分店商户入驻申请创建成功,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
|
||||
return Pair.of(true, "分店提交申请成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -301,7 +293,6 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
|
||||
// 1. 参数校验
|
||||
if (StrUtil.isBlank(reviewRelatedId) || StrUtil.isBlank(termNo)) {
|
||||
log.warn("分店商户入驻参数校验失败,reviewRelatedId: {}, termNo: {}", reviewRelatedId, termNo);
|
||||
return Pair.of(false, "参数不能为空");
|
||||
}
|
||||
|
||||
@ -309,7 +300,6 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
// 2. 查询分店入驻申请记录
|
||||
ShopMchEntryBranch shopMchEntryBranch = getByReviewRelatedId(reviewRelatedId);
|
||||
if (shopMchEntryBranch == null) {
|
||||
log.warn("分店商户入驻申请不存在,审核关联号: {}", reviewRelatedId);
|
||||
return Pair.of(false, "分店商户入驻申请不存在");
|
||||
}
|
||||
|
||||
@ -318,81 +308,63 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
shopMchEntryBranch.setStatus(CommonConstant.Enable);
|
||||
shopMchEntryBranch.setLkl_notify_reps(lklNotifyResp);
|
||||
if (!updateById(shopMchEntryBranch)) {
|
||||
log.error("更新分店入驻申请记录失败,审核关联号: {}", reviewRelatedId);
|
||||
throw new ApiException("更新分店入驻申请记录失败");
|
||||
}
|
||||
log.debug("更新分店入驻申请记录成功,审核关联号: {}", reviewRelatedId);
|
||||
|
||||
// 4. 解析分店入驻请求数据
|
||||
MainStoreBranchReqDTO mainStoreBranchReq = JSONUtil.toBean(shopMchEntryBranch.getLkl_req(), MainStoreBranchReqDTO.class);
|
||||
if (mainStoreBranchReq == null) {
|
||||
log.error("解析分店入驻请求数据失败,审核关联号: {}", reviewRelatedId);
|
||||
throw new ApiException("解析分店入驻请求数据失败");
|
||||
}
|
||||
|
||||
// 5. 获取总店入驻信息
|
||||
ShopMchEntry parentShopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(shopMchEntryBranch.getLkl_mer_cup_no());
|
||||
ShopMchEntry parentShopMchEntry = shopMchEntryService.getShopMerchEntryByMerCupNo(shopMchEntryBranch.getLkl_mer_cup_no(), 0L);
|
||||
if (parentShopMchEntry == null) {
|
||||
log.error("总店入驻信息不存在,拉卡拉商户号: {}", shopMchEntryBranch.getLkl_mer_cup_no());
|
||||
throw new ApiException("主店入驻信息不存在");
|
||||
}
|
||||
|
||||
// 总店店铺 Id
|
||||
Integer parentStoreId = Convert.toInt(parentShopMchEntry.getStore_id(), 0);
|
||||
|
||||
// 6. 构建分店入驻信息
|
||||
ShopMchEntry shopMchEntry = new ShopMchEntry();
|
||||
// 拷贝主店基础信息
|
||||
cn.hutool.core.bean.BeanUtil.copyProperties(parentShopMchEntry, shopMchEntry, "id"); // ID设置为null,以便插入新记录
|
||||
// 设置分店特有信息
|
||||
cn.hutool.core.bean.BeanUtil.copyProperties(parentShopMchEntry, shopMchEntry, "id");
|
||||
shopMchEntry.setId(null); // ID设置为null,以便插入新记录
|
||||
shopMchEntry.setLkl_term_no(termNo);
|
||||
shopMchEntry.setLogin_mobile(mainStoreBranchReq.getLogin_mobile());
|
||||
shopMchEntry.setParent_id(parentShopMchEntry.getId()); // 设置主店入驻ID为父ID
|
||||
shopMchEntry.setStore_name(mainStoreBranchReq.getStore_name());
|
||||
shopMchEntry.setContact_name(mainStoreBranchReq.getContact_name());
|
||||
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getEmail())) {
|
||||
shopMchEntry.setEmail(parentShopMchEntry.getLogin_mobile() + "@qq.com");
|
||||
} else {
|
||||
shopMchEntry.setEmail(mainStoreBranchReq.getEmail());
|
||||
}
|
||||
|
||||
shopMchEntry.setStore_address(mainStoreBranchReq.getStore_address());
|
||||
shopMchEntry.setStore_longitude(mainStoreBranchReq.getStore_longitude());
|
||||
shopMchEntry.setStore_latitude(mainStoreBranchReq.getStore_latitude());
|
||||
shopMchEntry.setStatus(CommonConstant.Enable);
|
||||
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getFront_facade_image())) {
|
||||
if (StrUtil.isNotBlank(mainStoreBranchReq.getContact_name())) {
|
||||
shopMchEntry.setContact_name(mainStoreBranchReq.getContact_name());
|
||||
}
|
||||
if (StrUtil.isNotBlank(mainStoreBranchReq.getFront_facade_image())) {
|
||||
shopMchEntry.setFront_facade_image(mainStoreBranchReq.getFront_facade_image());
|
||||
}
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getEnvironment_image())) {
|
||||
if (StrUtil.isNotBlank(mainStoreBranchReq.getEnvironment_image())) {
|
||||
shopMchEntry.setEnvironment_image(mainStoreBranchReq.getEnvironment_image());
|
||||
}
|
||||
shopMchEntry.setStatus(CommonConstant.Enable);
|
||||
shopMchEntry.setEmail(StrUtil.isBlank(mainStoreBranchReq.getEmail()) ? parentShopMchEntry.getLogin_mobile() + "@qq.com" : mainStoreBranchReq.getEmail());
|
||||
|
||||
// 7. 保存分店入驻记录
|
||||
if (!shopMchEntryService.saveOrUpdateShopMchEntry(shopMchEntry)) {
|
||||
log.error("保存分店入驻记录失败,店铺名称: {}", shopMchEntry.getStore_name());
|
||||
throw new ApiException("保存分店入驻记录失败:" + shopMchEntry.getStore_name());
|
||||
}
|
||||
log.info("保存分店入驻记录成功,分店ID: {}, 店铺名称: {}", shopMchEntry.getId(), shopMchEntry.getStore_name());
|
||||
|
||||
// 8. 创建分店店铺商家登录账号
|
||||
Pair<Boolean, String> registerResult = accountService.merchantInnerRegister(mainStoreBranchReq.getLogin_mobile());
|
||||
Pair<Boolean, String> registerResult = accountService.merchantInnerRegister(mainStoreBranchReq.getLogin_mobile(), mainStoreBranchReq.getPassword());
|
||||
if (!registerResult.getFirst()) {
|
||||
log.error("分店商户注册账号失败,手机号: {},错误信息: {}", mainStoreBranchReq.getLogin_mobile(), registerResult.getSecond());
|
||||
throw new ApiException("分店商户注册账号失败:" + registerResult.getSecond());
|
||||
}
|
||||
log.debug("分店商户注册账号成功,手机号: {}", mainStoreBranchReq.getLogin_mobile());
|
||||
|
||||
// 9. 创建分店店铺信息,创建分店店铺周边信息(公司、员工、权限等)
|
||||
Pair<Integer, String> storeResult = shopStoreBaseService.covMerchEntryInfo2StoreInfo(shopMchEntry.getId(), parentStoreId, true);
|
||||
// 9. 创建分店店铺信息
|
||||
Pair<Integer, String> storeResult = shopStoreBaseService.covMerchEntryInfo2StoreInfo(shopMchEntry.getId(), Convert.toInt(parentShopMchEntry.getStore_id(), 0), true);
|
||||
if (storeResult == null || storeResult.getFirst() <= 0) {
|
||||
log.error("创建分店店铺信息失败,分店入驻ID: {},错误信息: {}", shopMchEntry.getId(),
|
||||
storeResult != null ? storeResult.getSecond() : "返回结果为空");
|
||||
throw new ApiException("创建分店店铺信息失败: " + (storeResult != null ? storeResult.getSecond() : "未知错误"));
|
||||
}
|
||||
log.info("分店商户入驻处理成功,分店入驻ID: {}, 店铺ID: {}", shopMchEntry.getId(), storeResult.getFirst());
|
||||
|
||||
log.info("分店商户入驻处理成功,分店入驻ID: {}, 店铺ID: {}", shopMchEntry.getId(), storeResult.getFirst());
|
||||
return Pair.of(true, "分店商户入驻处理成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -402,4 +374,97 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清理分店商户入驻信息
|
||||
*
|
||||
* @param lklMerCupNo 拉卡拉商户号
|
||||
* @param lklTermNo 拉卡拉终端号
|
||||
* @return 清理结果
|
||||
*/
|
||||
@GlobalTransactional
|
||||
public Pair<Boolean, String> cleanMchEntryBranchStore(String lklMerCupNo, String lklTermNo) {
|
||||
log.info("开始清理分店商户入驻信息,拉卡拉商户号: {}, 终端号: {}", lklMerCupNo, lklTermNo);
|
||||
|
||||
// 1. 参数校验
|
||||
if (StrUtil.isBlank(lklMerCupNo) || StrUtil.isBlank(lklTermNo)) {
|
||||
log.warn("清理分店商户入驻参数校验失败,lklMerCupNo: {}, lklTermNo: {}", lklMerCupNo, lklTermNo);
|
||||
return Pair.of(false, "参数不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
log.debug("步骤1 - 查询分店入驻记录,拉卡拉商户号: {}, 终端号: {}", lklMerCupNo, lklTermNo);
|
||||
// 2. 查询分店入驻记录
|
||||
LambdaQueryWrapper<ShopMchEntry> entryQueryWrapper = new LambdaQueryWrapper<>();
|
||||
entryQueryWrapper.eq(ShopMchEntry::getLkl_mer_cup_no, lklMerCupNo)
|
||||
.eq(ShopMchEntry::getLkl_term_no, lklTermNo);
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.findOneByLambdaQueryWrapper(entryQueryWrapper);
|
||||
|
||||
if (shopMchEntry == null) {
|
||||
log.warn("未找到对应的分店入驻记录,拉卡拉商户号: {}, 终端号: {}", lklMerCupNo, lklTermNo);
|
||||
return Pair.of(false, "未找到对应的分店入驻记录");
|
||||
}
|
||||
log.debug("步骤1 - 找到分店入驻记录,分店ID: {}, 店铺名称: {}", shopMchEntry.getId(), shopMchEntry.getStore_name());
|
||||
|
||||
log.debug("步骤2 - 查询分店店铺信息,分店入驻ID: {}", shopMchEntry.getId());
|
||||
// 3. 查询分店店铺信息
|
||||
LambdaQueryWrapper<ShopStoreBase> storeQueryWrapper = new LambdaQueryWrapper<>();
|
||||
storeQueryWrapper.eq(ShopStoreBase::getStore_id, shopMchEntry.getStore_id());
|
||||
ShopStoreBase shopStore = shopStoreBaseService.getOne(storeQueryWrapper);
|
||||
|
||||
if (shopStore == null) {
|
||||
log.warn("未找到对应的分店店铺信息,分店入驻ID: {}", shopMchEntry.getId());
|
||||
} else {
|
||||
log.debug("步骤2 - 找到分店店铺信息,店铺ID: {}, 店铺名称: {}", shopStore.getStore_id(), shopStore.getStore_name());
|
||||
}
|
||||
|
||||
log.debug("步骤3 - 删除分店店铺信息,店铺ID: {}", shopStore != null ? shopStore.getStore_id() : "null");
|
||||
// 4. 删除分店店铺信息
|
||||
if (shopStore != null) {
|
||||
boolean deleteStoreResult = shopStoreBaseService.removeById(shopStore.getStore_id());
|
||||
if (!deleteStoreResult) {
|
||||
log.error("删除分店店铺信息失败,店铺ID: {}", shopStore.getStore_id());
|
||||
throw new ApiException("删除分店店铺信息失败");
|
||||
}
|
||||
log.debug("步骤3 - 删除分店店铺信息成功,店铺ID: {}", shopStore.getStore_id());
|
||||
}
|
||||
|
||||
log.debug("步骤4 - 删除分店入驻记录,分店ID: {}", shopMchEntry.getId());
|
||||
// 5. 删除分店入驻记录
|
||||
boolean deleteEntryResult = shopMchEntryService.removeByMchId(shopMchEntry.getId());
|
||||
if (!deleteEntryResult) {
|
||||
log.error("删除分店入驻记录失败,分店ID: {}", shopMchEntry.getId());
|
||||
throw new ApiException("删除分店入驻记录失败");
|
||||
}
|
||||
log.debug("步骤4 - 删除分店入驻记录成功,分店ID: {}", shopMchEntry.getId());
|
||||
|
||||
log.debug("步骤5 - 查询分店入驻申请记录,拉卡拉商户号: {}, 终端号: {}", lklMerCupNo, lklTermNo);
|
||||
// 6. 查询分店入驻申请记录
|
||||
LambdaQueryWrapper<ShopMchEntryBranch> branchQueryWrapper = new LambdaQueryWrapper<>();
|
||||
branchQueryWrapper.eq(ShopMchEntryBranch::getLkl_mer_cup_no, lklMerCupNo)
|
||||
.eq(ShopMchEntryBranch::getLkl_term_no, lklTermNo);
|
||||
ShopMchEntryBranch shopMchEntryBranch = getOne(branchQueryWrapper);
|
||||
|
||||
if (shopMchEntryBranch != null) {
|
||||
log.debug("步骤5 - 找到分店入驻申请记录,审核关联ID: {}", shopMchEntryBranch.getReview_related_id());
|
||||
|
||||
log.debug("步骤6 - 删除分店入驻申请记录,审核关联ID: {}", shopMchEntryBranch.getReview_related_id());
|
||||
// 7. 删除分店入驻申请记录
|
||||
boolean deleteBranchResult = removeById(shopMchEntryBranch.getId());
|
||||
if (!deleteBranchResult) {
|
||||
log.error("删除分店入驻申请记录失败,审核关联ID: {}", shopMchEntryBranch.getReview_related_id());
|
||||
throw new ApiException("删除分店入驻申请记录失败");
|
||||
}
|
||||
log.debug("步骤6 - 删除分店入驻申请记录成功,审核关联ID: {}", shopMchEntryBranch.getReview_related_id());
|
||||
}
|
||||
|
||||
log.info("分店商户入驻信息清理完成,拉卡拉商户号: {}, 终端号: {}", lklMerCupNo, lklTermNo);
|
||||
return Pair.of(true, "分店商户入驻信息清理成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("清理分店商户入驻信息时发生异常,拉卡拉商户号: {}, 终端号: {}", lklMerCupNo, lklTermNo, e);
|
||||
throw new ApiException("清理分店商户入驻信息时发生异常,拉卡拉商户号: " + lklMerCupNo + ", 终端号: " + lklTermNo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1319,16 +1319,21 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ShopMchEntry getShopMerchEntryByMerCupNo(String merCupNo) {
|
||||
public ShopMchEntry getShopMerchEntryByMerCupNo(String merCupNo, Long parentId) {
|
||||
if (StrUtil.isBlank(merCupNo)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
LambdaQueryWrapper<ShopMchEntry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ShopMchEntry::getLkl_mer_cup_no, merCupNo)
|
||||
.eq(ShopMchEntry::getParent_id, 0L) // 总店
|
||||
.eq(ShopMchEntry::getStatus, CommonConstant.Enable)
|
||||
.orderByAsc(ShopMchEntry::getId);
|
||||
|
||||
if (parentId != null && parentId >= 0) {
|
||||
queryWrapper.eq(ShopMchEntry::getParent_id, parentId);
|
||||
}
|
||||
|
||||
ShopMchEntry record = findOne(queryWrapper);
|
||||
if (ObjectUtil.isEmpty(record)) {
|
||||
return null;
|
||||
@ -1337,20 +1342,25 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopMchEntry getShopMerchEntryByMerCupNo(String merCupNo) {
|
||||
return getShopMerchEntryByMerCupNo(merCupNo, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopMchEntry getShopMerchEntryByMerInnerNo(String merInnerNo) {
|
||||
if (StrUtil.isBlank(merInnerNo)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
QueryWrapper<ShopMchEntry> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("lkl_mer_inner_no", merInnerNo).eq("status", CommonConstant.Enable).orderByAsc("id");
|
||||
List<ShopMchEntry> recordList = list(queryWrapper);
|
||||
if (CollectionUtil.isEmpty(recordList)) {
|
||||
LambdaQueryWrapper<ShopMchEntry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ShopMchEntry::getLkl_mer_inner_no, merInnerNo).eq(ShopMchEntry::getStatus, CommonConstant.Enable).orderByAsc(ShopMchEntry::getId);
|
||||
ShopMchEntry record = findOne(queryWrapper);
|
||||
if (ObjectUtil.isEmpty(record)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return recordList.get(0);
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2656,6 +2666,17 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商户入驻Id删除商户入驻记录
|
||||
*
|
||||
* @param mchId 商户入驻Id
|
||||
* @return 删除结果,true为成功,false为失败
|
||||
*/
|
||||
@Override
|
||||
public Boolean removeByMchId(Long mchId) {
|
||||
return remove(mchId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user