mitao
2025-03-19 0ab9dfd8f122195e4e9f09bd50c59e0a47450bec
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
<?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.system.mapper.TBankFlowMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TBankFlow">
        <id column="id" property="id" />
        <result column="bank_serial_number" property="bankSerialNumber" />
        <result column="flow_money" property="flowMoney" />
        <result column="deduction_money" property="deductionMoney" />
        <result column="remaining_money" property="remainingMoney" />
        <result column="pay_time" property="payTime" />
        <result column="payer" property="payer" />
        <result column="flow_status" property="flowStatus" />
        <result column="pay_type" property="payType" />
        <result column="payment_bill_id" property="paymentBillId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_by" property="createBy" />
        <result column="update_by" property="updateBy" />
        <result column="disabled" property="disabled" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, bank_serial_number, flow_money, deduction_money, remaining_money, pay_time, payer, flow_status, pay_type, payment_bill_id, create_time, update_time, create_by, update_by, disabled
    </sql>
 
 
    <!-- 定义结果映射 -->
    <resultMap id="PaymentStatsResultMap" type="com.ruoyi.system.vo.TBankFlowStatisticsVo">
        <result property="totalFlowMoney" column="totalFlowMoney" />
        <result property="totalDeductionMoney" column="totalDeductionMoney" />
        <result property="totalRemainingMoney" column="totalRemainingMoney" />
    </resultMap>
 
    <!-- 统计总额和微信支付金额 -->
    <select id="getPaymentStats" resultMap="PaymentStatsResultMap">
        SELECT
        ifnull(SUM(flow_money),0) AS totalFlowMoney,
        ifnull(SUM(deduction_money),0) AS totalDeductionMoney,
        ifnull(SUM(remaining_money),0) AS totalRemainingMoney
        FROM
        t_bank_flow
        <where>
            <if test="req.bankSerialNumber != null and req.bankSerialNumber != ''">
                and bank_serial_number = #{req.bankSerialNumber}
            </if>
            <if test="req.payer != null and req.payer != ''">
                and payer like concat('%', #{req.payer}, '%')
            </if>
            <if test="req.flowStatus != null and req.flowStatus != ''">
                and flow_status = #{req.flowStatus}
            </if>
            <if test="req.payStartTime != null and req.payStartTime != ''">
                and pay_time &gt;= #{req.payStartTime}
            </if>
            <if test="req.payEndTime != null and req.payEndTime != ''">
                and pay_time &lt;= #{req.payEndTime}
            </if>
            AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
    </select>
 
</mapper>