ContentPlatformDataStatMapperExt.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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.tzld.piaoquan.api.dao.mapper.contentplatform.ext.ContentPlatformDataStatMapperExt">
  4. <select id="getGzhAccountDatastatCount" resultType="java.lang.Integer">
  5. select count(1)
  6. from content_platform_gzh_datastat cpgd
  7. join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
  8. where cpgza.create_account_id = #{createAccountId}
  9. <if test="param.accountId!= null and param.accountId!= ''">
  10. and cpgza.id = #{param.accountId}
  11. </if>
  12. </select>
  13. <select id="getGzhAccountDatastatList"
  14. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
  15. select cpgd.*
  16. from content_platform_gzh_datastat cpgd
  17. join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
  18. where cpgza.create_account_id = #{createAccountId}
  19. <if test="param.accountId!= null and param.accountId!= ''">
  20. and cpgza.id = #{param.accountId}
  21. </if>
  22. order by cpgd.date_str desc, cpgd.account_id
  23. limit #{offset}, #{pageSize}
  24. </select>
  25. <select id="getGzhAccountVideoDatastatCount" resultType="java.lang.Integer">
  26. select count(1)
  27. from content_platform_gzh_video_datastat cpgvd
  28. join content_platform_gzh_account cpgza on cpgvd.account_id = cpgza.id
  29. where cpgza.create_account_id = #{createAccountId}
  30. <if test="param.accountId!= null and param.accountId!= ''">
  31. and cpgza.id = #{param.accountId}
  32. </if>
  33. </select>
  34. <select id="getGzhAccountVideoDatastatList"
  35. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhVideoDataStat">
  36. select cpgvd.*
  37. from content_platform_gzh_video_datastat cpgvd
  38. join content_platform_gzh_account cpgza on cpgvd.account_id = cpgza.id
  39. where cpgza.create_account_id = #{createAccountId}
  40. <if test="param.accountId!= null and param.accountId!= ''">
  41. and cpgza.id = #{param.accountId}
  42. </if>
  43. order by cpgvd.date_str desc
  44. limit #{offset}, #{pageSize}
  45. </select>
  46. <select id="getGzhTotalDatastatCount" resultType="java.lang.Integer">
  47. select count(1)
  48. from content_platform_gzh_datastat_total cpgdt
  49. join content_platform_account cpa on cpgdt.channel = cpa.channel
  50. where cpa.id = #{createAccountId}
  51. </select>
  52. <select id="getGzhTotalDatastatList"
  53. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStatTotal">
  54. select date_str, fans_increase_count, first_level_count, score, unit_price, settlement_amount
  55. from content_platform_gzh_datastat_total cpgdt
  56. join content_platform_account cpa on cpgdt.channel = cpa.channel
  57. where cpa.id = #{createAccountId}
  58. order by cpgdt.date_str desc
  59. limit #{offset}, #{pageSize}
  60. </select>
  61. <select id="getFwhAccountDatastatCount" resultType="java.lang.Integer">
  62. select count(1)
  63. from content_platform_fwh_datastat cpgd
  64. join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
  65. where cpgza.create_account_id = #{createAccountId}
  66. <if test="param.accountId!= null and param.accountId!= ''">
  67. and cpgza.id = #{param.accountId}
  68. </if>
  69. </select>
  70. <select id="getFwhAccountDatastatList"
  71. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
  72. select cpfd.*
  73. from content_platform_fwh_datastat cpfd
  74. join content_platform_gzh_account cpgza on cpfd.account_id = cpgza.id
  75. where cpgza.create_account_id = #{createAccountId}
  76. <if test="param.accountId!= null and param.accountId!= ''">
  77. and cpgza.id = #{param.accountId}
  78. </if>
  79. order by cpfd.date_str desc
  80. limit #{offset}, #{pageSize}
  81. </select>
  82. <select id="getFwhTotalDatastatCount" resultType="java.lang.Integer">
  83. select count(1)
  84. from content_platform_fwh_datastat_total cpfdt
  85. join content_platform_account cpa on cpfdt.channel = cpa.channel
  86. where cpa.id = #{createAccountId}
  87. </select>
  88. <select id="getFwhTotalDatastatList"
  89. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformFwhDataStatTotal">
  90. select date_str, fans_increase_count, first_level_count, score, unit_price, settlement_amount
  91. from content_platform_fwh_datastat_total cpfdt
  92. join content_platform_account cpa on cpfdt.channel = cpa.channel
  93. where cpa.id = #{createAccountId}
  94. order by cpfdt.date_str desc
  95. limit #{offset}, #{pageSize}
  96. </select>
  97. <select id="getGzhPushTotalDatastatCount" resultType="java.lang.Integer">
  98. select count(1)
  99. from content_platform_gzh_push_datastat_total cpfdt
  100. join content_platform_account cpa on cpfdt.channel = cpa.channel
  101. where cpa.id = #{createAccountId}
  102. </select>
  103. <select id="getGzhPushTotalDatastatList"
  104. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPushDataStatTotal">
  105. select date_str, fans_increase_count, first_level_count, score, unit_price, settlement_amount
  106. from content_platform_gzh_push_datastat_total cpfdt
  107. join content_platform_account cpa on cpfdt.channel = cpa.channel
  108. where cpa.id = #{createAccountId}
  109. order by cpfdt.date_str desc
  110. limit #{offset}, #{pageSize}
  111. </select>
  112. <select id="getGzhPushAccountDatastatCount" resultType="java.lang.Integer">
  113. select count(1)
  114. from content_platform_gzh_push_datastat cpgd
  115. join content_platform_gzh_account cpgza on cpgd.account_id = cpgza.id
  116. where cpgza.create_account_id = #{createAccountId}
  117. <if test="param.accountId!= null and param.accountId!= ''">
  118. and cpgza.id = #{param.accountId}
  119. </if>
  120. </select>
  121. <select id="getGzhPushAccountDatastatList"
  122. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhDataStat">
  123. select cpfd.*
  124. from content_platform_gzh_push_datastat cpfd
  125. join content_platform_gzh_account cpgza on cpfd.account_id = cpgza.id
  126. where cpgza.create_account_id = #{createAccountId}
  127. <if test="param.accountId!= null and param.accountId!= ''">
  128. and cpgza.id = #{param.accountId}
  129. </if>
  130. order by cpfd.date_str desc
  131. limit #{offset}, #{pageSize}
  132. </select>
  133. <select id="getQwRootSourceIdDatastatCount" resultType="java.lang.Integer">
  134. select count(1)
  135. from content_platform_qw_datastat cpqd
  136. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  137. where cpqp.create_account_id = #{createAccountId}
  138. </select>
  139. <select id="getQwRootSourceIdDatastatList"
  140. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  141. select cpqd.*
  142. from content_platform_qw_datastat cpqd
  143. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  144. where cpqp.create_account_id = #{createAccountId}
  145. order by cpqd.date_str desc
  146. limit #{offset}, #{pageSize}
  147. </select>
  148. <select id="getQwTotalDatastatCount" resultType="java.lang.Integer">
  149. select count(1)
  150. from content_platform_qw_datastat_total
  151. where channel = #{channel}
  152. </select>
  153. <select id="getQwTotalDatastatList"
  154. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
  155. select date_str, channel, first_level_count, score, unit_price, settlement_amount
  156. from content_platform_qw_datastat_total
  157. where channel = #{channel}
  158. order by date_str desc, id
  159. limit #{offset}, #{pageSize}
  160. </select>
  161. <select id="getQwReplyTotalDatastatCount" resultType="java.lang.Integer">
  162. select count(1)
  163. from content_platform_qw_datastat_reply_total
  164. where channel = #{channel}
  165. </select>
  166. <select id="getQwReplyTotalDatastatList"
  167. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatReplyTotal">
  168. select date_str, channel, first_level_count, score
  169. from content_platform_qw_datastat_reply_total
  170. where channel = #{channel}
  171. order by date_str desc, id
  172. limit #{offset}, #{pageSize}
  173. </select>
  174. <select id="getQwSubChannelDatastatCount" resultType="java.lang.Integer">
  175. select count(1)
  176. from content_platform_qw_datastat_sub_channel
  177. where create_account_id = #{createAccountId}
  178. </select>
  179. <select id="getQwSubChannelDatastatList"
  180. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatSubChannel">
  181. select date_str, sub_channel, first_level_count, score, unit_price, settlement_amount
  182. from content_platform_qw_datastat_sub_channel
  183. where create_account_id = #{createAccountId}
  184. order by date_str desc, id
  185. limit #{offset}, #{pageSize}
  186. </select>
  187. <select id="getQwSceneDatastatCount" resultType="java.lang.Integer">
  188. select count(1)
  189. from (select cpqd.date_str
  190. from content_platform_qw_datastat cpqd
  191. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  192. where cpqp.create_account_id = #{createAccountId}
  193. and cpqp.scene = #{scene}
  194. group by cpqd.date_str) t
  195. </select>
  196. <select id="getQwSceneDatastatList"
  197. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  198. select cpqd.date_str, sum(cpqd.first_level_count) as first_level_count, avg(cpqd.score) as score
  199. from content_platform_qw_datastat cpqd
  200. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  201. where cpqp.create_account_id = #{createAccountId}
  202. and cpqp.scene = #{scene}
  203. group by cpqd.date_str
  204. order by cpqd.date_str desc
  205. limit #{offset}, #{pageSize}
  206. </select>
  207. <select id="getQwReplyDatastatCount" resultType="java.lang.Integer">
  208. select count(1)
  209. from (select cpqd.date_str
  210. from content_platform_qw_datastat cpqd
  211. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  212. where cpqp.create_account_id = #{createAccountId}
  213. and cpqp.type = 1
  214. group by cpqd.date_str) t
  215. </select>
  216. <select id="getReplyDatastatList"
  217. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStat">
  218. select cpqd.date_str, sum(cpqd.first_level_count) as first_level_count, avg(cpqd.score) as score
  219. from content_platform_qw_datastat cpqd
  220. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  221. where cpqp.create_account_id = #{createAccountId}
  222. and cpqp.type = 1
  223. group by cpqd.date_str
  224. order by cpqd.date_str desc
  225. limit #{offset}, #{pageSize}
  226. </select>
  227. <insert id="batchInsertGzhDatastat">
  228. insert into content_platform_gzh_datastat (date_str, account_id, fans_increase_count, first_level_count, score,
  229. create_timestamp)
  230. values
  231. <foreach collection="records" item="item" separator=",">
  232. (#{item.dateStr}, #{item.accountId}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  233. #{item.createTimestamp})
  234. </foreach>
  235. </insert>
  236. <insert id="batchInsertGzhVideoDatastat">
  237. insert into content_platform_gzh_video_datastat (date_str, account_id, video_id, title, first_level_count,
  238. score, create_timestamp)
  239. values
  240. <foreach collection="records" item="item" separator=",">
  241. (#{item.dateStr}, #{item.accountId}, #{item.videoId}, #{item.title}, #{item.firstLevelCount}, #{item.score},
  242. #{item.createTimestamp})
  243. </foreach>
  244. </insert>
  245. <insert id="batchInsertGzhDatastatTotal">
  246. insert into content_platform_gzh_datastat_total (date_str, channel, fans_increase_count, first_level_count, score,
  247. unit_price, settlement_amount, create_timestamp)
  248. values
  249. <foreach collection="records" item="item" separator=",">
  250. (#{item.dateStr}, #{item.channel}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  251. #{item.unitPrice}, #{item.settlementAmount}, #{item.createTimestamp})
  252. </foreach>
  253. </insert>
  254. <insert id="batchInsertFwhDatastat">
  255. insert into content_platform_fwh_datastat (date_str, account_id, fans_increase_count, first_level_count, score,
  256. create_timestamp)
  257. values
  258. <foreach collection="records" item="item" separator=",">
  259. (#{item.dateStr}, #{item.accountId}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  260. #{item.createTimestamp})
  261. </foreach>
  262. </insert>
  263. <insert id="batchInsertFwhDatastatTotal">
  264. insert into content_platform_fwh_datastat_total (date_str, channel, fans_increase_count, first_level_count, score,
  265. unit_price, settlement_amount, create_timestamp)
  266. values
  267. <foreach collection="records" item="item" separator=",">
  268. (#{item.dateStr}, #{item.channel}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  269. #{item.unitPrice}, #{item.settlementAmount}, #{item.createTimestamp})
  270. </foreach>
  271. </insert>
  272. <insert id="batchInsertQwDatastat">
  273. insert into content_platform_qw_datastat (date_str, root_source_id, first_level_count, score, create_timestamp)
  274. values
  275. <foreach collection="records" item="item" separator=",">
  276. (#{item.dateStr}, #{item.rootSourceId}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  277. </foreach>
  278. </insert>
  279. <insert id="batchInsertQwDatastatTotal">
  280. insert into content_platform_qw_datastat_total (date_str, channel, first_level_count, score, unit_price,
  281. settlement_amount, create_timestamp)
  282. values
  283. <foreach collection="records" item="item" separator=",">
  284. (#{item.dateStr}, #{item.channel}, #{item.firstLevelCount}, #{item.score}, #{item.unitPrice},
  285. #{item.settlementAmount}, #{item.createTimestamp})
  286. </foreach>
  287. </insert>
  288. <insert id="batchInsertQwDatastatReplyTotal">
  289. insert into content_platform_qw_datastat_reply_total (date_str, channel, first_level_count, score, create_timestamp)
  290. values
  291. <foreach collection="records" item="item" separator=",">
  292. (#{item.dateStr}, #{item.channel}, #{item.firstLevelCount}, #{item.score}, #{item.createTimestamp})
  293. </foreach>
  294. </insert>
  295. <insert id="batchInsertQwDatastatSubChannel">
  296. insert into content_platform_qw_datastat_sub_channel (date_str, sub_channel, first_level_count, score,
  297. create_account_id, unit_price, settlement_amount, create_timestamp)
  298. values
  299. <foreach collection="records" item="item" separator=",">
  300. (#{item.dateStr}, #{item.subChannel}, #{item.firstLevelCount}, #{item.score}, #{item.createAccountId},
  301. #{item.unitPrice}, #{item.settlementAmount}, #{item.createTimestamp})
  302. </foreach>
  303. </insert>
  304. <insert id="batchInsertGzhPushDatastat">
  305. insert into content_platform_gzh_push_datastat (date_str, account_id, fans_increase_count, first_level_count, score,
  306. create_timestamp)
  307. values
  308. <foreach collection="records" item="item" separator=",">
  309. (#{item.dateStr}, #{item.accountId}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  310. #{item.createTimestamp})
  311. </foreach>
  312. </insert>
  313. <insert id="batchInsertGzhPushDatastatTotal">
  314. insert into content_platform_gzh_push_datastat_total (date_str, channel, fans_increase_count, first_level_count, score,
  315. unit_price, settlement_amount, create_timestamp)
  316. values
  317. <foreach collection="records" item="item" separator=",">
  318. (#{item.dateStr}, #{item.channel}, #{item.fansIncreaseCount}, #{item.firstLevelCount}, #{item.score},
  319. #{item.unitPrice}, #{item.settlementAmount}, #{item.createTimestamp})
  320. </foreach>
  321. </insert>
  322. <select id="getQwTotalDatastatScoreList"
  323. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatTotal">
  324. select cpa.channel, round(avg(cpqd.score), 2) as score
  325. from content_platform_qw_datastat cpqd
  326. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  327. join content_platform_account cpa on cpa.id = cpqp.create_account_id
  328. where cpqd.date_str = #{dt}
  329. group by cpa.channel
  330. </select>
  331. <select id="getQwTotalDatastatReplyScoreList"
  332. resultType="com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformQwDataStatReplyTotal">
  333. select cpa.channel, round(avg(cpqd.score), 2) as score
  334. from content_platform_qw_datastat cpqd
  335. join content_platform_qw_plan cpqp on cpqp.root_source_id = cpqd.root_source_id
  336. join content_platform_account cpa on cpa.id = cpqp.create_account_id
  337. where cpqd.date_str = #{dt} and cpqp.type = 1
  338. group by cpa.channel
  339. </select>
  340. <delete id="deleteQwDatastat">
  341. delete from content_platform_qw_datastat where date_str = #{dt}
  342. </delete>
  343. <delete id="deleteQwDatastatTotal">
  344. delete from content_platform_qw_datastat_total where date_str = #{dt}
  345. </delete>
  346. <delete id="deleteQwDatastatReplyTotal">
  347. delete from content_platform_qw_datastat_reply_total where date_str = #{dt}
  348. </delete>
  349. <delete id="deleteQwDatastatSubChannel">
  350. delete from content_platform_qw_datastat_sub_channel where date_str = #{dt}
  351. </delete>
  352. <delete id="deleteGzhDatastat">
  353. delete from content_platform_gzh_datastat where date_str = #{dt}
  354. </delete>
  355. <delete id="deleteGzhDatastatTotal">
  356. delete from content_platform_gzh_datastat_total where date_str = #{dt}
  357. </delete>
  358. <delete id="deleteFwhDatastat">
  359. delete from content_platform_fwh_datastat where date_str = #{dt}
  360. </delete>
  361. <delete id="deleteFwhDatastatTotal">
  362. delete from content_platform_fwh_datastat_total where date_str = #{dt}
  363. </delete>
  364. <delete id="deleteGzhVideoDatastat">
  365. delete from content_platform_gzh_video_datastat where date_str = #{dt}
  366. </delete>
  367. <delete id="deleteGzhPushDatastat">
  368. delete from content_platform_gzh_push_datastat where date_str = #{dt}
  369. </delete>
  370. <delete id="deleteGzhPushDatastatTotal">
  371. delete from content_platform_gzh_push_datastat_total where date_str = #{dt}
  372. </delete>
  373. </mapper>