From 3d18ffe2196677fe9669f0ff2085413803d4a73c Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 26 一月 2024 16:59:59 +0800
Subject: [PATCH] 修改数据权限bug

---
 ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml                     |    1 
 ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml                     |    4 
 ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml                        |   96 ++++++++++++++++----------------
 ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java     |    2 
 ruoyi-modules/ruoyi-system/src/main/resources/mapper/config/RecommendCooperationMapper.xml       |    2 
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java |   23 +++----
 6 files changed, 62 insertions(+), 66 deletions(-)

diff --git a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml
index e74af92..d1940e3 100644
--- a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml
+++ b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/coupon/CouponMapper.xml
@@ -370,6 +370,7 @@
             CASE tc.valid_time_type WHEN 1 THEN CONCAT(DATE_FORMAT(tc.valid_start_time, '%Y.%m.%d'),'-',DATE_FORMAT(tc.valid_end_time, '%Y.%m.%d')) WHEN 2 THEN CONCAT('领取后',tc.valid_day,'天有效') ELSE NULL END validTime
         FROM t_coupon tc
         WHERE tc.del_flag = 0 AND tc.coupon_status = 1 AND tc.audit_status = 2 AND tc.send_type = 1 AND (tc.coupon_from = 1 OR (tc.coupon_from = 2 AND tc.shop_id = #{shopId}))
+        AND IF(tc.valid_time_type = 1 , NOW() &lt; valid_end_time, 1 = 1)
         AND (tc.send_target = 2
              <if test="memberFlag != null and memberFlag = 1">
                  OR tc.send_target = 3
diff --git a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml
index b4465fc..faa4ad1 100644
--- a/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml
+++ b/ruoyi-modules/ruoyi-member/src/main/resources/mapper/member/MemberMapper.xml
@@ -601,9 +601,9 @@
         IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 31 AND 40 THEN 1 ELSE 0 END),0) AS ThirtyAge,
         IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) BETWEEN 41 AND 50 THEN 1 ELSE 0 END),0) AS fortyAge,
         IFNULL(SUM(CASE WHEN TIMESTAMPDIFF(YEAR, birthday, CURDATE()) &gt;= 51 THEN 1 ELSE 0 END),0) AS fiftyAge
-        FROM t_member WHERE del_flag = 0 AND binding_flag = 1
+        FROM t_member WHERE del_flag = 0
         <if test="param.shopIdList != null and param.shopIdList.size() > 0">
-            AND relation_shop_id IN
+            AND binding_flag = 1 AND relation_shop_id IN
             <foreach collection="param.shopIdList" item="item" open="(" separator="," close=")">
                 #{item}
             </foreach>
diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
index 3c3cb57..4332bf0 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -4232,6 +4232,14 @@
             return totalActivityTotalVo;
         }
 
+        //数据权限
+        List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId();
+        if(null != userIds){
+            List<Long> userIdList = mgtBasePlatformDto.getUserIdList();
+            userIdList.addAll(userIds);
+            mgtBasePlatformDto.setUserIdList(userIdList);
+        }
+
         List<Long> shopIdList = remoteShopService.listShopIdByPlTotal(mgtBasePlatformDto).getData();
         if (StringUtils.isNotBlank(mgtBasePlatformDto.getShopProvinceCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopCityCode()) || StringUtils.isNotBlank(mgtBasePlatformDto.getShopAreaCode())) {
             if(shopIdList==null||shopIdList.isEmpty()){
@@ -4242,20 +4250,7 @@
             shopIdList = new ArrayList<>();
             shopIdList.add(mgtBasePlatformDto.getShopId());
         }
-        //数据权限
-        List<Long> userIds = remoteUserService.getScopeOfAuthorityUserId();
-        if(null != userIds){
-            BoardMemberTotalDto boardMemberTotalDto = new BoardMemberTotalDto();
-            boardMemberTotalDto.setUserIds(userIds);
-            List<Shop> shopList = remoteShopService.getShopBySysUserIds(boardMemberTotalDto);
-            List<Long> collect = shopList.stream().map(Shop::getShopId).collect(Collectors.toList());
-            if(null != shopIdList){
-                shopIdList.addAll(collect);
-            }else{
-                shopIdList = collect;
-            }
-            mgtBasePlatformDto.setShopIdList(shopIdList);
-        }
+
         //获取基础统计
         MgtPlTotalActivityTotalVo mgtTotalActivityTotalVo = orderMapper.getPlTotalActivityTotal(mgtBasePlatformDto);
         totalActivityTotalVo.setOrderTotal(mgtTotalActivityTotalVo.getOrderTotal());
diff --git a/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
index 88f32d1..46a4181 100644
--- a/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
+++ b/ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -343,9 +343,9 @@
         CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
         toc.receivable_deposit receivableDeposit,
         toc.pay_money payMoney,
-        toc.change_receivable_money relReceiveMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
         CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
-        toc.change_receivable_money - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
         toc.create_time createTime,
         toc.close_flag closeFlag
         FROM t_order toc
@@ -368,9 +368,9 @@
         CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
         toc.receivable_deposit receivableDeposit,
         toc.pay_money payMoney,
-        toc.change_receivable_money relReceiveMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
         CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
-        toc.change_receivable_money - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
         toc.order_remark orderRemark,
         toc.create_time createTime,
         toc.order_from orderFrom,
@@ -428,7 +428,7 @@
         IFNULL(SUM(IFNULL(toc.receivable_money,0)),0) totalReceivableMoney,
         IFNULL(SUM(IFNULL(toc.discount_money,0)),0) totalDiscountMoney,
         IFNULL(SUM(IFNULL(toc.pay_money,0)),0) totalPayMoney,
-        IFNULL(SUM(IFNULL(toc.change_receivable_money,0)),0) totalReceiveMoney
+        IFNULL(SUM((CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END)),0) totalReceiveMoney
         FROM t_order toc
         WHERE toc.del_flag = 0 AND toc.user_id = #{param.memberUserId}
         <if test="param.orderStatus != null">
@@ -461,7 +461,7 @@
         toc.discount_money discountMoney,
         toc.receivable_money receivableMoney,
         toc.pay_money payMoney,
-        toc.change_receivable_money receiveMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) receiveMoney,
         toc.create_time createTime,
         toc.order_from orderFrom,
         CASE toc.order_from
@@ -597,7 +597,7 @@
         COUNT(temp.order_id) shopOrderTotal,
         IFNULL(SUM(CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END),0) shopOrderMoneyTotal,
         IFNULL(SUM(temp.pay_money),0) shopPayMoneyTotal,
-        IFNULL(SUM(CASE WHEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) &gt; temp.pay_money THEN temp.change_receivable_money - temp.pay_money ELSE 0 END),0) shopUnPayMoneyTotal
+        IFNULL(SUM(CASE WHEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) &gt; temp.pay_money THEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) - temp.pay_money ELSE 0 END),0) shopUnPayMoneyTotal
         FROM
         (SELECT toc.order_id,toc.change_receivable_money,toc.receivable_money,toc.pay_money
         FROM t_order toc
@@ -633,11 +633,11 @@
     <select id="totalOrderThird" resultType="com.ruoyi.order.domain.vo.MgtOrderTotal">
         SELECT
         COUNT(temp.order_id) activityOrderTotal,
-        IFNULL(SUM(temp.change_receivable_money),0) activityOrderMoneyTotal,
+        IFNULL(SUM(CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END),0) activityOrderMoneyTotal,
         IFNULL(SUM(temp.pay_money),0) activityPayMoneyTotal,
-        IFNULL(SUM(CASE WHEN temp.change_receivable_money &gt; temp.pay_money THEN temp.change_receivable_money - temp.pay_money ELSE 0 END),0)activityUnPayMoneyTotal
+        IFNULL(SUM(CASE WHEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) &gt; temp.pay_money THEN (CASE WHEN null = temp.change_receivable_money or temp.change_receivable_money = 0 THEN temp.receivable_money ELSE temp.change_receivable_money END) - temp.pay_money ELSE 0 END),0)activityUnPayMoneyTotal
         FROM
-        (SELECT toc.order_id,toc.change_receivable_money,toc.pay_money
+        (SELECT toc.order_id,toc.change_receivable_money,toc.receivable_money,toc.pay_money
         FROM t_order toc
         INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id
         WHERE toc.del_flag = 0 AND toc.order_from = 2
@@ -790,10 +790,10 @@
         IFNULL(SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END),0) onlineTotal,
         IFNULL(SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END),0) offlineTotal,
         IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
-        IFNULL(SUM(change_receivable_money),0) orderMoney,
-        IFNULL(SUM(CASE WHEN order_from = 1 THEN change_receivable_money ELSE 0 END),0) onlineMoney,
-        IFNULL(SUM(CASE WHEN order_from = 3 THEN change_receivable_money ELSE 0 END),0) offlineMoney,
-        IFNULL(SUM(CASE WHEN order_from = 2 THEN change_receivable_money ELSE 0 END),0) activityMoney
+        IFNULL(SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END),0) orderMoney,
+        IFNULL(SUM(CASE WHEN order_from = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) onlineMoney,
+        IFNULL(SUM(CASE WHEN order_from = 3 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) offlineMoney,
+        IFNULL(SUM(CASE WHEN order_from = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) activityMoney
         FROM t_order WHERE del_flag = 0 AND order_status = 3
         <if test="param.shopId != null and param.shopId != ''">
             AND shop_id = #{param.shopId}
@@ -860,7 +860,7 @@
         SELECT
             DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
             COUNT(order_id) AS mapValueFirst,
-            IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) AS mapValueSecond
+            IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
         FROM t_order
         WHERE del_flag = 0 AND order_status = 3
         <if test="param.shopId != null and param.shopId != ''">
@@ -923,7 +923,7 @@
         WHEN 2 THEN "秒杀订单"
         WHEN 3 THEN "线下订单"
         END mapKey,
-        IFNULL(SUM(CASE WHEN toc.pay_type = 1 THEN toc.change_receivable_money WHEN toc.pay_type = 2 THEN toc.change_receivable_money + toc.online_pay_money ELSE 0 END),0) mapValue
+        IFNULL(SUM(CASE WHEN toc.pay_type = 1 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) WHEN toc.pay_type = 2 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) + toc.online_pay_money ELSE 0 END),0) mapValue
         FROM t_order toc
         WHERE toc.del_flag = 0 AND toc.order_status = 3
         <if test="param.shopId != null and param.shopId != ''">
@@ -942,7 +942,7 @@
     <select id="getTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtTotalActivityTotalVo">
         SELECT
         COUNT(CASE WHEN order_status = 3 THEN order_id ELSE NULL END) orderTotal,
-        IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN change_receivable_money WHEN order_status = 3 AND pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) orderMoney,
+        IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN order_status = 3 AND pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) orderMoney,
         COUNT(DISTINCT user_id) orderJoinPerson
         FROM t_order WHERE del_flag = 0 AND order_from = 2 AND order_status =3 AND shop_id = #{param.shopId}
         <if test="param.startDate!=null and param.startDate!=''">
@@ -975,7 +975,7 @@
         SELECT
         DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
         COUNT(DISTINCT order_id) AS mapValueFirst,
-        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) AS mapValueSecond
+        IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
         FROM t_order
         WHERE del_flag = 0 AND order_from = 2 AND order_status = 3 AND shop_id = #{param.shopId}
         <if test="param.startDate!=null and param.startDate!=''">
@@ -1075,7 +1075,7 @@
     </select>
 
     <select id="shopSalesTotal" resultType="java.math.BigDecimal">
-        SELECT IFNULL(SUM(CASE pay_type WHEN 1 THEN change_receivable_money WHEN 2 THEN change_receivable_money+online_pay_money ELSE 0 END),0)
+        SELECT IFNULL(SUM(CASE pay_type WHEN 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0)
         FROM t_order
         WHERE del_flag = 0 AND order_status = 3
         <if test="param.shopId != null and param.shopId != ''">
@@ -1177,10 +1177,10 @@
         IFNULL(SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END),0) onlineTotal,
         IFNULL(SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END),0) offlineTotal,
         IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
-        IFNULL(SUM(change_receivable_money),0) orderMoney,
-        IFNULL(SUM(CASE WHEN order_from = 1 THEN change_receivable_money ELSE 0 END),0) onlineMoney,
-        IFNULL(SUM(CASE WHEN order_from = 3 THEN change_receivable_money ELSE 0 END),0) offlineMoney,
-        IFNULL(SUM(CASE WHEN order_from = 2 THEN change_receivable_money ELSE 0 END),0) activityMoney
+        IFNULL(SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END),0) orderMoney,
+        IFNULL(SUM(CASE WHEN order_from = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) onlineMoney,
+        IFNULL(SUM(CASE WHEN order_from = 3 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) offlineMoney,
+        IFNULL(SUM(CASE WHEN order_from = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) activityMoney
         FROM t_order WHERE del_flag = 0 AND order_status = 3
         <if test="param.shopIdList != null and param.shopIdList.size() > 0">
             AND shop_id IN
@@ -1225,7 +1225,7 @@
         SELECT
         DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
         COUNT(order_id) AS mapValueFirst,
-        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) AS mapValueSecond
+        IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
         FROM
         t_order
         WHERE del_flag = 0 AND order_status = 3
@@ -1299,7 +1299,7 @@
         WHEN 2 THEN "秒杀订单"
         WHEN 3 THEN "线下订单"
         END mapKey,
-        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) mapValue
+        IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) mapValue
         FROM t_order toc
         WHERE toc.del_flag = 0 AND order_status = 3
         <if test="param.shopIdList != null and param.shopIdList.size() > 0">
@@ -1321,7 +1321,7 @@
     <select id="getPlTotalActivityTotal" resultType="com.ruoyi.order.domain.vo.MgtPlTotalActivityTotalVo">
         SELECT
         COUNT(CASE WHEN order_status = 3 THEN order_id ELSE NULL END) orderTotal,
-        IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN change_receivable_money WHEN order_status = 3 AND pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) orderMoney,
+        IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN order_status = 3 AND pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) orderMoney,
         COUNT(DISTINCT user_id) orderJoinPerson
         FROM t_order WHERE del_flag = 0 AND order_from = 2
         <if test="param.shopId != null and param.shopId != ''">
@@ -1424,7 +1424,7 @@
         SELECT
         DATE_FORMAT(create_time, '%Y-%m-%d') AS mapKey,
         COUNT(DISTINCT order_id) AS mapValueFirst,
-        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money + online_pay_money ELSE 0 END),0) AS mapValueSecond
+        IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) + online_pay_money ELSE 0 END),0) AS mapValueSecond
         FROM t_order
         WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
         <if test="param.activityId!=null and param.activityId!=''">
@@ -1516,7 +1516,7 @@
     <select id="listPlTotalShopActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
         SELECT
         shop_id AS mapKey,
-        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money+online_pay_money ELSE 0 END),0) AS mapValue
+        IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) AS mapValue
         FROM t_order
         WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
         <if test="param.activityId!=null and param.activityId!=''">
@@ -1544,7 +1544,7 @@
     <select id="listPlTotalActivitySalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
         SELECT
         activity_name AS mapKey,
-        IFNULL(SUM(CASE WHEN pay_type = 1 THEN change_receivable_money WHEN pay_type = 2 THEN change_receivable_money+online_pay_money ELSE 0 END),0) AS mapValue
+        IFNULL(SUM(CASE WHEN pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) AS mapValue
         FROM t_order
         WHERE del_flag = 0 AND order_from = 2 AND order_status = 3
         <if test="param.activityId!=null and param.activityId!=''">
@@ -1572,7 +1572,7 @@
     <select id="getMerHomeShopTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo">
         SELECT
             IFNULL(SUM(CASE WHEN order_status = 2 AND order_from = 1 THEN 1 ELSE 0 END),0) unHandleOrder,
-            IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN change_receivable_money WHEN order_status = 3 AND pay_type = 2 THEN change_receivable_money+online_pay_money ELSE 0 END),0) shopTurnover
+            IFNULL(SUM(CASE WHEN order_status = 3 AND pay_type = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN order_status = 3 AND pay_type = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) shopTurnover
         FROM t_order
         WHERE del_flag = 0 AND shop_id = #{shopId} AND order_status IN (2,3)
     </select>
@@ -1600,7 +1600,7 @@
     </select>
 
     <select id="getMemberUnpaidOrder" resultType="java.math.BigDecimal">
-        SELECT IFNULL(SUM(toc.change_receivable_money-IFNULL(CASE toc.pay_type WHEN 1 THEN toc.online_pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END,0)),0)
+        SELECT IFNULL(SUM((CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END)-IFNULL(CASE toc.pay_type WHEN 1 THEN toc.online_pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END,0)),0)
         FROM t_order toc
         WHERE toc.del_flag = 0 AND toc.user_id = #{param.userId} AND toc.shop_id = #{param.shopId} AND toc.order_status IN (2,3) AND toc.close_flag = 0
     </select>
@@ -1612,10 +1612,10 @@
         IFNULL(SUM(CASE WHEN order_from = 1 THEN 1 ELSE 0 END),0) onlineTotal,
         IFNULL(SUM(CASE WHEN order_from = 3 THEN 1 ELSE 0 END),0) offlineTotal,
         IFNULL(SUM(CASE WHEN order_from = 2 THEN 1 ELSE 0 END),0) activityTotal,
-        IFNULL(SUM(change_receivable_money),0) orderMoney,
-        IFNULL(SUM(CASE WHEN order_from = 1 THEN change_receivable_money ELSE 0 END),0) onlineMoney,
-        IFNULL(SUM(CASE WHEN order_from = 3 THEN change_receivable_money ELSE 0 END),0) offlineMoney,
-        IFNULL(SUM(CASE WHEN order_from = 2 THEN change_receivable_money ELSE 0 END),0) activityMoney
+        IFNULL(SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END),0) orderMoney,
+        IFNULL(SUM(CASE WHEN order_from = 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) onlineMoney,
+        IFNULL(SUM(CASE WHEN order_from = 3 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) offlineMoney,
+        IFNULL(SUM(CASE WHEN order_from = 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) ELSE 0 END),0) activityMoney
         FROM t_order WHERE del_flag = 0 AND order_status = 3
         <if test="param.shopId != null and param.shopId != ''">
             AND shop_id = #{param.shopId}
@@ -1751,9 +1751,9 @@
         SELECT
         COUNT(toc.order_id) orderTotal,
         IFNULL(SUM(CASE toc.pay_type WHEN 1 THEN toc.receivable_money WHEN 2 THEN order_money-coupon_money-online_pay_money END),0) receivableMoney,
-        IFNULL(SUM(toc.change_receivable_money),0) relReceiveMoney,
+        IFNULL(SUM(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END),0) relReceiveMoney,
         IFNULL(SUM(IF(toc.order_from = 3, toc.offline_pay_money, IF(toc.order_from != 3 AND toc.pay_type = 1, toc.online_pay_money, IFNULL(toc.offline_pay_money,0)))),0) relPayMoney,
-        IFNULL(SUM(toc.change_receivable_money-IFNULL(IF(toc.order_from = 3, toc.offline_pay_money, IF(toc.order_from != 3 AND toc.pay_type = 1, toc.online_pay_money, IFNULL(toc.offline_pay_money,0))),0)),0) unpaidMoney,
+        IFNULL(SUM((CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END)-IFNULL(IF(toc.order_from = 3, toc.offline_pay_money, IF(toc.order_from != 3 AND toc.pay_type = 1, toc.online_pay_money, IFNULL(toc.offline_pay_money,0))),0)),0) unpaidMoney,
         IFNULL(SUM(CASE toc.pay_type WHEN 2 THEN toc.online_pay_money ELSE 0 END),0) receivableDeposit
         FROM t_order toc
         WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} and if(toc.order_from = 1, 1 = 1, toc.order_status = 3)<!--临时增加过滤-->
@@ -1800,7 +1800,7 @@
         toc.order_money orderMoney,
         toc.discount_money discountMoney,
         CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
-        toc.change_receivable_money payMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) payMoney,
         CASE toc.order_from WHEN 1 THEN '小程序' WHEN 2 THEN CONCAT('秒杀活动(',toc.activity_name,')') WHEN 3 THEN '线下创建' END orderFrom,
         CASE toc.order_status
         WHEN 0 THEN "已取消"
@@ -1841,7 +1841,7 @@
     <select id="getStaffActivityOrderTotal" resultType="com.ruoyi.order.domain.vo.StaffActivityOrderTotalVo">
         SELECT
             COUNT(DISTINCT toc.order_id) orderTotal,
-            IFNULL(SUM(CASE WHEN toc.pay_type = 1 THEN toc.change_receivable_money WHEN toc.pay_type = 2 THEN toc.change_receivable_money + toc.online_pay_money ELSE 0 END),0) orderMoney,
+            IFNULL(SUM(CASE WHEN toc.pay_type = 1 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) WHEN toc.pay_type = 2 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) + toc.online_pay_money ELSE 0 END),0) orderMoney,
             COUNT(DISTINCT toc.user_id) memberTotal
         FROM t_order toc
         WHERE toc.del_flag = 0 AND toc.shop_id = #{param.shopId} AND toc.order_from = 2 AND toc.order_status = 3
@@ -2079,7 +2079,7 @@
         SELECT
         COUNT(DISTINCT toc.order_id) orderTotal,
         IFNULL(SUM(toc.order_money),0) totalOrderMoney,
-        IFNULL(SUM(toc.change_receivable_money),0) totalReceiveMoney,
+        IFNULL(SUM(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END),0) totalReceiveMoney,
         IFNULL(SUM(CASE WHEN toc.pay_type = 2 THEN toc.online_pay_money ELSE 0 END),0) totalDepositMoney
         FROM t_order toc
         WHERE toc.del_flag = 0
@@ -2116,9 +2116,9 @@
             CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
             toc.receivable_deposit receivableDeposit,
             toc.pay_money payMoney,
-            toc.change_receivable_money relReceiveMoney,
+            (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
             CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
-            toc.change_receivable_money - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
+            (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
             tpr.pay_time receiveMoneyTime,
             tpr.pay_money thisReceiveMoney,
             CASE tpr.pay_type WHEN 1 THEN "微信" WHEN 2 THEN "现金" WHEN 3 THEN "支付宝" END thisReceiveType
@@ -2140,9 +2140,9 @@
         CASE toc.pay_type WHEN 1 THEN toc.order_money-toc.coupon_money WHEN 2 THEN toc.order_money-toc.coupon_money-toc.online_pay_money END receivableMoney,
         toc.receivable_deposit receivableDeposit,
         toc.pay_money payMoney,
-        toc.change_receivable_money relReceiveMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) relReceiveMoney,
         CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END receiveMoney,
-        toc.change_receivable_money - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
+        (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) unPaidMoney,
         toc.order_remark orderRemark,
         toc.create_time createTime,
         toc.order_from orderFrom,
@@ -2155,7 +2155,7 @@
     <select id="shopSalesRank" resultType="com.ruoyi.system.api.domain.vo.MgtMapBigTotalVo">
         SELECT
         shop_id mapKey,
-        SUM(change_receivable_money) mapValue
+        SUM(CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) mapValue
         FROM t_order
         WHERE del_flag = 0 AND order_status = 3 AND shop_id IN
         <foreach collection="shopIdList" item="item" open="(" separator="," close=")">
@@ -2167,7 +2167,7 @@
 
     <select id="getAgencyTotalVo" resultType="com.ruoyi.system.api.domain.vo.AgencyTotalVo">
         SELECT
-        IFNULL(SUM(CASE pay_type WHEN 1 THEN change_receivable_money WHEN 2 THEN change_receivable_money+online_pay_money ELSE 0 END),0) areaTurnover
+        IFNULL(SUM(CASE pay_type WHEN 1 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END) WHEN 2 THEN (CASE WHEN null = change_receivable_money or change_receivable_money = 0 THEN receivable_money ELSE change_receivable_money END)+online_pay_money ELSE 0 END),0) areaTurnover
         FROM t_order
         WHERE del_flag = 0 AND order_status = 3 AND shop_id IN
         <foreach collection="shopIdList" item="item" open="(" separator="," close=")">
@@ -2178,8 +2178,8 @@
     <select id="getMerMemberSimpleTotalVo" resultType="com.ruoyi.system.api.domain.vo.MerMemberSimpleTotalVo">
         SELECT
             COUNT(DISTINCT toc.order_id) userNumber,
-            IFNULL(SUM(toc.change_receivable_money),0) payMoney,
-            IFNULL(SUM(CASE WHEN toc.close_flag = 0 THEN toc.change_receivable_money - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) ELSE 0 END),0) unpaidMoney
+            IFNULL(SUM(CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END),0) payMoney,
+            IFNULL(SUM(CASE WHEN toc.close_flag = 0 THEN (CASE WHEN null = toc.change_receivable_money or toc.change_receivable_money = 0 THEN toc.receivable_money ELSE toc.change_receivable_money END) - (CASE toc.pay_type WHEN 1 THEN toc.pay_money WHEN 2 THEN IFNULL(toc.offline_pay_money,0) END) ELSE 0 END),0) unpaidMoney
         FROM t_order toc
         WHERE toc.del_flag = 0 AND toc.user_id = #{param.userId} AND toc.shop_id = #{param.shopId} AND toc.order_status IN (2,3)
     </select>
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 511a243..15f9a03 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
@@ -1249,7 +1249,7 @@
                 userIdList.add(mgtBasePlatformDto.getUserId());
             } else {
                 MgtUserIdByDept mgtUserIdByDept = new MgtUserIdByDept();
-                mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getUserId());
+                mgtUserIdByDept.setDeptId(mgtBasePlatformDto.getDeptId());
                 mgtUserIdByDept = configService.getUserIdByDept(mgtUserIdByDept).getData();
                 userIdList = mgtUserIdByDept.getUserIdList();
             }
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/config/RecommendCooperationMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/config/RecommendCooperationMapper.xml
index bbc6bbd..6aaf1ed 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/config/RecommendCooperationMapper.xml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/config/RecommendCooperationMapper.xml
@@ -22,7 +22,7 @@
             trc.id id,
             trc.recommended_name recommendedName,
             trc.recommended_phone recommendedPhone,
-            su.nick_name recommendUserName,
+            CONCAT(su.nick_name, "-", su.phonenumber) recommendUserName,
             trc.member_source memberSource,
             trc.create_time createTime
         FROM t_recommend_cooperation trc

--
Gitblit v1.7.1