選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

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