PcStatisticsMapper.xml 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.yunzhi.marketing.xlk.mapper.PcStatisticsMapper">
  4. <select id="selectAllPerson" resultType="java.lang.Integer">
  5. select count(1) from ta_person where org_id = #{params.orgId}
  6. </select>
  7. <select id="selectRegisterPerson" resultType="java.lang.Integer">
  8. select count(1) from ta_person where org_id = #{params.orgId} and phone is not null
  9. </select>
  10. <select id="selectTodayVisitNum" resultType="java.lang.Integer">
  11. SELECT
  12. COUNT(1)
  13. FROM
  14. ta_person_visit_record tp
  15. where tp.org_id = #{params.orgId} AND
  16. tp.event = 'start'
  17. AND DATE_FORMAT(tp.visit_time,'%Y-%m-%d') = DATE_FORMAT(#{params.todayTime},'%Y-%m-%d')
  18. </select>
  19. <select id="selectTodayAddPerson" resultType="java.lang.Integer">
  20. SELECT
  21. COUNT(1)
  22. FROM
  23. ta_person tp
  24. where tp.org_id = #{params.orgId}
  25. AND DATE_FORMAT(tp.create_date,'%Y-%m-%d') = DATE_FORMAT(#{params.todayTime},'%Y-%m-%d')
  26. </select>
  27. <select id="selectChannelNum" resultType="java.lang.Integer">
  28. SELECT
  29. COUNT(1)
  30. FROM
  31. ta_channel t
  32. WHERE
  33. t.org_id = #{params.orgId}
  34. <if test="params.institutionIds != null and params.institutionIds.size > 0">
  35. AND t.institution_id in
  36. <foreach collection="params.institutionIds" item="item" open="(" close=")" separator=",">
  37. #{item}
  38. </foreach>
  39. </if>
  40. </select>
  41. <select id="selectEstateAgentNum" resultType="java.lang.Integer">
  42. SELECT
  43. COUNT(1)
  44. FROM
  45. ta_person tp
  46. where tp.org_id = #{params.orgId}
  47. and tp.person_type in ('estate agent','channel agent')
  48. </select>
  49. <select id="getUserOriginStatistics" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsVO">
  50. SELECT
  51. sum(if(recommend_person_type = 'Realty Consultant', 1, 0)) as consultant_num,
  52. sum(if(recommend_person_type = 'customer', 1, 0)) as customer_num,
  53. sum(if(recommend_person_type in ('estate agent','channel agent'), 1, 0)) as estage_num,
  54. count(1) as all_person_num
  55. from ta_person
  56. where org_id = #{params.orgId}
  57. </select>
  58. <select id="getuserGenderStatistics" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsGenderVO">
  59. SELECT
  60. sum(if(gender = '1', 1, 0)) as male_num,
  61. sum(if(gender = '2', 1, 0)) as female_num
  62. from ta_person
  63. </select>
  64. <select id="getGkLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
  65. SELECT
  66. count(1) as num,
  67. b.building_id,
  68. d.building_name
  69. FROM
  70. ta_recommend_customer b
  71. LEFT JOIN ta_building d ON b.building_id = d.building_id
  72. WHERE
  73. b.STATUS > 0
  74. AND b.org_id = #{params.orgId}
  75. AND b.verify_status = 1
  76. AND ( b.realty_consultant IS NULL OR b.realty_consultant = '' )
  77. AND b.building_id IS NOT NULL
  78. <if test="params.cityId != null">
  79. and d.city_id = #{params.cityId}
  80. </if>
  81. <if test="params.startTime != null">
  82. and TO_DAYS(b.create_date) >= TO_DAYS(#{params.startTime})
  83. </if>
  84. <if test="params.endTime != null">
  85. and TO_DAYS(b.create_date) &lt;= TO_DAYS(#{params.endTime})
  86. </if>
  87. <if test="params.institutionIds != null and params.institutionIds.size > 0">
  88. AND b.institution_id in
  89. <foreach collection="params.institutionIds" item="item" open="(" close=")" separator=",">
  90. #{item}
  91. </foreach>
  92. </if>
  93. GROUP BY b.building_id
  94. ORDER BY num desc
  95. LIMIT 6
  96. </select>
  97. <select id="getSkLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
  98. SELECT
  99. count(1) as num,
  100. b.building_id,
  101. d.building_name
  102. FROM
  103. ta_recommend_customer b
  104. LEFT JOIN ta_building d ON b.building_id = d.building_id
  105. WHERE
  106. b.STATUS > 0
  107. AND b.org_id = #{params.orgId}
  108. AND b.verify_status = 1
  109. AND b.realty_consultant IS NOT NULL
  110. AND b.realty_consultant != ''
  111. AND b.building_id IS NOT NULL
  112. <if test="params.cityId != null">
  113. and d.city_id = #{params.cityId}
  114. </if>
  115. <if test="params.startTime != null">
  116. and TO_DAYS(b.create_date) >= TO_DAYS(#{params.startTime})
  117. </if>
  118. <if test="params.endTime != null">
  119. and TO_DAYS(b.create_date) &lt;= TO_DAYS(#{params.endTime})
  120. </if>
  121. <if test="params.institutionIds != null and params.institutionIds.size > 0">
  122. AND b.institution_id in
  123. <foreach collection="params.institutionIds" item="item" open="(" close=")" separator=",">
  124. #{item}
  125. </foreach>
  126. </if>
  127. GROUP BY b.building_id
  128. ORDER BY num desc
  129. LIMIT 6
  130. </select>
  131. <select id="getVisitNumLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
  132. SELECT
  133. count( * ) AS num,
  134. a.be_uv AS building_id,
  135. d.building_name
  136. FROM
  137. ta_uv a
  138. LEFT JOIN ta_building d ON a.be_uv = d.building_id
  139. WHERE
  140. a.tagert_type = 'project'
  141. AND d.org_id = #{params.orgId}
  142. AND a.be_uv != "undefined"
  143. <if test="params.cityId != null">
  144. and d.city_id = #{params.cityId}
  145. </if>
  146. <if test="params.startTime != null">
  147. and TO_DAYS(a.create_date) >= TO_DAYS(#{params.startTime})
  148. </if>
  149. <if test="params.endTime != null">
  150. and TO_DAYS(a.create_date) &lt;= TO_DAYS(#{params.endTime})
  151. </if>
  152. <if test="params.institutionIds != null and params.institutionIds.size > 0">
  153. AND d.institution_id in
  154. <foreach collection="params.institutionIds" item="item" open="(" close=")" separator=",">
  155. #{item}
  156. </foreach>
  157. </if>
  158. GROUP BY
  159. a.be_uv
  160. ORDER BY
  161. num DESC
  162. LIMIT 6
  163. </select>
  164. <select id="getSuccessLeaderboard" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsLeaderboardVO">
  165. SELECT
  166. count(1) as num,
  167. b.building_id,
  168. d.building_name
  169. FROM
  170. ta_recommend_customer b
  171. LEFT JOIN ta_building d ON b.building_id = d.building_id
  172. LEFT JOIN xlk_institution i ON b.institution_id = i.institution_id
  173. WHERE
  174. b.STATUS > 3
  175. AND b.org_id = #{params.orgId}
  176. AND b.verify_status = 1
  177. AND b.building_id IS NOT NULL
  178. <if test="params.cityId != null">
  179. and d.city_id = #{params.cityId}
  180. </if>
  181. <if test="params.startTime != null">
  182. and TO_DAYS(b.create_date) >= TO_DAYS(#{params.startTime})
  183. </if>
  184. <if test="params.endTime != null">
  185. and TO_DAYS(b.create_date) &lt;= TO_DAYS(#{params.endTime})
  186. </if>
  187. <if test="params.institutionIds != null and params.institutionIds.size > 0">
  188. AND b.institution_id in
  189. <foreach collection="params.institutionIds" item="item" open="(" close=")" separator=",">
  190. #{item}
  191. </foreach>
  192. </if>
  193. GROUP BY b.building_id
  194. ORDER BY num desc
  195. LIMIT 6
  196. </select>
  197. <select id="selectActivityList" resultType="com.yunzhi.marketing.xlk.vo.PcStatisticsActivityVO">
  198. SELECT
  199. p.visit_num,
  200. v.visit_person_num,
  201. d.sign_num,
  202. t.title,
  203. t.dynamic_id,
  204. t.building_id
  205. FROM
  206. ta_building_dynamic t
  207. LEFT JOIN (
  208. SELECT
  209. count( * ) AS visit_num,
  210. a.target_id
  211. FROM
  212. ta_person_visit_record a
  213. WHERE
  214. a.event_type = 'activity'
  215. AND a.`event` = 'detail'
  216. AND a.org_id = #{params.orgId}
  217. GROUP BY
  218. a.target_id
  219. ) p ON t.dynamic_id = p.target_id
  220. LEFT JOIN (
  221. SELECT
  222. count( DISTINCT ( a.person_id ) ) AS visit_person_num,
  223. a.target_id
  224. FROM
  225. ta_person_visit_record a
  226. WHERE
  227. a.event_type = 'activity'
  228. AND a.`event` = 'detail'
  229. AND a.org_id = #{params.orgId}
  230. GROUP BY
  231. a.target_id
  232. ) v ON t.dynamic_id = v.target_id
  233. LEFT JOIN ( SELECT COUNT( 1 ) AS sign_num, dynamic_id FROM ta_activity_dynamic_enlist GROUP BY dynamic_id ) d ON t.dynamic_id = d.dynamic_id
  234. LEFT JOIN xlk_institution i ON t.institution_id = i.institution_id
  235. where
  236. t.org_id = #{params.orgId}
  237. <if test="params.startTime != null">
  238. and TO_DAYS(t.create_date) >= TO_DAYS(#{params.startTime})
  239. </if>
  240. <if test="params.endTime != null">
  241. and TO_DAYS(t.create_date) &lt;= TO_DAYS(#{params.endTime})
  242. </if>
  243. <if test="params.buildingId != null and params.buildingId != ''">
  244. and t.building_id = #{params.buildingId}
  245. </if>
  246. <if test="params.institutionIds != null and params.institutionIds.size > 0">
  247. AND t.institution_id in
  248. <foreach collection="params.institutionIds" item="item" open="(" close=")" separator=",">
  249. #{item}
  250. </foreach>
  251. </if>
  252. order by t.create_date desc
  253. </select>
  254. </mapper>