PromoteAgentStatDayMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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.zanxiang.game.data.serve.dao.mapper.PromoteAgentStatDayMapper">
  4. <select id="getDayDate" resultType="com.zanxiang.game.data.serve.pojo.vo.GamePromoteVO">
  5. select
  6. concat(toString(stat_day),toString(agent_id)) as id,
  7. agent_id as agentId,
  8. promote_account_name as accountName,
  9. promote_account_id as accountId,
  10. put_agent as putAgent,
  11. promote_status as promoteStatus,
  12. sys_user_name as sysUserName,
  13. cp_id as cpId,
  14. cp_name as cpName,
  15. game_id as gameId,
  16. game_name as gameName,
  17. game_type as gameType,
  18. stat_day as costDay,
  19. sys_user_id as sysUserId,
  20. cost_today as cost,
  21. ad_count_today as adCount,
  22. ad_plan_count_today as adPlanCount,
  23. cost_back_today as costBack,
  24. cost_real_today as costReal,
  25. view_count_today as viewCount,
  26. click_count_today as clickCount,
  27. convert_count_today as convertCount,
  28. if(clickCount == 0,0,floor(convertCount/clickCount, 4)) as convertRate,
  29. if(convertCount == 0,0,floor(toFloat64(costReal)/convertCount, 4)) as avgConvertCost,
  30. deep_convert_count_today as deepConvertCount,
  31. if(deepConvertCount == 0,0,floor(toFloat64(costReal)/deepConvertCount, 4)) as deepConvertCost,
  32. if(convertCount == 0,0,floor(deepConvertCount/convertCount, 4)) as deepConvertRate,
  33. if(viewCount == 0,0,floor(toFloat64(costReal)/viewCount, 4)*1000) as thousandViewCost,
  34. if(viewCount == 0,0,floor(clickCount/viewCount, 4)) as clickRate,
  35. if(clickCount == 0,0,floor(toFloat64(costReal)/clickCount, 4)) as avgClickCost,
  36. app_download_count_today as appDownloadCount,
  37. if(appDownloadCount == 0,0,floor(toFloat64(costReal)/appDownloadCount, 4)) as appDownloadCost,
  38. if(clickCount == 0,0,floor(appDownloadCount/clickCount, 4)) as appDownloadRate,
  39. download_finish_today as downloadFinish,
  40. app_install_count_today as appInstallCount,
  41. if(appInstallCount == 0,0,floor(toFloat64(costReal)/appInstallCount, 4)) as appInstallCost,
  42. if(downloadFinish == 0,0,floor(appInstallCount/downloadFinish, 4)) as appInstallRate,
  43. if(downloadFinish == 0,0,floor(toFloat64(costReal)/downloadFinish, 4)) as downloadFinishCost,
  44. if(appDownloadCount == 0,0,floor(downloadFinish/appDownloadCount, 4)) as downloadFinishRate,
  45. app_active_count_today as appActiveCount,
  46. if(appActiveCount == 0,0,floor(toFloat64(costReal)/appActiveCount, 4)) as appActiveCost,
  47. if(clickCount == 0,0,floor(appActiveCount/clickCount, 4)) as appActiveRate,
  48. reg_user_count_today as regUserCount,
  49. active_user_count_today as activeUserCount,
  50. user_count_of_create_role_today as userCountOfCreateRole,
  51. first_user_count_of_first_create_role_today as firstUserCountOfFirstCreateRole,
  52. create_role_count_today as createRoleCount,
  53. first_create_role_count_today as firstCreateRoleCount,
  54. role_count_of_first_user_today as roleCountOfFirstUser,
  55. if(regUserCount == 0,0,floor(toFloat64(costReal)/regUserCount, 4)) as regCost,
  56. if(firstCreateRoleCount == 0,0,floor(toFloat64(costReal)/firstCreateRoleCount, 4)) as firstCreateRoleCost,
  57. if(roleCountOfFirstUser == 0,0,floor(toFloat64(costReal)/roleCountOfFirstUser, 4)) as firstUserCreateRoleCost,
  58. if(regUserCount == 0,0,floor(roleCountOfFirstUser/regUserCount, 4)) as firstCreateRoleRate,
  59. <!-- todayActiveUserLTV,-->
  60. <!-- todayAdCashROI,-->
  61. first_user_recharge_count_today as firstUserRechargeCount,
  62. first_user_recharge_user_today as firstUserRechargeUser,
  63. first_user_recharge_money_today as firstUserRechargeMoney,
  64. old_user_recharge_count_today as oldUserRechargeCount,
  65. old_user_recharge_user_today as oldUserRechargeUser,
  66. old_user_recharge_money_today as oldUserRechargeMoney,
  67. show_recharge_count_today as showRechargeCount,
  68. show_recharge_user_today as showRechargeUser,
  69. show_recharge_money_today as showRechargeMoney,
  70. new_user_recharge_count_today as newUserRechargeCount,
  71. new_user_recharge_user_today as newUserRechargeUser,
  72. new_user_recharge_money_today as newUserRechargeMoney,
  73. if(costReal == 0,0,floor(toFloat64(firstUserRechargeMoney)/toFloat64(costReal), 4)) as firstRecoveryRate,
  74. if(costReal == 0,0,floor(toFloat64(newUserRechargeMoney)/toFloat64(costReal), 4)) as buyRecoveryRate,
  75. newUserRechargeMoney-costReal as grossMargin,
  76. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day3)/toFloat64(costReal), 4)) as threeDayROI,
  77. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day5)/toFloat64(costReal), 4)) as fiveDayROI,
  78. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day7)/toFloat64(costReal), 4)) as sevenDayROI,
  79. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day15)/toFloat64(costReal), 4)) as fifteenDayROI,
  80. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day30)/toFloat64(costReal), 4)) as thirtyDayROI,
  81. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day60)/toFloat64(costReal), 4)) as sixtyDayROI,
  82. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day180)/toFloat64(costReal), 4)) as oneHundredAndEightyDayROI,
  83. if(costReal == 0,0,floor(toFloat64(new_user_recharge_money_day365)/toFloat64(costReal), 4)) as oneYearROI,
  84. if(regUserCount == 0,0,floor(firstUserRechargeUser/regUserCount, 4)) as firstRechargeRate,
  85. if(regUserCount == 0,0,floor(newUserRechargeUser/regUserCount, 4)) as buyUserRechargeRate,
  86. if(showRechargeUser == 0,0,floor(firstUserRechargeUser/showRechargeUser, 4)) as newUserRechargeRate,
  87. if(activeUserCount == 0,0,floor(firstUserRechargeUser/activeUserCount, 4)) as activeUserRechargeRate,
  88. if(firstUserRechargeCount == 0,0,floor(toFloat64(firstUserRechargeMoney)/firstUserRechargeCount, 4)) as avgFirstUserRecharge,
  89. if(newUserRechargeCount == 0,0,floor(toFloat64(newUserRechargeMoney)/newUserRechargeCount, 4)) as avgBuyUserRecharge,
  90. if(showRechargeCount == 0,0,floor(toFloat64(showRechargeMoney)/showRechargeCount, 4)) as avgShowUserRecharge,
  91. if(firstUserRechargeUser == 0,0,floor(toFloat64(costReal)/firstUserRechargeUser, 4)) as firstRechargeCost,
  92. if(newUserRechargeUser == 0,0,floor(toFloat64(costReal)/newUserRechargeUser, 4)) as buyUserRechargeCost,
  93. if(newUserRechargeUser == 0,0,floor(first_user_repeat_recharge_count/newUserRechargeUser, 4)) as repeatRechargeRate,
  94. if(active_user_count == 0,0,floor(recharge_user_count/active_user_count, 4)) as avgActiveRechargeRate,
  95. if(regUserCount == 0,0,floor(toFloat64(newUserRechargeMoney)/regUserCount, 4)) as newRegARPU,
  96. if(activeUserCount == 0,0,floor(toFloat64(firstUserRechargeMoney)/activeUserCount, 4)) as activeARPU,
  97. if(firstUserRechargeUser == 0,0,floor(toFloat64(firstUserRechargeMoney)/firstUserRechargeUser, 4)) as firstRechargeARPU,
  98. if(newUserRechargeUser == 0,0,floor(toFloat64(newUserRechargeMoney)/newUserRechargeUser, 4)) as todayRechargeARPU,
  99. if(showRechargeUser == 0,0,floor(toFloat64(showRechargeMoney)/showRechargeUser, 4)) as showRechargeARPU,
  100. new_user_recharge_money_dc_day1 as newUserRechargeMoneyDcDay1,
  101. new_user_recharge_money_dc_day2 as newUserRechargeMoneyDcDay2,
  102. new_user_recharge_money_dc_day3 as newUserRechargeMoneyDcDay3,
  103. new_user_recharge_money_dc_day4 as newUserRechargeMoneyDcDay4,
  104. new_user_recharge_money_dc_day5 as newUserRechargeMoneyDcDay5,
  105. new_user_recharge_money_dc_day6 as newUserRechargeMoneyDcDay6,
  106. new_user_recharge_money_dc_day7 as newUserRechargeMoneyDcDay7,
  107. new_user_recharge_money_dc_day14 as newUserRechargeMoneyDcDay14,
  108. new_user_recharge_money_dc_day15 as newUserRechargeMoneyDcDay15,
  109. new_user_recharge_money_dc_day29 as newUserRechargeMoneyDcDay29,
  110. new_user_recharge_money_dc_day30 as newUserRechargeMoneyDcDay30,
  111. new_user_recharge_money_dc_day59 as newUserRechargeMoneyDcDay59,
  112. new_user_recharge_money_dc_day60 as newUserRechargeMoneyDcDay60,
  113. new_user_recharge_money_dc_day89 as newUserRechargeMoneyDcDay89,
  114. new_user_recharge_money_dc_day90 as newUserRechargeMoneyDcDay90,
  115. new_user_recharge_user_dc_day1 as newUserRechargeUserDcDay1,
  116. new_user_recharge_user_dc_day2 as newUserRechargeUserDcDay2,
  117. new_user_recharge_user_dc_day3 as newUserRechargeUserDcDay3,
  118. new_user_recharge_user_dc_day4 as newUserRechargeUserDcDay4,
  119. new_user_recharge_user_dc_day5 as newUserRechargeUserDcDay5,
  120. new_user_recharge_user_dc_day6 as newUserRechargeUserDcDay6,
  121. new_user_recharge_user_dc_day7 as newUserRechargeUserDcDay7,
  122. new_user_recharge_user_dc_day14 as newUserRechargeUserDcDay14,
  123. new_user_recharge_user_dc_day15 as newUserRechargeUserDcDay15,
  124. new_user_recharge_user_dc_day29 as newUserRechargeUserDcDay29,
  125. new_user_recharge_user_dc_day30 as newUserRechargeUserDcDay30,
  126. new_user_recharge_user_dc_day59 as newUserRechargeUserDcDay59,
  127. new_user_recharge_user_dc_day60 as newUserRechargeUserDcDay60,
  128. new_user_recharge_user_dc_day89 as newUserRechargeUserDcDay89,
  129. new_user_recharge_user_dc_day90 as newUserRechargeUserDcDay90,
  130. new_user_recharge_money_day3 as newUserRechargeMoneyDay3,
  131. new_user_recharge_money_day5 as newUserRechargeMoneyDay5,
  132. new_user_recharge_money_day7 as newUserRechargeMoneyDay7,
  133. new_user_recharge_money_day15 as newUserRechargeMoneyDay15,
  134. new_user_recharge_money_day30 as newUserRechargeMoneyDay30,
  135. new_user_recharge_money_day60 as newUserRechargeMoneyDay60,
  136. new_user_recharge_money_day90 as newUserRechargeMoneyDay90,
  137. cost as totalCost
  138. <!-- oneDayLTV-->
  139. <!-- oneDayRetentionRate-->
  140. from t_promote_agent_stat_day
  141. <where>
  142. <if test="dto.sysUserId != null and dto.sysUserId != ''">
  143. and sys_user_id = #{dto.sysUserId}
  144. </if>
  145. <if test="dto.accountName != null and dto.accountName != ''">
  146. and promote_account_name = #{dto.accountName}
  147. </if>
  148. <if test="dto.accountId != null and dto.accountId != ''">
  149. and promote_account_id = #{dto.accountId}
  150. </if>
  151. <if test="dto.putAgent != null and dto.putAgent != ''">
  152. and put_agent = #{dto.putAgent}
  153. </if>
  154. <if test="dto.promoteStatus != null and dto.promoteStatus != ''">
  155. and promote_status = #{dto.promoteStatus}
  156. </if>
  157. <if test="dto.sysUserName != null and dto.sysUserName != ''">
  158. and sys_user_name = #{dto.sysUserName}
  159. </if>
  160. <if test="dto.cpId != null and dto.cpId != ''">
  161. and cp_id = #{dto.cpId}
  162. </if>
  163. <if test="dto.cpName != null and dto.cpName != ''">
  164. and cp_name = #{dto.cpName}
  165. </if>
  166. <if test="dto.gameId != null and dto.gameId != ''">
  167. and game_id = #{dto.gameId}
  168. </if>
  169. <if test="dto.gameName != null and dto.gameName != ''">
  170. and game_name = #{dto.gameName}
  171. </if>
  172. <if test="dto.gameType != null and dto.gameType != ''">
  173. and game_type = #{dto.gameType}
  174. </if>
  175. <if test="dto.beginDay != null and dto.beginDay != ''">
  176. and stat_day &gt;= #{dto.beginDay}
  177. </if>
  178. <if test="dto.endDay != null and dto.endDay != ''">
  179. and stat_day &lt;= #{dto.endDay}
  180. </if>
  181. </where>
  182. order by stat_day
  183. </select>
  184. </mapper>