2021-07-19 18:38:42 +08:00
|
|
|
<?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.xhpc.user.mapper.XhpcUserMapper">
|
|
|
|
|
|
2021-07-28 18:07:25 +08:00
|
|
|
<resultMap type="com.xhpc.system.api.domain.SysUser" id="XhpcUserResult">
|
2021-07-19 18:38:42 +08:00
|
|
|
<result column="user_id" property="userId"/>
|
|
|
|
|
<result column="dept_id" property="deptId"/>
|
|
|
|
|
<result column="user_name" property="userName"/>
|
2021-07-21 18:56:48 +08:00
|
|
|
<result column="user_type" property="userType"/>
|
2021-07-19 18:38:42 +08:00
|
|
|
<result column="nick_name" property="nickName"/>
|
|
|
|
|
<result column="email" property="email"/>
|
|
|
|
|
<result column="phonenumber" property="phonenumber"/>
|
|
|
|
|
<result column="operator_id" property="operatorId"/>
|
2021-07-20 15:55:12 +08:00
|
|
|
<result column="internet_user_id" property="internetUserId"/>
|
2021-07-19 18:38:42 +08:00
|
|
|
<result column="sex" property="sex"/>
|
|
|
|
|
<result column="avatar" property="avatar"/>
|
|
|
|
|
<result column="password" property="password"/>
|
|
|
|
|
<result column="data_power_type" property="dataPowerType"/>
|
|
|
|
|
<result column="status" property="status"/>
|
|
|
|
|
<result column="del_flag" property="delFlag"/>
|
|
|
|
|
<result column="login_ip" property="loginIp"/>
|
|
|
|
|
<result column="login_date" property="loginDate"/>
|
|
|
|
|
<result column="create_by" property="createBy"/>
|
|
|
|
|
<result column="create_time" property="createTime"/>
|
|
|
|
|
<result column="update_by" property="updateBy"/>
|
|
|
|
|
<result column="update_time" property="updateTime"/>
|
|
|
|
|
<result column="remark" property="remark"/>
|
2022-03-01 16:42:08 +08:00
|
|
|
<result column="tenant_id" property="tenantId"/>
|
2021-07-19 18:38:42 +08:00
|
|
|
</resultMap>
|
|
|
|
|
|
2021-07-28 18:07:25 +08:00
|
|
|
<update id="update" parameterType="com.xhpc.system.api.domain.SysUser">
|
2021-07-19 18:38:42 +08:00
|
|
|
UPDATE sys_user
|
|
|
|
|
<set>
|
|
|
|
|
<if test="null != deptId and '' != deptId">dept_id = #{deptId},</if>
|
|
|
|
|
<if test="null != userName and '' != userName">user_name = #{userName},</if>
|
|
|
|
|
<if test="null != nickName and '' != nickName">nick_name = #{nickName},</if>
|
|
|
|
|
<if test="null != userType and '' != userType">user_type = #{userType},</if>
|
|
|
|
|
<if test="null != email and '' != email">email = #{email},</if>
|
|
|
|
|
<if test="null != phonenumber and '' != phonenumber">phonenumber = #{phonenumber},</if>
|
|
|
|
|
<if test="null != operatorId and '' != operatorId">operator_id = #{operatorId},</if>
|
|
|
|
|
<if test="null != sex and '' != sex">sex = #{sex},</if>
|
|
|
|
|
<if test="null != avatar and '' != avatar">avatar = #{avatar},</if>
|
|
|
|
|
<if test="null != password and '' != password">password = #{password},</if>
|
2021-07-30 17:23:38 +08:00
|
|
|
<if test="null != dataPowerType ">data_power_type = #{dataPowerType},</if>
|
2021-07-27 18:38:32 +08:00
|
|
|
<if test="null != status">status = #{status},</if>
|
2021-07-19 18:38:42 +08:00
|
|
|
<if test="null != delFlag and '' != delFlag">del_flag = #{delFlag},</if>
|
|
|
|
|
<if test="null != loginIp and '' != loginIp">login_ip = #{loginIp},</if>
|
|
|
|
|
<if test="null != loginDate and '' != loginDate">login_date = #{loginDate},</if>
|
|
|
|
|
<if test="null != createBy and '' != createBy">create_by = #{createBy},</if>
|
2021-07-22 16:02:30 +08:00
|
|
|
<if test="null != createTime ">create_time = #{createTime},</if>
|
2021-07-19 18:38:42 +08:00
|
|
|
<if test="null != updateBy and '' != updateBy">update_by = #{updateBy},</if>
|
2021-07-22 16:02:30 +08:00
|
|
|
<if test="null != updateTime ">update_time = #{updateTime},</if>
|
2021-07-19 18:38:42 +08:00
|
|
|
<if test="null != remark and '' != remark">remark = #{remark}</if>
|
|
|
|
|
</set>
|
|
|
|
|
WHERE user_id = #{userId}
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteByIds" parameterType="java.lang.Long">
|
|
|
|
|
delete from sys_user where user_id in
|
|
|
|
|
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
|
|
|
|
#{userId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
|
2021-07-21 18:56:48 +08:00
|
|
|
<select id="selectUserByUserId" parameterType="java.lang.Long" resultMap="XhpcUserResult">
|
2021-07-19 18:38:42 +08:00
|
|
|
select *
|
|
|
|
|
from sys_user
|
|
|
|
|
where user_id = #{userId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectPcUserList" parameterType="java.lang.String" resultType="java.util.Map">
|
|
|
|
|
select user_id userId,user_name userName,
|
2021-07-29 14:56:41 +08:00
|
|
|
nick_name nickName, email,status,
|
|
|
|
|
create_by createBy ,create_time createTime,
|
|
|
|
|
CASE WHEN `status` = 0 THEN '正常' else '禁用' end statusName
|
2021-07-19 18:38:42 +08:00
|
|
|
from sys_user
|
2021-07-21 18:56:48 +08:00
|
|
|
WHERE del_flag = 0 and user_type = '00'
|
2021-07-19 18:38:42 +08:00
|
|
|
<if test="userName != null and userName != ''">
|
2021-12-27 15:45:06 +08:00
|
|
|
and user_name like concat('%', #{userName}, '%')
|
2021-07-19 18:38:42 +08:00
|
|
|
</if>
|
2022-03-01 16:42:08 +08:00
|
|
|
<if test="tenantId !=null and ''!=tenantId">
|
|
|
|
|
and tenant_id=#{tenantId}
|
|
|
|
|
</if>
|
2021-07-19 18:38:42 +08:00
|
|
|
<if test="nickName != null and nickName != ''">
|
2021-12-27 15:45:06 +08:00
|
|
|
and nick_name like concat('%', #{nickName}, '%')
|
2021-07-19 18:38:42 +08:00
|
|
|
</if>
|
2021-07-20 15:55:12 +08:00
|
|
|
ORDER BY update_time DESC
|
2021-07-19 18:38:42 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="pcInfo" parameterType="java.lang.Long" resultType="java.util.Map">
|
2021-10-29 10:39:29 +08:00
|
|
|
select su.user_id userId,su.user_name userName,su.user_type userType,
|
2021-07-30 17:23:38 +08:00
|
|
|
su.nick_name nickName, su.email,su.status,su.avatar,
|
2021-07-19 18:38:42 +08:00
|
|
|
su.create_by createBy ,su.create_time createTime,su.`status` ,
|
2021-07-29 18:28:07 +08:00
|
|
|
CASE WHEN su.`status` = 0 THEN '正常' else '禁用' end statusName,
|
2021-08-02 18:36:17 +08:00
|
|
|
sdd.dict_label sexName,(select role_id from sys_user_role where user_id = su.user_id LIMIT 1) roleId
|
2021-07-19 18:38:42 +08:00
|
|
|
from sys_user su
|
|
|
|
|
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = "sys_user_sex" and sdd.dict_code = su.sex
|
2021-07-29 18:28:07 +08:00
|
|
|
WHERE su.del_flag = 0 and su.user_id = #{userId}
|
2021-07-19 18:38:42 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="selectOperatorUserList" parameterType="java.lang.String" resultType="java.util.Map">
|
|
|
|
|
select su.user_id userId,su.user_name userName,
|
|
|
|
|
su.nick_name nickName, su.email,
|
|
|
|
|
su.create_by createBy ,su.create_time createTime,
|
|
|
|
|
xo.`name` operatorName,su.`status` ,
|
|
|
|
|
CASE WHEN su.`status` = 0 THEN '正常' else '禁用' end statusName
|
|
|
|
|
from sys_user su
|
|
|
|
|
LEFT JOIN xhpc_operator xo on xo.operator_id = su.operator_id
|
2021-11-18 16:30:46 +08:00
|
|
|
WHERE su.del_flag = 0 and user_type = '03'
|
2021-07-19 18:38:42 +08:00
|
|
|
<if test="userName != null and userName != ''">
|
2021-12-27 15:45:06 +08:00
|
|
|
and su.user_name like concat('%', #{userName}, '%')
|
2021-07-19 18:38:42 +08:00
|
|
|
</if>
|
2022-03-01 16:42:08 +08:00
|
|
|
<if test="tenantId !=null and tenantId !=''">
|
|
|
|
|
and su.tenant_id =#{tenantId}
|
|
|
|
|
</if>
|
2021-07-19 18:38:42 +08:00
|
|
|
<if test="nickName != null and nickName != ''">
|
2021-12-27 15:45:06 +08:00
|
|
|
and su.nick_name like concat('%', #{nickName}, '%')
|
2021-07-19 18:38:42 +08:00
|
|
|
</if>
|
|
|
|
|
<if test="operatorId != null and operatorId != ''">
|
2021-10-19 10:22:25 +08:00
|
|
|
and su.operator_id = #{operatorId}
|
2021-07-19 18:38:42 +08:00
|
|
|
</if>
|
2021-07-20 15:55:12 +08:00
|
|
|
ORDER BY su.update_time DESC
|
2021-07-19 18:38:42 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="operatorInfo" parameterType="java.lang.Long" resultType="java.util.Map">
|
|
|
|
|
select su.user_id userId,su.user_name userName,
|
2021-07-30 17:23:38 +08:00
|
|
|
su.nick_name nickName, su.email,su.sex,su.avatar,
|
2021-07-21 18:56:48 +08:00
|
|
|
su.create_by createBy ,su.create_time createTime,xo.operator_id operatorId,
|
2021-07-19 18:38:42 +08:00
|
|
|
xo.`name` operatorName,su.`status` ,
|
|
|
|
|
CASE WHEN su.`status` = 0 THEN '正常' else '禁用' end statusName,
|
2021-08-02 18:36:17 +08:00
|
|
|
sdd.dict_label sexName,(select role_id from sys_user_role where user_id = su.user_id LIMIT 1) roleId
|
2021-07-19 18:38:42 +08:00
|
|
|
from sys_user su
|
|
|
|
|
LEFT JOIN xhpc_operator xo on xo.operator_id = su.operator_id
|
2021-10-29 10:39:29 +08:00
|
|
|
LEFT JOIN sys_dict_data sdd on sdd.`dict_type` = "sys_user_sex" and sdd.dict_value = su.sex
|
2021-07-19 18:38:42 +08:00
|
|
|
WHERE su.del_flag = 0 and user_id = #{userId}
|
|
|
|
|
</select>
|
2021-07-26 18:02:59 +08:00
|
|
|
|
2021-07-28 18:07:25 +08:00
|
|
|
<select id="selectUserByUserName" parameterType="java.lang.String" resultType="com.xhpc.system.api.domain.SysUser">
|
|
|
|
|
select user_id userId,
|
|
|
|
|
dept_id deptid,
|
|
|
|
|
user_name userName,
|
|
|
|
|
nick_name nickName,
|
|
|
|
|
user_type userType,
|
|
|
|
|
email,
|
|
|
|
|
phonenumber,
|
|
|
|
|
operator_id operatorId,
|
|
|
|
|
internet_user_id internetUserId,
|
|
|
|
|
sex,
|
|
|
|
|
avatar,
|
|
|
|
|
password,
|
|
|
|
|
data_power_type dataPowerType,
|
|
|
|
|
status,
|
|
|
|
|
del_flag delFlag,
|
|
|
|
|
login_ip loginIp,
|
|
|
|
|
login_date loginDate,
|
|
|
|
|
create_by createBy,
|
|
|
|
|
create_time createTime,
|
|
|
|
|
update_by updateBy,
|
|
|
|
|
update_time updateTime,
|
|
|
|
|
remark
|
|
|
|
|
from sys_user
|
2021-07-29 18:28:07 +08:00
|
|
|
where user_name = #{userName} LIMIT 1
|
2021-07-26 18:02:59 +08:00
|
|
|
</select>
|
2021-07-29 14:56:41 +08:00
|
|
|
<select id="selectUserByCreateBy" parameterType="java.lang.String" resultType="com.xhpc.system.api.domain.SysUser">
|
|
|
|
|
select user_id userId,
|
|
|
|
|
dept_id deptid,
|
|
|
|
|
user_name userName,
|
|
|
|
|
nick_name nickName,
|
|
|
|
|
user_type userType,
|
|
|
|
|
email,
|
|
|
|
|
phonenumber,
|
|
|
|
|
operator_id operatorId,
|
|
|
|
|
internet_user_id internetUserId,
|
|
|
|
|
sex,
|
|
|
|
|
avatar,
|
|
|
|
|
password,
|
|
|
|
|
data_power_type dataPowerType,
|
|
|
|
|
status,
|
|
|
|
|
del_flag delFlag,
|
|
|
|
|
login_ip loginIp,
|
|
|
|
|
login_date loginDate,
|
|
|
|
|
create_by createBy,
|
|
|
|
|
create_time createTime,
|
|
|
|
|
update_by updateBy,
|
|
|
|
|
update_time updateTime,
|
|
|
|
|
remark
|
|
|
|
|
from sys_user
|
|
|
|
|
where create_by = #{createBy}
|
|
|
|
|
</select>
|
|
|
|
|
|
2021-07-29 18:28:07 +08:00
|
|
|
<select id="selectUserByRoleName" parameterType="java.lang.String" resultType="com.xhpc.system.api.domain.SysRole">
|
|
|
|
|
select role_id roleId,
|
|
|
|
|
role_name roleName,
|
|
|
|
|
role_key roleKey,
|
|
|
|
|
role_sort roleSort,
|
|
|
|
|
data_scope dataScope,
|
|
|
|
|
menu_check_strictly menuCheckStrictly,
|
|
|
|
|
dept_check_strictly deptCheckStrictly,
|
|
|
|
|
status,
|
|
|
|
|
del_flag delFlag,
|
|
|
|
|
create_by createBy,
|
|
|
|
|
create_time createTime,
|
|
|
|
|
update_by updateBy,
|
|
|
|
|
update_time updateTime,
|
|
|
|
|
remark
|
|
|
|
|
from sys_role
|
|
|
|
|
where role_name = #{userName} ORDER BY create_time DESC LIMIT 1
|
|
|
|
|
</select>
|
2021-07-30 11:20:54 +08:00
|
|
|
|
|
|
|
|
<insert id="insertRole" parameterType="com.xhpc.system.api.domain.SysRole" useGeneratedKeys="true"
|
|
|
|
|
keyProperty="roleId">
|
|
|
|
|
insert into sys_role(
|
|
|
|
|
<if test="roleId != null and roleId != 0">role_id,</if>
|
|
|
|
|
<if test="roleName != null and roleName != ''">role_name,</if>
|
|
|
|
|
<if test="roleKey != null and roleKey != ''">role_key,</if>
|
|
|
|
|
<if test="roleSort != null and roleSort != ''">role_sort,</if>
|
|
|
|
|
<if test="dataScope != null and dataScope != ''">data_scope,</if>
|
|
|
|
|
<if test="menuCheckStrictly != null">menu_check_strictly,</if>
|
|
|
|
|
<if test="deptCheckStrictly != null">dept_check_strictly,</if>
|
|
|
|
|
<if test="status != null and status != ''">status,</if>
|
|
|
|
|
<if test="remark != null and remark != ''">remark,</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
|
|
|
create_time
|
|
|
|
|
)values(
|
|
|
|
|
<if test="roleId != null and roleId != 0">#{roleId},</if>
|
|
|
|
|
<if test="roleName != null and roleName != ''">#{roleName},</if>
|
|
|
|
|
<if test="roleKey != null and roleKey != ''">#{roleKey},</if>
|
|
|
|
|
<if test="roleSort != null and roleSort != ''">#{roleSort},</if>
|
|
|
|
|
<if test="dataScope != null and dataScope != ''">#{dataScope},</if>
|
|
|
|
|
<if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
|
|
|
|
|
<if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
|
|
|
|
|
<if test="status != null and status != ''">#{status},</if>
|
|
|
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
|
|
sysdate()
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<insert id="insertUser" parameterType="com.xhpc.system.api.domain.SysUser" useGeneratedKeys="true"
|
|
|
|
|
keyProperty="userId">
|
|
|
|
|
insert into sys_user(
|
|
|
|
|
<if test="userId != null and userId != 0">user_id,</if>
|
|
|
|
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
|
|
|
|
<if test="userName != null and userName != ''">user_name,</if>
|
2021-07-30 17:23:38 +08:00
|
|
|
<if test="userType != null and userType != ''">user_type,</if>
|
2021-07-30 11:20:54 +08:00
|
|
|
<if test="nickName != null and nickName != ''">nick_name,</if>
|
|
|
|
|
<if test="email != null and email != ''">email,</if>
|
|
|
|
|
<if test="avatar != null and avatar != ''">avatar,</if>
|
|
|
|
|
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
|
|
|
|
<if test="operatorId != null and operatorId != ''">operator_id,</if>
|
|
|
|
|
<if test="internetUserId != null and internetUserId != ''">internet_user_id,</if>
|
|
|
|
|
<if test="dataPowerType != null and dataPowerType != ''">data_power_type,</if>
|
|
|
|
|
<if test="sex != null and sex != ''">sex,</if>
|
|
|
|
|
<if test="password != null and password != ''">password,</if>
|
|
|
|
|
<if test="status != null and status != ''">status,</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
|
|
|
|
<if test="remark != null and remark != ''">remark,</if>
|
2022-02-28 18:29:52 +08:00
|
|
|
<if test="tenantId != null and tenantId != ''">tenant_id,</if>
|
2021-07-30 11:20:54 +08:00
|
|
|
create_time
|
|
|
|
|
)values(
|
|
|
|
|
<if test="userId != null and userId != ''">#{userId},</if>
|
|
|
|
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
|
|
|
|
<if test="userName != null and userName != ''">#{userName},</if>
|
2021-07-30 17:23:38 +08:00
|
|
|
<if test="userType != null and userType != ''">#{userType},</if>
|
2021-07-30 11:20:54 +08:00
|
|
|
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
|
|
|
|
<if test="email != null and email != ''">#{email},</if>
|
|
|
|
|
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
|
|
|
|
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
|
|
|
|
<if test="operatorId != null and operatorId != ''">#{operatorId},</if>
|
|
|
|
|
<if test="internetUserId != null and internetUserId != ''">#{internetUserId},</if>
|
|
|
|
|
<if test="dataPowerType != null and dataPowerType != ''">#{dataPowerType},</if>
|
|
|
|
|
<if test="sex != null and sex != ''">#{sex},</if>
|
|
|
|
|
<if test="password != null and password != ''">#{password},</if>
|
|
|
|
|
<if test="status != null and status != ''">#{status},</if>
|
|
|
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
2022-02-28 18:29:52 +08:00
|
|
|
<if test="tenantId != null and tenantId != ''">#{tenantId},</if>
|
2021-07-30 11:20:54 +08:00
|
|
|
sysdate()
|
|
|
|
|
)
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<insert id="batchUserRole">
|
2022-02-28 18:29:52 +08:00
|
|
|
insert into sys_user_role(user_id, role_id,tenant_id) values
|
2021-07-30 11:20:54 +08:00
|
|
|
<foreach item="item" index="index" collection="list" separator=",">
|
2022-02-28 18:29:52 +08:00
|
|
|
(#{item.userId},#{item.roleId},#{item.tenantId})
|
2021-07-30 11:20:54 +08:00
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<select id="checkUserNameUnique" parameterType="java.lang.String" resultType="int">
|
2021-10-29 10:39:29 +08:00
|
|
|
select count(1) from sys_user where user_name = #{userName}
|
|
|
|
|
<if test="userId !=null">
|
|
|
|
|
and user_id=#{userId}
|
|
|
|
|
</if>
|
|
|
|
|
limit 1
|
2021-07-30 11:20:54 +08:00
|
|
|
</select>
|
2021-10-29 10:39:29 +08:00
|
|
|
|
|
|
|
|
<insert id="addXhpcDataDimension">
|
|
|
|
|
insert into xhpc_data_dimension(user_id, charging_station_id) values(#{userId},#{chargingStationId})
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateXhpcDataDimension">
|
|
|
|
|
update xhpc_data_dimension set del_flag = 1 where user_id = #{userId}
|
|
|
|
|
</update>
|
2022-03-23 13:27:58 +08:00
|
|
|
|
|
|
|
|
<select id="getOrderTimeNumber" resultType="int">
|
|
|
|
|
select
|
|
|
|
|
count(history_order_id) number
|
|
|
|
|
from xhpc_history_order
|
|
|
|
|
where source = 0
|
|
|
|
|
<if test="tenantId !=null and tenantId !=''">
|
|
|
|
|
and tenant_id =#{tenantId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime !=null and startTime !=''">
|
|
|
|
|
and end_time >=#{startTime}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="endTime !=null and endTime !=''">
|
|
|
|
|
and end_time <= #{endTime}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="userId !=null">
|
|
|
|
|
and end_time <= #{endTime}
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getUserDimension" resultType="map">
|
|
|
|
|
SELECT
|
|
|
|
|
us.number number,
|
|
|
|
|
us.totalPrice totalPrice,
|
|
|
|
|
us.activity activity,
|
|
|
|
|
us.appUserId appUserId,
|
|
|
|
|
us.phone phone
|
|
|
|
|
from xhpc_app_user AS xaus
|
|
|
|
|
JOIN (
|
|
|
|
|
SELECT
|
|
|
|
|
count(xho.history_order_id) number,
|
|
|
|
|
IFNULL(SUM(xho.total_price),0) totalPrice,
|
|
|
|
|
IFNULL(TRUNCATE((count(xho.history_order_id)/#{number})*100,0),0) activity,
|
|
|
|
|
xau.app_user_id appUserId,
|
|
|
|
|
xau.phone phone
|
|
|
|
|
from xhpc_app_user as xau
|
|
|
|
|
LEFT JOIN xhpc_history_order xho on xau.app_user_id = xho.user_id and xho.source = 0 and xho.tenant_id =#{tenantId}
|
|
|
|
|
where xau.del_flag =0
|
|
|
|
|
<if test="startTime !=null and startTime !=''">
|
|
|
|
|
and xho.end_time >=#{startTime}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="endTime !=null and endTime !=''">
|
|
|
|
|
and xho.end_time <= #{endTime}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="phone !=null and phone !=''">
|
|
|
|
|
and xau.phone like concat('%', #{phone}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY xau.app_user_id
|
|
|
|
|
order by totalPrice desc) us on xaus.app_user_id = us.appUserId
|
|
|
|
|
where xaus.del_flag = 0
|
|
|
|
|
<if test="activity !=null">
|
|
|
|
|
and activity >= #{activity}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="frequency !=null">
|
|
|
|
|
and frequency >= #{frequency}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="amount !=null">
|
|
|
|
|
and amount >= #{amount}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="tenantId !=null and tenantId !=''">
|
|
|
|
|
and xaus.tenant_id =#{tenantId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="userId !=null">
|
|
|
|
|
and xaus.user_id = #{userId}
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY xaus.app_user_id
|
|
|
|
|
order by totalPrice desc,number desc,activity desc
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
2021-07-28 18:07:25 +08:00
|
|
|
</mapper>
|