Sunshine
2024-11-04 7f1a0e49c1fe0c3f9f8a2493f30451d90b62ab64
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?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.nova.sankuai.infra.mapper.SysUserMapper">
 
    <select id="pageModel" resultType="com.nova.sankuai.domain.vo.sysuser.MechanismVo">
        select su.id as id,
        su.user_name as userName,
        su.user_phone as userPhone,
        su.status as status,
        su.last_login_time as lastLoginTime,
        su.delivery_city as deliveryCity,
        su.delivery_city_name as deliveryCityName,
        su.company_name as companyName,
        su.product_name as productName,
        su.product_type as productType,
        su.product_attributes as productAttributes,
        su.profession_info as professionInfo,
        su.single_customer_price as singleCustomerPrice,
        su.creation_date as creationDate,
        su.default_flag as defaultFlag,
        su.percentage_of_customers as percentageOfCustomers,
        su.recharge_flag as rechargeFlag,
        su.daily_upper_limit as dailyUpperLimit,
        su.daily_lower_limit as dailyLowerLimit,
        su.min_loan_amount as minLoanAmount,
        sum(re.recharge_amount) as rechargeAmount,
        sum(re.use_amount) as useAmount,
        su.age_lower_limit as ageLowerLimit,
        su.age_upper_limit as ageUpperLimit
        from sys_user su
        left join recharge_record re on su.id = re.mechanism_id and re.status = 0
        <where>
            su.delete_flag = 0 and su.type = 1
            <if test="sysUser.id != null">
                and su.id = #{sysUser.id}
            </if>
            <if test="sysUser.phone != null and sysUser.phone !=''">
                and su.user_phone like concat('%',#{sysUser.phone},'%')
            </if>
            <if test="sysUser.companyName != null and sysUser.companyName !=''">
                and su.company_name like concat('%',#{sysUser.companyName},'%')
            </if>
            <if test="sysUser.productName != null and sysUser.productName !=''">
                and su.product_name like concat('%',#{sysUser.productName},'%')
            </if>
            <if test="sysUser.productType != null ">
                and su.product_type like concat('%',#{sysUser.productType},'%')
            </if>
            <if test="sysUser.productAttributes != null">
                and su.product_attributes like concat('%',#{sysUser.productAttributes},'%')
            </if>
            <if test="sysUser.professionInfo != null ">
                and su.profession_info like concat('%',#{sysUser.professionInfo},'%')
            </if>
            <if test="sysUser.priceMin != null">
                and su.single_customer_price &gt;= #{sysUser.priceMin}
            </if>
            <if test="sysUser.priceMax != null">
                and su.single_customer_price &lt;= #{sysUser.priceMax}
            </if>
        </where>
        group by su.id
    </select>
 
    <select id="selectMechanism" resultType="com.nova.sankuai.domain.vo.sysuser.MechanismVo">
        select su.id as id,
        su.user_name as userName,
        su.user_phone as userPhone,
        su.status as status,
        su.last_login_time as lastLoginTime,
        su.delivery_city as deliveryCity,
        su.delivery_city_name as deliveryCityName,
        su.company_name as companyName,
        su.product_name as productName,
        su.product_type as productType,
        su.product_attributes as productAttributes,
        su.profession_info as professionInfo,
        su.single_customer_price as singleCustomerPrice,
        su.creation_date as creationDate,
        su.default_flag as defaultFlag,
        su.percentage_of_customers as percentageOfCustomers,
        su.recharge_flag as rechargeFlag,
        su.daily_upper_limit as dailyUpperLimit,
        su.daily_lower_limit as dailyLowerLimit,
        su.min_loan_amount as minLoanAmount,
        sum(re.recharge_amount) as rechargeAmount,
        sum(re.use_amount) as useAmount,
        su.age_lower_limit as ageLowerLimit,
        su.age_upper_limit as ageUpperLimit
        from sys_user su
        left join recharge_record re on su.id = re.mechanism_id and re.status = 0
        <where>
            su.delete_flag = 0 and su.type = 1 and su.recharge_flag = 1 and su.default_flag = 0
            <if test="compareDto.city != null and compareDto.city !=''">
                and (
                su.delivery_city like concat('%',#{compareDto.city},'%')
                or su.delivery_city = #{compareDto.province}
                or su.delivery_city like concat('%,',#{compareDto.province},',%')
                or su.delivery_city like concat('%,',#{compareDto.province})
                or su.delivery_city like concat('%',#{compareDto.province},',%')
                )
            </if>
            and ( 1=2
            <if test="compareDto.professionInfo != null">
                or su.profession_info like concat('%',#{compareDto.professionInfo},'%')
            </if>
            <if test="compareDto.isHouseStatus">
                or su.product_attributes like '%0%'
            </if>
            <if test="compareDto.isCarStatus">
                or su.product_attributes like '%1%'
            </if>
            <if test="compareDto.isProvidentFund">
                or su.product_attributes like '%2%'
            </if>
            <if test="compareDto.isInsurancePolicy">
                or su.product_attributes like '%3%'
            </if>
            <if test="compareDto.isSocialSecurity">
                or su.product_attributes like '%4%'
            </if>
            <if test="compareDto.isSesame">
                or su.product_attributes like '%5%'
            </if>
            <if test="compareDto.isCreditCard">
                or su.product_attributes like '%6%'
            </if>
            <if test="compareDto.isEnterprise">
                or su.profession_info like '%2%'
            </if>
        </where>
        ) group by su.id order by su.single_customer_price desc
    </select>
 
    <select id="selectDefaultMechanism" resultType="com.nova.sankuai.domain.vo.sysuser.MechanismVo">
        select * from sys_user where delete_flag = 0 and default_flag = 1
    </select>
 
    <select id="welcomePage" resultType="com.nova.sankuai.domain.vo.WelcomePageVo">
        select su.id AS id,
        ifnull( sum( rr.recharge_amount ), 0 ) AS rechargeAmount,
        ifnull( sum( rr.use_amount ), 0 ) AS useAmount
        from sys_user su
        left join recharge_record rr on su.id = rr.mechanism_id and rr.status = 0
        where su.id = #{id} and su.delete_flag = 0
    </select>
 
 
    <select id="pageStaff" resultType="com.nova.sankuai.domain.vo.sysuser.StaffVo">
        select su.id as id,
        su.user_name as userName,
        su.user_phone as userPhone,
        su.status as status,
        su.last_login_time as lastLoginTime,
        group_concat(ru.role_id) as roleIds
        from sys_user su
        left join role_user ru on su.id = ru.user_id
        <where>
            su.delete_flag = 0 and su.type = 3
            <if test="staffDto.id != null">
                and su.id = #{staffDto.id}
            </if>
            <if test="staffDto.userName != null and staffDto.userName !=''">
                and su.user_name like concat('%',#{staffDto.userName},'%')
            </if>
            <if test="staffDto.userPhone != null and staffDto.userPhone !=''">
                and su.user_phone like concat('%',#{staffDto.userPhone},'%')
            </if>
        </where>
        group by su.id
    </select>
 
    <select id="pageAdmin" resultType="com.nova.sankuai.domain.vo.sysuser.AdminVo">
        select su.id as id,
        su.user_name as userName,
        su.user_phone as userPhone,
        su.status as status,
        su.last_login_time as lastLoginTime,
        group_concat(ru.role_id) as roleIds
        from sys_user su
        left join role_user ru on su.id = ru.user_id
        <where>
            su.delete_flag = 0 and su.type = 0
            <if test="adminDto.userName != null and adminDto.userName !=''">
                and su.user_name like concat('%',#{adminDto.userName},'%')
            </if>
            <if test="adminDto.userPhone != null and adminDto.userPhone !=''">
                and su.user_phone like concat('%',#{adminDto.userPhone},'%')
            </if>
        </where>
        group by su.id
    </select>
 
    <select id="pageSysUser" resultType="com.nova.sankuai.domain.dto.SysUserDto">
        select su.id as id,
        su.user_name as userName,
        su.user_phone as userPhone,
        su.status as status,
        su.type as type,
        su.last_login_time as lastLoginTime,
        group_concat(ru.role_id) as roleIds
        from sys_user su
        left join role_user ru on su.id = ru.user_id
        <where>
            su.delete_flag = 0
            <if test="sysUserDto.userName != null and sysUserDto.userName !=''">
                and su.user_name like concat('%',#{sysUserDto.userName},'%')
            </if>
            <if test="sysUserDto.userPhone != null and sysUserDto.userPhone !=''">
                and su.user_phone like concat('%',#{sysUserDto.userPhone},'%')
            </if>
            <if test="sysUserDto.type != null ">
                and su.type = #{sysUserDto.type}
            </if>
        </where>
        group by su.id
    </select>
 
    <select id="selectMechanismConfig" resultType="com.nova.sankuai.domain.vo.customer.CustomerMechanismConfigVo">
        select su.id as mechanismId,
        su.company_name as MechanismName,
        su.product as product,
        su.icon_url as iconUrl,
        su.amount_limit as amountLimit,
        su.annual_interest_rate as annualInterestRate,
        su.service_speed as serviceSpeed,
        100+ count(cu.id) as customerNum
        from sys_user su
        left join customer cu on cu.mechanism_id = su.id and cu.delete_flag = 0
        where su.id = #{id}
    </select>
 
    <select id="pageMechanismConfig" resultType="com.nova.sankuai.domain.vo.sysuser.MechanismConfigVo">
        select su.id as mechanismId,
        su.company_name as MechanismName,
        su.product as product,
        su.user_phone as phone,
        su.icon_url as iconUrl,
        su.amount_limit as amountLimit,
        su.annual_interest_rate as annualInterestRate,
        su.service_speed as serviceSpeed
        from sys_user su
        <where>
            su.delete_flag = 0 and su.type = 1
            <if test="pageDto.id != null">
                and su.id = #{pageDto.id}
            </if>
            <if test="pageDto.phone != null and pageDto.phone !=''">
                and su.user_phone like concat('%',#{pageDto.phone},'%')
            </if>
            <if test="pageDto.product != null and pageDto.product !=''">
                and su.product like concat('%',#{pageDto.product},'%')
            </if>
            <if test="pageDto.mechanismName != null and pageDto.mechanismName !=''">
                and su.company_name like concat('%',#{pageDto.mechanismName},'%')
            </if>
        </where>
    </select>
 
    <select id="selectMechanismById" resultType="com.nova.sankuai.domain.vo.sysuser.MechanismVo">
        select su.id as id,
        su.user_name as userName,
        su.user_phone as userPhone,
        su.status as status,
        su.last_login_time as lastLoginTime,
        su.delivery_city as deliveryCity,
        su.delivery_city_name as deliveryCityName,
        su.company_name as companyName,
        su.product_name as productName,
        su.product_type as productType,
        su.product_attributes as productAttributes,
        su.profession_info as professionInfo,
        su.single_customer_price as singleCustomerPrice,
        su.creation_date as creationDate,
        su.default_flag as defaultFlag,
        su.percentage_of_customers as percentageOfCustomers,
        su.recharge_flag as rechargeFlag,
        su.daily_upper_limit as dailyUpperLimit,
        su.daily_lower_limit as dailyLowerLimit,
        su.min_loan_amount as minLoanAmount,
        sum(re.recharge_amount) as rechargeAmount,
        sum(re.use_amount) as useAmount
        from sys_user su
        left join recharge_record re on su.id = re.mechanism_id and re.status = 0
        where su.delete_flag = 0 and su.type = 1 and su.id = #{id}
    </select>
 
    <select id="getAssignableMechanism" resultType="com.nova.sankuai.domain.vo.sysuser.MechanismVo">
        select su.id as id,
        su.company_name as companyName,
        su.user_phone as userPhone
        from sys_user su
        where su.delete_flag = 0 and su.type = 1 and su.recharge_flag = 1
    </select>
 
</mapper>