123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.juxiao.xchat.module.xbd.mapper.marketing.DailyReportChannelMapper">
- <resultMap id="BaseResultMap" type="com.juxiao.xchat.module.xbd.domain.marketing.DailyReportChannel" >
- <id column="report_id" property="reportId" jdbcType="INTEGER"/>
- <result column="reportDate" property="reportDate" jdbcType="TIMESTAMP"/>
- <result column="str1" property="str1" jdbcType="VARCHAR"/>
- <result column="str2" property="str2" jdbcType="VARCHAR"/>
- <result column="str3" property="str3" jdbcType="VARCHAR"/>
- <result column="str4" property="str4" jdbcType="VARCHAR"/>
- <result column="str5" property="str5" jdbcType="VARCHAR"/>
- <result column="str6" property="str6" jdbcType="VARCHAR"/>
- <result column="str7" property="str7" jdbcType="VARCHAR"/>
- <result column="str8" property="str8" jdbcType="VARCHAR"/>
- <result column="str9" property="str9" jdbcType="VARCHAR"/>
- <result column="str10" property="str10" jdbcType="VARCHAR"/>
- <result column="str11" property="str11" jdbcType="VARCHAR"/>
- <result column="str12" property="str12" jdbcType="VARCHAR"/>
- <result column="str13" property="str13" jdbcType="VARCHAR"/>
- <result column="str14" property="str14" jdbcType="VARCHAR"/>
- <result column="str15" property="str15" jdbcType="VARCHAR"/>
- <result column="str16" property="str16" jdbcType="VARCHAR"/>
- <result column="str17" property="str17" jdbcType="VARCHAR"/>
- <result column="str18" property="str18" jdbcType="VARCHAR"/>
- <result column="str19" property="str19" jdbcType="VARCHAR"/>
- <result column="str20" property="str20" jdbcType="VARCHAR"/>
- <result column="str21" property="str21" jdbcType="VARCHAR"/>
- <result column="str22" property="str22" jdbcType="VARCHAR"/>
- <result column="str23" property="str23" jdbcType="VARCHAR"/>
- <result column="str24" property="str24" jdbcType="VARCHAR"/>
- <result column="str25" property="str25" jdbcType="VARCHAR"/>
- <result column="str26" property="str26" jdbcType="VARCHAR"/>
- <result column="str27" property="str27" jdbcType="VARCHAR"/>
- <result column="str28" property="str28" jdbcType="VARCHAR"/>
- <result column="str29" property="str29" jdbcType="VARCHAR"/>
- <result column="str30" property="str30" jdbcType="VARCHAR"/>
- </resultMap>
- <select id="selectDailyReportChannelByList" resultMap="BaseResultMap">
- SELECT if(#{statistical} = 1, drc.report_date, null) as reportDate, if(#{statistical} = 2, drc.str1, ifnull(#{channel}, '全部')) as str1, sum(drc.str2) as str2, sum(drc.str3) as str3, sum(drc.str5) as str5, sum(drc.str6) as str6, sum(drc.str7) as str7, sum(drc.str8) as str8,
- 0 as str9, 0 as str10, 0 as str11, 0 as str12, 0 as str13, 0 as str14, 0 as str15, 0 as str16, 0 as str17, 0 as str18, 0 as str19, 0 as str20, 0 as str21,
- sum(drc.str5) - sum(drc.str3) as str22,
- CONCAT(if(sum(drc.str2) = 0, 0, ROUND(sum(drc.str3)*100/sum(drc.str2), 2)),'%') as str23,
- CONCAT(if(sum(drc.str3) = 0, 0, ROUND(sum(drc.str4)*100/sum(drc.str3), 2)),'%') as str24,
- CONCAT(if(sum(drc.str3) = 0, 0, ROUND(sum(drc.str6)*100/sum(drc.str3), 2)),'%') as str27,
- '0.00%' as str25, '0.00%' as str26, 0 as str28, 0 as str29, 0 as str30
- from daily_report_channel drc
- where 1=1
- <if test="channel != null and channel != ''">
- AND drc.str1 in (SELECT hc.channel from home_channel hc where hc.channel = #{channel} UNION ALL SELECT hc.channel from home_channel hc where hc.superior_channel = #{channel})
- </if>
- <if test="app != null and app != ''">
- AND drc.str9 = #{app}
- </if>
- <choose>
- <when test="statistical == 1">
- <if test="beginTime != null and beginTime != ''">
- AND drc.report_date >= #{beginTime}
- </if>
- <if test="endTime != null and endTime != ''">
- AND drc.report_date <= #{endTime}
- </if>
- GROUP BY drc.report_date
- ORDER BY drc.report_date desc, drc.str1
- </when>
- <when test="statistical==2">
- <if test="beginTime != null and beginTime != ''">
- AND drc.report_date = #{beginTime}
- </if>
- GROUP BY drc.str1
- ORDER BY drc.str1, drc.report_date desc
- </when>
- </choose>
- </select>
- <select id="selectDailyReportChannelRetain" resultMap="BaseResultMap">
- SELECT
- CONCAT(ROUND(sum(if(a.idiff = 1, 1, 0))*100/COUNT(DISTINCT a.deviceId), 2),'%') as str1,
- CONCAT(ROUND(sum(if(a.idiff = 7, 1, 0))*100/COUNT(DISTINCT a.deviceId), 2),'%') as str2,
- CONCAT(ROUND(sum(if(a.idiff = 30, 1, 0))*100/COUNT(DISTINCT a.deviceId), 2),'%') as str3,
- sum(if(a.idiff = 1, 1, 0)) as str4
- FROM
- (SELECT
- u.device_id as deviceId, DATEDIFF(alr.create_time, #{startDate}) as idiff
- from users u
- INNER JOIN home_channel hc on u.channel = hc.channel
- LEFT JOIN account_login_record alr on alr.uid = u.uid
- where
- u.def_user = 1 and u.create_time BETWEEN #{startDate} and #{endDate}
- and alr.create_time BETWEEN #{startDate} and date_add(#{endDate}, interval 30 day)
- <if test="channel != null and channel != ''">
- AND (hc.channel = #{channel} or hc.superior_channel = #{channel})
- </if>
- <if test="app != null and app != ''">
- <if test="app == 'tmxq_an'">
- AND ifnull(u.app, '') = 'tmxq_an'
- </if>
- <if test="app != 'tmxq_an'">
- AND ifnull(u.app, '') != 'tmxq_an'
- </if>
- </if>
- GROUP BY u.device_id, idiff
- ) a
- </select>
- <select id="selectDailyReportChannelCharge" resultMap="BaseResultMap">
- SELECT
- ROUND(sum(if(a.cdiff < 8, a.amount/100, 0)), 0) as str1,
- ROUND(sum(if(a.cdiff < 16, a.amount/100, 0)), 0) as str2,
- ROUND(sum(a.amount/100), 0) as str3
- FROM
- (SELECT
- DATEDIFF(cr.create_time, #{startDate}) as cdiff,
- cr.amount
- from users u
- INNER JOIN home_channel hc on u.channel = hc.channel
- LEFT JOIN charge_record cr on u.uid = cr.uid and cr.charge_status = 2 and cr.create_time BETWEEN #{startDate} and DATE_ADD(#{endDate}, INTERVAL 30 DAY)
- where
- u.def_user = 1 and u.create_time BETWEEN #{startDate} and #{endDate}
- <if test="channel != null and channel != ''">
- AND (hc.channel = #{channel} or hc.superior_channel = #{channel})
- </if>
- <if test="app != null and app != ''">
- <if test="app == 'tmxq_an'">
- AND ifnull(u.app, '') = 'tmxq_an'
- </if>
- <if test="app != 'tmxq_an'">
- AND ifnull(u.app, '') != 'tmxq_an'
- </if>
- </if>
- ) a
- </select>
- <resultMap id="BaseDailyReportChannelPutInResultMap" type="com.juxiao.xchat.module.xbd.domain.marketing.DailyReportChannelPutIn" >
- <id column="put_in_date" property="putInDate" jdbcType="TIMESTAMP" />
- <id column="channel" property="channel" jdbcType="VARCHAR" />
- <id column="app" property="app" jdbcType="VARCHAR" />
- <result column="amount_invested" property="amountInvested" jdbcType="INTEGER" />
- <result column="total_download" property="totalDownload" jdbcType="INTEGER" />
- <result column="purchase_download" property="purchaseDownload" jdbcType="INTEGER" />
- </resultMap>
- <select id="selectDailyReportChannelPutIn" resultMap="BaseDailyReportChannelPutInResultMap">
- SELECT
- SUM(drcpi.amount_invested) as amountInvested, SUM(drcpi.total_download) as totalDownload, SUM(drcpi.purchase_download) as purchaseDownload
- FROM
- daily_report_channel_put_in drcpi
- INNER JOIN home_channel hc on drcpi.channel = hc.channel
- WHERE
- 1 = 1
- <if test="putInDate != null">
- AND drcpi.put_in_date = #{putInDate}
- </if>
- <if test="channel != null and channel != ''">
- AND (hc.channel = #{channel} or hc.superior_channel = #{channel})
- </if>
- <if test="app != null and app != ''">
- and drcpi.app = #{app}
- </if>
- </select>
- </mapper>
|