From b4882b114f082e010d4cc3359d78d18095ef3b83 Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期一, 26 六月 2023 19:49:38 +0800
Subject: [PATCH] 商户端和管理台联调bug

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |  152 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 141 insertions(+), 11 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..b4e2b45 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;
     }
 
@@ -779,4 +877,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