| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- <?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.ydtech.modules.admin.dao.SysPartnerMapper">
- <resultMap type="com.ydtech.modules.admin.model.SysPartner" id="SysPartnerMap">
- <result property="id" column="id" jdbcType="INTEGER"/>
- <result property="userId" column="user_id" jdbcType="VARCHAR"/>
- <result property="userName" column="user_name" jdbcType="VARCHAR"/>
- <result property="proportional" column="proportional" jdbcType="VARCHAR"/>
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
- <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
- <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
- </resultMap>
- <select id="queryPage" resultType="com.ydtech.modules.admin.model.dto.SysPartnerConsoleDto">
- select
- sp.id as "id",
- sp.user_id as "userId",
- su.name as "userName",
- sp.type as "type",
- sp.proportional as "proportional",
- sp.suggest_id as "suggestId",
- sp.suggest_name as "suggestName",
- sp.create_time as "createTime",
- sp.create_by as "createBy",
- sp.del_flag as "delFlag",
- sd.name as "deptName",
- sd.comlevel as "comlevel",
- su.mobile as "mobile",
- sp.type as "patnerLevel"
- from sys_partner sp
- left join sys_user su on su.id = sp.user_id
- left join sys_dept sd on sd.id = su.dept_id
- <where>
- 1=1
- and sp.del_flag ='1'
- and sp.type ='1'
- <if test="vo.deptId !=null and vo.deptId!='' ">
- and sd.id LIKE concat('%', #{vo.deptId}, '%')
- </if>
- <if test="vo.phoneNumber !=null and vo.phoneNumber !=''">
- and su.mobile =#{vo.phoneNumber}
- </if>
- <if test="vo.name !=null and vo.name !=''">
- and su.name =#{vo.name}
- </if>
- <if test="vo.userCode !=null and vo.userCode !=''">
- and su.id= #{vo.userCode}
- </if>
- <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
- AND sd.id in
- <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
- AND su.id in
- <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </where>
- </select>
- <select id="getTreeDeptUser" resultType="com.ydtech.modules.admin.model.dto.SysPartnerConsoleDto">
- select sal.user_id as "userId",
- sal.user_name as "userName"
- from sys_partner sal
- where sal.del_flag = '1'
- and sal.suggest_id is null
- </select>
- <select id="queryByLoginId" resultType="com.ydtech.modules.admin.model.SysPartner">
- select sal.*
- from sys_partner sal
- left join sys_relation_person srp on srp.agency_leader_id=sal.user_id
- where srp.type = 0 and srp.source = 0 and srp.suggest_id = #{userId}
- </select>
- <select id="queryIndirectByLoginId" resultType="com.ydtech.modules.admin.model.SysPartner">
- select sal.*
- from sys_partner sal
- left join sys_relation_person srp on srp.agency_leader_id=sal.user_id
- where srp.type = 0 and srp.source = 1 and srp.suggest_id = #{userId}
- </select>
- <select id="queryPartnerById" resultType="com.ydtech.modules.admin.model.SysPartner">
- select sal.*
- from sys_partner sal
- left join sys_relation_person srp on srp.agency_leader_id=sal.user_id
- <where>
- srp.type = 0 and srp.source = 0
- <if test="userId != null and userId != '' ">
- and srp.suggest_id = #{userId}
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(sal.create_time, '%Y-%m-%d %H:%i:%s') between DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d %H:%i:%s'))
- </if>
- </where>
- </select>
- <select id="queryDeptByTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
- FROM sys_dept s
- <where>
- s.del_flag = 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d %H:%i:%s') between DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d %H:%i:%s'))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryDeptByTimes" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
- FROM sys_dept s
- <where>
- s.del_flag = 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryDeptByFive" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
- FROM sys_dept s
- <where>
- s.del_flag = 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d %H:%i:%s') between DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d %H:%i:%s'))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryDeptByFiveTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
- FROM sys_dept s
- <where>
- s.del_flag = 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryUserByTimes" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
- FROM sys_user s
- <where>
- s.status != 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.dept_id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryUserByTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
- FROM sys_user s
- <where>
- s.status != 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.dept_id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d %H:%i:%s') between DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d %H:%i:%s'))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryUserByFive" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
- FROM sys_user s
- <where>
- s.status != 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.dept_id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryUserByFiveTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
- FROM sys_user s
- <where>
- s.status != 0
- <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
- AND s.dept_id in
- <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
- #{deptId}
- </foreach>
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d %H:%i:%s') between DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d %H:%i:%s'))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryPartnerByTimes" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
- FROM sys_partner s
- left join sys_relation_person srp on srp.agency_leader_id = s.user_id
- <where>
- s.del_flag = 1 and srp.type = 0 and srp.source = 0
- <if test="userId != null and userId != '' ">
- and srp.suggest_id = #{userId}
- </if>
- <if test="dto.type != null and dto.type != 0 ">
- and s.type = #{dto.type}
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- <select id="queryPartnerByTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
- select spa.time, COUNT(spa.id) as countNum
- from(
- SELECT
- s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
- FROM sys_partner s
- left join sys_relation_person srp on srp.agency_leader_id = s.user_id
- <where>
- s.del_flag = 1 and srp.type = 0 and srp.source = 0
- <if test="userId != null and userId != '' ">
- and srp.suggest_id = #{userId}
- </if>
- <if test="dto.type != null and dto.type != 0 ">
- and s.type = #{dto.type}
- </if>
- <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
- and (DATE_FORMAT(s.create_time, '%Y-%m-%d %H:%i:%s') between DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d %H:%i:%s') and DATE_FORMAT( #{dto.endTime}, '%Y-%m-%d %H:%i:%s'))
- </if>
- </where>
- ) as spa
- GROUP BY
- spa.time
- ORDER BY
- spa.time ASC
- </select>
- </mapper>
|