From db3c1f464e80458a1b6ccbe31b0355775df8e574 Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期三, 23 八月 2023 20:45:34 +0800
Subject: [PATCH] bug

---
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java |   88 ++++++++++++++++++++++++++++++++------------
 1 files changed, 64 insertions(+), 24 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 1f31e90..ea3587f 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
@@ -8,6 +8,7 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult;
 import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult;
+import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReceiver;
 import com.github.binarywang.wxpay.exception.WxPayException;
 import com.ruoyi.common.core.constant.CacheConstants;
 import com.ruoyi.common.core.exception.ServiceException;
@@ -129,6 +130,8 @@
 
     @Resource
     private RemoteUserService remoteUserService;
+
+
 
     /**
      * 获取商户详情
@@ -798,17 +801,28 @@
             mgtBasePlatformDto.setUserIdList(userIds);
             shopIds = shopMapper.listShopIdByTotal(mgtBasePlatformDto);
             Shop shop = this.getShopByBelongUserId(userId);
-            shopIds.add(shop.getShopId());
-            userIds.add(userId);
+            if(shop!=null){
+                shopIds.add(shop.getShopId());
+                userIds.add(userId);
+            }
         }else {
             //普通员工查询商户归属的shopId
             Shop shop = this.getShopByBelongUserId(userId);
-
             shopIds.add(shop.getShopId());
         }
         //分别查询
-        StaffHomeShopTotalVo staffHomeShopTotalVo = shopMapper.getStaffHomeTotal(userIds);
-        Integer shopTaskCount = shopTaskService.getShopIngTotal(shopIds);
+        StaffHomeShopTotalVo staffHomeShopTotalVo = new StaffHomeShopTotalVo();
+        if(userIds!=null&&!userIds.isEmpty()){
+            staffHomeShopTotalVo = shopMapper.getStaffHomeTotal(userIds);
+        }else{
+            staffHomeShopTotalVo.setShopTotal(0);
+            staffHomeShopTotalVo.setAgencyTotal(0);
+            staffHomeShopTotalVo.setDealerTotal(0);
+        }
+        Integer shopTaskCount = 0;
+        if(shopIds!=null&&!shopIds.isEmpty()){
+            shopTaskService.getShopIngTotal(shopIds);
+        }
         staffHomeShopTotalVo.setFollowMember(0);
         staffHomeShopTotalVo.setNewMember(0);
         staffHomeShopTotalVo.setShopTask(shopTaskCount);
@@ -1011,7 +1025,7 @@
         Shop shop = this.getByShopId(shopAuthentication.getShopId());
 
         if(mgtShopAuthDto.getBlBusinessFoeverFlag()!=null&&mgtShopAuthDto.getBlBusinessFoeverFlag()==1){
-            mgtShopAuthDto.setBlBusinessDeanline(mgtShopAuthDto.getBlBusinessStartTime()+",长期");
+            mgtShopAuthDto.setBlBusinessDeanline("长期");
         }
         if(mgtShopAuthDto.getLpIcForeverFlag()!=null&&mgtShopAuthDto.getLpIcForeverFlag()==1){
             mgtShopAuthDto.setLpIcEndDate("长期");
@@ -1027,7 +1041,7 @@
             applymentsResult = wechatPayUtils.ecommerceApply(shopAuthentication,applyNumber,shop);
         } catch (Exception e) {
             log.debug("-----"+shop.getShopId()+":进件异常-----");
-            throw new RuntimeException(e);
+            throw new ServiceException(e.getMessage());
         }
         shopAuthentication.setAuditStatus(3);
         shopAuthenticationService.saveOrUpdate(shopAuthentication);
@@ -1264,7 +1278,12 @@
         }else {
             userIdList.add(userId);
         }
-        return shopMapper.getStaffSimpleTotal(userIdList);
+        StaffShopSimpleTotalVo shopTotal = shopMapper.getStaffSimpleTotal(1,userIdList);
+        StaffShopSimpleTotalVo agencyTotal = shopMapper.getStaffSimpleTotal(2,userIdList);
+        shopTotal.setAgencyTotal(agencyTotal.getShopTotal());
+        shopTotal.setOpenAgencyTotal(agencyTotal.getOpenShopTotal());
+        shopTotal.setCloseAgencyTotal(agencyTotal.getCloseAgencyTotal());
+        return shopTotal;
     }
 
     /**
@@ -1388,6 +1407,8 @@
         List<ExtendContactsVo> extendContactsVoList = staffShopECEditDto.getExtendContactsVoList();
         if(extendContactsVoList!=null&&!extendContactsVoList.isEmpty()){
             extendContacts = JSON.toJSONString(extendContactsVoList);
+        }else{
+            extendContacts = "";
         }
         shop.setExtendContacts(extendContacts);
         shop.setShopId(staffShopECEditDto.getShopId());
@@ -1517,7 +1538,24 @@
     public StaffShopDetailVo getShopDetail(Long shopId){
         ShopDetail shopDetail = shopDetailService.getById(shopId);
         StaffShopDetailVo staffShopDetailVo = new StaffShopDetailVo();
-        BeanUtils.copyProperties(shopDetail, staffShopDetailVo);
+        if(shopDetail!=null){
+            BeanUtils.copyProperties(shopDetail, staffShopDetailVo);
+            //处理联系人
+            String customerName = shopDetail.getCustomerName();
+            String customerMobile = shopDetail.getCustomerMobile();
+            List<StaffCustomerDto> staffCustomerDtoList = new ArrayList<>();
+            String[] customerNameArr = customerName.split(",");
+            String[] customerMobileArr = customerMobile.split(",");
+            staffShopDetailVo.setContactName(customerNameArr[0]);
+            StaffCustomerDto staffCustomerDto;
+            for(int i=0;i<customerNameArr.length;i++){
+                staffCustomerDto = new StaffCustomerDto();
+                staffCustomerDto.setCustomerName(customerNameArr[i]);
+                staffCustomerDto.setCustomerMobile(customerMobileArr[i]);
+                staffCustomerDtoList.add(staffCustomerDto);
+            }
+            staffShopDetailVo.setStaffCustomerDtoList(staffCustomerDtoList);
+        }
         //归属客户
         Shop shop = this.getByShopId(shopId);
         Long belongUserId = shop.getBelongUserId();
@@ -1532,21 +1570,23 @@
         if(shopTask!=null){
             staffShopDetailVo.setNextTaskDate(shopTask.getTaskDate());
         }
-        //处理联系人
-        String customerName = shopDetail.getCustomerName();
-        String customerMobile = shopDetail.getCustomerMobile();
-        List<StaffCustomerDto> staffCustomerDtoList = new ArrayList<>();
-        String[] customerNameArr = customerName.split(",");
-        String[] customerMobileArr = customerMobile.split(",");
-        staffShopDetailVo.setContactName(customerNameArr[0]);
-        StaffCustomerDto staffCustomerDto;
-        for(int i=0;i<customerNameArr.length;i++){
-            staffCustomerDto = new StaffCustomerDto();
-            staffCustomerDto.setCustomerName(customerNameArr[i]);
-            staffCustomerDto.setCustomerMobile(customerMobileArr[i]);
-            staffCustomerDtoList.add(staffCustomerDto);
-        }
-        staffShopDetailVo.setStaffCustomerDtoList(staffCustomerDtoList);
         return staffShopDetailVo;
     }
+
+
+    /**
+     * @description
+     * @author  jqs
+     * @date    2023/8/23 9:44
+     * @param
+     * @return  void
+     */
+    @Override
+    public void addProfitSharingReceiver(ProfitSharingReceiver profitSharingReceiver){
+        try {
+            ProfitSharingReceiver result = wechatPayUtils.addProfitSharingReceiver(profitSharingReceiver);
+        } catch (WxPayException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }

--
Gitblit v1.7.1