SysPartnerMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.ydtech.modules.admin.dao.SysPartnerMapper">
  4. <resultMap type="com.ydtech.modules.admin.model.SysPartner" id="SysPartnerMap">
  5. <result property="id" column="id" jdbcType="INTEGER"/>
  6. <result property="userId" column="user_id" jdbcType="VARCHAR"/>
  7. <result property="userName" column="user_name" jdbcType="VARCHAR"/>
  8. <result property="proportional" column="proportional" jdbcType="VARCHAR"/>
  9. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  10. <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
  11. <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
  12. </resultMap>
  13. <select id="queryPage" resultType="com.ydtech.modules.admin.model.dto.SysPartnerConsoleDto">
  14. select
  15. sp.id as "id",
  16. sp.user_id as "userId",
  17. su.name as "userName",
  18. sp.type as "type",
  19. sp.proportional as "proportional",
  20. sp.suggest_id as "suggestId",
  21. sp.suggest_name as "suggestName",
  22. sp.create_time as "createTime",
  23. sp.create_by as "createBy",
  24. sp.del_flag as "delFlag",
  25. sd.name as "deptName",
  26. sd.comlevel as "comlevel",
  27. su.mobile as "mobile",
  28. sp.type as "patnerLevel"
  29. from sys_partner sp
  30. left join sys_user su on su.id = sp.user_id
  31. left join sys_dept sd on sd.id = su.dept_id
  32. <where>
  33. 1=1
  34. and sp.del_flag ='1'
  35. and sp.type ='1'
  36. <if test="vo.deptId !=null and vo.deptId!='' ">
  37. and sd.id LIKE concat('%', #{vo.deptId}, '%')
  38. </if>
  39. <if test="vo.phoneNumber !=null and vo.phoneNumber !=''">
  40. and su.mobile =#{vo.phoneNumber}
  41. </if>
  42. <if test="vo.name !=null and vo.name !=''">
  43. and su.name =#{vo.name}
  44. </if>
  45. <if test="vo.userCode !=null and vo.userCode !=''">
  46. and su.id= #{vo.userCode}
  47. </if>
  48. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  49. AND sd.id in
  50. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  51. #{item}
  52. </foreach>
  53. </if>
  54. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  55. AND su.id in
  56. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  57. #{item}
  58. </foreach>
  59. </if>
  60. </where>
  61. </select>
  62. <select id="getTreeDeptUser" resultType="com.ydtech.modules.admin.model.dto.SysPartnerConsoleDto">
  63. select sal.user_id as "userId",
  64. sal.user_name as "userName"
  65. from sys_partner sal
  66. where sal.del_flag = '1'
  67. and sal.suggest_id is null
  68. </select>
  69. <select id="queryByLoginId" resultType="com.ydtech.modules.admin.model.SysPartner">
  70. select sal.*
  71. from sys_partner sal
  72. left join sys_relation_person srp on srp.agency_leader_id=sal.user_id
  73. where srp.type = 0 and srp.source = 0 and srp.suggest_id = #{userId}
  74. </select>
  75. <select id="queryIndirectByLoginId" resultType="com.ydtech.modules.admin.model.SysPartner">
  76. select sal.*
  77. from sys_partner sal
  78. left join sys_relation_person srp on srp.agency_leader_id=sal.user_id
  79. where srp.type = 0 and srp.source = 1 and srp.suggest_id = #{userId}
  80. </select>
  81. <select id="queryPartnerById" resultType="com.ydtech.modules.admin.model.SysPartner">
  82. select sal.*
  83. from sys_partner sal
  84. left join sys_relation_person srp on srp.agency_leader_id=sal.user_id
  85. <where>
  86. srp.type = 0 and srp.source = 0
  87. <if test="userId != null and userId != '' ">
  88. and srp.suggest_id = #{userId}
  89. </if>
  90. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  91. 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'))
  92. </if>
  93. </where>
  94. </select>
  95. <select id="queryDeptByTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  96. select spa.time, COUNT(spa.id) as countNum
  97. from(
  98. SELECT
  99. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
  100. FROM sys_dept s
  101. <where>
  102. s.del_flag = 0
  103. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  104. AND s.id in
  105. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  106. #{deptId}
  107. </foreach>
  108. </if>
  109. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  110. 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'))
  111. </if>
  112. </where>
  113. ) as spa
  114. GROUP BY
  115. spa.time
  116. ORDER BY
  117. spa.time ASC
  118. </select>
  119. <select id="queryDeptByTimes" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  120. select spa.time, COUNT(spa.id) as countNum
  121. from(
  122. SELECT
  123. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
  124. FROM sys_dept s
  125. <where>
  126. s.del_flag = 0
  127. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  128. AND s.id in
  129. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  130. #{deptId}
  131. </foreach>
  132. </if>
  133. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  134. and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
  135. </if>
  136. </where>
  137. ) as spa
  138. GROUP BY
  139. spa.time
  140. ORDER BY
  141. spa.time ASC
  142. </select>
  143. <select id="queryDeptByFive" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  144. select spa.time, COUNT(spa.id) as countNum
  145. from(
  146. SELECT
  147. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
  148. FROM sys_dept s
  149. <where>
  150. s.del_flag = 0
  151. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  152. AND s.id in
  153. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  154. #{deptId}
  155. </foreach>
  156. </if>
  157. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  158. 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'))
  159. </if>
  160. </where>
  161. ) as spa
  162. GROUP BY
  163. spa.time
  164. ORDER BY
  165. spa.time ASC
  166. </select>
  167. <select id="queryDeptByFiveTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  168. select spa.time, COUNT(spa.id) as countNum
  169. from(
  170. SELECT
  171. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
  172. FROM sys_dept s
  173. <where>
  174. s.del_flag = 0
  175. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  176. AND s.id in
  177. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  178. #{deptId}
  179. </foreach>
  180. </if>
  181. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  182. and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
  183. </if>
  184. </where>
  185. ) as spa
  186. GROUP BY
  187. spa.time
  188. ORDER BY
  189. spa.time ASC
  190. </select>
  191. <select id="queryUserByTimes" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  192. select spa.time, COUNT(spa.id) as countNum
  193. from(
  194. SELECT
  195. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
  196. FROM sys_user s
  197. <where>
  198. s.status != 0
  199. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  200. AND s.dept_id in
  201. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  202. #{deptId}
  203. </foreach>
  204. </if>
  205. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  206. and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
  207. </if>
  208. </where>
  209. ) as spa
  210. GROUP BY
  211. spa.time
  212. ORDER BY
  213. spa.time ASC
  214. </select>
  215. <select id="queryUserByTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  216. select spa.time, COUNT(spa.id) as countNum
  217. from(
  218. SELECT
  219. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
  220. FROM sys_user s
  221. <where>
  222. s.status != 0
  223. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  224. AND s.dept_id in
  225. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  226. #{deptId}
  227. </foreach>
  228. </if>
  229. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  230. 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'))
  231. </if>
  232. </where>
  233. ) as spa
  234. GROUP BY
  235. spa.time
  236. ORDER BY
  237. spa.time ASC
  238. </select>
  239. <select id="queryUserByFive" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  240. select spa.time, COUNT(spa.id) as countNum
  241. from(
  242. SELECT
  243. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
  244. FROM sys_user s
  245. <where>
  246. s.status != 0
  247. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  248. AND s.dept_id in
  249. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  250. #{deptId}
  251. </foreach>
  252. </if>
  253. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  254. and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
  255. </if>
  256. </where>
  257. ) as spa
  258. GROUP BY
  259. spa.time
  260. ORDER BY
  261. spa.time ASC
  262. </select>
  263. <select id="queryUserByFiveTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  264. select spa.time, COUNT(spa.id) as countNum
  265. from(
  266. SELECT
  267. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
  268. FROM sys_user s
  269. <where>
  270. s.status != 0
  271. <if test="deptIds != null and deptIds != '' and deptIds.size() > 0">
  272. AND s.dept_id in
  273. <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
  274. #{deptId}
  275. </foreach>
  276. </if>
  277. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  278. 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'))
  279. </if>
  280. </where>
  281. ) as spa
  282. GROUP BY
  283. spa.time
  284. ORDER BY
  285. spa.time ASC
  286. </select>
  287. <select id="queryPartnerByTimes" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  288. select spa.time, COUNT(spa.id) as countNum
  289. from(
  290. SELECT
  291. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d %H' ) as time
  292. FROM sys_partner s
  293. left join sys_relation_person srp on srp.agency_leader_id = s.user_id
  294. <where>
  295. s.del_flag = 1 and srp.type = 0 and srp.source = 0
  296. <if test="userId != null and userId != '' ">
  297. and srp.suggest_id = #{userId}
  298. </if>
  299. <if test="dto.type != null and dto.type != 0 ">
  300. and s.type = #{dto.type}
  301. </if>
  302. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  303. and (DATE_FORMAT(s.create_time, '%Y-%m-%d' ) like CONCAT( DATE_FORMAT( #{dto.beginTime}, '%Y-%m-%d' ), '%' ))
  304. </if>
  305. </where>
  306. ) as spa
  307. GROUP BY
  308. spa.time
  309. ORDER BY
  310. spa.time ASC
  311. </select>
  312. <select id="queryPartnerByTime" resultType="com.ydtech.modules.admin.model.vo.CountUserNumVo">
  313. select spa.time, COUNT(spa.id) as countNum
  314. from(
  315. SELECT
  316. s.id,DATE_FORMAT(s.create_time, '%Y-%m-%d' ) as time
  317. FROM sys_partner s
  318. left join sys_relation_person srp on srp.agency_leader_id = s.user_id
  319. <where>
  320. s.del_flag = 1 and srp.type = 0 and srp.source = 0
  321. <if test="userId != null and userId != '' ">
  322. and srp.suggest_id = #{userId}
  323. </if>
  324. <if test="dto.type != null and dto.type != 0 ">
  325. and s.type = #{dto.type}
  326. </if>
  327. <if test="dto.beginTime != null and dto.beginTime != '' and dto.endTime != null and dto.endTime != ''">
  328. 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'))
  329. </if>
  330. </where>
  331. ) as spa
  332. GROUP BY
  333. spa.time
  334. ORDER BY
  335. spa.time ASC
  336. </select>
  337. </mapper>