From cfd0118ef446a66f91999afc7b1e46ca607adf50 Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期四, 13 七月 2023 20:32:35 +0800
Subject: [PATCH] 定时任务 统计

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |  163 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 95 insertions(+), 68 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 691d59d..e268b21 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
@@ -30,6 +30,7 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
 import java.text.ParseException;
 import java.util.*;
 import java.util.function.Function;
@@ -202,6 +203,12 @@
             newShop = true;
         }
         BeanUtils.copyProperties(mgtEditShopDto,shop);
+        String shopDetail = shop.getShopDetail();
+        if(StringUtils.isNotBlank(shopDetail)){
+            byte[] decodedBytes = Base64.getDecoder().decode(shopDetail);
+            shopDetail = new String(decodedBytes, StandardCharsets.UTF_8);
+            shop.setShopDetail(shopDetail);
+        }
         //商户编号
         if(mgtEditShopDto.getShopId()==null){
             String shopNo = CodeFactoryUtil.getShopNo();
@@ -276,68 +283,82 @@
             }
         }
         if(newShop){
-            //商户账户信息初始化
-            ShopAccount shopAccount = new ShopAccount();
-            shopAccount.setShopId(shop.getShopId());
-            shopAccount.setDelFlag(0);
-            shopAccount.setTotalIncome(new BigDecimal("0"));
-            shopAccount.setTotalDisburse(new BigDecimal("0"));
-            shopAccount.setTotalRefund(new BigDecimal("0"));
-            shopAccount.setTotalProfitsharing(new BigDecimal("0"));
-            shopAccount.setTotalMoney(new BigDecimal("0"));
-            shopAccountService.save(shopAccount);
-            //商户认证信息初始化
-            String authId = IdUtils.simpleUUID();
-            ShopAuthentication shopAuthentication = new ShopAuthentication();
-            shopAuthentication.setAuthId(authId);
-            shopAuthentication.setDelFlag(0);
-            shopAuthentication.setShopId(shop.getShopId());
-            shopAuthenticationService.save(shopAuthentication);
-            //商户分成信息初始化
-            ShopProportion shopProportion = new ShopProportion();
-            shopProportion.setDelFlag(0);
-            shopProportion.setShopId(shop.getShopId());
-            shopProportion.setShopType(shop.getShopType());
-            shopProportion.setProportionPercent(new BigDecimal("100.00"));
-            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.setTotalExperienceOrder(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);
+            //生成商户关联记录
+            initNewShop(shop,mgtEditShopDto.getUserId());
         }
+    }
+
+    /**
+     * @description  商户关联类初始化
+     * @author  jqs
+     * @date    2023/7/7 11:25
+     * @param shop
+     * @param userId
+     * @return  void
+     */
+    private void initNewShop(Shop shop,Long userId){
+        BigDecimal zeroBig = new BigDecimal("0.00");
+        //商户账户信息初始化
+        ShopAccount shopAccount = new ShopAccount();
+        shopAccount.setShopId(shop.getShopId());
+        shopAccount.setDelFlag(0);
+        shopAccount.setTotalIncome(new BigDecimal("0"));
+        shopAccount.setTotalDisburse(new BigDecimal("0"));
+        shopAccount.setTotalRefund(new BigDecimal("0"));
+        shopAccount.setTotalProfitsharing(new BigDecimal("0"));
+        shopAccount.setTotalMoney(new BigDecimal("0"));
+        shopAccountService.save(shopAccount);
+        //商户认证信息初始化
+        String authId = IdUtils.simpleUUID();
+        ShopAuthentication shopAuthentication = new ShopAuthentication();
+        shopAuthentication.setAuthId(authId);
+        shopAuthentication.setDelFlag(0);
+        shopAuthentication.setShopId(shop.getShopId());
+        shopAuthenticationService.save(shopAuthentication);
+        //商户分成信息初始化
+        ShopProportion shopProportion = new ShopProportion();
+        shopProportion.setDelFlag(0);
+        shopProportion.setShopId(shop.getShopId());
+        shopProportion.setShopType(shop.getShopType());
+        shopProportion.setProportionPercent(new BigDecimal("100.00"));
+        shopProportion.setUpdateTime(new Date());
+        shopProportion.setUpdateUserId(userId);
+        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.setTotalExperienceOrder(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);
     }
 
     /**
@@ -481,6 +502,12 @@
         Shop shop = this.getById(shopId);
         //基本信息拷贝
         BeanUtils.copyProperties(shop,mgtShopInfoVo);
+        String shopDetail = mgtShopInfoVo.getShopDetail();
+        if(StringUtils.isNotBlank(shopDetail)){
+            byte[] encodedBytes = Base64.getEncoder().encode(shopDetail.getBytes(StandardCharsets.UTF_8));
+            shopDetail = new String(encodedBytes, StandardCharsets.UTF_8);
+            mgtShopInfoVo.setShopDetail(shopDetail);
+        }
         //商户标签
         List<ShopRelTag> shopRelTagList = shopRelTagService.listShopRelTagByShopId(shopId);
         if(shopRelTagList!=null&&!shopRelTagList.isEmpty()){
@@ -578,7 +605,7 @@
         }
         shop.setBelongUserId(mgtTransferShopDto.getTransferUserId());
         this.saveOrUpdate(shop);
-        ShopRelUser shopRelUser = new ShopRelUser();
+        /*ShopRelUser shopRelUser = new ShopRelUser();
         shopRelUser.setDelFlag(0);
         shopRelUser.setShopId(shop.getShopId());
         shopRelUser.setUserId(mgtTransferShopDto.getTransferUserId());
@@ -586,7 +613,7 @@
         shopRelUser.setUserMobile(sysUser.getPhonenumber());
         shopRelUser.setUserDeptId(sysUser.getDeptId());
         shopRelUser.setUserName(sysUser.getNickName());
-        shopRelUserService.save(shopRelUser);
+        shopRelUserService.save(shopRelUser);*/
     }
 
     /**
@@ -664,12 +691,12 @@
             MerHomeShopTotalVo merHomeShopTotalVo = new MerHomeShopTotalVo();
             merHomeShopTotalVo.setShopIds(shopIds);
             MerHomeShopTotalVo orderVo = remoteOrderService.getMerHomeTotal(merHomeShopTotalVo).getData();
-            merHomeShopTotalVo.setTodayShop(orderVo.getTodayShop());
-            merHomeShopTotalVo.setUnHandleOrder(orderVo.getUnHandleOrder());
-            merHomeShopTotalVo.setShopTurnover(orderVo.getShopTurnover());
+            merHomeShopTotalVo.setTodayShop(null!=orderVo?orderVo.getTodayShop():0);
+            merHomeShopTotalVo.setUnHandleOrder(null!=orderVo?orderVo.getUnHandleOrder():0);
+            merHomeShopTotalVo.setShopTurnover(null!=orderVo?orderVo.getShopTurnover():BigDecimal.ZERO);
             ShopTotal shopTotal = shopTotalService.shopsTotalByIds(shopIds);
-            merHomeShopTotalVo.setCycleSurp(shopTotal.getUseableCyclePerson());
-            merHomeShopTotalVo.setExplorationSurp(shopTotal.getUseableExperiencePerson());
+            merHomeShopTotalVo.setCycleSurp(null!=shopTotal?shopTotal.getUseableCyclePerson():0);
+            merHomeShopTotalVo.setExplorationSurp(null!=shopTotal?shopTotal.getUseableExperiencePerson():0);
             Integer taskCount = memberTaskService.getMembersIngTotal(shopIds);
             merHomeShopTotalVo.setTask(taskCount);
             return merHomeShopTotalVo;

--
Gitblit v1.7.1