后台服务
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

206 satır
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
  120. from (
  121. select wcuf.from_id,wcuf.from_type,
  122. <if test=" fromType == 2 ">wcubi.nick_name from_name,wcubi.phone from_phone,</if>
  123. <if test=" fromType == 5 ">wm.name from_name,wm.link_phone from_phone,</if>
  124. count(*) visits
  125. from wx_c_user_from wcuf
  126. <if test=" fromType == 2 ">left join wx_c_user_basic_info wcubi on wcuf.from_type = 2 and wcubi.id = wcuf.from_id</if>
  127. <if test=" fromType == 5 ">left join wx_merchant wm on wcuf.from_type = 5 and wm.id = wcuf.from_id</if>
  128. where wcuf.from_type = #{fromType}
  129. <if test=" null != tenantId and '' != tenantId">
  130. and wcuf.`tenant_id` = #{tenantId}
  131. </if>
  132. <if test=" null != parentTenantId and '' != parentTenantId">
  133. and wcuf.`parent_tenant_id` = #{parentTenantId}
  134. </if>
  135. <if test=" null != startDate ">
  136. and wcuf.`create_date` &gt;= #{startDate}
  137. </if>
  138. <if test=" null != endDate">
  139. and wcuf.`create_date` &lt;= #{endDate}
  140. </if>
  141. group by wcuf.from_id
  142. ) a
  143. left join (
  144. select wcuf.from_id,
  145. count(DISTINCT wcuf.c_user_id) reach_user
  146. from wx_c_user_from wcuf
  147. where wcuf.from_type = #{fromType}
  148. <if test=" null != tenantId and '' != tenantId">
  149. and wcuf.`tenant_id` = #{tenantId}
  150. </if>
  151. <if test=" null != parentTenantId and '' != parentTenantId">
  152. and wcuf.`parent_tenant_id` = #{parentTenantId}
  153. </if>
  154. <if test=" null != startDate ">
  155. and wcuf.`create_date` &gt;= #{startDate}
  156. </if>
  157. <if test=" null != endDate">
  158. and wcuf.`create_date` &lt;= #{endDate}
  159. </if>
  160. group by wcuf.from_id
  161. ) b on b.from_id = a.from_id
  162. left join (
  163. select wcuf.from_id,
  164. count(DISTINCT wcuf.c_user_id) new_user
  165. from wx_c_user_from wcuf
  166. where wcuf.from_type = #{fromType}
  167. and wcuf.is_new_user = 1
  168. <if test=" null != tenantId and '' != tenantId">
  169. and wcuf.`tenant_id` = #{tenantId}
  170. </if>
  171. <if test=" null != parentTenantId and '' != parentTenantId">
  172. and wcuf.`parent_tenant_id` = #{parentTenantId}
  173. </if>
  174. <if test=" null != startDate ">
  175. and wcuf.`create_date` &gt;= #{startDate}
  176. </if>
  177. <if test=" null != endDate">
  178. and wcuf.`create_date` &lt;= #{endDate}
  179. </if>
  180. group by wcuf.from_id
  181. ) c on c.from_id = a.from_id
  182. order by a.visits desc
  183. <if test=" null != begin ">
  184. limit #{begin}, #{limit}
  185. </if>
  186. </select>
  187. </mapper>