From 80537e4bcdde2634a8ce241cd21b52fd27ee5298 Mon Sep 17 00:00:00 2001 From: Tankaikai Date: Wed, 9 Apr 2025 16:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E5=BA=97=E9=93=BA=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ShopInfoServiceImpl.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java index 873200461..1f84b9adf 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java @@ -256,15 +256,24 @@ public class ShopInfoServiceImpl extends ServiceImpl i String shopType = shopInfo.getShopType(); Long mainId = shopInfo.getMainId(); Integer isHeadShop = shopInfo.getIsHeadShop(); - // 禁止加盟店/连锁店修改为单店 - if (!shopType.equals(shopInfoEditDTO.getShopType())) { - shopInfoEditDTO.setShopType(shopType); - } - if (!isHeadShop.equals(shopInfoEditDTO.getIsHeadShop())) { - shopInfoEditDTO.setIsHeadShop(isHeadShop); - } - if (mainId != null && !mainId.equals(shopInfoEditDTO.getMainId())) { - shopInfoEditDTO.setMainId(mainId); + // 原来是单店,现在不是单店,那么就允许修改,否则不允许修改 + if (ShopTypeEnum.ONLY.equals(shopType) && !ShopTypeEnum.ONLY.getValue().equals(shopInfoEditDTO.getShopType())) { + if (shopInfoEditDTO.getIsHeadShop() == null) { + throw new CzgException("加盟店/连锁店请选择是否主店"); + } + if (shopInfoEditDTO.getIsHeadShop() == YesNoEnum.NO.value() && shopInfoEditDTO.getMainId() == null) { + throw new CzgException("请选择一个店铺做为主店"); + } + if (shopInfoEditDTO.getIsHeadShop() == YesNoEnum.YES.value()) { + if (mainId != null) { + throw new CzgException("数据错误:当前店铺是非主店,不允许随意切换为主店"); + } + } + if (isHeadShop == YesNoEnum.YES.value() && shopInfoEditDTO.getIsHeadShop() == YesNoEnum.NO.value()) { + throw new CzgException("数据错误:当前店铺是主店,不允许随意切换为非主店"); + } + } else { + throw new CzgException("禁止连锁店/加盟店修改为单店"); } if (shopInfoEditDTO.getActivateCode() != null) { activateShop(shopInfo, shopInfoEditDTO.getActivateCode());