Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

205 righe
8.1 KiB

  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.iformall.mapper.WxCUserFromMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserFrom">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
  8. <result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
  9. <result column="user_nick_name" jdbcType="VARCHAR" property="userNickName" />
  10. <result column="user_phone" jdbcType="VARCHAR" property="userPhone" />
  11. <result column="scene" jdbcType="VARCHAR" property="scene"/>
  12. <result column="scene_address" jdbcType="VARCHAR" property="sceneAddress"/>
  13. <result column="scene_address_desc" jdbcType="VARCHAR" property="sceneAddressDesc" />
  14. <result column="from_type" jdbcType="INTEGER" property="fromType" />
  15. <result column="from_id" jdbcType="BIGINT" property="fromId" />
  16. <result column="from_name" jdbcType="VARCHAR" property="fromName" />
  17. <result column="is_new_user" jdbcType="INTEGER" property="isNewUser" />
  18. <result column="share_user_type" jdbcType="INTEGER" property="shareUserType" />
  19. <result column="share_user" jdbcType="BIGINT" property="shareUser" />
  20. <result column="share_user_name" jdbcType="VARCHAR" property="shareUserName" />
  21. <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
  22. <result column="plat" jdbcType="INTEGER" property="plat" />
  23. </resultMap>
  24. <sql id="allColumns">
  25. wcuf.`id`,wcuf.`tenant_id`,wcuf.`parent_tenant_id`,wcuf.`c_user_id`,wcuf.`scene`,wcuf.`scene_address`,
  26. wcuf.`from_type`,wcuf.`from_id`,wcuf.`is_new_user`,wcuf.`share_user_type`,wcuf.`share_user`,wcuf.`create_date`,
  27. wcuf.`plat`
  28. </sql>
  29. <sql id="dynamicWhereConditions">
  30. where 1 = 1
  31. <if test=" null != id ">
  32. and wcuf.`id` = #{id}
  33. </if>
  34. <if test=" null != tenantId and '' != tenantId">
  35. and wcuf.`tenant_id` = #{tenantId}
  36. </if>
  37. <if test=" null != parentTenantId and '' != parentTenantId">
  38. and wcuf.`parent_tenant_id` = #{parentTenantId}
  39. </if>
  40. <if test=" null != cUserId ">
  41. and wcuf.`c_user_id` = #{cUserId}
  42. </if>
  43. <if test=" null != scene and '' != scene">
  44. and wcuf.`scene` = #{scene}
  45. </if>
  46. <if test=" null != sceneAddress and '' != sceneAddress">
  47. and wcuf.`scene_address` = #{sceneAddress}
  48. </if>
  49. <if test=" null != fromType ">
  50. and wcuf.`from_type` = #{fromType}
  51. </if>
  52. <if test=" null != fromId ">
  53. and wcuf.`from_id` = #{fromId}
  54. </if>
  55. <!--<if test=" null != isNewUser ">
  56. and wcuf.`is_new_user` = #{isNewUser}
  57. </if>-->
  58. <if test=" null != shareUserType ">
  59. and wcuf.`share_user_type` = #{shareUserType}
  60. </if>
  61. <if test=" null != shareUser ">
  62. and wcuf.`share_user` = #{shareUser}
  63. </if>
  64. <if test=" null != startDate ">
  65. and wcuf.`create_date` &gt;= #{startDate}
  66. </if>
  67. <if test=" null != endDate">
  68. and wcuf.`create_date` &lt;= #{endDate}
  69. </if>
  70. <if test=" null != plat">
  71. and wcuf.`plat` = #{plat}
  72. </if>
  73. <if test=" null != ids ">
  74. and wcuf.id in
  75. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  76. #{idItem}
  77. </foreach>
  78. </if>
  79. </sql>
  80. <select id="findList" parameterType="com.iformall.domain.po.WxCUserFrom" resultMap="BaseResultMap">
  81. select <include refid="allColumns" />
  82. ,wcu.nick_name user_nick_name
  83. ,wcu.phone user_phone
  84. ,wuc.description scene_address_desc
  85. from wx_c_user_from wcuf
  86. left join wx_c_user wcu on wcu.id = wcuf.c_user_id
  87. left join wx_user_channel wuc on wuc.scene_address = wcuf.scene_address
  88. <include refid="dynamicWhereConditions" />
  89. <if test=" null != isNewUser and isNewUser == 1">
  90. and wcuf.`is_new_user` = 1
  91. </if>
  92. <if test=" null != isNewUser and isNewUser == 0 ">
  93. and wcuf.c_user_id not in (select c_user_id from wx_c_user_from wcuf <include refid="dynamicWhereConditions" /> and wcuf.`is_new_user` = 1)
  94. </if>
  95. order by wcuf.`create_date` desc
  96. <if test=" null != begin ">
  97. limit #{begin}, #{limit}
  98. </if>
  99. <!-- select <include refid="allColumns" />-->
  100. <!-- ,(select nick_name from wx_c_user where id = wcuf.c_user_id ) user_nick_name-->
  101. <!-- ,(select description from wx_user_channel where scene_address = wcuf.scene_address ) scene_address_desc-->
  102. <!-- ,case when wcuf.from_type = 1 then (select nick_name from wx_c_user where id = wcuf.from_id)-->
  103. <!-- when wcuf.from_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.from_id)-->
  104. <!-- when wcuf.from_type = 3 then (select name from wx_merchant_b_user where id = wcuf.from_id)-->
  105. <!-- when wcuf.from_type = 4 then (select name from mall_user_info where id = wcuf.from_id)-->
  106. <!-- when wcuf.from_type = 5 then (select name from wx_merchant where id = wcuf.from_id)-->
  107. <!-- when wcuf.from_type = 6 then (select title from wx_coupon_channel where id = wcuf.from_id)-->
  108. <!-- when wcuf.from_type = 7 then (select title from wx_activity where id = wcuf.from_id)-->
  109. <!-- else '' end from_name-->
  110. <!-- ,case when wcuf.share_user_type = 1 then (select nick_name from wx_c_user where id = wcuf.share_user)-->
  111. <!-- when wcuf.share_user_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.share_user)-->
  112. <!-- when wcuf.share_user_type = 3 then (select name from wx_merchant_b_user where id = wcuf.share_user)-->
  113. <!-- when wcuf.share_user_type = 4 then (select name from mall_user_info where id = wcuf.share_user)-->
  114. <!-- else '' end share_user_name-->
  115. <!-- from wx_c_user_from wcuf-->
  116. <!-- <include refid="dynamicWhereConditions" />-->
  117. </select>
  118. <select id="visits" parameterType="com.iformall.domain.vo.WxCUserFromVo" resultType="com.iformall.domain.vo.WxCUserFromVo">
  119. select a.from_id fromId,a.from_type fromType,a.from_name fromName,a.from_phone fromPhone,IFNULL(a.visits,0) visits,IFNULL(b.reach_user,0) reachUser,IFNULL(c.new_user,0) newUser from (
  120. select wcuf.from_id,wcuf.from_type,
  121. <if test=" fromType == 2 ">wcubi.nick_name from_name,wcubi.phone from_phone,</if>
  122. <if test=" fromType == 5 ">wm.name from_name,wm.link_phone from_phone,</if>
  123. count(*) visits
  124. from wx_c_user_from wcuf
  125. <if test=" fromType == 2 ">left join wx_c_user_basic_info wcubi on wcuf.from_type = 2 and wcubi.id = wcuf.from_id</if>
  126. <if test=" fromType == 5 ">left join wx_merchant wm on wcuf.from_type = 5 and wm.id = wcuf.from_id</if>
  127. where wcuf.from_type = #{fromType}
  128. <if test=" null != tenantId and '' != tenantId">
  129. and wcuf.`tenant_id` = #{tenantId}
  130. </if>
  131. <if test=" null != parentTenantId and '' != parentTenantId">
  132. and wcuf.`parent_tenant_id` = #{parentTenantId}
  133. </if>
  134. <if test=" null != startDate ">
  135. and wcuf.`create_date` &gt;= #{startDate}
  136. </if>
  137. <if test=" null != endDate">
  138. and wcuf.`create_date` &lt;= #{endDate}
  139. </if>
  140. group by wcuf.from_id
  141. ) a
  142. left join (
  143. select wcuf.from_id,
  144. count(DISTINCT wcuf.c_user_id) reach_user
  145. from wx_c_user_from wcuf
  146. where wcuf.from_type = #{fromType}
  147. <if test=" null != tenantId and '' != tenantId">
  148. and wcuf.`tenant_id` = #{tenantId}
  149. </if>
  150. <if test=" null != parentTenantId and '' != parentTenantId">
  151. and wcuf.`parent_tenant_id` = #{parentTenantId}
  152. </if>
  153. <if test=" null != startDate ">
  154. and wcuf.`create_date` &gt;= #{startDate}
  155. </if>
  156. <if test=" null != endDate">
  157. and wcuf.`create_date` &lt;= #{endDate}
  158. </if>
  159. group by wcuf.from_id
  160. ) b on b.from_id = a.from_id
  161. left join (
  162. select wcuf.from_id,
  163. count(DISTINCT wcuf.c_user_id) new_user
  164. from wx_c_user_from wcuf
  165. where wcuf.from_type = #{fromType}
  166. and wcuf.is_new_user = 1
  167. <if test=" null != tenantId and '' != tenantId">
  168. and wcuf.`tenant_id` = #{tenantId}
  169. </if>
  170. <if test=" null != parentTenantId and '' != parentTenantId">
  171. and wcuf.`parent_tenant_id` = #{parentTenantId}
  172. </if>
  173. <if test=" null != startDate ">
  174. and wcuf.`create_date` &gt;= #{startDate}
  175. </if>
  176. <if test=" null != endDate">
  177. and wcuf.`create_date` &lt;= #{endDate}
  178. </if>
  179. group by wcuf.from_id
  180. ) c on c.from_id = a.from_id
  181. order by a.visits desc
  182. <if test=" null != begin ">
  183. limit #{begin}, #{limit}
  184. </if>
  185. </select>
  186. </mapper>