longz
2026-07-28 79f1a19bb3344de47dff029cf5498d787e223782
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
<?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.TAccountSettlementStatementMapper">
 
    <sql id="statementWhere">
        <where>
            <if test="req.type != null and req.type == 1">
                AND site_id = 0
            </if>
            <if test="req.type != null and req.type == 2">
                AND site_id &gt; 0
            </if>
            <if test="req.state != null">
                AND status = #{req.state}
            </if>
            AND account_type = 3
            <if test="req.uid != null and req.uid != ''">
                AND id = #{req.uid}
            </if>
            <if test="startCycle != null">
                AND billing_cycle &gt;= #{startCycle}
            </if>
            <if test="endCycle != null">
                AND billing_cycle &lt; #{endCycle}
            </if>
            AND site_id IN
            <foreach collection="siteIds" open="(" close=")" separator="," item="siteId">
                #{siteId}
            </foreach>
        </where>
    </sql>
 
    <select id="selectStatementPage" resultType="com.ruoyi.order.api.model.TAccountSettlementStatement">
        SELECT id, site_id, billing_cycle, status, code, account_type,
               recharge_amount, refund_amount, platform_fee,
               tripartite_commission, recorded_amount,
               platform_income, partner_income, create_time
        FROM t_account_settlement_statement
        <include refid="statementWhere"/>
        ORDER BY billing_cycle DESC, account_type ASC, site_id ASC
    </select>
 
    <select id="selectStatementSummary" resultType="com.ruoyi.order.api.vo.AccountListVO">
        SELECT COUNT(*) AS billCount,
               COALESCE(SUM(recorded_amount), 0) AS totalAmount,
               COALESCE(SUM(recharge_amount), 0) AS paymentAmount,
               COALESCE(SUM(refund_amount), 0) AS refundAmount,
               COALESCE(SUM(platform_fee), 0) AS commissionAmount,
               COALESCE(SUM(tripartite_commission), 0) AS sharingAmount,
               COALESCE(SUM(platform_income), 0) AS platformIncome,
               COALESCE(SUM(partner_income), 0) AS partnerIncome
        FROM t_account_settlement_statement
        <include refid="statementWhere"/>
    </select>
 
</mapper>