Bläddra i källkod

【admin】用户列表新增实付金额、优惠金额,退款扣减优惠金额显示

skyline 2 år sedan
förälder
incheckning
a176f27713

+ 6 - 3
admin-web/src/views/admin/account/index.vue

@@ -88,7 +88,7 @@
             :show-overflow-tooltip="!field.fixed&&field.width>150"
         >
           <template #default="{row}">
-            <template v-if="['rechargeAmount','totalMoney','refundAmount','balance'].includes(field.prop)">
+            <template v-if="['rechargeAmount','totalMoney','refundAmount','balance','payAmount','discountAmount','refundDiscountAmount'].includes(field.prop)">
               {{ u.fmt.fmtMoney(row[field.prop]) }}
             </template>
             <template v-else-if="'status'===field.prop">
@@ -162,8 +162,11 @@ const state = reactive({
       {label: '退款次数', width: 90, prop: 'refundTimes', resizable: true},
       {label: '退款金额', width: 90, prop: 'refundAmount', resizable: true},
       {label: '充电次数', width: 90, prop: 'chargeTimes', resizable: true},
-      {label: '总电量(度)', width: 120, prop: 'totalPower', resizable: true},
-      {label: '总金额(元)', width: 120, prop: 'totalMoney', resizable: true},
+      {label: '总电量/度', width: 100, prop: 'totalPower', resizable: true},
+      {label: '订单总额', width: 100, prop: 'totalMoney', resizable: true},
+      {label: '实付总额', width: 100, prop: 'payAmount', resizable: true},
+      {label: '优惠总额', width: 100, prop: 'discountAmount', resizable: true},
+      {label: '退款扣除优惠', width: 125, prop: 'refundDiscountAmount', resizable: true},
       // {
       //   label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
       // }

+ 6 - 0
entity/src/main/java/com/kym/entity/admin/vo/CustomUserVo.java

@@ -25,8 +25,14 @@ public class CustomUserVo {
     private int chargeTimes;
     private double totalPower;
     private int totalMoney;
+    private int payAmount;
+    private int discountAmount;
     private int balance;
     private Long refundTimes;
     private int refundAmount;
+    /**
+     * 退款扣除优惠总金额
+     */
+    private int refundDiscountAmount;
 
 }

+ 28 - 6
mapper/src/main/resources/mappers/miniapp/UserMapper.xml

@@ -31,6 +31,8 @@
         <result column="charge_times" property="chargeTimes"/>
         <result column="total_power" property="totalPower"/>
         <result column="total_money" property="totalMoney"/>
+        <result column="pay_amount" property="payAmount"/>
+        <result column="discount_amount" property="discountAmount"/>
     </resultMap>
 
     <!-- 通用查询结果列 -->
@@ -52,7 +54,9 @@
             t3.recharge_amount,
             t2.charge_times,
             t2.total_power,
-            t2.total_money
+            t2.total_money,
+            t2.pay_amount,
+            t2.discount_amount
             FROM
             t_user t1
             LEFT JOIN
@@ -60,10 +64,12 @@
             user_id,
             COUNT(IFNULL(1, 0)) charge_times,
             SUM(IFNULL(total_power, 0)) total_power,
-            SUM(IFNULL(total_money, 0)) total_money
+            SUM(IFNULL(total_money, 0)) total_money,
+            SUM(IFNULL(pay_amount, 0)) pay_amount,
+            SUM(IFNULL(discount_amount, 0)) discount_amount
             FROM
             t_charge_order
-            WHERE user_id = ${userId}
+            WHERE user_id = #{userId}
             AND order_status = 1) t2
             ON t1.`id` = t2.`user_id`
             LEFT JOIN
@@ -73,7 +79,7 @@
             SUM(IFNULL(amount, 0)) recharge_amount
             FROM
             t_wallet_detail
-            WHERE user_id = ${userId}
+            WHERE user_id = #{userId}
             AND TYPE = 1 AND status = 1) t3
             ON t1.`id` = t3.`user_id`
             WHERE t1.id = ${userId}
@@ -91,7 +97,9 @@
             t.recharge_amount,
             t1.charge_times,
             t1.total_power,
-            t1.total_money
+            t1.total_money,
+            t1.pay_amount,
+            t1.discount_amount
             FROM t_user `user`
             LEFT JOIN
             (SELECT user_id,
@@ -134,7 +142,21 @@
             THEN o.`total_money`
             ELSE 0
             END
-            ) total_money
+            ) total_money,
+            SUM(
+            CASE
+            WHEN o.`pay_amount` > 0
+            THEN o.`pay_amount`
+            ELSE 0
+            END
+            ) pay_amount,
+            SUM(
+            CASE
+            WHEN o.`discount_amount` > 0
+            THEN o.`discount_amount`
+            ELSE 0
+            END
+            ) discount_amount
             FROM t_charge_order o
             GROUP BY o.user_id) t1
             ON t1.user_id = user.id

+ 2 - 0
service/src/main/java/com/kym/service/miniapp/impl/UserServiceImpl.java

@@ -257,6 +257,7 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
         var refund = refundLogService.lambdaQuery().in(RefundLog::getUserId, result.stream().map(CustomUserVo::getUserId).toList()).list();
         // refund按照用户维度计算退款次数和退款总金额
         var user2RefundAmount = refund.stream().collect(Collectors.groupingBy(RefundLog::getUserId, Collectors.summingInt(RefundLog::getRefund)));
+        var user2RefundDiscountAmount = refund.stream().collect(Collectors.groupingBy(RefundLog::getUserId, Collectors.summingInt(RefundLog::getDiscountAmount)));
         var user2RefundTimes = refund.stream().collect(Collectors.groupingBy(RefundLog::getUserId, Collectors.counting()));
 
         // 将用户余额,退款次数,退款金额放入result中
@@ -264,6 +265,7 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
             vo.setBalance(user2Balance.getOrDefault(vo.getUserId(), 0));
             vo.setRefundTimes(user2RefundTimes.getOrDefault(vo.getUserId(), 0L));
             vo.setRefundAmount(user2RefundAmount.getOrDefault(vo.getUserId(), 0));
+            vo.setRefundDiscountAmount(user2RefundDiscountAmount.getOrDefault(vo.getUserId(), 0));
         }).toList();
         page.setList(res);
         return page;