分店逻辑增加,逻辑编写,拉卡拉增终,收到通知,创建分店,分店周边信息、账号、入驻信息等
This commit is contained in:
parent
1897281b38
commit
2ff93df44b
@ -30,7 +30,9 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -231,5 +233,11 @@ public class AccountUserBaseController extends BaseControllerImpl {
|
||||
return CommonResult.success(accountUserBaseService.logout());
|
||||
}
|
||||
|
||||
@ApiOperation("服务间注册商家账号,项目之间远程调用")
|
||||
@RequestMapping(value = "/merchant/inner-register", method = RequestMethod.POST)
|
||||
public Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile) {
|
||||
return accountUserBaseService.merchantInnerRegister(mobile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -296,4 +296,12 @@ public interface AccountUserBaseService extends IBaseService<AccountUserBase> {
|
||||
* @return
|
||||
*/
|
||||
ThirdApiRes saveBatchAccountInfo(List<AccountUserInfo> accountUserInfoList);
|
||||
|
||||
/**
|
||||
* 商家内部注册(服务之间调用)
|
||||
*
|
||||
* @param mobile 商家手机号
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示提示信息
|
||||
*/
|
||||
Pair<Boolean, String> merchantInnerRegister(String mobile);
|
||||
}
|
||||
|
||||
@ -3267,17 +3267,63 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
params.put("username", accountUserBase.getUser_account());
|
||||
params.put("password", "");
|
||||
params.put("user_mobile", user_mobile);
|
||||
params.put("is_merch", "1"); // 是否为商家入驻 1-是;其他-否
|
||||
params.put("is_merch", CommonConstant.Enable.toString()); // 是否为商家入驻 1-是;其他-否
|
||||
|
||||
if (StrUtil.isNotBlank(cid)) {
|
||||
params.put("cid", cid); // 个推客户端Id
|
||||
params.put("os_type", osType);// 个推客系统类别 1-Android;2-iOS;3-微信小程序;
|
||||
// logger.info("推送参数2 cid:{}, osType:{}", cid, osType);
|
||||
}
|
||||
|
||||
return login(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家内部注册(服务之间调用)
|
||||
*
|
||||
* @param mobile 商家手机号
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示提示信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> merchantInnerRegister(String mobile) {
|
||||
log.info("商家内部注册开始,手机号: {}", mobile);
|
||||
|
||||
// 1. 参数校验
|
||||
if (StrUtil.isBlank(mobile)) {
|
||||
log.warn("商家内部注册失败:手机号为空");
|
||||
return Pair.of(false, "手机号不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
// 2. 转换手机号格式(添加国家区号)
|
||||
String convertedMobile = PhoneNumberUtils.convZhPhoneNumber(mobile);
|
||||
|
||||
// 3. 检查手机号是否已注册为商家
|
||||
Integer isExists = accountUserBindConnectService.isMerchantExists(convertedMobile);
|
||||
if (CommonConstant.Enable.equals(isExists)) {
|
||||
log.warn("商家内部注册失败:手机号已注册,手机号: {}", convertedMobile);
|
||||
return Pair.of(false, "该手机号已注册!");
|
||||
}
|
||||
|
||||
// 4. 执行手机号绑定登录(注册商家账号)
|
||||
CommonResult result = doMobileBindLogin(convertedMobile, CommonConstant.USER_TYPE_MCH, null, null);
|
||||
|
||||
// 5. 检查注册结果
|
||||
if (result == null || result.getCode() != ResultCode.SUCCESS.getCode()) {
|
||||
String errorMsg = result != null ? result.getMsg() : "注册结果为空";
|
||||
log.error("商家账号注册失败:{},手机号: {}", errorMsg, convertedMobile);
|
||||
return Pair.of(false, "商家账号注册失败:" + errorMsg);
|
||||
}
|
||||
|
||||
log.info("商家内部注册成功,手机号: {}", convertedMobile);
|
||||
return Pair.of(true, "商家注册成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("商家内部注册异常,手机号: {}", mobile, e);
|
||||
return Pair.of(false, "商家注册失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> doAppConnectLogin(String bind_name, String code) {
|
||||
String id_prefix = "";
|
||||
|
||||
@ -6,7 +6,9 @@ import com.suisung.mall.common.modules.push.PushTemplate;
|
||||
import com.suisung.mall.common.pojo.output.TimelineOutput;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -313,4 +315,10 @@ public interface AccountService {
|
||||
*/
|
||||
@RequestMapping(value = "/admin/account/account-user-bind-connect/is-merchant-exists", method = RequestMethod.POST)
|
||||
Integer isMerchantExists(@RequestParam(name = "mobile") String mobile);
|
||||
|
||||
/**
|
||||
* 服务间注册商家账号,项目之间远程调用
|
||||
*/
|
||||
@RequestMapping(value = "/merchant/inner-register", method = RequestMethod.POST)
|
||||
Pair<Boolean, String> merchantInnerRegister(@Param("mobile") String mobile);
|
||||
}
|
||||
|
||||
@ -259,7 +259,7 @@ public class ShopMchEntry implements Serializable {
|
||||
private Integer has_bind_receiver;
|
||||
|
||||
@ApiModelProperty(value = "父入驻id(总店入驻id)")
|
||||
private Integer parent_id;
|
||||
private Long parent_id;
|
||||
|
||||
@ApiModelProperty(value = "该商家入驻记录是否有效,0:无效,1:有效")
|
||||
private Integer status;
|
||||
|
||||
@ -44,14 +44,15 @@ public class ShopMchEntryBranch implements Serializable {
|
||||
@ApiModelProperty(value = "请求拉卡拉参数")
|
||||
private String lkl_req;
|
||||
|
||||
@ApiModelProperty(value = "拉卡拉响应参数")
|
||||
@ApiModelProperty(value = "拉卡拉响应数据")
|
||||
private String lkl_reps;
|
||||
|
||||
@ApiModelProperty(value = "拉卡拉通知响应数据")
|
||||
private String lkl_notify_reps;
|
||||
|
||||
@ApiModelProperty(value = "该商家入驻记录是否有效,0:无效,1:有效")
|
||||
private Integer status;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "商家入驻记录的创建时间")
|
||||
private Date created_at;
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ import com.suisung.mall.shop.lakala.service.LklBanksService;
|
||||
import com.suisung.mall.shop.lakala.service.LklLedgerReceiverService;
|
||||
import com.suisung.mall.shop.lakala.utils.LakalaUtil;
|
||||
import com.suisung.mall.shop.page.service.impl.OssServiceImpl;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryBranchService;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import org.slf4j.Logger;
|
||||
@ -96,13 +97,13 @@ public class LklTkServiceImpl {
|
||||
@Resource
|
||||
private LklLedgerReceiverService lklLedgerReceiverService;
|
||||
|
||||
// @Lazy
|
||||
// @Lazy
|
||||
// @Resource
|
||||
// private EsignContractService esignContractService;
|
||||
//
|
||||
// @Lazy
|
||||
// @Resource
|
||||
// private EsignContractFillingFileService esignContractFillingFileService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private ShopMchEntryBranchService shopMchEntryBranchService;
|
||||
|
||||
@Lazy
|
||||
@Resource
|
||||
@ -828,7 +829,7 @@ public class LklTkServiceImpl {
|
||||
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);
|
||||
|
||||
@ -836,7 +837,7 @@ public class LklTkServiceImpl {
|
||||
if (dataJSON.isEmpty() ||
|
||||
StrUtil.isBlank(reviewPass) ||
|
||||
StrUtil.isBlank(merCupNo) ||
|
||||
StrUtil.isBlank(merInnerNo) ||
|
||||
StrUtil.isBlank(reviewRelatedId) ||
|
||||
StrUtil.isBlank(termNo)) {
|
||||
logger.warn("拉卡拉改进异步通知参数解析出错,数据: {}", data);
|
||||
return new JSONObject().set("code", "500").set("message", "参数解析出错");
|
||||
@ -864,27 +865,8 @@ public class LklTkServiceImpl {
|
||||
|
||||
logger.info("拉卡拉增终审核通过,商户ID: {},开始更新商户信息", mchId);
|
||||
|
||||
// RMK 拉卡拉进价提交成功,边处理周边的数据,边等待审核异步通知
|
||||
|
||||
// 更新已进件成功的商户号和设备号
|
||||
logger.debug("开始更新商户拉卡拉审核状态");
|
||||
Boolean success = shopMchEntryService.updateMerchEntryLklAuditStatusByLklMerCupNo(
|
||||
merInnerNo, merCupNo, termNo, CommonConstant.Enable, null, data);
|
||||
|
||||
if (!Boolean.TRUE.equals(success)) {
|
||||
logger.error("拉卡拉进件审核通过但更新商户号失败,商户ID: {}", mchId);
|
||||
shopMchEntryService.updateMerchEntryApprovalByMchId(mchId, CommonConstant.MCH_APPR_STA_LKL_NOPASS, "进件时更新商户号失败");
|
||||
return new JSONObject().set("code", "500").set("message", "更新商户号失败");
|
||||
}
|
||||
|
||||
logger.info("商户拉卡拉审核状态更新成功,商户ID: {}", mchId);
|
||||
|
||||
shopMchEntryService.updateMerchEntryApprovalByMchId(shopMchEntry.getId(), CommonConstant.MCH_APPR_STA_LKL_PADDING,
|
||||
"进件、申请分账业务、创建分账接收方均已成功,等待拉卡拉审核分账业务请求!");
|
||||
|
||||
//密集操作:进件审核通过之后,要下一步流程操作:申请分账业务、创建分账接收方
|
||||
logger.info("开始执行进件后续操作,商户ID: {},拉卡拉商户号: {}", mchId, merCupNo);
|
||||
registrationMerchantAfterHook(mchId, merCupNo);
|
||||
// RMK 拉卡拉增终成功, 创建分店入驻记录,创建商家账号、创建店铺和周边信息
|
||||
shopMchEntryBranchService.createMchEntryBranchStore(reviewRelatedId, termNo, data);
|
||||
|
||||
logger.info("拉卡拉进件异步通知处理完成,商户ID: {}", mchId);
|
||||
return new JSONObject().set("code", "200").set("message", "处理成功");
|
||||
@ -917,10 +899,8 @@ public class LklTkServiceImpl {
|
||||
feeInfoDto.set("topFee", Convert.toDouble(wxFee));
|
||||
feeInfoDto.set("fee", Convert.toDouble(wxFee));
|
||||
feeInfoDto.set("feeType", "WECHAT");
|
||||
|
||||
requestParams.set("fees", feeInfoDto);
|
||||
|
||||
|
||||
String privateKey = LakalaUtil.getResourceFile(apiPriKeyPath, false, false);
|
||||
if (StrUtil.isBlank(privateKey)) {
|
||||
logger.error("获取拉卡拉私钥失败,apiPriKeyPath={}", apiPriKeyPath);
|
||||
@ -1026,7 +1006,6 @@ public class LklTkServiceImpl {
|
||||
|
||||
|
||||
// 发送请求
|
||||
|
||||
JSONObject response = RestTemplateHttpUtil.sendLklPostSrc(
|
||||
urlPath, header, requestBody, JSONObject.class);
|
||||
|
||||
|
||||
@ -37,5 +37,15 @@ public interface ShopMchEntryBranchService {
|
||||
* @param mainStoreBranchReq 商户终端入驻申请门店信息
|
||||
* @return 创建结果
|
||||
*/
|
||||
Pair<Boolean, String> createMchEntryBranchStore(MainStoreBranchReqDTO mainStoreBranchReq);
|
||||
Pair<Boolean, String> applyMchEntryBranchStore(MainStoreBranchReqDTO mainStoreBranchReq);
|
||||
|
||||
/**
|
||||
* (重要)创建商户终端入驻申请门店信息、创建商户终端入驻申请门店员工信息、创建商户终端入驻申请门店权限信息、创建商户终端入驻申请门店入驻信息
|
||||
*
|
||||
* @param reviewRelatedId 商户终端入驻申请ID
|
||||
* @param termNo 终端号
|
||||
* @param lklNotifyResp 拉卡拉通知响应数据
|
||||
* @return 创建结果
|
||||
*/
|
||||
Pair<Boolean, String> createMchEntryBranchStore(String reviewRelatedId, String termNo, String lklNotifyResp);
|
||||
}
|
||||
|
||||
@ -19,6 +19,14 @@ import java.util.List;
|
||||
|
||||
public interface ShopMchEntryService {
|
||||
|
||||
/**
|
||||
* 新增或修改商家入驻申请信息
|
||||
*
|
||||
* @param shopMchEntry
|
||||
* @return
|
||||
*/
|
||||
Boolean saveOrUpdateShopMchEntry(ShopMchEntry shopMchEntry);
|
||||
|
||||
/**
|
||||
* 获取店铺的经营类目列表
|
||||
*
|
||||
|
||||
@ -5,6 +5,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.feignService.AccountService;
|
||||
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
||||
import com.suisung.mall.common.modules.store.ShopMchEntryBranch;
|
||||
@ -18,8 +19,10 @@ import com.suisung.mall.shop.store.mapper.ShopMchEntryMapper;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryBranchService;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -29,19 +32,23 @@ import java.util.Objects;
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryBranchMapper, ShopMchEntryBranch> implements ShopMchEntryBranchService {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ShopStoreBaseService shopStoreBaseService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ShopMchEntryService shopMchEntryService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ShopMchEntryMapper shopMchEntryMapper;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private LklTkServiceImpl lklTkService;
|
||||
|
||||
@ -126,13 +133,13 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建分店商户入驻申请
|
||||
* 检测分店信息,并向拉卡拉申请创建分店商户入驻申请
|
||||
*
|
||||
* @param mainStoreBranchReq 分店入驻请求DTO
|
||||
* @return Pair<Boolean, String> - 执行结果和提示信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> createMchEntryBranchStore(MainStoreBranchReqDTO mainStoreBranchReq) {
|
||||
public Pair<Boolean, String> applyMchEntryBranchStore(MainStoreBranchReqDTO mainStoreBranchReq) {
|
||||
log.info("开始创建分店商户入驻申请,请求参数: {}", JSONUtil.toJsonStr(mainStoreBranchReq));
|
||||
|
||||
try {
|
||||
@ -147,7 +154,7 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
return Pair.of(false, "主店ID不能为空");
|
||||
}
|
||||
|
||||
// 2. 检查主店信息是否存在
|
||||
// 2. 检查主店信息是否存在及入驻状态
|
||||
log.debug("检查主店信息是否存在,主店ID: {}", mainStoreBranchReq.getParent_store_id());
|
||||
LambdaQueryWrapper<ShopMchEntry> entryQueryWrapper = new LambdaQueryWrapper<>();
|
||||
entryQueryWrapper.eq(ShopMchEntry::getStore_id, mainStoreBranchReq.getParent_store_id())
|
||||
@ -159,27 +166,14 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
log.warn("主店商户入驻信息不存在,主店ID: {}", mainStoreBranchReq.getParent_store_id());
|
||||
return Pair.of(false, "主店商户入驻信息不存在");
|
||||
}
|
||||
log.debug("找到主店信息,商户ID: {}, 拉卡拉商户号: {}", mchEntry.getId(), mchEntry.getLkl_mer_cup_no());
|
||||
|
||||
// 3. 检查主店入驻状态是否已经完成
|
||||
log.debug("检查主店入驻状态,当前状态: {}", mchEntry.getLkl_tk_audit_status());
|
||||
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());
|
||||
|
||||
// 4. 检查主店信息是否存在(根据parent_store_id获取shop_store_base表记录)
|
||||
log.debug("检查主店基础信息是否存在");
|
||||
LambdaQueryWrapper<ShopStoreBase> baseQueryWrapper = new LambdaQueryWrapper<>();
|
||||
baseQueryWrapper.eq(ShopStoreBase::getStore_id, mainStoreBranchReq.getParent_store_id());
|
||||
ShopStoreBase parentStore = shopStoreBaseService.getOne(baseQueryWrapper);
|
||||
if (parentStore == null) {
|
||||
log.warn("主店信息不存在,主店ID: {}", mainStoreBranchReq.getParent_store_id());
|
||||
return Pair.of(false, "主店信息不存在");
|
||||
}
|
||||
log.debug("主店基础信息存在,店铺名称: {}", parentStore.getStore_name());
|
||||
|
||||
// 5. 检查店铺名称是否已经存在
|
||||
// 3. 检查店铺名称是否已经存在
|
||||
log.debug("检查店铺名称是否已存在: {}", mainStoreBranchReq.getStore_name());
|
||||
LambdaQueryWrapper<ShopStoreBase> nameQueryWrapper = new LambdaQueryWrapper<>();
|
||||
nameQueryWrapper.eq(ShopStoreBase::getStore_name, mainStoreBranchReq.getStore_name());
|
||||
@ -190,7 +184,7 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
}
|
||||
log.debug("店铺名称检查通过");
|
||||
|
||||
// 6. 检查分店登录手机号是否已经注册过商户
|
||||
// 4. 检查分店登录手机号是否已经注册过商户
|
||||
log.debug("检查手机号是否已注册商户: {}", mainStoreBranchReq.getLogin_mobile());
|
||||
Integer status = accountService.isMerchantExists(mainStoreBranchReq.getLogin_mobile());
|
||||
if (CheckUtil.isEmpty(status)) {
|
||||
@ -198,13 +192,13 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
return Pair.of(false, "检查商户信息失败!");
|
||||
}
|
||||
|
||||
if (status == CommonConstant.Enable) {
|
||||
if (CommonConstant.Enable.equals(status)) {
|
||||
log.warn("手机号商户已被注册: {}", mainStoreBranchReq.getLogin_mobile());
|
||||
return Pair.of(false, "手机号商户已被注册");
|
||||
}
|
||||
log.debug("手机号检查通过");
|
||||
|
||||
// 7. 检查分店终端号是否已经申请或申请中
|
||||
// 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())
|
||||
@ -213,35 +207,35 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
if (existingBranchCount > 0) {
|
||||
log.info("分店终端号已申请或申请中,拉卡拉内部商户号: {},已存在申请数量: {}",
|
||||
mchEntry.getLkl_mer_inner_no(), existingBranchCount);
|
||||
return Pair.of(true, "分店终端号已申请或申请中,请等待审核");
|
||||
return Pair.of(false, "分店终端号已申请或申请中,请等待审核");
|
||||
}
|
||||
log.debug("终端号检查通过");
|
||||
|
||||
// 8. 调用拉卡拉接口创建商户终端
|
||||
// 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, "分店提交申请失败");
|
||||
}
|
||||
log.info("拉卡拉接口调用成功,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
|
||||
String reviewRelatedId = lklResp.getStr("reviewRelatedId");
|
||||
log.info("拉卡拉接口调用成功,审核关联号: {}", reviewRelatedId);
|
||||
|
||||
// 9. 保存商户入驻申请信息
|
||||
// 7. 保存商户入驻申请信息
|
||||
log.debug("开始保存商户入驻申请信息");
|
||||
ShopMchEntryBranch shopMchEntryBranch = new ShopMchEntryBranch();
|
||||
shopMchEntryBranch.setLkl_mer_cup_no(mchEntry.getLkl_mer_cup_no());
|
||||
shopMchEntryBranch.setReview_related_id(lklResp.getStr("reviewRelatedId"));
|
||||
shopMchEntryBranch.setReview_related_id(reviewRelatedId);
|
||||
shopMchEntryBranch.setLkl_req(JSONUtil.toJsonStr(mainStoreBranchReq));
|
||||
shopMchEntryBranch.setLkl_reps(JSONUtil.toJsonStr(lklResp));
|
||||
|
||||
Boolean isSuccess = saveShopMchEntryBranch(shopMchEntryBranch);
|
||||
if (!isSuccess) {
|
||||
log.error("保存商户入驻申请信息失败,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
|
||||
log.error("保存商户入驻申请信息失败,审核关联号: {}", reviewRelatedId);
|
||||
return Pair.of(false, "分店提交申请失败");
|
||||
}
|
||||
log.info("商户入驻申请信息保存成功,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
|
||||
|
||||
log.info("分店商户入驻申请创建成功,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
|
||||
|
||||
return Pair.of(true, "分店提交申请成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
@ -250,5 +244,117 @@ public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryB
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (重要)创建商户终端入驻申请门店信息、创建商户终端入驻申请门店员工信息、创建商户终端入驻申请门店权限信息、创建商户终端入驻申请门店入驻信息
|
||||
*
|
||||
* @param reviewRelatedId 商户终端入驻申请ID
|
||||
* @param termNo 商户终端编号
|
||||
* @param lklNotifyResp 拉卡拉通知响应数据
|
||||
* @return 创建结果
|
||||
*/
|
||||
@GlobalTransactional
|
||||
@Override
|
||||
public Pair<Boolean, String> createMchEntryBranchStore(String reviewRelatedId, String termNo, String lklNotifyResp) {
|
||||
log.info("开始处理分店商户入驻,审核关联号: {}, 终端号: {}", reviewRelatedId, termNo);
|
||||
|
||||
// 1. 参数校验
|
||||
if (StrUtil.isBlank(reviewRelatedId) || StrUtil.isBlank(termNo)) {
|
||||
log.warn("分店商户入驻参数校验失败,reviewRelatedId: {}, termNo: {}", reviewRelatedId, termNo);
|
||||
return Pair.of(false, "参数不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
// 2. 查询分店入驻申请记录
|
||||
ShopMchEntryBranch shopMchEntryBranch = getByReviewRelatedId(reviewRelatedId);
|
||||
if (shopMchEntryBranch == null) {
|
||||
log.warn("分店商户入驻申请不存在,审核关联号: {}", reviewRelatedId);
|
||||
return Pair.of(false, "分店商户入驻申请不存在");
|
||||
}
|
||||
|
||||
// 3. 更新分店入驻申请记录
|
||||
shopMchEntryBranch.setLkl_term_no(termNo);
|
||||
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());
|
||||
if (parentShopMchEntry == null) {
|
||||
log.error("主店入驻信息不存在,拉卡拉商户号: {}", shopMchEntryBranch.getLkl_mer_cup_no());
|
||||
throw new ApiException("主店入驻信息不存在");
|
||||
}
|
||||
|
||||
// 6. 构建分店入驻信息
|
||||
ShopMchEntry shopMchEntry = new ShopMchEntry();
|
||||
// 拷贝主店基础信息
|
||||
cn.hutool.core.bean.BeanUtil.copyProperties(parentShopMchEntry, shopMchEntry, "id"); // 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());
|
||||
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getFront_facade_image())) {
|
||||
shopMchEntry.setFront_facade_image(mainStoreBranchReq.getFront_facade_image());
|
||||
}
|
||||
if (StrUtil.isBlank(mainStoreBranchReq.getEnvironment_image())) {
|
||||
shopMchEntry.setEnvironment_image(mainStoreBranchReq.getEnvironment_image());
|
||||
}
|
||||
shopMchEntry.setStatus(CommonConstant.Enable);
|
||||
|
||||
// 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());
|
||||
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(), 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());
|
||||
|
||||
return Pair.of(true, "分店商户入驻处理成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理分店商户入驻时发生异常,审核关联号: {}, 终端号: {}", reviewRelatedId, termNo, e);
|
||||
throw new ApiException("处理分店商户入驻时发生异常,审核关联号: " + reviewRelatedId + ", 终端号: " + termNo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -103,6 +103,57 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
@Resource
|
||||
private ShopStoreInfoService shopStoreInfoService;
|
||||
|
||||
/**
|
||||
* 新增或修改商家入驻申请信息
|
||||
*
|
||||
* @param shopMchEntry 商家入驻申请信息实体对象,不能为空
|
||||
* @return Boolean 操作结果,true表示成功,false表示失败
|
||||
*/
|
||||
@Override
|
||||
public Boolean saveOrUpdateShopMchEntry(ShopMchEntry shopMchEntry) {
|
||||
// 1. 参数校验
|
||||
if (shopMchEntry == null) {
|
||||
log.warn("商家入驻申请信息不能为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// 2. 记录操作日志
|
||||
Long mchId = shopMchEntry.getId();
|
||||
String storeName = shopMchEntry.getStore_name();
|
||||
String loginMobile = shopMchEntry.getLogin_mobile();
|
||||
|
||||
if (mchId != null && mchId > 0) {
|
||||
log.info("开始更新商家入驻申请信息,ID: {}, 店铺名称: {}, 手机号: {}", mchId, storeName, loginMobile);
|
||||
} else {
|
||||
log.info("开始新增商家入驻申请信息,店铺名称: {}, 手机号: {}", storeName, loginMobile);
|
||||
}
|
||||
|
||||
// 3. 执行保存或更新操作
|
||||
boolean result = saveOrUpdate(shopMchEntry);
|
||||
|
||||
// 4. 记录操作结果
|
||||
if (result) {
|
||||
if (mchId != null && mchId > 0) {
|
||||
log.info("商家入驻申请信息更新成功,ID: {}", mchId);
|
||||
} else {
|
||||
log.info("商家入驻申请信息新增成功,新ID: {}", shopMchEntry.getId());
|
||||
}
|
||||
} else {
|
||||
log.error("商家入驻申请信息保存或更新失败,ID: {}, 店铺名称: {}, 手机号: {}",
|
||||
mchId, storeName, loginMobile);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("商家入驻申请信息保存或更新异常,店铺名称: {}, 手机号: {}",
|
||||
shopMchEntry.getStore_name(), shopMchEntry.getLogin_mobile(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取店铺的经营类目列表
|
||||
*
|
||||
@ -1273,14 +1324,14 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
return null;
|
||||
}
|
||||
|
||||
QueryWrapper<ShopMchEntry> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("lkl_mer_cup_no", merCupNo).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_cup_no, merCupNo).eq(ShopMchEntry::getStatus, CommonConstant.Enable).orderByAsc(ShopMchEntry::getId);
|
||||
ShopMchEntry record = findOne(queryWrapper);
|
||||
if (ObjectUtil.isEmpty(record)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return recordList.get(0);
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -74,6 +74,7 @@ import com.suisung.mall.shop.wechat.service.WxQrCodeService;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -3281,9 +3282,10 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
// 检查店铺名称
|
||||
ShopStoreBase shopStoreBase = findOneByStoreName(shopMchEntry.getStore_name());
|
||||
if (shopStoreBase != null
|
||||
&& StrUtil.isNotBlank(shopStoreBase.getLkl_merchant_no())
|
||||
&& StrUtil.isNotBlank(shopMchEntry.getLkl_mer_cup_no())
|
||||
&& !shopStoreBase.getLkl_merchant_no().equals(shopMchEntry.getLkl_mer_cup_no())) {
|
||||
&& StringUtils.isAnyBlank(shopStoreBase.getLkl_merchant_no(), shopStoreBase.getLkl_term_no(), shopMchEntry.getLkl_mer_cup_no(), shopMchEntry.getLkl_term_no())
|
||||
&& !shopStoreBase.getLkl_merchant_no().equals(shopMchEntry.getLkl_mer_cup_no())
|
||||
&& !shopStoreBase.getLkl_term_no().equals(shopMchEntry.getLkl_term_no())
|
||||
) {
|
||||
logger.error("生成店铺:店铺名称已存在");
|
||||
return Pair.of(0, "店铺名称已存在,请使用另一名称");
|
||||
}
|
||||
@ -3532,13 +3534,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
|
||||
// 创建顺丰店铺
|
||||
// if (storeArea != null) {
|
||||
// String[] areaNames = storeArea.split("/");
|
||||
// String cityName = areaNames.length > 0 ? areaNames[areaNames.length - 1] : storeArea.replace("/", "");
|
||||
|
||||
sfExpressApiService.createSfExpressShop(mchId, storeId, shopMchEntry.getContact_name(),
|
||||
contact_mobile, shopMchEntry.getStore_longitude(), shopMchEntry.getStore_latitude());
|
||||
// }
|
||||
|
||||
return Pair.of(storeId, "新增成功");
|
||||
} catch (Exception e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user