<?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 >= #{sysUser.priceMin}
|
</if>
|
<if test="sysUser.priceMax != null">
|
and su.single_customer_price <= #{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>
|