puzhibing
2023-06-30 f58cca364b731eac2d60a440ffaa804be3cd43fd
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
<?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.stylefeng.guns.modular.system.dao.TRechargeRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.stylefeng.guns.modular.system.model.TRechargeRecord">
        <id column="id" property="id" />
        <result column="type" property="type" />
        <result column="userId" property="userId" />
        <result column="code" property="code" />
        <result column="amount" property="amount" />
        <result column="payType" property="payType" />
        <result column="payTime" property="payTime" />
        <result column="payStatus" property="payStatus" />
        <result column="orderNumber" property="orderNumber" />
        <result column="createTime" property="createTime" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, `type`, userId, code, amount, payType, payTime, payStatus, orderNumber, createTime
    </sql>
    <select id="userRecharge" resultType="com.stylefeng.guns.modular.system.controller.resp.TRechargeRecordUserResp">
        select rr.id, rr.`type`, rr.userId, rr.code, rr.amount, rr.payType, rr.payTime, rr.payStatus, rr.orderNumber, rr.createTime,au.nickname AS userName,au.phone AS userPhone
        from t_recharge_record rr
        left join t_app_user au on rr.userId = au.id
        <where>
            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                AND rr.createTime between #{startTime} and #{endTime}
            </if>
            <if test="userName != null and userName != ''">
                AND au.nickname LIKE concat('%',#{userName},'%')
            </if>
            <if test="userPhone != null and userPhone != ''">
                AND au.phone LIKE concat('%',#{userPhone},'%')
            </if>
            <if test="code != null and code != ''">
                AND rr.code LIKE concat('%',#{code},'%')
            </if>
            AND rr.`type` = 1
        </where>
        ORDER BY rr.createTime DESC
    </select>
    <select id="agentRechargeList" resultType="com.stylefeng.guns.modular.system.controller.resp.TRechargeRecordAgentResp">
        select rr.id, rr.`type`, rr.userId, rr.code, rr.amount, rr.payType, rr.payTime, rr.payStatus, rr.orderNumber, rr.createTime,
               d.name AS driverName,d.phone AS driverPhone,a.principal,a.principalPhone,a.provinceName,a.cityName
        from t_recharge_record rr
        left join t_driver d on rr.userId = d.id
        left join t_agent a on d.agentId = a.id
        <where>
            <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
                AND rr.createTime between #{startTime} and #{endTime}
            </if>
            <if test="driverName != null and driverName != ''">
                AND d.name LIKE concat('%',#{driverName},'%')
            </if>
            <if test="driverPhone != null and driverPhone != ''">
                AND d.phone LIKE concat('%',#{driverPhone},'%')
            </if>
            <if test="roleType != null and roleType == 3">
                AND a.id = #{objectId}
            </if>
            AND rr.`type` = 3
        </where>
        ORDER BY rr.createTime DESC
    </select>
 
</mapper>