luodangjia
2025-01-15 2bc35df79fca920ad584a82b5ea7b35b6ca7b8a0
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
<?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.account.mapper.BalanceChangeRecordMapper">
 
    <select id="pageList" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
                select t1.*,t2.name as userName,t2.phone as userPhone
                from t_balance_change_record t1
                left join  t_app_user t2 on t1.app_user_id = t2.id
                <where>
                    <if test="agentQuery.userName != null and agentQuery.userName != ''">
                        and t2.name like concat('%',#{agentQuery.userName},'%')
                    </if>
                    <if test="agentQuery.userPhone != null and agentQuery.userPhone != ''">
                        and t2.phone like concat('%',#{agentQuery.userPhone},'%')
                    </if>
                    <if test="agentQuery.changeType != null">
                        and t1.change_type = #{agentQuery.changeType}
                    </if>
                    <if test="agentQuery.localDate1 != null">
                        and DATE(t1.create_time) between  #{agentQuery.localDate1} and #{agentQuery.localDate2}
                    </if>
                </where>
                order by t1.create_time desc
    </select>
 
    <sql id="balanceChangeRecordList">
        SELECT
            tau.`name` userName,
            tau.phone userPhone,
            tbcr.change_type,
            tbcr.create_time,
            tbcr.change_amount,
        tbcr.before_amount,
        tbcr.after_amount
        FROM
            t_balance_change_record tbcr
        LEFT JOIN t_app_user tau ON tbcr.app_user_id = tau.id
        <where>
            and tbcr.change_type = 4
            <if test="changeRecord.userName != null and changeRecord.userName != ''">
                and tau.name like concat('%',#{changeRecord.userName},'%')
            </if>
            <if test="changeRecord.userPhone != null and changeRecord.userPhone != ''">
                and tau.phone like concat('%',#{changeRecord.userPhone},'%')
            </if>
            <if test="changeRecord.startTime != null and changeRecord.endTime != null">
                and (tbcr.create_time between  #{changeRecord.startTime} and #{changeRecord.endTime})
            </if>
            <if test="changeRecord.changeType != null">
                and tbcr.change_type = #{changeRecord.changeType}
            </if>
        </where>
    </sql>
 
    <select id="selectBalanceChangeRecordList" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
        <include refid="balanceChangeRecordList"/>
    </select>
    <select id="queryCommissionStatistics" resultType="com.ruoyi.account.api.model.BalanceChangeRecord">
        <include refid="balanceChangeRecordList"/>
    </select>
</mapper>