SysTelemarketingWechatDataMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ydtech.modules.admin.dao.SysTelemarketingWechatDataMapper">
  6. <resultMap id="BaseResultMap" type="com.ydtech.modules.admin.model.po.SysTelemarketingWechatData">
  7. <id property="id" column="id" jdbcType="INTEGER"/>
  8. <result property="userId" column="user_id" jdbcType="VARCHAR"/>
  9. <result property="number" column="number" jdbcType="INTEGER"/>
  10. <result property="createTime" column="create_time" jdbcType="DATE"/>
  11. <result property="updateTime" column="update_time" jdbcType="DATE"/>
  12. </resultMap>
  13. <sql id="Base_Column_List">
  14. id,user_id,number,
  15. create_time, update_time
  16. </sql>
  17. <select id="queryUserDataPage" resultType="com.ydtech.modules.admin.model.dto.DxReportDataDto">
  18. SELECT
  19. t1.id AS userId,
  20. t1.NAME AS userName,
  21. t1.mobile AS mobile,
  22. t2.id AS deptId,
  23. t2.`name` AS deptName,
  24. t5.NAME AS groupName,
  25. t5.id AS groupId,
  26. zgd.zgd_user_id AS zgdUserId,
  27. zzb.zzb_user_id AS zzdUserId,
  28. dx.dx_user_id AS dxUserId
  29. FROM
  30. sys_user t1
  31. LEFT JOIN sys_dept t2 ON t1.dept_id = t2.id
  32. LEFT JOIN sys_user_link_dx_user_id dx ON t1.id = dx.user_id
  33. LEFT JOIN sys_user_link_dept_internal_agent t4 ON t4.user_id = t1.id
  34. LEFT JOIN sys_user_link_zgd_user_id zgd ON t1.id = zgd.user_id
  35. LEFT JOIN sys_user_link_zzb_user_id zzb ON t1.id = zzb.user_id
  36. LEFT JOIN
  37. (select t3.bind_dept_id,t4.id,t4.name from sys_dept_internal_agent t3 left join sys_dept_internal_agent t4 on t4.parent_id =t3.id ) t5
  38. ON t2.id = t5.bind_dept_id
  39. WHERE
  40. t1.`status` = 1
  41. AND t1.dept_id= '9914D13'
  42. AND ( t1.id != '9914D1305' and t1.id != '9914D1316' )
  43. <if test='vo !=null '>
  44. <if test='vo.userName !=null and vo.userName!="" '>
  45. and t1.name like CONCAT('%', #{vo.userName}, '%')
  46. </if>
  47. <if test='vo.userId !=null and vo.userId!="" '>
  48. and t1.id = #{vo.userId}
  49. </if>
  50. <if test='vo.deptId !=null and vo.deptId!="" '>
  51. and t2.id like CONCAT('', #{vo.deptId}, '%')
  52. </if>
  53. <if test='vo.mobile !=null and vo.mobile!="" '>
  54. and t1.mobile = #{vo.mobile}
  55. </if>
  56. <if test='vo.groupId !=null and vo.groupId!="" '>
  57. and t5.id like CONCAT('', #{vo.groupId}, '%')
  58. </if>
  59. <if test="vo.deptIds != null and vo.deptIds != '' and vo.deptIds.size() > 0">
  60. AND t2.id in
  61. <foreach collection="vo.deptIds" item="item" open="(" separator="," close=")">
  62. #{item}
  63. </foreach>
  64. </if>
  65. <if test="vo.userIds != null and vo.userIds != '' and vo.userIds.size() > 0">
  66. AND t1.id in
  67. <foreach collection="vo.userIds" item="item" open="(" separator="," close=")">
  68. #{item}
  69. </foreach>
  70. </if>
  71. </if>
  72. order by t1.id
  73. </select>
  74. <select id="queryDataPage" resultType="com.ydtech.modules.admin.model.dto.DxReportDataDto">
  75. select
  76. a.dateStr as dateTime,
  77. ifnull(b.number,0) as wxCount
  78. from
  79. ( SELECT
  80. DATE_ADD(#{vo.beginDate}, INTERVAL seq.seq DAY) AS dateStr
  81. FROM (
  82. SELECT (t3.num*100 + t2.num*10 + t1.num) AS seq
  83. FROM (SELECT 0 AS num UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS t1,
  84. (SELECT 0 AS num UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS t2,
  85. (SELECT 0 AS num UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS t3
  86. ) AS seq
  87. WHERE DATE_ADD(#{vo.beginDate}, INTERVAL seq.seq DAY) &lt;= #{vo.endDate} order BY DATE_ADD(#{vo.beginDate}, INTERVAL seq.seq DAY)
  88. ) a
  89. left join ( select create_time,user_id,number from sys_telemarketing_wechat_data where user_id =#{vo.userId}) b ON
  90. a.dateStr = date(b.create_time)
  91. order by a.dateStr
  92. </select>
  93. <select id="queryCountByUserId" resultType="java.lang.Integer">
  94. SELECT
  95. sum(number)
  96. FROM
  97. sys_telemarketing_wechat_data
  98. <where>
  99. user_id =#{vo.userId}
  100. <if test="vo.beginDate != null and vo.beginDate != '' and vo.endDate != null and vo.endDate != '' ">
  101. AND create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  102. </if>
  103. </where>
  104. </select>
  105. <select id="findDataByUserId" resultType="com.ydtech.modules.admin.model.dto.DxReportDataDto">
  106. SELECT
  107. t1.id AS userId,
  108. t1.NAME AS userName,
  109. t1.mobile AS mobile,
  110. t2.id AS deptId,
  111. t2.`name` AS deptName,
  112. t5.NAME AS groupName,
  113. t5.id AS groupId,
  114. zgd.zgd_user_id AS zgdUserId,
  115. zzb.zzb_user_id AS zzdUserId,
  116. dx.dx_user_id AS dxUserId
  117. FROM
  118. sys_user t1
  119. LEFT JOIN sys_dept t2 ON t1.dept_id = t2.id
  120. LEFT JOIN sys_user_link_dx_user_id dx ON t1.id = dx.user_id
  121. LEFT JOIN sys_user_link_dept_internal_agent t4 ON t4.user_id = t1.id
  122. LEFT JOIN sys_user_link_zgd_user_id zgd ON t1.id = zgd.user_id
  123. LEFT JOIN sys_user_link_zzb_user_id zzb ON t1.id = zzb.user_id
  124. LEFT JOIN
  125. (select t3.bind_dept_id,t4.id,t4.name from sys_dept_internal_agent t3 left join sys_dept_internal_agent t4 on t4.parent_id =t3.id ) t5
  126. ON t2.id = t5.bind_dept_id
  127. WHERE
  128. t1.`status` = 1
  129. AND t1.dept_id= '9914D13'
  130. AND ( t1.id != '9914D1305' and t1.id != '9914D1316' )
  131. and t1.id = #{userId}
  132. </select>
  133. </mapper>