增加一个平台修改商家入驻信息接口

This commit is contained in:
Jack 2025-08-21 00:03:02 +08:00
parent 8e6ff03395
commit 58998d62b9
4 changed files with 334 additions and 1 deletions

View File

@ -729,4 +729,42 @@ public final class StringUtils extends org.apache.commons.lang3.StringUtils {
*/
ALL
}
/**
* 判断字符串是否为有效的经度值
* 经度范围-180° ~ 180°
*
* @param longitude 待校验的经度字符串
* @return 若校验通过返回 true否则返回 false
*/
public static boolean isLongitude(String longitude) {
if (longitude == null || longitude.trim().isEmpty()) {
return false;
}
try {
double value = Double.parseDouble(longitude);
return value >= -180.0 && value <= 180.0;
} catch (NumberFormatException e) {
return false;
}
}
/**
* 判断字符串是否为有效的纬度值
* 纬度范围-90° ~ 90°
*
* @param latitude 待校验的纬度字符串
* @return 若校验通过返回 true否则返回 false
*/
public static boolean isLatitude(String latitude) {
if (latitude == null || latitude.trim().isEmpty()) {
return false;
}
try {
double value = Double.parseDouble(latitude);
return value >= -90.0 && value <= 90.0;
} catch (NumberFormatException e) {
return false;
}
}
}

View File

@ -9,11 +9,14 @@
package com.suisung.mall.shop.store.controller.admin;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.suisung.mall.common.api.CommonResult;
import com.suisung.mall.common.modules.store.ShopMchEntry;
import com.suisung.mall.common.service.impl.BaseControllerImpl;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -21,11 +24,13 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@Slf4j
@Api(tags = "店铺基础信息表")
@RestController
@RequestMapping("/admin/shop/merch")
public class ShopMchEntryAdminController extends BaseControllerImpl {
@Resource
private ShopMchEntryService shopMchEntryService;
@ -60,5 +65,25 @@ public class ShopMchEntryAdminController extends BaseControllerImpl {
return shopMchEntryService.checkMchEntryStoreAllStatus(jsonParam.getLong("mchId"), jsonParam.getInt("storeId"));
}
@ApiOperation(value = "平台修改商家入驻信息", notes = "平台修改商家入驻信息")
@RequestMapping(value = "/update", method = RequestMethod.POST)
public CommonResult updateMerchEntry(@RequestBody JSONObject jsonParam) {
try {
if (jsonParam == null) {
return CommonResult.failed("请求参数不能为空");
}
ShopMchEntry record = JSONUtil.toBean(jsonParam, ShopMchEntry.class);
if (record == null) {
return CommonResult.failed("参数转换失败,请检查数据格式");
}
return shopMchEntryService.updateMerchEntry(record);
} catch (Exception e) {
log.error("平台修改商家入驻信息异常: ", e);
return CommonResult.failed("系统异常,请稍后重试");
}
}
}

View File

@ -304,4 +304,12 @@ public interface ShopMchEntryService {
* @param record 商户入驻记录
*/
void updateMerchEntrySignedStatusAndContractDownloadUrl(ShopMchEntry record);
/**
* 平台更新商户入驻信息
*
* @param record 商户入驻记录
* @return
*/
CommonResult updateMerchEntry(ShopMchEntry record);
}

View File

@ -8,6 +8,7 @@
package com.suisung.mall.shop.store.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@ -665,6 +666,48 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
}
}
/**
* 平台更新商户入驻信息
*
* @param record 商户入驻记录
* @return
*/
@Override
public CommonResult updateMerchEntry(ShopMchEntry record) {
if (record == null || record.getId() == null || record.getId() <= 0) {
return CommonResult.failed("缺少必要参数!");
}
// 固定用户ID模拟管理员
Integer userId = 0;
// UserDto user = getCurrentUser();
// if (!user.isAdmin()) {
// return CommonResult.failed(ResultCode.FORBIDDEN);
// }
// userId = user.getId();
record.setUpdated_by(userId);
record.setUpdated_at(new Date());
if (record.getSettlement_method() != null
|| record.getSettlement_method() < 0
|| record.getSettlement_method() > 1) {
record.setSettlement_method(0);
}
// 检查全部非空字段的格式
Pair<Boolean, String> checkResult = checkMchEntryInfo(record, false, true);
if (!checkResult.getFirst()) {
return CommonResult.failed(checkResult.getSecond());
}
if (!updateById(record)) {
return CommonResult.failed("更新商户入驻信息失败!");
}
return CommonResult.success();
}
/**
* 商家入驻审批
*
@ -1759,4 +1802,223 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return CommonResult.failed("系统异常,请稍后重试");
}
}
}
protected Pair<Boolean, String> checkMchEntryInfo(ShopMchEntry record, boolean checkEmpty, boolean checkFormat) {
if (record == null) {
return Pair.of(false, "商户入驻信息不能为空");
}
if (checkEmpty) {
// 检查通用必填字段
if (StringUtils.isEmpty(record.getLogin_mobile())) {
return Pair.of(false, "商家注册手机号不能为空");
}
if (StringUtils.isEmpty(record.getStore_name())) {
return Pair.of(false, "店铺名称不能为空");
}
if (StringUtils.isEmpty(record.getEmail())) {
return Pair.of(false, "商家邮箱不能为空");
}
if (record.getBiz_category() == null) {
return Pair.of(false, "店铺一级分类不能为空");
}
if (StringUtils.isEmpty(record.getStore_longitude())) {
return Pair.of(false, "店铺经度不能为空");
}
if (StringUtils.isEmpty(record.getStore_latitude())) {
return Pair.of(false, "店铺纬度不能为空");
}
if (StringUtils.isEmpty(record.getStore_area())) {
return Pair.of(false, "店铺省市区名称不能为空");
}
if (StringUtils.isEmpty(record.getStore_address())) {
return Pair.of(false, "带省市区店铺的详细地址不能为空");
}
if (StringUtils.isEmpty(record.getFront_facade_image())) {
return Pair.of(false, "店铺门店照片不能为空");
}
if (StringUtils.isEmpty(record.getEnvironment_image())) {
return Pair.of(false, "店铺室内环境照片不能为空");
}
if (record.getEntity_type() == null) {
return Pair.of(false, "入驻类型是企业或个人?");
}
// 根据入驻主体类型检查相应字段
if (record.getEntity_type() == CommonConstant.MCH_ENTITY_TYPE_QY) {
// 企业类型必填字段检查
if (StringUtils.isEmpty(record.getBiz_license_image())) {
return Pair.of(false, "营业执照图片不能为空");
}
if (StringUtils.isEmpty(record.getBiz_license_number())) {
return Pair.of(false, "营业执照编号不能为空");
}
if (StringUtils.isEmpty(record.getBiz_license_company())) {
return Pair.of(false, "企业名不能为空");
}
if (StringUtils.isEmpty(record.getBiz_license_period_begin())) {
return Pair.of(false, "营业执照开始有效日期不能为空");
}
if (StringUtils.isEmpty(record.getBiz_license_period_end())) {
return Pair.of(false, "营业执照截止有效日期不能为空");
}
if (StringUtils.isEmpty(record.getLegal_person_id_images())) {
return Pair.of(false, "法人身份证正面照不能为空");
}
if (StringUtils.isEmpty(record.getLegal_person_id_images2())) {
return Pair.of(false, "法人身份证反面照不能为空");
}
if (StringUtils.isEmpty(record.getLegal_person_name())) {
return Pair.of(false, "法人姓名不能为空");
}
if (StringUtils.isEmpty(record.getLegal_person_id_number())) {
return Pair.of(false, "法人身份证号码不能为空");
}
if (StringUtils.isEmpty(record.getLegal_person_id_period_begin())) {
return Pair.of(false, "法人身份证开始有效日期不能为空");
}
if (StringUtils.isEmpty(record.getLegal_person_id_period_end())) {
return Pair.of(false, "法人身份证截止有效日期不能为空");
}
} else if (record.getEntity_type() == CommonConstant.MCH_ENTITY_TYPE_GR) {
// 个人类型必填字段检查
if (StringUtils.isEmpty(record.getIndividual_id_images())) {
return Pair.of(false, "身份证正面照不能为空");
}
if (StringUtils.isEmpty(record.getIndividual_id_images2())) {
return Pair.of(false, "身份证反面照不能为空");
}
if (StringUtils.isEmpty(record.getIndividual_id_name())) {
return Pair.of(false, "个人姓名不能为空");
}
if (StringUtils.isEmpty(record.getIndividual_id_number())) {
return Pair.of(false, "身份证号码不能为空");
}
if (StringUtils.isEmpty(record.getIndividual_id_addr())) {
return Pair.of(false, "身份证详细地址不能为空");
}
if (StringUtils.isEmpty(record.getIndividual_id_period_begin())) {
return Pair.of(false, "身份证开始有效日期不能为空");
}
if (StringUtils.isEmpty(record.getIndividual_id_period_end())) {
return Pair.of(false, "身份证截止有效日期不能为空");
}
}
// 检查结算信息必填字段
if (StringUtils.isEmpty(record.getBank_area())) {
return Pair.of(false, "结算账号省市区名称不能为空");
}
if (StringUtils.isEmpty(record.getBank_name())) {
return Pair.of(false, "银行名称不能为空");
}
if (StringUtils.isEmpty(record.getOpenning_bank_code())) {
return Pair.of(false, "结算账户开户号不能为空");
}
if (StringUtils.isEmpty(record.getAccount_number())) {
return Pair.of(false, "结算银行卡号不能为空");
}
}
if (checkFormat) {
// 检查手机号格式
if (StringUtils.isNotEmpty(record.getLogin_mobile()) && !PhoneNumberUtils.checkPhoneNumber(record.getLogin_mobile())) {
return Pair.of(false, "商家注册手机号格式不正确");
}
if (StringUtils.isNotEmpty(record.getLegal_person_mobile()) && !PhoneNumberUtils.checkPhoneNumber(record.getLegal_person_mobile())) {
return Pair.of(false, "法人手机号格式不正确");
}
// 检查邮箱格式
if (StringUtils.isNotEmpty(record.getEmail()) && !CheckUtil.isEmail(record.getEmail())) {
return Pair.of(false, "商家邮箱格式不正确");
}
// 检查身份证号格式
if (StringUtils.isNotEmpty(record.getLegal_person_id_number()) && !StringUtils.validateIDCard(record.getLegal_person_id_number())) {
return Pair.of(false, "法人身份证号码格式不正确");
}
if (StringUtils.isNotEmpty(record.getIndividual_id_number()) && !StringUtils.validateIDCard(record.getIndividual_id_number())) {
return Pair.of(false, "身份证号码格式不正确");
}
// 检查日期格式 (yyyy-MM-dd)
if (StringUtils.isNotEmpty(record.getBiz_license_period_begin()) && !DateTimeUtils.isValidDateFormat(record.getBiz_license_period_begin()).getFirst()) {
return Pair.of(false, "营业执照开始有效日期参考yyyy-MM-dd格式");
}
if (StringUtils.isNotEmpty(record.getBiz_license_period_end()) && !DateTimeUtils.isValidDateFormat(record.getBiz_license_period_end()).getFirst()) {
return Pair.of(false, "营业执照截止有效日期参考yyyy-MM-dd格式");
}
if (StringUtils.isNotEmpty(record.getLegal_person_id_period_begin()) && !DateTimeUtils.isValidDateFormat(record.getLegal_person_id_period_begin()).getFirst()) {
return Pair.of(false, "法人身份证开始有效日期参考yyyy-MM-dd格式");
}
if (StringUtils.isNotEmpty(record.getLegal_person_id_period_end()) && !DateTimeUtils.isValidDateFormat(record.getLegal_person_id_period_end()).getFirst()) {
return Pair.of(false, "法人身份证截止有效日期参考yyyy-MM-dd格式");
}
if (StringUtils.isNotEmpty(record.getIndividual_id_period_begin()) && !DateTimeUtils.isValidDateFormat(record.getIndividual_id_period_begin()).getFirst()) {
return Pair.of(false, "身份证开始有效日期参考yyyy-MM-dd格式");
}
if (StringUtils.isNotEmpty(record.getIndividual_id_period_end()) && !DateTimeUtils.isValidDateFormat(record.getIndividual_id_period_end()).getFirst()) {
return Pair.of(false, "身份证截止有效日期参考yyyy-MM-dd格式");
}
// 检查银行卡号格式
boolean isQy = record.getEntity_type() != null && record.getEntity_type() == CommonConstant.MCH_ENTITY_TYPE_QY;
if (StringUtils.isNotEmpty(record.getAccount_number()) && !BankUtil.validateBankCard(record.getAccount_number(), "CN", isQy)) {
return Pair.of(false, "结算银行卡号格式不正确");
}
// 检查营业执照编号格式
if (StringUtils.isNotEmpty(record.getBiz_license_number()) && !StringUtils.verifyBusinessLicense(record.getBiz_license_number())) {
return Pair.of(false, "营业执照编号格式不正确");
}
if (StringUtils.isNotEmpty(record.getStore_latitude()) && !StringUtils.isLatitude(record.getStore_latitude())) {
return Pair.of(false, "店铺纬度格式不正确");
}
if (StringUtils.isNotEmpty(record.getStore_longitude()) && !StringUtils.isLongitude(record.getStore_longitude())) {
return Pair.of(false, "店铺经度格式不正确");
}
}
return Pair.of(true, "");
}
}