From 58998d62b9fc67a9490722da0e2f1b9f9dca0057 Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Thu, 21 Aug 2025 00:03:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E4=BF=AE=E6=94=B9=E5=95=86=E5=AE=B6=E5=85=A5=E9=A9=BB?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/common/utils/StringUtils.java | 38 +++ .../admin/ShopMchEntryAdminController.java | 25 ++ .../store/service/ShopMchEntryService.java | 8 + .../service/impl/ShopMchEntryServiceImpl.java | 264 +++++++++++++++++- 4 files changed, 334 insertions(+), 1 deletion(-) diff --git a/mall-common/src/main/java/com/suisung/mall/common/utils/StringUtils.java b/mall-common/src/main/java/com/suisung/mall/common/utils/StringUtils.java index 50f1d601..58bb46d6 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/utils/StringUtils.java +++ b/mall-common/src/main/java/com/suisung/mall/common/utils/StringUtils.java @@ -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; + } + } } \ No newline at end of file diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMchEntryAdminController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMchEntryAdminController.java index 36839cac..062cee70 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMchEntryAdminController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMchEntryAdminController.java @@ -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("系统异常,请稍后重试"); + } + } + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java index bf428110..e9f68310 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java @@ -304,4 +304,12 @@ public interface ShopMchEntryService { * @param record 商户入驻记录 */ void updateMerchEntrySignedStatusAndContractDownloadUrl(ShopMchEntry record); + + /** + * 平台更新商户入驻信息 + * + * @param record 商户入驻记录 + * @return + */ + CommonResult updateMerchEntry(ShopMchEntry record); } \ No newline at end of file diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java index 051db328..54a39ee8 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java @@ -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 1) { + record.setSettlement_method(0); + } + + // 检查全部非空字段的格式 + Pair 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 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, ""); + } +} \ No newline at end of file