hjl
2024-07-02 242725f795b4cca830421c07f714a3ec36af0add
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?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.admin.mapper.WithdrawMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.admin.entity.Withdraw">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="user_phone" property="userPhone"/>
        <result column="apply_for_time" property="applyForTime"/>
        <result column="apply_for_money" property="applyForMoney"/>
        <result column="state" property="state"/>
        <result column="opinion" property="opinion"/>
        <result column="createBy" property="createBy"/>
        <result column="updateBy" property="updateBy"/>
        <result column="createTime" property="createTime"/>
        <result column="updateTime" property="updateTime"/>
        <result column="is_delete" property="isDelete"/>
    </resultMap>
 
    <select id="withdrawalTotalMoney" resultType="java.math.BigDecimal">
        SELECT sum(w.apply_for_money)
        FROM t_withdraw w
                 LEFT JOIN t_user u on w.user_id = u.id
        <where>
            <if test="cityList != null and cityList.size() != 0">
                u.city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="withdrawalTotalMoneyByYear" resultType="java.math.BigDecimal">
        SELECT sum(w.apply_for_money)
        FROM t_withdraw w
                 LEFT JOIN t_user u on w.user_id = u.id
        <where>
            YEAR(w.createTime) = YEAR(NOW())
              and w.is_delete = 0
            <if test="cityList != null and cityList.size() != 0">
                and u.city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="withdrawalTotalMoneyByMonth" resultType="java.math.BigDecimal">
        SELECT sum(w.apply_for_money)
        FROM t_withdraw w
                 LEFT JOIN t_user u on w.user_id = u.id
        <where>
            YEAR(w.createTime) = YEAR(NOW())
              AND YEAR(w.createTime) = YEAR(NOW())
              and w.is_delete = 0
            <if test="cityList != null and cityList.size() != 0">
                and u.city in
                <foreach collection="cityList" item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
    </select>
 
    <!--vo类映射-->
    <resultMap id="voMap" type="com.ruoyi.admin.vo.UserWithdrawRecordVO">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="apply_for_time" property="applyForTime"/>
        <result column="apply_for_money" property="applyForMoney"/>
        <result column="state" property="state"/>
        <result column="opinions" property="opinions"/>
        <result column="user_no" property="userNo"/>
        <result column="profile_picture" property="profilePicture"/>
        <result column="nickname" property="nickname"/>
        <result column="phone" property="userPhone"/>
    </resultMap>
    <select id="withdrawList" resultMap="voMap">
        SELECT w.*, u.user_no, u.profile_picture, u.nickname
        FROM t_withdraw w
                 LEFT JOIN t_user u on w.user_id = u.id
        <where>
            w.is_delete = 0
              and u.is_delete = 0
            <if test="userId != null and userId != ''">
                and w.user_id = #{userId}
            </if>
        </where>
    </select>
 
    <select id="withdrawPage" resultMap="voMap">
        SELECT w.*, u.user_no, u.profile_picture, u.nickname
        FROM t_withdraw w
                 LEFT JOIN t_user u on w.user_id = u.id
        <where>
            w.is_delete = 0
              and u.is_delete = 0
            <if test="name != null and name != ''">
                and u.nickname like concat('%', #{name}, '%')
            </if>
            <if test="phone != null and phone != ''">
                and u.phone like concat('%', #{phone}, '%')
            </if>
            <if test="time != null and time != ''">
                and DATE(w.apply_for_time) = #{time}
            </if>
            <if test="state != null">
                and w.state = #{state}
            </if>
        </where>
        order by w.createTime desc
    </select>
 
    <select id="exportList" resultMap="voMap">
        SELECT w.*, u.user_no, u.profile_picture, u.nickname, u.phone
        FROM t_withdraw w
                 LEFT JOIN t_user u on w.user_id = u.id
        <where>
            w.is_delete = 0
              and u.is_delete = 0
            <if test="name != null and name != ''">
                and u.nickname like concat('%', #{name}, '%')
            </if>
            <if test="phone != null and phone != ''">
                and u.phone like concat('%', #{phone}, '%')
            </if>
            <if test="time != null and time != ''">
                and DATE(w.apply_for_time) = #{time}
            </if>
            <if test="state != null">
                and w.state = #{state}
            </if>
        </where>
        order by w.createTime desc
    </select>
 
    <select id="exportByIdList" resultMap="voMap">
        SELECT w.*, u.user_no, u.profile_picture, u.nickname
        FROM t_withdraw w
                 LEFT JOIN t_user u on w.user_id = u.id
        <where>
            w.is_delete = 0
              and u.is_delete = 0
              and w.id in
            <foreach collection="list" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </where>
        order by w.createTime desc
    </select>
</mapper>