From 1ffb6c7910cfb4d55b4c169142b67ea872fcf614 Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期二, 27 六月 2023 19:55:50 +0800
Subject: [PATCH] BUG联调

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |  216 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 165 insertions(+), 51 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 a84c332..6a6339d 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
@@ -10,17 +10,16 @@
 import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.security.utils.CodeFactoryUtil;
 import com.ruoyi.shop.domain.dto.*;
+import com.ruoyi.shop.domain.pojo.ShopTotal;
 import com.ruoyi.shop.domain.pojo.shop.*;
 import com.ruoyi.shop.domain.pojo.task.ShopFile;
 import com.ruoyi.shop.domain.vo.*;
 import com.ruoyi.shop.mapper.shop.ShopMapper;
 import com.ruoyi.shop.service.shop.*;
+import com.ruoyi.shop.service.task.MemberTaskService;
 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.dto.MgtBasePlatformDto;
-import com.ruoyi.system.api.domain.dto.MgtShopIdByCodeDto;
-import com.ruoyi.system.api.domain.dto.MgtUserIdByDept;
+import com.ruoyi.system.api.domain.dto.*;
 import com.ruoyi.system.api.domain.poji.config.SysTag;
 import com.ruoyi.system.api.domain.poji.member.Member;
 import com.ruoyi.system.api.domain.poji.shop.Shop;
@@ -37,6 +36,7 @@
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -89,7 +89,14 @@
     @Resource
     private ShopProportionService shopProportionService;
 
-    
+    @Resource
+    private RemoteConfigService remoteConfigService;
+
+    @Resource
+    private ShopTotalService shopTotalService;
+
+    @Resource
+    private MemberTaskService memberTaskService;
 
     /**
      * 获取商户详情
@@ -134,6 +141,7 @@
     public void createShop(MgtEditShopDto mgtEditShopDto){
         Shop shop = new Shop();
         Boolean newShop = false;
+        BigDecimal zeroBig = BigDecimal.ZERO;
         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())){
@@ -263,6 +271,41 @@
             shopProportion.setUpdateTime(new Date());
             shopProportion.setUpdateUserId(mgtEditShopDto.getUserId());
             shopProportionService.save(shopProportion);
+            //商户统计
+            ShopTotal shopTotal = new ShopTotal();
+            shopTotal.setShopId(shop.getShopId());
+            shopTotal.setDelFlag(0);
+            shopTotal.setLastPayMoney(zeroBig);
+            shopTotal.setTotalActivityCount(0);
+            shopTotal.setTotalOrder(0);
+            shopTotal.setTotalCycleOrder(0);
+            shopTotal.setToltaExperienceOrder(0);
+            shopTotal.setTotalServiceOrder(0);
+            shopTotal.setTotalGoodsOrder(0);
+            shopTotal.setTotalServiceCount(0);
+            shopTotal.setUsedServiceCount(0);
+            shopTotal.setUseableServiceCount(0);
+            shopTotal.setTotalCycleService(0);
+            shopTotal.setUsedCycleService(0);
+            shopTotal.setUseableCycleService(0);
+            shopTotal.setTotalCyclePerson(0);
+            shopTotal.setUseableCyclePerson(0);
+            shopTotal.setTotalServiceService(0);
+            shopTotal.setUsedServiceService(0);
+            shopTotal.setUseableServiceService(0);
+            shopTotal.setTotalServicePerson(0);
+            shopTotal.setUseableServicePerson(0);
+            shopTotal.setTotalExperienceService(0);
+            shopTotal.setUsedExperienceService(0);
+            shopTotal.setUseableExperienceService(0);
+            shopTotal.setTotalExperiencePerson(0);
+            shopTotal.setUseableExperiencePerson(0);
+            shopTotal.setTotalOrderMoney(zeroBig);
+            shopTotal.setTotalCycleMoney(zeroBig);
+            shopTotal.setTotalExperienceMoney(zeroBig);
+            shopTotal.setTotalServiceMoney(zeroBig);
+            shopTotal.setTotalGoodsMoney(zeroBig);
+            shopTotalService.save(shopTotal);
         }
     }
 
@@ -341,11 +384,58 @@
      */
     @Override
     public List<MgtShopPageVo> pageMgtShop(Page page, MgtShopPageDto mgtShopPageDto){
-        //处理标签为正则表达
-        if(StringUtils.isNotBlank(mgtShopPageDto.getShopTags())){
-            mgtShopPageDto.setShopTags(mgtShopPageDto.getShopTags().replace(",","|"));
+        if (StringUtils.isNotBlank(mgtShopPageDto.getShopTags())) {
+            mgtShopPageDto.setShopTags(mgtShopPageDto.getShopTags().replace(",", "|"));
         }
+        // 分页查询商铺信息
         List<MgtShopPageVo> mgtShopPageVoList = shopMapper.pageMgtShop(page, mgtShopPageDto);
+        // 如果查询结果不为空
+        if (!mgtShopPageVoList.isEmpty()) {
+            // 创建签约用户ID集合和所属用户ID集合
+            HashSet<Long> signUserIdSet = new HashSet<>();
+            HashSet<Long> belongUserIdSet = new HashSet<>();
+            // 遍历查询结果,将签约用户和所属用户添加到对应的集合中
+            for (MgtShopPageVo shopPageVo : mgtShopPageVoList) {
+                if (shopPageVo.getSignUserId() != null) {
+                    signUserIdSet.add(shopPageVo.getSignUserId());
+                }
+                if (shopPageVo.getBelongUserId() != null) {
+                    belongUserIdSet.add(shopPageVo.getBelongUserId());
+                }
+            }
+            MgtBaseBathDto mgtBaseBathDto;
+            Map<Long, MgtSysSimpleUserVo> signUserMap = null;
+            Map<Long, MgtSysSimpleUserVo> belongUserMap = null;
+            if(signUserIdSet!=null&&!signUserIdSet.isEmpty()){
+                String signUserString = String.join(",", signUserIdSet.stream().map(Object::toString).collect(Collectors.toList()));
+                mgtBaseBathDto = new MgtBaseBathDto();
+                mgtBaseBathDto.setIds(signUserString);
+                List<MgtSysSimpleUserVo> signUserVoList = remoteConfigService.listSimpleUserVo(mgtBaseBathDto).getData();
+                signUserMap = signUserVoList.stream()
+                        .collect(Collectors.toMap(MgtSysSimpleUserVo::getUserId, Function.identity()));
+            }
+            if(belongUserIdSet!=null&&!belongUserIdSet.isEmpty()){
+                // 将签约用户ID集合和所属用户ID集合转为字符串
+                String belongUserString = String.join(",", belongUserIdSet.stream().map(Object::toString).collect(Collectors.toList()));
+                // 查询签约用户和所属用户的详细信息
+                mgtBaseBathDto = new MgtBaseBathDto();
+                mgtBaseBathDto.setIds(belongUserString);
+                List<MgtSysSimpleUserVo> belongUserVoList = remoteConfigService.listSimpleUserVo(mgtBaseBathDto).getData();
+                belongUserMap = belongUserVoList.stream()
+                        .collect(Collectors.toMap(MgtSysSimpleUserVo::getUserId, Function.identity()));
+            }
+            // 遍历查询结果,将签约用户和所属用户的详细信息添加到商铺信息中
+            for (MgtShopPageVo shopPageVo : mgtShopPageVoList) {
+                if (signUserMap!=null&&!signUserMap.isEmpty()&&shopPageVo.getSignUserId() != null) {
+                    shopPageVo.setSignUser(signUserMap.get(shopPageVo.getSignUserId()).getNickName());
+                }
+                if (belongUserMap!=null&&!belongUserMap.isEmpty()&&shopPageVo.getBelongUserId() != null) {
+                    shopPageVo.setBelongUser(belongUserMap.get(shopPageVo.getBelongUserId()).getNickName());
+                    shopPageVo.setBelongDept(belongUserMap.get(shopPageVo.getBelongUserId()).getDeptName());
+                }
+            }
+        }
+        // 返回商铺信息
         return mgtShopPageVoList;
     }
 
@@ -495,9 +585,17 @@
         merHomeShopTotalVo.setShopId(shopId);
         Shop shop = this.getById(shopId);
         merHomeShopTotalVo.setShopType(shop.getShopType());
-        Integer task = 0;
-        merHomeShopTotalVo.setTask(task);
-        merHomeShopTotalVo = remoteOrderService.getMerHomeTotal(merHomeShopTotalVo).getData();
+        MerHomeShopTotalVo orderVo = remoteOrderService.getMerHomeTotal(merHomeShopTotalVo).getData();
+        ShopTotal shopTotal = shopTotalService.getById(shopId);
+        merHomeShopTotalVo.setShopId(shopId);
+        merHomeShopTotalVo.setShopType(shop.getShopType());
+        merHomeShopTotalVo.setTodayShop(orderVo.getTodayShop());
+        merHomeShopTotalVo.setUnHandleOrder(orderVo.getUnHandleOrder());
+        Integer taskCount = memberTaskService.getMemberIngTotal(shopId);
+        merHomeShopTotalVo.setTask(taskCount);
+        merHomeShopTotalVo.setShopTurnover(orderVo.getShopTurnover());
+        merHomeShopTotalVo.setCycleSurp(shopTotal.getUseableCyclePerson());
+        merHomeShopTotalVo.setExplorationSurp(shopTotal.getUseableExperiencePerson());
         return merHomeShopTotalVo;
     }
 
@@ -698,45 +796,20 @@
         //获取商户类型
         List<MgtMapTotalVo> shopTypeTotal = shopMapper.listShopTypeTotal(mgtBasePlatformDto);
         if (shopTypeTotal != null && shopTypeTotal.size() > 0) {
-            String[] shopTypeKey = new String[shopTypeTotal.size()];
-            Integer[] shopTypeValue = new Integer[shopTypeTotal.size()];
-            // 遍历不同商品类型的会员数列表,设置商品类型数组和对应的会员数数组
-            for (int i = 0; i < shopTypeTotal.size(); i++) {
-                if (shopTypeTotal.get(i).getMapKey().equals("1")) {
-                    shopTypeKey[i] = "经销商";
-                } else if (shopTypeTotal.get(i).getMapKey().equals("2")) {
-                    shopTypeKey[i] = "代理商";
-                }
-                shopTypeValue[i] = shopTypeTotal.get(i).getMapValue();
-            }
-            plTotalShopTotalVo.setShopTypeKey(shopTypeKey);
-            plTotalShopTotalVo.setShopTypeValue(shopTypeValue);
+            shopTypeTotal = listRemoveNull(shopTypeTotal);
+            plTotalShopTotalVo.setShopTypeVos(shopTypeTotal);
         }
         //获取商户状态
         List<MgtMapTotalVo> shopStatusTotal = shopMapper.listShopStatusTotal(mgtBasePlatformDto);
         if (shopStatusTotal != null && shopStatusTotal.size() > 0) {
-            String[] shopStatusKey = new String[shopStatusTotal.size()];
-            Integer[] shopStatusValue = new Integer[shopStatusTotal.size()];
-            // 遍历不同商品类型的会员数列表,设置商品类型数组和对应的会员数数组
-            for (int i = 0; i < shopStatusTotal.size(); i++) {
-                shopStatusKey[i] = shopStatusTotal.get(i).getMapKey();
-                shopStatusValue[i] = shopStatusTotal.get(i).getMapValue();
-            }
-            plTotalShopTotalVo.setShopStatusKey(shopStatusKey);
-            plTotalShopTotalVo.setShopStatusValue(shopStatusValue);
+            shopStatusTotal = listRemoveNull(shopStatusTotal);
+            plTotalShopTotalVo.setShopStatusVos(shopStatusTotal);
         }
         //获取区域排名
         List<MgtMapTotalVo> shopAreaRank = shopMapper.listShopAreaRank(mgtBasePlatformDto);
         if (shopAreaRank != null && shopAreaRank.size() > 0) {
-            String[] shopRankKey = new String[shopAreaRank.size()];
-            Integer[] shopRankValue = new Integer[shopAreaRank.size()];
-            // 遍历不同商品类型的会员数列表,设置商品类型数组和对应的会员数数组
-            for (int i = 0; i < shopAreaRank.size(); i++) {
-                shopRankKey[i] = shopAreaRank.get(i).getMapKey();
-                shopRankValue[i] = shopAreaRank.get(i).getMapValue();
-            }
-            plTotalShopTotalVo.setAreaRankKey(shopRankKey);
-            plTotalShopTotalVo.setAreaRankValue(shopRankValue);
+            shopAreaRank = listRemoveNull(shopAreaRank);
+            plTotalShopTotalVo.setAreaRankVos(shopAreaRank);
         }
         //获取销售排名
         List<MgtMapTotalVo> shopSalesRank = shopMapper.listShopSalesRank(mgtBasePlatformDto);
@@ -754,17 +827,26 @@
         //获取推荐
         List<MgtMapTotalVo> shopRecommendRank = shopMapper.listShopRecommendRank(mgtBasePlatformDto);
         if (shopRecommendRank != null && shopRecommendRank.size() > 0) {
-            String[] shopRecommendKey = new String[shopRecommendRank.size()];
-            Integer[] shopRecommendValue = new Integer[shopRecommendRank.size()];
-            // 遍历不同商品类型的会员数列表,设置商品类型数组和对应的会员数数组
-            for (int i = 0; i < shopRecommendRank.size(); i++) {
-                shopRecommendKey[i] = shopRecommendRank.get(i).getMapKey();
-                shopRecommendValue[i] = shopRecommendRank.get(i).getMapValue();
-            }
-            plTotalShopTotalVo.setShopRecommendKey(shopRecommendKey);
-            plTotalShopTotalVo.setShopRecommendValue(shopRecommendValue);
+            shopRecommendRank = listRemoveNull(shopRecommendRank);
+            plTotalShopTotalVo.setShopRecommendVos(shopRecommendRank);
         }
         return plTotalShopTotalVo;
+    }
+
+    /**
+     * @description  去除空字符串
+     * @author  jqs
+     * @date    2023/6/27 17:35
+     * @param mgtMapTotalVos
+     * @return  List<MgtMapTotalVo>
+     */
+    private List<MgtMapTotalVo> listRemoveNull(List<MgtMapTotalVo> mgtMapTotalVos){
+        for (int i = 0; i < mgtMapTotalVos.size(); i++) {
+            if(StringUtils.isBlank(mgtMapTotalVos.get(i).getMapKey())){
+                mgtMapTotalVos.remove(i);
+            }
+        }
+        return mgtMapTotalVos;
     }
 
     /**
@@ -779,4 +861,36 @@
         List<Long> shopIdList = shopMapper.listShopIdByPlTotal(mgtBasePlatformDto);
         return shopIdList;
     }
+
+
+    /**
+     * @description  获取商户审核资料
+     * @author  jqs
+     * @date    2023/6/25 10:37
+     * @param authId
+     * @return  MgtShopAuthGetVo
+     */
+    @Override
+    public MgtShopAuthGetVo getMgtShopAuth(String authId){
+        MgtShopAuthGetVo shopAuthGetVo = new MgtShopAuthGetVo();
+        ShopAuthentication shopAuthentication = shopAuthenticationService.getById(authId);
+        BeanUtils.copyProperties(shopAuthentication, shopAuthGetVo);
+        return shopAuthGetVo;
+    }
+
+    /**
+     * @description  获取商户验证信息
+     * @author  jqs
+     * @date    2023/6/26 10:38
+     * @param authId
+     * @return  MgtShopAuthCodeVo
+     */
+    @Override
+    public MgtShopAuthCodeVo getMgtShopAuthCode(String authId){
+        MgtShopAuthCodeVo mgtShopAuthCodeVo = new MgtShopAuthCodeVo();
+        ShopAuthentication shopAuthentication = shopAuthenticationService.getById(authId);
+        mgtShopAuthCodeVo.setSignUrl(shopAuthentication.getSignUrl());
+        mgtShopAuthCodeVo.setLegalValidationUrl(shopAuthentication.getLegalValidationUrl());
+        return mgtShopAuthCodeVo;
+    }
 }

--
Gitblit v1.7.1