From 17b48b4731e2ac2b6d571049718be724eb31972b Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 19 三月 2025 20:52:35 +0800
Subject: [PATCH] 充电桩bug修改

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java |    3 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java  |   23 ++--
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml                  |  155 +++++++++++++++++++++++++++++++
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java |    9 -
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java            |    1 
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TShoppingOrderMapper.java            |    3 
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml                  |   54 ++++++++++
 7 files changed, 229 insertions(+), 19 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
index 7f5ff3e..ae7dd94 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TChargingOrderMapper.java
@@ -55,6 +55,7 @@
 	                                        @Param("pageCurr") Integer pageCurr, @Param("pageSize") Integer pageSize);
 
     List<ChargingOrderVO> chargingOrder(@Param("pageInfo") PageInfo<ChargingOrderVO> pageInfo, @Param("req") ChargingOrderQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2,@Param("endTime1") String endTime1,@Param("endTime2") String endTime11);
+    List<ChargingOrderVO> chargingOrderNolimit( @Param("req") ChargingOrderQuery dto, @Param("startTime1")String startTime1, @Param("startTime2")String startTime2,@Param("endTime1") String endTime1,@Param("endTime2") String endTime11);
 
     List<PayOrderDto> payOrderQuery(@Param("pageInfo")PageInfo<PayOrderDto> pageInfo,@Param("data") PayOrderQueryDto payOrderQueryDto);
 
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TShoppingOrderMapper.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TShoppingOrderMapper.java
index 262c3e1..f75922a 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TShoppingOrderMapper.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/mapper/TShoppingOrderMapper.java
@@ -28,7 +28,8 @@
 public interface TShoppingOrderMapper extends BaseMapper<TShoppingOrder> {
 
     List<TActivityStatisticslVO> activityStatistics(@Param("pageInfo") PageInfo<TActivityStatisticslVO> pageInfo, @Param("req")TActivityStatisticsQuery dto);
-    
+    List<TActivityStatisticslVO> activityStatisticsNolimit(@Param("req")TActivityStatisticsQuery dto);
+
     
     /**
      * 获取未开票的订单数据
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java
index 80d608d..0f7d4b0 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingBillServiceImpl.java
@@ -363,8 +363,8 @@
                             .setScale(2,BigDecimal.ROUND_DOWN));
                 }
                 // 累加平台分佣
-                if (tChargingOrder.getSharingAmount()!=null){
-                    sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount());
+                if (tChargingOrder.getOrderSource()==2 && tChargingOrder.getServiceCharge()!=null){
+                    sharingAmount = sharingAmount.add(tChargingOrder.getServiceCharge().multiply(BigDecimal.valueOf(0.2)).setScale(2,BigDecimal.ROUND_DOWN));
                 }
                 // 累加充电度数
                 if (tChargingOrder.getChargingCapacity()!=null){
@@ -412,11 +412,15 @@
         BigDecimal bigDecimal = new BigDecimal("0");
         int i = 0;
         for (ChargingBillListVO chargingBillListVO : list1) {
-            if (chargingBillListVO.getSiteId()!=0&&!siteIds.contains(chargingBillListVO.getSiteId())){
-                continue;
-            }
-            if (chargingBillListVO.getType()==1){
-                continue;
+            if (dto.getType() == 1){
+
+            }else{
+                if (chargingBillListVO.getSiteId()!=0&&!siteIds.contains(chargingBillListVO.getSiteId())){
+                    continue;
+                }
+                if (chargingBillListVO.getType()==1){
+                    continue;
+                }
             }
             i++;
             LocalDateTime billTime = chargingBillListVO.getBillTime();
@@ -447,7 +451,6 @@
                 if (tChargingOrder.getOrderAmount()!=null){
                     paymentAmountTotal = paymentAmountTotal.add(tChargingOrder.getPaymentAmount());
                 }
-
                 // 累加订单金额
                 if (tChargingOrder.getRechargeAmount()!=null){
                     orderAmountTotal = orderAmountTotal.add(tChargingOrder.getRechargeAmount());
@@ -475,8 +478,8 @@
                             .setScale(2,BigDecimal.ROUND_DOWN));
                 }
                 // 累加平台分佣
-                if (tChargingOrder.getSharingAmount()!=null){
-                    sharingAmountTotal = sharingAmountTotal.add(tChargingOrder.getSharingAmount());
+                if (tChargingOrder.getOrderSource()==2 && tChargingOrder.getServiceCharge()!=null){
+                    sharingAmountTotal = sharingAmountTotal.add(tChargingOrder.getServiceCharge().multiply(BigDecimal.valueOf(0.2)).setScale(2,BigDecimal.ROUND_DOWN));
                 }
                 // 累加充电度数
                 if (tChargingOrder.getElectricity()!=null){
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
index e332428..75c13ed 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -1287,7 +1287,6 @@
 			endTime2 = split[1];
 		}
 		PageInfo<ChargingOrderVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
-		PageInfo<ChargingOrderVO> pageInfo1 = new PageInfo<>(1,999999999);
 
 		if (StringUtils.hasLength(dto.getPhone())){
 			List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData();
@@ -1333,7 +1332,7 @@
 		if (siteIds.isEmpty())siteIds.add(-1);
 		dto.setSiteIds(siteIds);
 		List<ChargingOrderVO> list = this.baseMapper.chargingOrder(pageInfo,dto,startTime1,startTime2,endTime1,endTime2);
-		List<ChargingOrderVO> list1 = this.baseMapper.chargingOrder(pageInfo1,dto,startTime1,startTime2,endTime1,endTime2);
+		List<ChargingOrderVO> list1 = this.baseMapper.chargingOrderNolimit(dto,startTime1,startTime2,endTime1,endTime2);
 		 BigDecimal total = new BigDecimal("0");
 		 long time = 0L;
 		 BigDecimal electronicMoney = new BigDecimal("0");
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
index 3665af1..b52b3f8 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java
@@ -103,9 +103,8 @@
 
 
         PageInfo<TActivityStatisticslVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize());
-        PageInfo<TActivityStatisticslVO> pageInfo1 = new PageInfo<>(1,9999999);
         List<TActivityStatisticslVO> list = this.baseMapper.activityStatistics(pageInfo,dto);
-        List<TActivityStatisticslVO> list1 = this.baseMapper.activityStatistics(pageInfo1,dto);
+        List<TActivityStatisticslVO> list1 = this.baseMapper.activityStatisticsNolimit(dto);
 
         // 优惠券金额
         BigDecimal coupon = new BigDecimal("0");
@@ -179,9 +178,9 @@
                         tActivityStatisticslVO.setType("赠送会员");
                         tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime());
                     }else{
-                        // 赠送
-                        grantVip = grantVip.add(tActivityStatisticslVO.getVipDiscountAmount());
-                        tActivityStatisticslVO.setType("赠送会员");
+                        // 会员活动
+                        vipActivity = vipActivity.add(tActivityStatisticslVO.getVipDiscountAmount());
+                        tActivityStatisticslVO.setType("会员活动");
                         tActivityStatisticslVO.setTime(tActivityStatisticslVO.getCreateTime());
                     }
                     break;
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
index c92c846..ac677f1 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -392,7 +392,7 @@
         FROM
             t_charging_order
         <where>
-            del_flag = 0 and recharge_payment_status = 2
+            del_flag = 0
             <if test="siteIds != null and siteIds.size() > 0">
                 AND site_id IN
                 <foreach collection="siteIds" item="siteId" open="(" separator="," close=")">
@@ -1627,4 +1627,56 @@
         </foreach>
         </if>
     </select>
+    <select id="chargingOrderNolimit" resultType="com.ruoyi.order.api.vo.ChargingOrderVO">
+        select t1.*
+        from t_charging_order t1
+        where 1=1
+        <if test="null != req.code and req.code!=''">
+            and t1.code  LIKE CONCAT('%',#{req.code},'%')
+        </if>
+        <if test="null != req.userIds and req.userIds.size()>0" >
+            and t1.app_user_id in
+            <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="null != req.siteIds and req.siteIds.size()>0" >
+            and t1.site_id in
+            <foreach collection="req.siteIds" item="item" index="index" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="req.orderType != null ">
+            and t1.order_type = #{req.orderType}
+        </if>
+        <if test="req.status != null ">
+            and t1.status = #{req.status}
+        </if>
+        <if test="req.orderSource != null and req.orderSource == 1 ">
+            and (t1.order_source = 0 or t1.order_source = 1 )
+        </if>
+        <if test="req.orderSource != null and req.orderSource == 2 ">
+            and t1.tripartite_platform_name = 'KuaiDian'
+        </if>
+        <if test="req.orderSource != null and req.orderSource == 3 ">
+            and t1.tripartite_platform_name = 'XinDianTu'
+        </if>
+        <if test="req.siteId != null ">
+            and t1.site_id = #{req.siteId}
+        </if>
+        <if test="req.pileId != null ">
+            and t1.charging_pile_id = #{req.pileId}
+        </if>
+        <if test="req.gunId != null ">
+            and t1.charging_gun_id = #{req.gunId}
+        </if>
+        <if test="startTime1 != null and startTime1!=''">
+            and (t1.pay_time between #{startTime1} and #{startTime2})
+        </if>
+        <if test="endTime1 != null and endTime1!=''">
+            and (t1.end_time between #{endTime1} and #{endTime2})
+        </if>
+        and t1.del_flag = 0
+        order by t1.create_time desc
+    </select>
 </mapper>
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
index decc40a..1a6ea85 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml
@@ -308,4 +308,159 @@
 
 
     </select>
+    <select id="activityStatisticsNolimit" resultType="com.ruoyi.order.api.vo.TActivityStatisticslVO">
+        select * from (
+        select t9.code ,t9.order_amount as orderAmount,
+        t9.coupon_discount_amount as couponDiscountAmount,
+        t9.vip_discount_amount as vipDiscountAmount,
+        t9.payment_amount as paymentAmount,
+        t9.create_time as createTime,
+        t9.app_user_id as appUserId,
+        1 as orderType
+        from t_charging_order t9
+        where t9.id = 0
+        <if test="req.orderType == null or req.orderType == 1">
+            <if test="req.type == null or req.type == 1 or req.type == 2">
+                union all
+                select
+                t1.code ,
+                t1.order_amount as orderAmount,
+                t1.coupon_discount_amount as couponDiscountAmount,
+                t1.vip_discount_amount as vipDiscountAmount,
+                t1.payment_amount as paymentAmount,
+                t1.create_time as createTime,
+                t1.app_user_id as appUserId,
+                1 as orderType
+                from t_charging_order t1
+                where 1 = 1
+                <if test="null != req.code and req.code!=''">
+                    and t1.code  LIKE CONCAT('%',#{req.code},'%')
+                </if>
+                <if test="req.type != null and req.type == 1">
+                    and t1.coupon_discount_amount > 0
+                </if>
+                <if test="req.type != null and req.type == 2">
+                    and t1.vip_discount_amount > 0
+                </if>
+                <if test="null != req.userIds and req.userIds.size()>0" >
+                    and t1.app_user_id in
+                    <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="null != req.chargingPileIds and req.chargingPileIds.size()>0" >
+                    and t1.charging_pile_id in
+                    <foreach collection="req.chargingPileIds" item="item" index="index" separator="," open="(" close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
+                    AND (t1.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
+                </if>
+                and (t1.vip_discount_amount > 0 or t1.coupon_discount_amount > 0)
+                and t1.recharge_payment_status =2
+                AND t1.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+            </if>
+        </if>
+        <if test="req.siteId == null">
+            <if test="req.orderType == null or req.orderType == 2">
+                <if test="req.type == null or req.type == 1 or req.type == 2">
+                    union all
+                    select t2.code ,t2.order_amount as paymentAmount,
+                    t2.coupon_discount_amount as couponDiscountAmount,
+                    t2.vip_discount_amount as vipDiscountAmount,
+                    t2.payment_amount as orderAmount,
+                    t2.create_time as createTime,
+                    t2.app_user_id as appUserId,
+                    2 as orderType
+                    from t_shopping_order t2
+                    where 1 = 1
+                    <if test="null != req.code and req.code!=''">
+                        and t2.code  LIKE CONCAT('%',#{req.code},'%')
+                    </if>
+                    <if test="req.type != null and req.type != '' and req.type == 1">
+                        and (t2.coupon_discount_amount  > 0)
+                    </if>
+                    <if test="req.type != null and req.type != '' and req.type == 2">
+                        and ( t2.vip_discount_amount  > 0)
+                    </if>
+                    <if test="req.type == null ">
+                        and (t2.vip_discount_amount  > 0 or t2.coupon_discount_amount  > 0)
+                    </if>
+                    <if test="null != req.userIds and req.userIds.size()>0" >
+                        and t2.app_user_id in
+                        <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
+                        AND (t2.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
+                    </if>
+                    and t2.payment_status =2
+                    AND t2.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+                </if>
+            </if>
+            <if test="req.orderType == null or req.orderType == 3">
+                <if test="req.type == null or req.type == 3">
+                    union all
+                    select t3.code ,t3.order_amount as orderAmount,
+                    0 as couponDiscountAmount,
+                    t3.discount_amount as vipDiscountAmount,
+                    t3.payment_amount as paymentAmount,
+                    t3.create_time as createTime,
+                    t3.app_user_id as appUserId,
+                    3 as orderType
+                    from t_vip_order t3
+                    where 1 = 1
+                    and t3.type =1
+                    <if test="null != req.code and req.code!=''">
+                        and t3.code  LIKE CONCAT('%',#{req.code},'%')
+                    </if>
+                    and t3.discount_amount  > 0
+                    <if test="null != req.userIds and req.userIds.size()>0" >
+                        and t3.app_user_id in
+                        <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
+                        AND (t3.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
+                    </if>
+                    and t3.payment_status =2
+                    AND t3.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+                </if>
+            </if>
+            <if test="req.orderType == null or req.orderType == 4">
+                <if test="req.type == null or req.type == 4">
+                    union all
+                    select t5.code ,t5.order_amount as orderAmount,
+                    0 as couponDiscountAmount,
+                    0 as vipDiscountAmount,
+                    0 as paymentAmount,
+                    t5.create_time as createTime,
+                    t5.app_user_id as appUserId,
+                    4 as orderType
+                    from t_grant_vip t5
+                    where 1 = 1
+                    <if test="null != req.code and req.code!=''">
+                        and t5.code  LIKE CONCAT('%',#{req.code},'%')
+                    </if>
+                    <if test="null != req.userIds and req.userIds.size()>0" >
+                        and t5.app_user_id in
+                        <foreach collection="req.userIds" item="item" index="index" separator="," open="(" close=")">
+                            #{item}
+                        </foreach>
+                    </if>
+                    <if test="req.endTime != null and req.endTime != '' and req.startTime != null and req.startTime != ''">
+                        AND (t5.create_time between CONCAT(#{req.startTime},':00') and CONCAT(#{req.endTime},':59'))
+                    </if>
+                    AND t5.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
+                </if>
+            </if>
+        </if>
+        )
+        order by createTime DESC
+
+
+    </select>
 </mapper>

--
Gitblit v1.7.1