From 77723a7720dab6bebc8b6c6af963df205e4dba7c Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期四, 08 六月 2023 16:17:40 +0800
Subject: [PATCH] 基础配置

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |   61 +++++++++++++++++++++++-------
 1 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
index b549e3b..ce41987 100644
--- a/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
+++ b/ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -4,6 +4,7 @@
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.security.utils.CodeFactoryUtil;
@@ -14,6 +15,7 @@
 import com.ruoyi.shop.mapper.shop.ShopMapper;
 import com.ruoyi.shop.service.shop.*;
 import com.ruoyi.shop.service.task.ShopFileService;
+import com.ruoyi.system.api.constant.AppErrorConstant;
 import com.ruoyi.system.api.domain.dto.AppMemberBindingDto;
 import com.ruoyi.system.api.domain.poji.config.SysTag;
 import com.ruoyi.system.api.domain.poji.member.Member;
@@ -34,6 +36,7 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 import java.util.StringJoiner;
 
 /**
@@ -125,16 +128,20 @@
 
     /**
      * 创建商户
-     * @param MGTEditShopDto
+     * @param mgtEditShopDto
      */
     @Override
-    public void createShop(MgtEditShopDto MGTEditShopDto){
+    public void createShop(MgtEditShopDto mgtEditShopDto){
         Shop shop = new Shop();
         Boolean newShop = false;
-        if(MGTEditShopDto.getShopId()!=null){
-            shop = this.getById(MGTEditShopDto.getShopId());
+        Shop shopSame = this.getOne(new LambdaQueryWrapper<Shop>().eq(Shop::getDelFlag,0).eq(Shop::getShopName,mgtEditShopDto.getShopName()));
+        if(mgtEditShopDto.getShopId()!=null){
+            if(shopSame!=null&&!Objects.equals(shopSame.getShopId(),mgtEditShopDto.getShopId())){
+                throw new ServiceException(AppErrorConstant.SHOP_DOUBLE);
+            }
+            shop = this.getById(mgtEditShopDto.getShopId());
             shop.setUpdateTime(new Date());
-            shop.setUpdateUserId(MGTEditShopDto.getUserId());
+            shop.setUpdateUserId(mgtEditShopDto.getUserId());
             shop.setShopTags(null);
             //清空关联记录
             shopFileService.deleteByShopId(shop.getShopId());
@@ -144,22 +151,25 @@
             shopRelUserService.deleteByShopId(shop.getShopId());
             shopStaffService.clearShopStaffRelation(shop.getShopId());
         }else{
+            if(shopSame!=null){
+                throw new ServiceException(AppErrorConstant.SHOP_DOUBLE);
+            }
             shop.setShopStatus(3);
             shop.setCreateTime(new Date());
-            shop.setCreateUserId(MGTEditShopDto.getUserId());
+            shop.setCreateUserId(mgtEditShopDto.getUserId());
             shop.setFrozenFlag(0);
             shop.setCooperativeFlag(0);
             newShop = true;
         }
-        BeanUtils.copyProperties(MGTEditShopDto,shop);
+        BeanUtils.copyProperties(mgtEditShopDto,shop);
         this.saveOrUpdate(shop);
         //商户编号
-        if(MGTEditShopDto.getShopId()==null){
+        if(mgtEditShopDto.getShopId()==null){
             String shopNo = CodeFactoryUtil.getShopNo(shop.getShopId());
             shop.setShopNumber(shopNo);
         }
         //商户标签
-        String shopTagIds = MGTEditShopDto.getShopTagIds();
+        String shopTagIds = mgtEditShopDto.getShopTagIds();
         if(StringUtils.isNotBlank(shopTagIds)){
             String[] shopTagIdArray = shopTagIds.split(",");
             ShopRelTag shopRelTag;
@@ -183,7 +193,7 @@
         SysUser belongSysUser = sysUserService.getSysUser(shop.getBelongUserId()).getData();
         handleShopStaff(shop.getShopId(),belongSysUser);
         //商户关联人员
-        String relUserIds = MGTEditShopDto.getRelUserIds();
+        String relUserIds = mgtEditShopDto.getRelUserIds();
         if(StringUtils.isNotBlank(relUserIds)){
             String[] relUserIdArray = relUserIds.split(",");
             ShopRelUser shopRelUser;
@@ -207,12 +217,12 @@
         ShopFile shopFile = new ShopFile();
         shopFile.setDelFlag(0);
         shopFile.setFileType(1);
-        shopFile.setFileUrl(MGTEditShopDto.getShopPicture());
+        shopFile.setFileUrl(mgtEditShopDto.getShopPicture());
         shopFile.setShopId(shop.getShopId());
         shopFileService.save(shopFile);
         //商户banner
-        if(StringUtils.isNotBlank(MGTEditShopDto.getShopBanners())){
-            String shopBanners= MGTEditShopDto.getShopBanners();
+        if(StringUtils.isNotBlank(mgtEditShopDto.getShopBanners())){
+            String shopBanners= mgtEditShopDto.getShopBanners();
             String[] shopBannerArray = shopBanners.split(",");
             for(String str : shopBannerArray){
                 shopFile = new ShopFile();
@@ -248,7 +258,7 @@
             shopProportion.setShopType(shop.getShopType());
             shopProportion.setProportionPercent(new BigDecimal("100.00"));
             shopProportion.setUpdateTime(new Date());
-            shopProportion.setUpdateUserId(MGTEditShopDto.getUserId());
+            shopProportion.setUpdateUserId(mgtEditShopDto.getUserId());
             shopProportionService.save(shopProportion);
         }
     }
@@ -484,5 +494,28 @@
         shopStaffService.saveOrUpdate(shopStaff);
     }
 
+    /**
+     * @description  平台获取商户分成列表
+     * @author  jqs
+     * @date    2023/6/8 9:25
+     * @param page
+     * @param mgtShopProportionPageDto
+     * @return  List<MgtShopProportionPageVo>
+     */
+    @Override
+    public List<MgtShopProportionPageVo> pageMgtShopProportion(Page page, MgtShopProportionPageDto mgtShopProportionPageDto){
+        return shopMapper.pageMgtShopProportion(page,mgtShopProportionPageDto);
+    }
 
+    /**
+     * @description  删除商户标签
+     * @author  jqs
+     * @date    2023/6/8 15:53
+     * @param shopTag
+     * @return  void
+     */
+    @Override
+    public void deleteShopTag(String shopTag){
+        shopMapper.deleteShopTag(shopTag);
+    }
 }

--
Gitblit v1.7.1