分店逻辑增加

This commit is contained in:
Jack 2025-12-25 01:24:11 +08:00
parent 43dacf4744
commit 1897281b38
12 changed files with 552 additions and 52 deletions

View File

@ -85,5 +85,17 @@ public class AccountUserBindConnectController {
return accountUserBindConnectService.getUserBindConnectUserIdByCondition(bind_id, bind_type, user_type);
}
/**
* 检查手机注册的商家是否存在(仅供内部调用)
*
* @param mobile
* @return
*/
@ApiOperation(value = "检查手机注册的商家是否存在(仅供内部调用)", notes = "检查手机注册的商家是否存在(仅供内部调用)")
@RequestMapping(value = "/is-merchant-exists", method = RequestMethod.POST)
public Integer isMerchantExists(@RequestParam(name = "mobile") String mobile) {
return accountUserBindConnectService.isMerchantExists(mobile);
}
}

View File

@ -4,6 +4,7 @@ import cn.hutool.json.JSONObject;
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
import com.suisung.mall.core.web.service.IBaseService;
import java.util.List;
import java.util.Map;
@ -89,9 +90,17 @@ public interface AccountUserBindConnectService extends IBaseService<AccountUserB
*/
AccountUserBindConnect initAccountUserBindConnect(String bindId, Integer bindType, Integer userId, Integer userType);
List<AccountUserBindConnect> getAllBindPage(String bindTmpl,Integer pageNum, Integer pageSize);
List<AccountUserBindConnect> getAllBindPage(String bindTmpl, Integer pageNum, Integer pageSize);
long getAllBindCount(String bindTmpl);
void bindTmplId(JSONObject jsonObject);
/**
* 检查手机注册的商家是否存在
*
* @param mobile
* @return 1-存在2-不存在3-参数有误
*/
Integer isMerchantExists(String mobile);
}

View File

@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.suisung.mall.account.mapper.AccountUserBindConnectMapper;
@ -19,6 +20,7 @@ import com.suisung.mall.common.modules.account.AccountUserBase;
import com.suisung.mall.common.modules.account.AccountUserBindConnect;
import com.suisung.mall.common.modules.account.AccountUserInfo;
import com.suisung.mall.common.pojo.req.WxUserInfoReq;
import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.common.utils.StringUtils;
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
@ -367,6 +369,65 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
}
}
/**
* 检查手机注册的商家是否存在
*
* @param mobile
* @return 1-已存在 2-不存在 3-格式错误
*/
@Override
public Integer isMerchantExists(String mobile) {
log.debug("检查商家是否存在,手机号: {}", mobile);
if (StrUtil.isBlank(mobile)) {
log.warn("手机号为空,无法检查商家是否存在");
return 3;
}
try {
String convertedMobile = PhoneNumberUtils.convZhPhoneNumber(mobile);
if (CheckUtil.isEmpty(convertedMobile)) {
log.warn("手机号格式无效: {}", mobile);
return 3;
}
// 使用正确的绑定类型检查手机号
LambdaQueryWrapper<AccountUserBindConnect> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AccountUserBindConnect::getBind_id, convertedMobile)
.eq(AccountUserBindConnect::getBind_type, BindCode.MOBILE) // 1-手机号
.eq(AccountUserBindConnect::getUser_type, CommonConstant.USER_TYPE_MCH) // 2-入驻商家
.eq(AccountUserBindConnect::getBind_active, CommonConstant.Enable)
.orderByAsc(AccountUserBindConnect::getBind_time)
.select(AccountUserBindConnect::getUser_id);
log.debug("执行查询,转换后的手机号: {}, 查询条件: {}", convertedMobile, queryWrapper.getSqlSegment());
AccountUserBindConnect accountUserBindConnect = getOne(queryWrapper);
if (accountUserBindConnect == null || CheckUtil.isEmpty(accountUserBindConnect.getUser_id())) {
log.info("未找到手机号绑定的商家记录,手机号: {}", convertedMobile);
return 2;
}
Integer userId = accountUserBindConnect.getUser_id();
log.debug("找到用户ID: {}", userId);
AccountUserBase accountUserBase = accountUserBaseService.get(userId);
if (accountUserBase == null) {
log.warn("用户基础信息不存在用户ID: {}", userId);
return 2;
}
log.info("商家存在用户ID: {}", userId);
return 1;
} catch (Exception e) {
log.error("查询商家绑定信息时发生异常,手机号: {}", mobile, e);
return null;
}
}
/**
* 用户绑定手机号和openid
*
@ -505,24 +566,24 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
}
@Override
public List<AccountUserBindConnect> getAllBindPage(String bindTmpl,Integer pageNum, Integer pageSize) {
public List<AccountUserBindConnect> getAllBindPage(String bindTmpl, Integer pageNum, Integer pageSize) {
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
queryWrapper.select("bind_id,bind_type,user_id,user_type");
queryWrapper.in("bind_type", Arrays.asList(BindCode.MOBILE,BindCode.WEIXIN_XCX))
queryWrapper.in("bind_type", Arrays.asList(BindCode.MOBILE, BindCode.WEIXIN_XCX))
.eq("user_type", CommonConstant.USER_TYPE_NORMAL)
.eq("bind_active", CommonConstant.Enable)
.eq("bind_tmpl",bindTmpl)
.eq("bind_tmpl", bindTmpl)
.orderByAsc("bind_time");
return this.lists(queryWrapper,pageNum,pageSize).getRecords();
return this.lists(queryWrapper, pageNum, pageSize).getRecords();
}
@Override
public long getAllBindCount(String bindTmpl) {
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
queryWrapper.in("bind_type", Arrays.asList(BindCode.MOBILE,BindCode.WEIXIN_XCX))
queryWrapper.in("bind_type", Arrays.asList(BindCode.MOBILE, BindCode.WEIXIN_XCX))
.eq("user_type", CommonConstant.USER_TYPE_NORMAL)
.eq("bind_active", CommonConstant.Enable)
.eq("bind_tmpl",bindTmpl)
.eq("bind_tmpl", bindTmpl)
.orderByAsc("bind_time");
return this.count(queryWrapper);
}
@ -537,42 +598,42 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
// log.info("错误信息--{}",e.getMessage());
// }
log.info("jsonObject:{}", jsonObject);
String openId=jsonObject.getStr("FromUserName");//用户openid
String openId = jsonObject.getStr("FromUserName");//用户openid
QueryWrapper<AccountUserBindConnect> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("bind_openid",openId)
queryWrapper.eq("bind_openid", openId)
.eq("user_type", CommonConstant.USER_TYPE_NORMAL)
.in("bind_type",Arrays.asList(1,15))
.in("bind_type", Arrays.asList(1, 15))
.eq("bind_active", CommonConstant.Enable);
List<AccountUserBindConnect> accountUserBindConnectList= list(queryWrapper);
List<AccountUserBindConnect> accountUserBindConnectList = list(queryWrapper);
if (!accountUserBindConnectList.isEmpty()) {
AccountUserBindConnect accountUserBindConnect=accountUserBindConnectList.get(0);
JSONArray jsonArray=null;
JSONObject object= null;
AccountUserBindConnect accountUserBindConnect = accountUserBindConnectList.get(0);
JSONArray jsonArray = null;
JSONObject object = null;
try {
jsonArray= jsonObject.getJSONArray("List");
}catch (RuntimeException runtimeException){
jsonArray = jsonObject.getJSONArray("List");
} catch (RuntimeException runtimeException) {
log.info("单个模板");
object=jsonObject.getJSONObject("List");
object = jsonObject.getJSONObject("List");
}
UpdateWrapper<AccountUserBindConnect> updateWrapper = new UpdateWrapper<>();
if (jsonArray != null) {
object= (JSONObject) jsonArray.get(0);
String templateId= object.getStr("TemplateId");//模板id
String SubscribeStatusString= object.getStr("SubscribeStatusString");//订阅结果accept接收reject拒收参考地址https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html#%E8%AE%A2%E9%98%85%E6%B6%88%E6%81%AF%E8%AF%AD%E9%9F%B3%E6%8F%90%E9%86%92
if(SubscribeStatusString.equals("accept")){
object = (JSONObject) jsonArray.get(0);
String templateId = object.getStr("TemplateId");//模板id
String SubscribeStatusString = object.getStr("SubscribeStatusString");//订阅结果accept接收reject拒收参考地址https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message.html#%E8%AE%A2%E9%98%85%E6%B6%88%E6%81%AF%E8%AF%AD%E9%9F%B3%E6%8F%90%E9%86%92
if (SubscribeStatusString.equals("accept")) {
accountUserBindConnect.setBind_tmpl(templateId);
getUpdateWrapper(updateWrapper, accountUserBindConnect);
}
}else {
} else {
assert object != null;
String templateId= object.getStr("TemplateId");//模板id
String SubscribeStatusString= object.getStr("SubscribeStatusString");
if(StringUtils.isNotEmpty(SubscribeStatusString)&&SubscribeStatusString.equals("accept")){
String templateId = object.getStr("TemplateId");//模板id
String SubscribeStatusString = object.getStr("SubscribeStatusString");
if (StringUtils.isNotEmpty(SubscribeStatusString) && SubscribeStatusString.equals("accept")) {
accountUserBindConnect.setBind_tmpl(templateId);
getUpdateWrapper(updateWrapper, accountUserBindConnect);
}else {
String ErrorStatus=object.getStr("ErrorStatus");
if(ErrorStatus.equals("success")){
} else {
String ErrorStatus = object.getStr("ErrorStatus");
if (ErrorStatus.equals("success")) {
log.info("消息推送成功给用户,不需要操作");
return;
}
@ -584,16 +645,17 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl<AccountUs
/**
* 封装相同参数的调用方法
*
* @param updateWrapper
* @param accountUserBindConnect
*/
private void getUpdateWrapper(UpdateWrapper<AccountUserBindConnect> updateWrapper,
AccountUserBindConnect accountUserBindConnect) {
updateWrapper.set("bind_tmpl",accountUserBindConnect.getBind_tmpl());
updateWrapper.eq("bind_id",accountUserBindConnect.getBind_id());
updateWrapper.eq("bind_type",accountUserBindConnect.getBind_type());
updateWrapper.eq("user_id",accountUserBindConnect.getUser_id());
updateWrapper.eq("user_type",accountUserBindConnect.getUser_type());
updateWrapper.set("bind_tmpl", accountUserBindConnect.getBind_tmpl());
updateWrapper.eq("bind_id", accountUserBindConnect.getBind_id());
updateWrapper.eq("bind_type", accountUserBindConnect.getBind_type());
updateWrapper.eq("user_id", accountUserBindConnect.getUser_id());
updateWrapper.eq("user_type", accountUserBindConnect.getUser_type());
}
}

View File

@ -303,4 +303,14 @@ public interface AccountService {
@GetMapping(value = "/admin/account/accountController/getAllBindCount")
long getAllBindCount(@RequestParam(name = "bindTmpl") String bindTmpl);
/**
* 检查手机注册的商家是否存在(仅供内部调用)
*
* @param mobile
* @return
*/
@RequestMapping(value = "/admin/account/account-user-bind-connect/is-merchant-exists", method = RequestMethod.POST)
Integer isMerchantExists(@RequestParam(name = "mobile") String mobile);
}

View File

@ -0,0 +1,72 @@
package com.suisung.mall.common.pojo.dto;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 新增主店的分店的请求DTO实体类
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "新增主店的分店的请求DTO实体类", description = "新增主店的分店的请求DTO实体类")
public class MainStoreBranchReqDTO implements java.io.Serializable {
private static final long serialVersionUID = 1L;
/**
* 主店店铺 ID
*/
private Integer parent_store_id;
/**
* 登录手机号
*/
private String login_mobile;
/**
* 登录密码
*/
private String password;
/**
* 分店名称
*/
private String store_name;
/**
* 分店联系人
*/
private String contact_name;
/**
* 分店联系人手机号
*/
private String email;
/**
* 门头图片
*/
private String front_facade_image;
/**
* 环境图片
*/
private String environment_image;
/**
* 分店地址
*/
private String store_address;
/**
* 分店经度
*/
private String store_longitude;
/**
* 分店纬度
*/
private String store_latitude;
}

View File

@ -0,0 +1,17 @@
/*
* 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.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.suisung.mall.common.modules.store.ShopMchEntryBranch;
import org.springframework.stereotype.Component;
@Component
public interface ShopMchEntryBranchMapper extends BaseMapper<ShopMchEntryBranch> {
}

View File

@ -0,0 +1,41 @@
/*
* 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.service;
import com.suisung.mall.common.modules.store.ShopMchEntryBranch;
import com.suisung.mall.common.pojo.dto.MainStoreBranchReqDTO;
import org.springframework.data.util.Pair;
public interface ShopMchEntryBranchService {
/**
* 保存或更新商户终端入驻申请信息
*
* @param shopMchEntryBranch 商户入驻申请信息
* @return 保存结果
*/
Boolean saveShopMchEntryBranch(ShopMchEntryBranch shopMchEntryBranch);
/**
* 根据商户终端入驻申请ID查询商户终端入驻申请信息
*
* @param reviewRelatedId 商户终端入驻申请ID
* @return 商户入驻申请信息
*/
ShopMchEntryBranch getByReviewRelatedId(String reviewRelatedId);
/**
* 重要创建主店铺的分店账号店铺信息店铺员工信息店铺权限信息入驻信息
*
* @param mainStoreBranchReq 商户终端入驻申请门店信息
* @return 创建结果
*/
Pair<Boolean, String> createMchEntryBranchStore(MainStoreBranchReqDTO mainStoreBranchReq);
}

View File

@ -9,6 +9,7 @@
package com.suisung.mall.shop.store.service;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.modules.store.ShopMchEntry;
import org.springframework.data.util.Pair;
@ -375,4 +376,6 @@ public interface ShopMchEntryService {
* @return
*/
ShopMchEntry getLklContractStatusUrl(Integer storeId);
ShopMchEntry findOneByLambdaQueryWrapper(LambdaQueryWrapper<ShopMchEntry> query);
}

View File

@ -0,0 +1,254 @@
package com.suisung.mall.shop.store.service.impl;
import cn.hutool.core.util.StrUtil;
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.feignService.AccountService;
import com.suisung.mall.common.modules.store.ShopMchEntry;
import com.suisung.mall.common.modules.store.ShopMchEntryBranch;
import com.suisung.mall.common.modules.store.ShopStoreBase;
import com.suisung.mall.common.pojo.dto.MainStoreBranchReqDTO;
import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.lakala.service.impl.LklTkServiceImpl;
import com.suisung.mall.shop.store.mapper.ShopMchEntryBranchMapper;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.Objects;
@Slf4j
@Service
public class ShopMchEntryBranchServiceImpl extends BaseServiceImpl<ShopMchEntryBranchMapper, ShopMchEntryBranch> implements ShopMchEntryBranchService {
@Autowired
private ShopStoreBaseService shopStoreBaseService;
@Autowired
private ShopMchEntryService shopMchEntryService;
@Autowired
private AccountService accountService;
@Autowired
private ShopMchEntryMapper shopMchEntryMapper;
@Autowired
private LklTkServiceImpl lklTkService;
/**
* 保存或更新商户终端入驻申请信息
* <p>
* 根据 reviewRelatedId 确定新增或更改记录
*
* @param shopMchEntryBranch 商户入驻申请信息
* @return 保存结果
*/
@Override
public Boolean saveShopMchEntryBranch(ShopMchEntryBranch shopMchEntryBranch) {
try {
if (shopMchEntryBranch == null) {
log.error("商户终端入驻申请信息不能为空");
return false;
}
// 验证必要字段
if (StrUtil.isBlank(shopMchEntryBranch.getReview_related_id())) {
log.error("审核关联号不能为空");
return false;
}
String reviewRelatedId = shopMchEntryBranch.getReview_related_id();
// 查询是否已存在记录
ShopMchEntryBranch existingRecord = getByReviewRelatedId(reviewRelatedId);
boolean result;
if (existingRecord != null) {
// 更新现有记录
shopMchEntryBranch.setId(existingRecord.getId());
result = updateById(shopMchEntryBranch);
log.info("更新商户终端入驻申请信息成功,审核关联号: {}", reviewRelatedId);
} else {
// 新增记录
result = save(shopMchEntryBranch);
log.info("新增商户终端入驻申请信息成功,审核关联号: {}", reviewRelatedId);
}
return result;
} catch (Exception e) {
log.error("保存或更新商户终端入驻申请信息失败,审核关联号: {}",
shopMchEntryBranch != null ? shopMchEntryBranch.getReview_related_id() : "null", e);
return false;
}
}
/**
* 根据商户终端入驻申请ID查询商户终端入驻申请信息
*
* @param reviewRelatedId 商户终端入驻申请ID
* @return 商户入驻申请信息
*/
@Override
public ShopMchEntryBranch getByReviewRelatedId(String reviewRelatedId) {
try {
if (StrUtil.isBlank(reviewRelatedId)) {
log.warn("审核关联号为空,无法查询商户终端入驻申请信息");
return null;
}
LambdaQueryWrapper<ShopMchEntryBranch> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ShopMchEntryBranch::getReview_related_id, reviewRelatedId);
ShopMchEntryBranch result = findOne(queryWrapper);
if (result != null) {
log.debug("查询商户终端入驻申请信息成功,审核关联号: {}", reviewRelatedId);
} else {
log.info("未找到对应的商户终端入驻申请信息,审核关联号: {}", reviewRelatedId);
}
return result;
} catch (Exception e) {
log.error("查询商户终端入驻申请信息失败,审核关联号: {}", reviewRelatedId, e);
return null;
}
}
/**
* 创建分店商户入驻申请
*
* @param mainStoreBranchReq 分店入驻请求DTO
* @return Pair<Boolean, String> - 执行结果和提示信息
*/
@Override
public Pair<Boolean, String> createMchEntryBranchStore(MainStoreBranchReqDTO mainStoreBranchReq) {
log.info("开始创建分店商户入驻申请,请求参数: {}", JSONUtil.toJsonStr(mainStoreBranchReq));
try {
// 1. 参数校验
if (mainStoreBranchReq == null) {
log.warn("分店入驻信息不能为空");
return Pair.of(false, "分店入驻信息不能为空");
}
if (mainStoreBranchReq.getParent_store_id() == null) {
log.warn("主店ID不能为空");
return Pair.of(false, "主店ID不能为空");
}
// 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.Enable)
.eq(ShopMchEntry::getParent_id, 0L);
ShopMchEntry mchEntry = shopMchEntryService.findOneByLambdaQueryWrapper(entryQueryWrapper);
if (mchEntry == null) {
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, "主店入驻状态未完成,无法创建分店");
}
// 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. 检查店铺名称是否已经存在
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());
return Pair.of(false, "店铺名称已存在");
}
log.debug("店铺名称检查通过");
// 6. 检查分店登录手机号是否已经注册过商户
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 (status == CommonConstant.Enable) {
log.warn("手机号商户已被注册: {}", mainStoreBranchReq.getLogin_mobile());
return Pair.of(false, "手机号商户已被注册");
}
log.debug("手机号检查通过");
// 7. 检查分店终端号是否已经申请或申请中
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);
return Pair.of(true, "分店终端号已申请或申请中,请等待审核");
}
log.debug("终端号检查通过");
// 8. 调用拉卡拉接口创建商户终端
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"));
// 9. 保存商户入驻申请信息
log.debug("开始保存商户入驻申请信息");
ShopMchEntryBranch shopMchEntryBranch = new ShopMchEntryBranch();
shopMchEntryBranch.setLkl_mer_cup_no(mchEntry.getLkl_mer_cup_no());
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("保存商户入驻申请信息失败,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
return Pair.of(false, "分店提交申请失败");
}
log.info("商户入驻申请信息保存成功,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
log.info("分店商户入驻申请创建成功,审核关联号: {}", lklResp.getStr("reviewRelatedId"));
return Pair.of(true, "分店提交申请成功");
} catch (Exception e) {
log.error("创建分店商户入驻申请时发生异常,请求参数: {}", JSONUtil.toJsonStr(mainStoreBranchReq), e);
return Pair.of(false, "分店提交申请失败:" + e.getMessage());
}
}
}

View File

@ -2579,6 +2579,29 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
}
}
/**
* 根据Lambda查询条件获取单个商户入驻记录
*
* @param query Lambda查询条件不能为空
* @return 商户入驻记录未找到时返回null
*/
@Override
public ShopMchEntry findOneByLambdaQueryWrapper(LambdaQueryWrapper<ShopMchEntry> query) {
// 参数校验
if (query == null) {
log.warn("查询条件为空,无法执行查询");
return null;
}
try {
// 执行查询
return findOne(query);
} catch (Exception e) {
log.error("执行商户入驻查询时发生异常", e);
return null;
}
}
}

View File

@ -2473,12 +2473,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
}
// 打包费
BigDecimal packingFee = Convert.toBigDecimal(getParameter("packing_fee"));
if (packingFee == null || packingFee.compareTo(BigDecimal.ZERO) <= 0) {
packingFee = BigDecimal.ZERO;
}
if (packingFee.compareTo(new BigDecimal("10")) > 0) {
BigDecimal packingFee = Convert.toBigDecimal(getParameter("packing_fee"), BigDecimal.ZERO);
if (packingFee.compareTo(new BigDecimal("10")) >= 0) {
logger.warn("打包费超出范围: {}", packingFee);
return CommonResult.failed("打包费请控制在0到10元范围");
}
@ -2668,12 +2664,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
}
// 打包费
BigDecimal packingFee = Convert.toBigDecimal(getParameter("packing_fee"));
if (packingFee == null || packingFee.compareTo(BigDecimal.ZERO) <= 0) {
packingFee = BigDecimal.ZERO;
}
if (packingFee.compareTo(new BigDecimal("10")) > 0) {
BigDecimal packingFee = Convert.toBigDecimal(getParameter("packing_fee"), BigDecimal.ZERO);
if (packingFee.compareTo(new BigDecimal("10")) >= 0) {
logger.warn("打包费超出范围: {}", packingFee);
return CommonResult.failed("打包费请控制在0到10元范围");
}
@ -3327,6 +3319,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
if (CheckUtil.isEmpty(shopStoreBase.getSplit_ratio())) {
shopStoreBase.setSplit_ratio(splitRatio);
}
if (CheckUtil.isEmpty(shopStoreBase.getPacking_fee())) {
shopStoreBase.setPacking_fee(BigDecimal.ZERO);
}

View File

@ -16,7 +16,6 @@ import com.suisung.mall.common.api.ResultCode;
import com.suisung.mall.common.api.StateCode;
import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.domain.UserDto;
import com.suisung.mall.common.enums.DicEnum;
import com.suisung.mall.common.exception.ApiException;
import com.suisung.mall.common.exception.ApiUserException;
import com.suisung.mall.common.feignService.AccountService;
@ -52,7 +51,6 @@ import com.suisung.mall.shop.product.pojo.vo.FixOrderVo;
import com.suisung.mall.shop.product.pojo.vo.ProductVo;
import com.suisung.mall.shop.product.service.*;
import com.suisung.mall.shop.store.service.*;
import com.suisung.mall.shop.sync.keymanage.RedisKey;
import com.suisung.mall.shop.user.mapper.ShopUserCartMapper;
import com.suisung.mall.shop.user.service.ShopUserCartService;
import com.suisung.mall.shop.user.service.ShopUserDeliveryAddressService;
@ -3156,20 +3154,26 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
// logger.info("店铺ID为{},同城配送,收取打包费{}元", storeId, packingFee);
// 如果打包费为空或小于等于0直接返回0
if (packingFee == null || packingFee.compareTo(BigDecimal.ZERO) <= 0) {
if (CheckUtil.isEmpty(packingFee)) {
return BigDecimal.ZERO;
}
deliveryTypeId = deliveryTypeId == null ? StateCode.DELIVERY_TYPE_SAME_CITY : deliveryTypeId;
// deliveryTypeId = deliveryTypeId == null ? StateCode.DELIVERY_TYPE_SAME_CITY : deliveryTypeId;
// 只有同城配送才收取打包费
if (Boolean.FALSE.equals(isVirtualOrder)
&& deliveryTypeId != null && deliveryTypeId.intValue() == StateCode.DELIVERY_TYPE_SAME_CITY) {
// if (Boolean.FALSE.equals(isVirtualOrder)
// && deliveryTypeId != null && (deliveryTypeId.intValue() == StateCode.DELIVERY_TYPE_SAME_CITY)
// || deliveryTypeId.intValue() == StateCode.DELIVERY_TYPE_IN_STORE_SERVICE) {
// logger.debug("店铺ID同城配送符合收取打包费{}元", storeId, packingFee);
// return packingFee;
// }
if (Boolean.FALSE.equals(isVirtualOrder)) {
logger.debug("店铺ID同城配送符合收取打包费{}元", storeId, packingFee);
return packingFee;
}
// 非同城配送不收取打包费
// 虚拟商品不收取打包费
return BigDecimal.ZERO;
}