From 01af32e3c41700b9992fd6469cf2161eea393288 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期六, 26 十月 2024 14:04:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TShoppingOrderMapper.xml                  |   36 ++++++++++++++++++------------------
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TShoppingOrderServiceImpl.java |   12 ++++--------
 2 files changed, 22 insertions(+), 26 deletions(-)

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 0e55c4c..674d491 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
@@ -106,7 +106,6 @@
         List<TActivityStatisticslVO> list = this.baseMapper.activityStatistics(pageInfo,dto);
         List<TActivityStatisticslVO> list1 = this.baseMapper.activityStatistics(pageInfo1,dto);
 
-        list.sort((o1, o2) -> o2.getCreateTime().compareTo(o1.getCreateTime()));
         // 优惠券金额
         BigDecimal coupon = new BigDecimal("0");
         // 会员抵扣金额
@@ -166,9 +165,7 @@
                     break;
                 case 3:
                     // 会员订单 优惠金额大于0
-                    if (tActivityStatisticslVO.getVipDiscountAmount()!=null
-                            &&
-                            (tActivityStatisticslVO.getCouponDiscountAmount().compareTo(BigDecimal.ZERO)>0)){
+                    if (tActivityStatisticslVO.getVipDiscountAmount()!=null){
                         vipActivity = vipActivity.add(tActivityStatisticslVO.getVipDiscountAmount());
                     }
                     tActivityStatisticslVO.setType("会员活动");
@@ -198,11 +195,10 @@
                     // 充电订单 优惠券金额大于0
                     if (tActivityStatisticslVO.getCouponDiscountAmount()!=null
                             &&
-                        (tActivityStatisticslVO.getCouponDiscountAmount().compareTo(BigDecimal.ZERO)>0)){
-                        stringBuilder.append("优惠券抵扣").append("+");
-                }
+                            (tActivityStatisticslVO.getCouponDiscountAmount().compareTo(BigDecimal.ZERO)>0)){
+                            stringBuilder.append("优惠券抵扣").append("+");
+                    }
                     if (tActivityStatisticslVO.getVipDiscountAmount()!=null &&(tActivityStatisticslVO.getVipDiscountAmount().compareTo(BigDecimal.ZERO)>0)){
-                        discount = discount.add(tActivityStatisticslVO.getVipDiscountAmount());
                         stringBuilder.append("会员抵扣").append("+");
                     }
                     if (stringBuilder.length()>0){
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 8d9321b..51bc3bb 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
@@ -44,6 +44,7 @@
         id, code, app_user_id, order_type, goods_id, coupon_id, purchase_quantity, app_user_address_id, order_amount, app_coupon_id, coupon_discount_amount, vip_discount, vip_discount_amount, payment_amount, payment_status, payment_type, serial_number, remark, status, express_company, express_number, consigner_id, consigner_time, receiving_time, cancellation_time, cancellation_id, refund_code, refund_amount, refund_status, refund_serial_number, refund_time, create_time, del_flag
     </sql>
     <select id="activityStatistics" 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,
@@ -52,32 +53,29 @@
         t9.app_user_id as appUserId,
         1 as orderType
         from t_charging_order t9
-        where t9.id = 0 limit 1
+        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.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
+            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 != '' and req.type == 1">
+            <if test="req.type != null and req.type == 1">
                 and t1.coupon_discount_amount > 0
             </if>
-            <if test="req.type != null and req.type != '' and req.type == 2">
+            <if test="req.type != null and req.type == 2">
                 and t1.vip_discount_amount > 0
-            </if>
-            <if test="req.type == null ">
-                and (t1.vip_discount_amount > 0 or t1.coupon_discount_amount > 0)
             </if>
             <if test="null != req.userIds and req.userIds.size()>0" >
                 and t1.app_user_id in
@@ -94,8 +92,9 @@
             <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.recharge_payment_status =2
-        and t1.refund_status !=2
+            and (t1.vip_discount_amount > 0 or t1.coupon_discount_amount > 0)
+            and t1.recharge_payment_status =2
+            and t1.refund_status !=2
             AND t1.del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()}
         </if>
         </if>
@@ -141,8 +140,8 @@
                 <if test="req.type == null or req.type == 3">
                     union all
                     select t3.code ,t3.order_amount as orderAmount,
-                    t3.discount_amount as couponDiscountAmount,
-                    0 as vipDiscountAmount,
+                    0 as couponDiscountAmount,
+                    t3.discount_amount as vipDiscountAmount,
                     t3.payment_amount as paymentAmount,
                     t3.create_time as createTime,
                     t3.app_user_id as appUserId,
@@ -194,10 +193,11 @@
                         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>
     
     

--
Gitblit v1.7.1