longz
2026-07-20 1494c13bfe2b16e34e503cf2527c38e2c2091fc4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.order.mapper.TChargingSettlementBillMapper">
 
    <select id="queryList" resultType="map">
        select
        a.*,
        DATE_FORMAT(a.billing_cycle, '%Y-%m') as billingCycle,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as createTime
        from t_charging_settlement_bill a
        <where>
            <if test="null != type and 1 == type">
                and a.site_id = 0
            </if>
            <if test="null != type and 2 == type">
                and a.site_id != 0
            </if>
            <if test="null != status">
                and a.`status` = #{status}
            </if>
            <if test="null != statisticalDateType">
                and a.statistical_date_type = #{statisticalDateType}
            </if>
            <if test="null != dateRange and dateRange.size() > 0">
                and DATE_FORMAT(a.billing_cycle, '%Y-%m') in
                <foreach collection="dateRange" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="null != siteIds and siteIds.size() > 0">
                and a.site_id in
                <foreach collection="siteIds" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        order by a.site_id
    </select>
 
 
    <select id="queryListSum" resultType="map">
        select
        sum(total_electricity) as totalElectricity,
        sum(funds_received) as fundsReceived,
        sum(total_amount) as totalAmount,
        sum(total_electricity_charge) as totalElectricityCharge,
        sum(total_service_fee) as totalServiceFee,
        sum(platform_fee) as platformFee,
        sum(tripartite_commission) as tripartiteCommission,
        sum(order_number) as orderNumber,
        sum(coupon_deduction) as couponDeduction
        from t_charging_settlement_bill
        <where>
            <if test="null != type and 1 == type">
                and site_id = 0
            </if>
            <if test="null != type and 2 == type">
                and site_id != 0
            </if>
            <if test="null != status">
                and `status` = #{status}
            </if>
            <if test="null != statisticalDateType">
                and statistical_date_type = #{statisticalDateType}
            </if>
            <if test="null != dateRange and dateRange.size() > 0">
                and DATE_FORMAT(billing_cycle, '%Y-%m') in
                <foreach collection="dateRange" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="null != siteIds and siteIds.size() > 0">
                and site_id in
                <foreach collection="siteIds" item="item" index="index" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
</mapper>