SysTelemarketingWechatDataMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. t3.NAME AS groupName,
  25. t3.id AS groupId,
  26. zgd.zgd_user_id AS zgdUserId,
  27. zzb.zzb_user_id AS zzdUserId
  28. FROM
  29. sys_user t1
  30. LEFT JOIN sys_dept t2 ON t1.dept_id = t2.id
  31. LEFT JOIN sys_user_link_dept_internal_agent t4 ON t4.user_id = t1.id
  32. LEFT JOIN sys_dept_internal_agent t3 ON t2.id = t3.bind_dept_id
  33. LEFT JOIN sys_user_link_zgd_user_id zgd ON t2.id = zgd.user_id
  34. LEFT JOIN sys_user_link_zzb_user_id zzb ON t2.id = zzb.user_id
  35. WHERE
  36. t1.`status` = 1
  37. <if test='vo !=null '>
  38. <if test='vo.userName !=null and vo.userName!="" '>
  39. and t1.name like CONCAT('%', #{vo.userName}, '%')
  40. </if>
  41. <if test='vo.userId !=null and vo.userId!="" '>
  42. and t1.id = #{vo.userId}
  43. </if>
  44. <if test='vo.deptId !=null and vo.deptId!="" '>
  45. and t2.id like CONCAT('', #{vo.deptId}, '%')
  46. </if>
  47. <if test='vo.mobile !=null and vo.mobile!="" '>
  48. and t1.mobile = #{vo.mobile}
  49. </if>
  50. <if test='vo.groupId !=null and vo.groupId!="" '>
  51. and t3.id like CONCAT('', #{vo.groupId}, '%')
  52. </if>
  53. </if>
  54. order by t1.id
  55. </select>
  56. <select id="queryDataPage" resultType="com.ydtech.modules.admin.model.dto.DxReportDataDto">
  57. select
  58. a.dateStr as dateTime,
  59. ifnull(b.number,0) as wxCount
  60. from
  61. ( SELECT
  62. DATE_ADD(#{vo.beginDate}, INTERVAL seq.seq DAY) AS dateStr
  63. FROM (
  64. SELECT (t3.num*100 + t2.num*10 + t1.num) AS seq
  65. 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,
  66. (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,
  67. (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
  68. ) AS seq
  69. WHERE DATE_ADD(#{vo.beginDate}, INTERVAL seq.seq DAY) &lt;= #{vo.endDate} order BY DATE_ADD(#{vo.beginDate}, INTERVAL seq.seq DAY)
  70. ) a
  71. left join ( select create_time,user_id,number from sys_telemarketing_wechat_data where user_id =#{vo.userId}) b ON
  72. a.dateStr = date(b.create_time)
  73. order by a.dateStr
  74. </select>
  75. <select id="queryCountByUserId" resultType="java.lang.Integer">
  76. SELECT
  77. sum(number)
  78. FROM
  79. sys_telemarketing_wechat_data
  80. <where>
  81. user_id =#{vo.userId}
  82. <if test="vo.beginDate != null and vo.beginDate != '' and vo.endDate != null and vo.endDate != '' ">
  83. AND create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
  84. </if>
  85. </where>
  86. </select>
  87. <select id="findDataByUserId" resultType="com.ydtech.modules.admin.model.dto.DxReportDataDto">
  88. SELECT
  89. t1.id AS userId,
  90. t1.NAME AS userName,
  91. t1.mobile AS mobile,
  92. t2.id AS deptId,
  93. t2.`name` AS deptName,
  94. t3.NAME AS groupName,
  95. t3.id AS groupId,
  96. zgd.zgd_user_id AS zgdUserId,
  97. zzb.zzb_user_id AS zzdUserId,
  98. dx.dial_username AS dxUserId
  99. FROM
  100. sys_user t1
  101. LEFT JOIN sys_dept t2 ON t1.dept_id = t2.id
  102. LEFT JOIN sys_user_is_dial dx ON t1.id =dx.user_id
  103. LEFT JOIN sys_user_link_dept_internal_agent t4 ON t4.user_id = t1.id
  104. LEFT JOIN sys_dept_internal_agent t3 ON t2.id = t3.bind_dept_id
  105. LEFT JOIN sys_user_link_zgd_user_id zgd ON t2.id = zgd.user_id
  106. LEFT JOIN sys_user_link_zzb_user_id zzb ON t2.id = zzb.user_id
  107. WHERE
  108. t1.`status` = 1
  109. and t1.id = #{userId}
  110. </select>
  111. </mapper>