入驻流程 fix bug,增加审核错误返回逻辑

This commit is contained in:
Jack 2025-06-24 22:40:26 +08:00
parent d856c1c501
commit 7adbd801cd
8 changed files with 129 additions and 56 deletions

View File

@ -40,9 +40,9 @@ public class ContextUtil {
public static UserDto getCurrentUser() {
try {
UserDto loginUser = staticUserInfoService.getUser();
log.info("##### 当前登录用户:{}###", JsonUtil.object2json(loginUser));
return loginUser;//todo 测试去除
// UserDto user= new UserDto();
// log.info("##### 当前登录用户:{}###", JsonUtil.object2json(loginUser));
return loginUser;//todo 测试去除
// UserDto user= new UserDto();
//user.setStore_id("1");
//user.setRole_id(9);
//user.setUser_account("18260885688");
@ -81,14 +81,15 @@ public class ContextUtil {
/**
* 传入的
*
* @param storeId
* @return
*/
public static String getStoreId(String storeId){
if(getCurrentUser()==null){
public static String getStoreId(String storeId) {
if (getCurrentUser() == null) {
throw new RuntimeException("未登录");
}
if(Objects.requireNonNull(getCurrentUser()).getRole_id()==9){//平台
if (Objects.requireNonNull(getCurrentUser()).getRole_id() == 9) {//平台
return storeId;
}
return Objects.requireNonNull(getCurrentUser()).getStore_id();
@ -96,10 +97,11 @@ public class ContextUtil {
/**
* 校验是否为平台
*
* @return
*/
public static boolean checkouRole(){
UserDto userDto=getCurrentUser();
public static boolean checkouRole() {
UserDto userDto = getCurrentUser();
assert userDto != null;
return userDto.getRole_id() == 9;
}

View File

@ -42,12 +42,13 @@ public interface LklLedgerEcService extends IBaseService<LklLedgerEc> {
/**
* 根据商户手机号查询记录
*
* @param mchId
* @param mchMobile
* @param ecStatus
* @param status
* @return
*/
LklLedgerEc getByMchMobile(String mchMobile, String ecStatus, Integer status);
LklLedgerEc getByMchMobile(Long mchId, String mchMobile, String ecStatus, Integer status);
}

View File

@ -384,9 +384,14 @@ public class LakalaApiServiceImpl implements LakalaApiService {
return Pair.of(false, I18nUtil._("缺少商家相关信息!"));
}
LklLedgerEc lklLedgerEc = lklLedgerEcService.getByMchMobile(mchMobile, "", CommonConstant.Enable);
if (lklLedgerEc != null && "COMPLETED".equals(lklLedgerEc.getEc_status())) {
return Pair.of(true, I18nUtil._("商家已经申请过入网电子合同!"));
LklLedgerEc lklLedgerEc = lklLedgerEcService.getByMchMobile(shopMchEntry.getId(), mchMobile, "", CommonConstant.Enable);
if (lklLedgerEc != null
&& "COMPLETED".equals(lklLedgerEc.getEc_status())) {
// TODO 这种情况需要怎么处理
// 更新拉卡拉的电子合同信息到商家入驻表中
// return Pair.of(true, I18nUtil._("已提交进件申请,请等待机构审核!"));
log.info("商户:{} 电子合同已签署过,重新提交将被覆盖!", mchMobile);
}
// 是企业类型商家
@ -535,6 +540,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
record.setReq_params(reqBody.toString());
record.setNotify_url(retUrl);
record.setEc_apply_id(respData.getLong("ec_apply_id"));
record.setStatus(CommonConstant.Enable);
String ecResultUrl = respData.getStr("result_url");
record.setResult_url(ecResultUrl);
record.setResp_body(respBody.toString());

View File

@ -129,19 +129,28 @@ public class LklLedgerEcServiceImpl extends BaseServiceImpl<LklLedgerEcMapper, L
/**
* 根据商户手机号查询记录
*
* @param mchId
* @param mchMobile
* @param ecStatus
* @param status
* @return
*/
@Override
public LklLedgerEc getByMchMobile(String mchMobile, String ecStatus, Integer status) {
if (ObjectUtil.isEmpty(mchMobile)) {
public LklLedgerEc getByMchMobile(Long mchId, String mchMobile, String ecStatus, Integer status) {
if (StrUtil.isBlank(mchMobile) && (mchId == null || mchId <= 0)) {
return null;
}
QueryWrapper<LklLedgerEc> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("mch_mobile", mchMobile).orderByDesc("id");
if (StrUtil.isNotBlank(mchMobile)) {
queryWrapper.eq("mch_mobile", mchMobile);
}
if (mchId != null && mchId > 0) {
queryWrapper.eq("mch_id", mchId);
}
queryWrapper.orderByDesc("id");
if (ObjectUtil.isNotEmpty(status)) {
queryWrapper.eq("status", status);
}

View File

@ -606,7 +606,7 @@ public class LklTkServiceImpl {
// 给商家入驻表增加拉卡拉的商户号和拉卡拉返回的数据
if (ObjectUtil.isEmpty(shopMchEntry)) {
if (shopMchEntry == null) {
logger.error("拉卡拉进件异步通知:{}内部商户号入驻信息不存在!", merInnerNo);
return new JSONObject().put("code", "500").put("message", merInnerNo + "内部商户号入驻信息不存在");
}
@ -642,11 +642,10 @@ public class LklTkServiceImpl {
String mchMobile = shopEntry.getLogin_mobile();
try {
Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, false);
Pair<Integer, String> retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, true);
if (retPair.getFirst() > 0) {
boolean updateSuccess = shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0, 1, CommonConstant.MCH_APPR_STA_LKL_PADDING);
// boolean updateSuccess = shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable);
boolean updateSuccess = shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING);
if (!updateSuccess) {
logger.warn("更新店铺状态失败: mchMobile={}", mchMobile);
} else {
@ -663,7 +662,6 @@ public class LklTkServiceImpl {
}
// 1电子合同给商家申请分账功能使用务必检查是否申请过申请过忽略
// 下一步等待拉卡拉审核通过再绑定接收方和商家的关系
Pair<Boolean, String> retPair = lakalaApiService.innerApplyLedgerMer(merCupNo);
// 2新增一个接收方记录起码要一个平台方代理商根据入驻信息新增

View File

@ -10,6 +10,7 @@ package com.suisung.mall.shop.store.controller.mobile;
import cn.hutool.json.JSONObject;
import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.modules.store.ShopMchEntry;
import com.suisung.mall.common.service.impl.BaiduMapServiceImpl;
import com.suisung.mall.common.service.impl.BaseControllerImpl;
@ -17,12 +18,14 @@ import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
import com.suisung.mall.shop.store.service.ShopMchEntryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Slf4j
@Api(tags = "店铺基础信息表")
@RestController
@RequestMapping("/mobile/shop/merch")
@ -74,30 +77,79 @@ public class ShopMchEntryController extends BaseControllerImpl {
return record.getApproval_status();
}
/**
* 获取商家入驻审核状态终端接口调用
*
* <p>根据手机号查询商家入驻信息并返回当前审核状态及相关字段
* 若未找到记录或状态为空则返回默认值以适配前端需求</p>
*
* @param jsonParam 请求参数包含手机号 "mobile"
* @return CommonResult 包含审核状态及扩展字段的封装结果
*/
@ApiOperation(value = "通过手机号mobile获取商家入驻审核状态", notes = "通过手机号获取商家入驻审核状态,终端接口调用")
@RequestMapping(value = "/fresh/approval/status", method = RequestMethod.POST)
public CommonResult shopMerchEntryApprovalStatus2(@RequestBody JSONObject jsonParam) {
// approvalStatus 入驻商家的审批状态1-已通过2-未通过3-待审核4-未申请
ShopMchEntry record = shopMchEntryService.shopMerchEntryApprovalInfo(jsonParam.getStr("mobile"));
Map<String, Object> result = new HashMap<>();
if (record == null || record.getApproval_status() == null) {
// 配合前端的要求没有申请过入驻商城平台的时候返回未申请状态
result.put("id", 0L);
result.put("approval_status", 4);
result.put("approval_remark", "");
result.put("signed_status", -1);
result.put("store_status", 2);
result.put("approval_invalid_col", "[]");
} else {
result.put("id", record.getId());
result.put("approval_status", record.getApproval_status());
result.put("approval_remark", record.getApproval_remark());
result.put("signed_status", record.getSigned_status());
result.put("store_status", record.getStore_status());
result.put("approval_invalid_col", record.getApproval_invalid_col());
}
try {
// 参数校验防止空指针和无效请求
if (jsonParam == null || !jsonParam.containsKey("mobile")) {
return CommonResult.failed("请求参数缺失:必须提供 mobile 字段");
}
return CommonResult.success(result);
String mobile = jsonParam.getStr("mobile");
if (mobile == null || mobile.isEmpty()) {
return CommonResult.failed("手机号不能为空");
}
// 查询商家入驻审核信息一次调用获取所有数据
ShopMchEntry entry = shopMchEntryService.shopMerchEntryApprovalInfo(mobile);
// 初始化结果 Map使用基本类型常量避免动态字符串拼接
Map<String, Object> result = new HashMap<>(16);
// 如果无记录或状态为空填充默认值
if (entry == null || entry.getApproval_status() == null) {
result.put("id", 0L);
result.put("approval_status", CommonConstant.MCH_APPR_STA_NONE);
result.put("approval_remark", "");
result.put("has_ec_signed", CommonConstant.Disable);
result.put("has_apply_mer", CommonConstant.Disable);
result.put("store_status", CommonConstant.Disable);
result.put("has_apply_split", CommonConstant.Disable);
result.put("has_apply_receiver", CommonConstant.Disable);
result.put("has_bind_receiver", CommonConstant.Disable);
result.put("approval_invalid_col", "[]");
} else {
// 存在记录直接赋值避免多次调用 getter
Long id = entry.getId();
Integer approvalStatus = entry.getApproval_status();
String approvalRemark = entry.getApproval_remark();
Integer hasEcSigned = entry.getHas_ec_signed();
Integer hasApplyMer = entry.getHas_apply_mer();
Integer storeStatus = entry.getStore_status();
Integer hasApplySplit = entry.getHas_apply_split();
Integer hasApplyReceiver = entry.getHas_apply_receiver();
Integer hasBindReceiver = entry.getHas_bind_receiver();
String approvalInvalidCol = entry.getApproval_invalid_col();
// 避免重复调用 put集中设置
result.put("id", id != null ? id : 0L);
result.put("approval_status", approvalStatus);
result.put("approval_remark", approvalRemark != null ? approvalRemark : "");
result.put("has_ec_signed", hasEcSigned != null ? hasEcSigned : CommonConstant.Disable);
result.put("has_apply_mer", hasApplyMer != null ? hasApplyMer : CommonConstant.Disable);
result.put("store_status", storeStatus != null ? storeStatus : CommonConstant.Disable);
result.put("has_apply_split", hasApplySplit != null ? hasApplySplit : CommonConstant.Disable);
result.put("has_apply_receiver", hasApplyReceiver != null ? hasApplyReceiver : CommonConstant.Disable);
result.put("has_bind_receiver", hasBindReceiver != null ? hasBindReceiver : CommonConstant.Disable);
result.put("approval_invalid_col", approvalInvalidCol != null ? approvalInvalidCol : "[]");
}
return CommonResult.success(result);
} catch (Exception e) {
log.error("获取商家入驻审核状态失败,手机号: {}, 错误信息: {}", jsonParam.getStr("mobile"), e.getMessage(), e);
return CommonResult.failed("系统异常,请稍后重试");
}
}
@ApiOperation(value = "商家重新申请入驻商城平台", notes = "商家申请入驻材料被驳回的时候,修正材料,重新申请入驻")

View File

@ -173,6 +173,11 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return CommonResult.failed(isApplied.getSecond());
}
if (shopStoreBaseService.isExistsByStoreName(record.getStore_name())) {
log.error("生成店铺:店铺名称已存在");
return CommonResult.failed("店铺名称已存在");
}
Boolean isQy = true;
// 检查企业法人或个人的营业执照或身份证
@ -778,7 +783,6 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
QueryWrapper<ShopMchEntry> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("login_mobile", loginMobile)
.select("id", "approval_status", "approval_remark", "login_mobile", "approval_invalid_col", "signed_status", "contract_download_url", "store_status")
.orderByAsc("id");
List<ShopMchEntry> recordList = list(queryWrapper);
@ -1037,7 +1041,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return update(new UpdateWrapper<ShopMchEntry>()
.eq("id", id)
.set("store_id", storeId));
.set("store_id", storeId).set("store_status", CommonConstant.Enable));
}
// /**
@ -1232,13 +1236,13 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
@Override
public Boolean updateMerchEntryEcResultUrlByMchId(Long mchId, String lklEcResultUrl) {
// 检查参数是否有效
if (mchId == null || StrUtil.isBlank(lklEcResultUrl)) {
log.error("参数无效: mchId={}, lklEcResultUrl={}", mchId, lklEcResultUrl);
return false;
}
try {
// 检查参数是否有效
if (mchId == null || mchId <= 0 || StrUtil.isBlank(lklEcResultUrl)) {
log.error("参数无效: mchId={}, lklEcResultUrl={}", mchId, lklEcResultUrl);
return false;
}
// 构建更新条件
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", mchId) // 根据商家入驻申请 ID 进行匹配

View File

@ -3003,6 +3003,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
/**
* 重要入驻审批通过并且合同盖章完结之后把商家入驻信息转换成店铺信息正式生成店铺所需的数据
* 独立新的事务执行
*
* @param mchMobile
* @param allowThrown 是否允许抛出异常
@ -3024,15 +3025,15 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
}
ShopMchEntry shopMchEntry = shopMchEntryService.getShopMerchEntryByCondition(mchMobile, "");
if (ObjectUtil.isEmpty(shopMchEntry)) {
if (shopMchEntry == null) {
logger.error("生成店铺:入驻信息不能为空");
return Pair.of(0, "入驻信息不能为空");
}
if (isExistsByStoreName(shopMchEntry.getStore_name())) {
logger.error("生成店铺:店铺名称已存在");
return Pair.of(0, "店铺名称已存在");
}
// if (isExistsByStoreName(shopMchEntry.getStore_name())) {
// logger.error("生成店铺:店铺名称已存在");
// return Pair.of(0, "店铺名称已存在");
// }
// 校验店铺状态
if (CommonConstant.Enable.equals(shopMchEntry.getStore_status())) {
@ -3042,7 +3043,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
if (!CommonConstant.Enable.equals(shopMchEntry.getStore_status())
&& !CommonConstant.Enable.equals(shopMchEntry.getHas_ec_signed())
&& !CommonConstant.Enable.equals(shopMchEntry.getHas_apply_mer())) {
return Pair.of(0, "前置条件满足,请检查电子合同或申请进件状态");
return Pair.of(0, "前置条件满足,请检查电子合同或申请进件状态");
}
try {
@ -3223,7 +3224,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
} catch (Exception e) {
logger.error("店铺生成失败", e);
if (allowThrown) {
throw new ApiException(I18nUtil._("新增店铺失败"));
throw new ApiException(I18nUtil._("店铺生成失败"));
}
return Pair.of(0, e.getMessage());
}
@ -3464,7 +3465,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
@Override
public Boolean isExistsByStoreName(String storeName) {
if (StrUtil.isBlank(storeName)) {
return true;
return false;
}
QueryWrapper<ShopStoreBase> queryWrapper = new QueryWrapper<>();