jiangqs
2023-07-01 2dcfe238ab12f4f18cbd5705a6af5357b367a886
ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -155,13 +155,24 @@
            String[] relUserIdArray = relUserIds.split(",");
            ShopRelUser shopRelUser;
            Long userId;
            for (String str : relUserIdArray) {
                userId = Long.valueOf(str);
                shopRelUser = shopRelUserService.getByUserId(userId);
                if(shopRelUser!=null){
                    throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE);
            if(mgtEditShopDto.getShopId()!=null){
                for (String str : relUserIdArray) {
                    userId = Long.valueOf(str);
                    shopRelUser = shopRelUserService.getByUserId(userId);
                    if(shopRelUser!=null&&!shopRelUser.getShopId().equals(mgtEditShopDto.getShopId())){
                        throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE);
                    }
                }
            }else {
                for (String str : relUserIdArray) {
                    userId = Long.valueOf(str);
                    shopRelUser = shopRelUserService.getByUserId(userId);
                    if(shopRelUser!=null){
                        throw new ServiceException(AppErrorConstant.SHOP_USER_DOUBLE);
                    }
                }
            }
        }
        //验证商户名唯一
        Shop shopSame = this.getOne(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag,0).eq(Shop::getShopName,mgtEditShopDto.getShopName()));