FsAdvSemMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.bdAdv.mapper.FsAdvSemMapper">
  6. <resultMap type="FsAdvSem" id="FsAdvSemResult">
  7. <result property="id" column="id" />
  8. <result property="imei" column="imei" />
  9. <result property="idfa" column="idfa" />
  10. <result property="oaid" column="oaid" />
  11. <result property="androidId" column="android_id" />
  12. <result property="akey" column="akey" />
  13. <result property="aType" column="a_type" />
  14. <result property="aValue" column="a_value" />
  15. <result property="joinType" column="join_type" />
  16. <result property="ip" column="ip" />
  17. <result property="ua" column="ua" />
  18. <result property="osVersion" column="os_version" />
  19. <result property="model" column="model" />
  20. <result property="osType" column="os_type" />
  21. <result property="deviceId" column="device_id" />
  22. <result property="aid" column="aid" />
  23. <result property="pid" column="pid" />
  24. <result property="uid" column="uid" />
  25. <result property="clickId" column="click_id" />
  26. <result property="callbackUrl" column="callback_url" />
  27. <result property="advType" column="adv_type" />
  28. <result property="cmdType" column="cmd_type" />
  29. <result property="createTime" column="create_time" />
  30. <result property="updateTime" column="update_time" />
  31. <result property="userId" column="user_id" />
  32. </resultMap>
  33. <sql id="selectFsAdvSemVo">
  34. select id, imei, idfa, oaid,user_id, android_id, akey, a_type, a_value, join_type, ip, ua, os_version, model, os_type, device_id, aid, pid, uid, click_id, callback_url, adv_type,cmd_type, create_time, update_time from fs_adv_sem
  35. </sql>
  36. <select id="selectFsAdvSemList" parameterType="FsAdvSem" resultMap="FsAdvSemResult">
  37. <include refid="selectFsAdvSemVo"/>
  38. <where>
  39. <if test="imei != null and imei != ''"> and imei = #{imei}</if>
  40. <if test="idfa != null and idfa != ''"> and idfa = #{idfa}</if>
  41. <if test="oaid != null and oaid != ''"> and oaid = #{oaid}</if>
  42. <if test="androidId != null and androidId != ''"> and android_id = #{androidId}</if>
  43. <if test="akey != null and akey != ''"> and akey = #{akey}</if>
  44. <if test="aType != null and aType != ''"> and a_type = #{aType}</if>
  45. <if test="aValue != null and aValue != ''"> and a_value = #{aValue}</if>
  46. <if test="joinType != null and joinType != ''"> and join_type = #{joinType}</if>
  47. <if test="ip != null and ip != ''"> and ip = #{ip}</if>
  48. <if test="ua != null and ua != ''"> and ua = #{ua}</if>
  49. <if test="osVersion != null and osVersion != ''"> and os_version = #{osVersion}</if>
  50. <if test="model != null and model != ''"> and model = #{model}</if>
  51. <if test="osType != null "> and os_type = #{osType}</if>
  52. <if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
  53. <if test="aid != null and aid != ''"> and aid = #{aid}</if>
  54. <if test="pid != null and pid != ''"> and pid = #{pid}</if>
  55. <if test="uid != null and uid != ''"> and uid = #{uid}</if>
  56. <if test="clickId != null and clickId != ''"> and click_id = #{clickId}</if>
  57. <if test="callbackUrl != null and callbackUrl != ''"> and callback_url = #{callbackUrl}</if>
  58. <if test="advType != null "> and adv_type = #{advType}</if>
  59. </where>
  60. </select>
  61. <select id="selectFsAdvSemById" parameterType="Long" resultMap="FsAdvSemResult">
  62. <include refid="selectFsAdvSemVo"/>
  63. where id = #{id}
  64. </select>
  65. <select id="selectFsAdvSemStatisticsByDayVo" parameterType="com.fs.bdAdv.param.FsAdvSemStatisticsByDayParam" resultType="com.fs.bdAdv.vo.FsAdvSemStatisticsByDayVo">
  66. SELECT * FROM (
  67. SELECT
  68. DATE(create_time) AS date,
  69. adv_type,
  70. COUNT(CASE WHEN cmd_type = 0 THEN 1 END) AS activation_count,
  71. COUNT(CASE WHEN cmd_type = 1 THEN 1 END) AS registration_count,
  72. COUNT(CASE WHEN cmd_type = 4 THEN 1 END) AS jump_count,
  73. COUNT(CASE WHEN cmd_type = 5 THEN 1 END) AS binding_count,
  74. COUNT(*) AS total_count,
  75. ROUND(COUNT(CASE WHEN cmd_type = 0 THEN 1 END) / COUNT(*) * 100, 2) AS activation_rate,
  76. ROUND(COUNT(CASE WHEN cmd_type = 1 THEN 1 END) / COUNT(*) * 100, 2) AS registration_rate,
  77. ROUND(COUNT(CASE WHEN cmd_type = 4 THEN 1 END) / COUNT(*) * 100, 2) AS jump_rate,
  78. ROUND(COUNT(CASE WHEN cmd_type = 5 THEN 1 END) / COUNT(*) * 100, 2) AS binding_rate
  79. FROM
  80. fs_adv_sem
  81. WHERE
  82. create_time IS NOT NULL
  83. <if test="advType != null">
  84. and adv_type = #{advType}
  85. </if>
  86. GROUP BY
  87. DATE(create_time) ,adv_type
  88. ORDER BY
  89. DATE(create_time)) a
  90. <where>
  91. <if test="totalCountMax != null">
  92. a.total_count &lt;= #{totalCountMax}
  93. </if>
  94. <if test="totalCountMin != null">
  95. a.total_count &gt;= #{totalCountMin}
  96. </if>
  97. <if test="activationCountMax != null">
  98. a.activation_count &lt;= #{activationCountMax}
  99. </if>
  100. <if test="activationCountMin != null">
  101. a.activation_count &gt;= #{activationCountMin}
  102. </if>
  103. <if test="registrationCountMax != null">
  104. a.registration_count &lt;= #{registrationCountMax}
  105. </if>
  106. <if test="registrationCountMin != null">
  107. a.registration_count &gt;= #{registrationCountMin}
  108. </if>
  109. <if test="jumpCountMax != null">
  110. a.jump_count &lt;= #{jumpCountMax}
  111. </if>
  112. <if test="jumpCountMin != null">
  113. a.jump_count &gt;= #{jumpCountMin}
  114. </if>
  115. <if test="bindingCountMax != null">
  116. a.binding_count &lt;= #{bindingCountMax}
  117. </if>
  118. <if test="bindingCountMin != null">
  119. a.binding_count &gt;= #{bindingCountMin}
  120. </if>
  121. <if test="activationRateMax != null">
  122. a.activation_rate &lt;= #{activationRateMax}
  123. </if>
  124. <if test="activationRateMin != null">
  125. a.activation_rate &gt;= #{activationRateMin}
  126. </if>
  127. <if test="registrationRateMax != null">
  128. a.registration_rate &lt;= #{registrationRateMax}
  129. </if>
  130. <if test="registrationRateMin != null">
  131. a.registration_rate &gt;= #{registrationRateMin}
  132. </if>
  133. <if test="jumpRateMax != null">
  134. a.jump_rate &lt;= #{jumpRateMax}
  135. </if>
  136. <if test="jumpRateMin != null">
  137. a.jump_rate &gt;= #{jumpRateMin}
  138. </if>
  139. <if test="bindingRateMax != null">
  140. a.binding_rate &lt;= #{bindingRateMax}
  141. </if>
  142. <if test="bindingRateMin != null">
  143. a.binding_rate &gt;= #{bindingRateMin}
  144. </if>
  145. <if test="dateMax != null and dateMax != ''">
  146. and date_format(a.date,'%y%m%d') &lt;= date_format(#{dateMax},'%y%m%d')
  147. </if>
  148. <if test="dateMin != null and dateMin != ''">
  149. and date_format(a.date,'%y%m%d') &gt;= date_format(#{dateMin},'%y%m%d')
  150. </if>
  151. </where>
  152. ${params.dataScope}
  153. </select>
  154. <insert id="insertFsAdvSem" parameterType="FsAdvSem" useGeneratedKeys="true" keyProperty="id">
  155. insert into fs_adv_sem
  156. <trim prefix="(" suffix=")" suffixOverrides=",">
  157. <if test="imei != null">imei,</if>
  158. <if test="idfa != null">idfa,</if>
  159. <if test="oaid != null">oaid,</if>
  160. <if test="androidId != null">android_id,</if>
  161. <if test="akey != null">akey,</if>
  162. <if test="aType != null">a_type,</if>
  163. <if test="aValue != null">a_value,</if>
  164. <if test="joinType != null">join_type,</if>
  165. <if test="ip != null">ip,</if>
  166. <if test="ua != null">ua,</if>
  167. <if test="osVersion != null">os_version,</if>
  168. <if test="model != null">model,</if>
  169. <if test="osType != null">os_type,</if>
  170. <if test="deviceId != null">device_id,</if>
  171. <if test="aid != null">aid,</if>
  172. <if test="pid != null">pid,</if>
  173. <if test="uid != null">uid,</if>
  174. <if test="clickId != null">click_id,</if>
  175. <if test="callbackUrl != null">callback_url,</if>
  176. <if test="advType != null">adv_type,</if>
  177. <if test="cmdType != null">cmd_type,</if>
  178. <if test="createTime != null">create_time,</if>
  179. <if test="updateTime != null">update_time,</if>
  180. <if test="userId != null">user_id,</if>
  181. </trim>
  182. <trim prefix="values (" suffix=")" suffixOverrides=",">
  183. <if test="imei != null">#{imei},</if>
  184. <if test="idfa != null">#{idfa},</if>
  185. <if test="oaid != null">#{oaid},</if>
  186. <if test="androidId != null">#{androidId},</if>
  187. <if test="akey != null">#{akey},</if>
  188. <if test="aType != null">#{aType},</if>
  189. <if test="aValue != null">#{aValue},</if>
  190. <if test="joinType != null">#{joinType},</if>
  191. <if test="ip != null">#{ip},</if>
  192. <if test="ua != null">#{ua},</if>
  193. <if test="osVersion != null">#{osVersion},</if>
  194. <if test="model != null">#{model},</if>
  195. <if test="osType != null">#{osType},</if>
  196. <if test="deviceId != null">#{deviceId},</if>
  197. <if test="aid != null">#{aid},</if>
  198. <if test="pid != null">#{pid},</if>
  199. <if test="uid != null">#{uid},</if>
  200. <if test="clickId != null">#{clickId},</if>
  201. <if test="callbackUrl != null">#{callbackUrl},</if>
  202. <if test="advType != null">#{advType},</if>
  203. <if test="cmdType != null">#{cmdType},</if>
  204. <if test="createTime != null">#{createTime},</if>
  205. <if test="updateTime != null">#{updateTime},</if>
  206. <if test="userId != null">#{userId},</if>
  207. </trim>
  208. </insert>
  209. <update id="updateFsAdvSem" parameterType="FsAdvSem">
  210. update fs_adv_sem
  211. <trim prefix="SET" suffixOverrides=",">
  212. <if test="imei != null">imei = #{imei},</if>
  213. <if test="idfa != null">idfa = #{idfa},</if>
  214. <if test="oaid != null">oaid = #{oaid},</if>
  215. <if test="androidId != null">android_id = #{androidId},</if>
  216. <if test="akey != null">akey = #{akey},</if>
  217. <if test="aType != null">a_type = #{aType},</if>
  218. <if test="aValue != null">a_value = #{aValue},</if>
  219. <if test="joinType != null">join_type = #{joinType},</if>
  220. <if test="ip != null">ip = #{ip},</if>
  221. <if test="ua != null">ua = #{ua},</if>
  222. <if test="osVersion != null">os_version = #{osVersion},</if>
  223. <if test="model != null">model = #{model},</if>
  224. <if test="osType != null">os_type = #{osType},</if>
  225. <if test="deviceId != null">device_id = #{deviceId},</if>
  226. <if test="aid != null">aid = #{aid},</if>
  227. <if test="pid != null">pid = #{pid},</if>
  228. <if test="uid != null">uid = #{uid},</if>
  229. <if test="clickId != null">click_id = #{clickId},</if>
  230. <if test="callbackUrl != null">callback_url = #{callbackUrl},</if>
  231. <if test="advType != null">adv_type = #{advType},</if>
  232. <if test="cmdType != null">cmd_type = #{cmdType},</if>
  233. <if test="createTime != null">create_time = #{createTime},</if>
  234. <if test="updateTime != null">update_time = #{updateTime},</if>
  235. <if test="userId != null">user_id = #{userId},</if>
  236. </trim>
  237. where id = #{id}
  238. </update>
  239. <delete id="deleteFsAdvSemById" parameterType="Long">
  240. delete from fs_adv_sem where id = #{id}
  241. </delete>
  242. <delete id="deleteFsAdvSemByIds" parameterType="String">
  243. delete from fs_adv_sem where id in
  244. <foreach item="id" collection="array" open="(" separator="," close=")">
  245. #{id}
  246. </foreach>
  247. </delete>
  248. </mapper>