|
|
@@ -1,693 +0,0 @@
|
|
|
-<?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="advertiser.adReportSqlMapper">
|
|
|
-
|
|
|
- <sql id="base_column">
|
|
|
- id,
|
|
|
- advertiser_id as advertiserId,
|
|
|
- order_id as orderId,
|
|
|
- campaign_id as campaignId,
|
|
|
- adgroup_id as adGroupId,
|
|
|
- banner.id as bannerId,
|
|
|
- t_banner.banner_template_id as bannerTemplateId,
|
|
|
- t_advertiser.name as advertiserName,
|
|
|
- t_order.name as orderName,
|
|
|
- t_campaign.name as campaignName,
|
|
|
- t_adgroup.name as adGroupName,
|
|
|
- t_banner_template.name as bannerName,
|
|
|
- date as reportDate,
|
|
|
- request,
|
|
|
- impression,
|
|
|
- impressionRate,
|
|
|
- click,
|
|
|
- visit,
|
|
|
- conversion,
|
|
|
- conversionRate,
|
|
|
- clickRate,
|
|
|
- visitRate,
|
|
|
- conversionRate,
|
|
|
- ecmp as eCmp,
|
|
|
- consume,
|
|
|
- os,
|
|
|
- location,
|
|
|
- impressionSum,
|
|
|
- clickSum,
|
|
|
- visitSum,
|
|
|
- conversionSum,
|
|
|
- eCmpSum,
|
|
|
- consumeSum,
|
|
|
- clickRatesum,
|
|
|
- visitRatesum,
|
|
|
- conversionRatesum
|
|
|
-
|
|
|
- </sql>
|
|
|
-
|
|
|
- <select id="findCountForDeliverEffectAnalysis" parameterType="map" resultType="int">
|
|
|
- select count(1) from (
|
|
|
- select b.name advertiserName,c.name orderName,d.name campaignName,e.name adgroupName,g.name bannerName,a.date reportDate,sum(a.impression) as impression,sum(a.click) as click,100*sum(a.click)/sum(a.impression) as clickRate,sum(a.visit) as visit,100*sum(a.visit)/sum(a.click) as visitRate,sum(a.conversion) as conversion,100*sum(a.conversion)/sum(a.visit) as conversionRate,sum(a.ecmp) as ecmp,sum(a.consume) as consume
|
|
|
- from t_rpt_advertiser a,t_advertiser b,t_order c,t_campaign d,t_adgroup e,t_banner f,t_banner_template g
|
|
|
- where a.advertiser_id=b.id and a.order_id=c.id and a.campaign_id=d.id and a.adgroup_id=e.id and a.banner_id=f.id and f.banner_template_id=g.id
|
|
|
- <if test="advertiserId != null and advertiserId ">
|
|
|
- and a.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId != null and orderId != ''">
|
|
|
- and a.order_id = #{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaginId != null and campaginId != ''">
|
|
|
- and a.campagin_id = #{campaginId}
|
|
|
- </if>
|
|
|
- <if test="adgroupId != null and adgroupId != ''">
|
|
|
- and a.adgroup_id = #{adgroupId}
|
|
|
- </if>
|
|
|
- <if test="startDate != null and startDate != ''and endDate != nul and endDate != ''">
|
|
|
- and a.date >=#{startDate} and a.date <=#{endDate}
|
|
|
- </if>
|
|
|
- <choose>
|
|
|
- <when test="dimensionStr != null and dimensionStr != ''">
|
|
|
- GROUP BY ${dimensionStr}
|
|
|
- </when>
|
|
|
- <otherwise>
|
|
|
- group by reportDate order by reportDate desc
|
|
|
- </otherwise>
|
|
|
- </choose>
|
|
|
- ) t
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <select id="findCountForLocation" parameterType="map" resultType="int">
|
|
|
- select count(location) from ( select location
|
|
|
- from t_rpt_adv_location a, t_advertiser b
|
|
|
- <where>
|
|
|
- a.advertiser_id = b.id and a.date >= #{startDate} and #{endDate} >=a.date
|
|
|
- <if test="advertiserId ==null">
|
|
|
- and b.agent_id=#{agentId}
|
|
|
- </if>
|
|
|
- <if test="advertiserId != null">
|
|
|
- and a.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId !=null">
|
|
|
- and a.order_id=#{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaignId !=null">
|
|
|
- and a.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and a.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- group by a.location
|
|
|
- ) as c
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findCountForOs" parameterType="map" resultType="int">
|
|
|
- select count(1)
|
|
|
- from t_rpt_adv_os ros, t_advertiser, t_order, t_campaign, t_adgroup
|
|
|
- <where>
|
|
|
- ros.advertiser_id = t_advertiser.id and ros.order_id = t_order.id and ros.campaign_id = t_campaign.id and ros.adgroup_id = t_adgroup.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and ros.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and ros.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and ros.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and ros.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and ros.date >= #{startDate} and #{endDate} >=ros.date
|
|
|
- </if>
|
|
|
-
|
|
|
- </where>
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <select id="findCountForScene" parameterType="map" resultType="int">
|
|
|
- select count(1)
|
|
|
- from t_rpt_adv_place rp, t_advertiser, t_order, t_campaign, t_adgroup , t_place
|
|
|
-
|
|
|
- <where>
|
|
|
- rp.place_id = t_place.id and rp.advertiser_id = t_advertiser.id
|
|
|
- and rp.order_id = t_order.id and rp.campaign_id = t_campaign.id and rp.adgroup_id = t_adgroup.id
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and rp.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and rp.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and rp.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and rp.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and rp.date >= #{startDate} and rp.date <= #{endDate}
|
|
|
- </if>
|
|
|
-
|
|
|
- </where>
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByTotalReport" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select b.name advertiserName,c.name orderName,d.name campaignName,e.name adgroupName,g.name bannerName,a.date reportDate,sum(a.impression) as impression,sum(a.click) as click,100*sum(a.click)/sum(a.impression) as clickRate,sum(a.visit) as visit,100*sum(a.visit)/sum(a.click) as visitRate,sum(a.conversion) conversion,100*sum(a.conversion)/sum(a.visit) as conversionRate,sum(a.ecmp) ecmp,sum(a.consume) as consume
|
|
|
- from t_rpt_advertiser a,t_advertiser b,t_order c,t_campaign d,t_adgroup e,t_banner f,t_banner_template g
|
|
|
- where a.advertiser_id=b.id and a.order_id=c.id and a.campaign_id=d.id and a.adgroup_id=e.id and a.banner_id=f.id and f.banner_template_id=g.id
|
|
|
- <if test="advertiserId != null and advertiserId ">
|
|
|
- and a.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId != null and orderId != ''">
|
|
|
- and a.order_id = #{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaginId != null and campaginId != ''">
|
|
|
- and a.campagin_id = #{campaginId}
|
|
|
- </if>
|
|
|
- <if test="adgroupId != null and adgroupId != ''">
|
|
|
- and a.adgroup_id = #{adgroupId}
|
|
|
- </if>
|
|
|
- <if test="startDate != null and startDate != ''and endDate != nul and endDate != ''">
|
|
|
- and a.date >=#{startDate} and a.date <=#{endDate}
|
|
|
- </if>
|
|
|
- <choose>
|
|
|
- <when test="dimensionStr != null and dimensionStr != ''">
|
|
|
- GROUP BY ${dimensionStr}
|
|
|
- </when>
|
|
|
- <otherwise>
|
|
|
- group by reportDate
|
|
|
- </otherwise>
|
|
|
- </choose>
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByTotalReport2" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select
|
|
|
- t_advertiser.name as advertiserName, t_order.name as orderName, t_campaign.name as campaignName, t_adgroup.name as adGroupName, t_banner_template.name as bannerName,
|
|
|
-
|
|
|
- ad.date as reportDate, ad.hour as hour,
|
|
|
- (select sum(impression) from t_rpt_advertiser_hour) as impressionSum,ad.impression,ad.click,visit,ad.conversion,
|
|
|
- 100*ad.click/ad.impression as clickRate ,100*visit/ad.click as visitRate ,100*ad.conversion/visit as conversionRate ,ecmp as eCmp,ad.consume,
|
|
|
- (select sum(click) from t_rpt_advertiser_hour) as clickSum, (select sum(visit) from t_rpt_advertiser_hour) as visitSum,
|
|
|
- (select sum(conversion) from t_rpt_advertiser_hour) as conversionSum,
|
|
|
- (select sum(ecmp) from t_rpt_advertiser_hour) as eCmpSum, (select sum(consume) from t_rpt_advertiser_hour) as consumeSum,
|
|
|
- 100*(select sum(click) from t_rpt_advertiser_hour)/(select sum(impression) from t_rpt_advertiser_hour) as clickRatesum,
|
|
|
- 100*(select sum(visit) from t_rpt_advertiser_hour)/(select sum(click) from t_rpt_advertiser_hour) as visitRatesum,
|
|
|
- 100*(select sum(conversion) from t_rpt_advertiser_hour)/(select sum(visit) from t_rpt_advertiser_hour) as conversionRatesum
|
|
|
-
|
|
|
- from t_rpt_advertiser_hour ad,t_advertiser,t_order, t_campaign, t_banner, t_adgroup, t_banner_template
|
|
|
-
|
|
|
-
|
|
|
- <where>
|
|
|
- ad.advertiser_id=t_advertiser.id and ad.order_id = t_order.id and ad.campaign_id= t_campaign.id
|
|
|
- and ad.adgroup_id=t_adgroup.id
|
|
|
- and ad.banner_id=t_banner.id
|
|
|
- and t_banner.banner_template_id = t_banner_template.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and ad.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and ad.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and ad.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and ad.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and date >= #{startDate} and #{endDate} >=date
|
|
|
- </if>
|
|
|
-
|
|
|
- </where>
|
|
|
-
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByLocation" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select t_location.cn_city as location, 100 * sum(impression) /(select sum(impression) from t_rpt_adv_location a1,t_advertiser b1
|
|
|
- <where>
|
|
|
- a1.advertiser_id = b1.id and a1.date >= #{startDate} and #{endDate} >=a1.date
|
|
|
- <if test="advertiserId ==null">
|
|
|
- and b1.agent_id=#{agentId}
|
|
|
- </if>
|
|
|
- <if test="advertiserId != null">
|
|
|
- and a1.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId !=null">
|
|
|
- and a1.order_id=#{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaignId !=null">
|
|
|
- and a1.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and a1.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- ) as impressionRate, sum(impression) as impression, sum(click) as click, 100 * sum(click) / sum(impression) as clickRate,
|
|
|
- sum(visit) as visit, 100 * sum(visit) / sum(click) as visitRate, 100 * sum(conversion) / sum(visit) as conversionRate,
|
|
|
- sum(conversion) as conversion, sum(ecmp) as eCmp, sum(consume) as consume from t_rpt_adv_location a, t_advertiser b,t_location
|
|
|
- <where>
|
|
|
- a.advertiser_id = b.id and a.location = t_location.location and a.date >= #{startDate} and #{endDate} >=a.date
|
|
|
- <if test="advertiserId ==null">
|
|
|
- and b.agent_id=#{agentId}
|
|
|
- </if>
|
|
|
- <if test="advertiserId != null">
|
|
|
- and a.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId !=null">
|
|
|
- and a.order_id=#{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaignId !=null">
|
|
|
- and a.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and a.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- group by a.location
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByOs" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select
|
|
|
- t_advertiser.name as advertiserName, t_order.name as orderName, t_campaign.name as campaignName, t_adgroup.name as adGroupName,
|
|
|
-
|
|
|
- ros.date as reportDate,
|
|
|
- ros.impression,ros.click,visit,ros.conversion,os,
|
|
|
- 100*ros.impression/(select sum(t_rpt_adv_os.impression) from t_rpt_adv_os, t_advertiser, t_order, t_campaign, t_adgroup
|
|
|
-
|
|
|
-
|
|
|
- where
|
|
|
-
|
|
|
- t_rpt_adv_os.advertiser_id = t_advertiser.id and t_rpt_adv_os.order_id = t_order.id and t_rpt_adv_os.campaign_id = t_campaign.id and t_rpt_adv_os.adgroup_id = t_adgroup.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and t_rpt_adv_os.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and t_rpt_adv_os.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and t_rpt_adv_os.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and t_rpt_adv_os.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and t_rpt_adv_os.date >= #{startDate} and #{endDate} >=t_rpt_adv_os.date
|
|
|
- </if>
|
|
|
- ) as impressionRate,100*ros.click/ros.impression as clickRate ,
|
|
|
- 100*visit/ros.click as visitRate ,100*ros.conversion/visit as conversionRate,ecmp as eCmp,consume
|
|
|
- from t_rpt_adv_os ros, t_advertiser, t_order, t_campaign, t_adgroup
|
|
|
-
|
|
|
-
|
|
|
- <where>
|
|
|
-
|
|
|
- ros.advertiser_id = t_advertiser.id and ros.order_id = t_order.id and ros.campaign_id = t_campaign.id and ros.adgroup_id = t_adgroup.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and ros.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and ros.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and ros.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and ros.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and ros.date >= #{startDate} and #{endDate} >=ros.date
|
|
|
- </if>
|
|
|
-
|
|
|
- </where>
|
|
|
-
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByPlaceName" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select
|
|
|
- t_place.name as placeName, t_advertiser.name as advertiserName, t_order.name as orderName,
|
|
|
- t_campaign.name as campaignName, t_adgroup.name as adGroupName,
|
|
|
-
|
|
|
- rp.date as reportDate,
|
|
|
- rp.impression,rp.click,visit,rp.conversion,
|
|
|
- 100*rp.impression/(select sum(t_rpt_adv_place.impression) from t_rpt_adv_place , t_advertiser, t_order, t_campaign, t_adgroup , t_place
|
|
|
-
|
|
|
-
|
|
|
- where
|
|
|
- t_rpt_adv_place.place_id = t_place.id and t_rpt_adv_place.advertiser_id = t_advertiser.id
|
|
|
- and t_rpt_adv_place.order_id = t_order.id and t_rpt_adv_place.campaign_id = t_campaign.id and t_rpt_adv_place.adgroup_id = t_adgroup.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and t_rpt_adv_place.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and t_rpt_adv_place.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and t_rpt_adv_place.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and t_rpt_adv_place.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and t_rpt_adv_place.date >= #{startDate} and #{endDate} >=t_rpt_adv_place.date
|
|
|
- </if>) as impressionRate,100*rp.click/rp.impression as clickRate ,
|
|
|
- 100*visit/rp.click as visitRate ,100*rp.conversion/visit as conversionRate,ecmp as eCmp,consume
|
|
|
- from t_rpt_adv_place rp, t_advertiser, t_order, t_campaign, t_adgroup , t_place
|
|
|
-
|
|
|
-
|
|
|
- <where>
|
|
|
- rp.place_id = t_place.id and rp.advertiser_id = t_advertiser.id
|
|
|
- and rp.order_id = t_order.id and rp.campaign_id = t_campaign.id and rp.adgroup_id = t_adgroup.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and rp.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and rp.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and rp.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and rp.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and rp.date >= #{startDate} and #{endDate} >=rp.date
|
|
|
- </if>
|
|
|
-
|
|
|
- </where>
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <!--<select id="findByOrderName" parameterType="map" resultType="DeliverAnalysis">
|
|
|
- select
|
|
|
- t_order.name as orderName,impression,click,visit,conversion,click/impression as clickRate ,visit/click as visitRate ,conversion/visit as conversionRate,eCmp,income
|
|
|
- from t_rpt_daily
|
|
|
- left join t_order
|
|
|
- ON t_rpt_daily.order_id=t_order.id
|
|
|
- order by order_id desc
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findByCampaignName" parameterType="map" resultType="DeliverAnalysis">
|
|
|
- select
|
|
|
- t_campaign.name as campaignName,impression,click,visit,conversion,click/impression as clickRate ,visit/click as visitRate ,conversion/visit as conversionRate ,eCmp,income
|
|
|
- from t_rpt_daily
|
|
|
- left join t_campaign
|
|
|
- ON t_rpt_daily.campaign_id=t_campaign.id
|
|
|
- order by campaign_id desc
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findByAdGroupName" parameterType="map" resultType="DeliverAnalysis">
|
|
|
- select
|
|
|
- t_adgroup.name as adGroupName,impression,click,visit,conversion,click/impression as clickRate ,visit/click as visitRate ,conversion/visit as conversionRate ,eCmp,income
|
|
|
- from t_rpt_daily
|
|
|
- left join t_adgroup
|
|
|
- ON t_rpt_daily.adgroup_id=t_adgroup.id
|
|
|
- order by adgroup_id desc
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findByBannerName" parameterType="map" resultType="DeliverAnalysis">
|
|
|
- select
|
|
|
- t_banner.name as bannerName,impression,click,visit,conversion,click/impression as clickRate ,visit/click as visitRate ,conversion/visit as conversionRate ,eCmp,income
|
|
|
- from t_rpt_daily
|
|
|
- left join t_banner
|
|
|
- ON t_rpt_daily.banner_id=t_banner.id
|
|
|
- order by banner_id desc
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select> -->
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByAdvertiser" parameterType="map" resultType="map">
|
|
|
- select ad.name as advertiserName,date as reportDate,sum(a.consume) as totalConsume,sum(a.impression) as totalImpression,
|
|
|
-sum(click) as totalClick, if(sum(a.impression) > 0,sum(a.click)/sum(a.impression),0)
|
|
|
- as clickRate from t_rpt_advertiser as a left join t_advertiser ad on a.advertiser_id=ad.id
|
|
|
- where a.advertiser_id=#{advertiserId}
|
|
|
- and a.date >= #{startDate} and a.date <=#{endDate}
|
|
|
- group by date(a.date)
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findByAdvertiser3" parameterType="map" resultType="map">
|
|
|
- select ad.name as advertiserName,date as reportDate,sum(a.consume) as totalConsume,sum(a.impression) as totalImpression,
|
|
|
-sum(click) as totalClick, if(sum(a.impression) > 0,sum(a.click)/sum(a.impression),0)
|
|
|
- as clickRate from t_rpt_advertiser as a left join t_advertiser ad on a.advertiser_id=ad.id
|
|
|
- where a.advertiser_id=#{advertiserId}
|
|
|
- and a.date >= #{startDate} and a.date <=#{endDate}
|
|
|
- group by date(a.date)
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByAdvertiser1" parameterType="map" resultType="map">
|
|
|
- select ad.name as advertiserName,date as reportDate, a.hour as hour,sum(a.consume) as totalConsume,sum(a.impression) as totalImpression,
|
|
|
-sum(click) as totalClick, if(sum(a.impression) > 0,sum(a.click)/sum(a.impression),0)
|
|
|
- as clickRate from t_rpt_advertiser_hour as a left join t_advertiser ad on a.advertiser_id=ad.id
|
|
|
- where a.advertiser_id=#{advertiserId} and a.date = #{startDate}
|
|
|
- group by a.hour
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByAdvertiser2" parameterType="map" resultType="map">
|
|
|
- select ad.name as advertiserName,date as reportDate, a.hour as hour,sum(a.consume) as totalConsume,sum(a.impression) as totalImpression,
|
|
|
-sum(click) as totalClick, if(sum(a.impression) > 0,sum(a.click)/sum(a.impression),0)
|
|
|
- as clickRate from t_rpt_advertiser_hour as a left join t_advertiser ad on a.advertiser_id=ad.id
|
|
|
- where a.advertiser_id=#{advertiserId} and a.date = #{startDate}
|
|
|
- group by a.hour
|
|
|
- limit #{pager.offset}, #{pager.limit}
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findCountForChart" parameterType="map" resultType="int">
|
|
|
- select count(date) from((select distinct date from t_rpt_advertiser where advertiser_id=#{advertiserId}
|
|
|
- and date >= #{startDate} and date <=#{endDate}) as a)
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findCountForChart1" parameterType="map" resultType="int">
|
|
|
- select count(hour) from ((select distinct hour from t_rpt_advertiser_hour where advertiser_id=#{advertiserId} and date = #{startDate}) as a)
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findTotalImpressionAndClickByAdvertiserId" parameterType="map" resultType="map">
|
|
|
- select sum(impression) as totalImpression, sum(click) as totalClick
|
|
|
- from t_rpt_advertiser
|
|
|
- where advertiser_id = #{advertiserId} and date = #{date}
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
- <select id="findTotalImpressionAndClickByAgentId" parameterType="map" resultType="map">
|
|
|
- select sum(a.impression) as totalImpression, sum(a.click) as totalClick
|
|
|
- from t_rpt_advertiser a,t_advertiser b
|
|
|
- where b.id = a.advertiser_id and b.agent_id = #{agentId}
|
|
|
- and a.date = #{date}
|
|
|
-
|
|
|
- </select>
|
|
|
-
|
|
|
- <!--数据报表 导出excel -->
|
|
|
- <select id="findByTotalForExcel" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select b.name advertiserName,c.name orderName,d.name campaignName,e.name adgroupName,g.name bannerName,a.date reportDate,sum(a.impression) as impression,sum(a.click) as click,100*sum(a.click)/sum(a.impression) as clickRate,sum(a.visit) as visit,100*sum(a.visit)/sum(a.click) as visitRate,sum(a.conversion) conversion,100*sum(a.conversion)/sum(a.visit) as conversionRate,sum(a.ecmp) ecmp,sum(a.consume) as consume
|
|
|
- from t_rpt_advertiser a,t_advertiser b,t_order c,t_campaign d,t_adgroup e,t_banner f,t_banner_template g
|
|
|
- where a.advertiser_id=b.id and a.order_id=c.id and a.campaign_id=d.id and a.adgroup_id=e.id and a.banner_id=f.id and f.banner_template_id=g.id
|
|
|
- <if test="advertiserId != null and advertiserId ">
|
|
|
- and a.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId != null and orderId != ''">
|
|
|
- and a.order_id = #{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaginId != null and campaginId != ''">
|
|
|
- and a.campagin_id = #{campaginId}
|
|
|
- </if>
|
|
|
- <if test="adgroupId != null and adgroupId != ''">
|
|
|
- and a.adgroup_id = #{adgroupId}
|
|
|
- </if>
|
|
|
- <if test="startDate != null and startDate != ''and endDate != nul and endDate != ''">
|
|
|
- and a.date >=#{startDate} and a.date <=#{endDate}
|
|
|
- </if>
|
|
|
- <choose>
|
|
|
- <when test="dimensionStr != null and dimensionStr != ''">
|
|
|
- GROUP BY ${dimensionStr}
|
|
|
- </when>
|
|
|
- <otherwise>
|
|
|
- group by reportDate
|
|
|
- </otherwise>
|
|
|
- </choose>
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findByLocationForExcel" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select t_location.cn_city as location, 100 * sum(impression) /(select sum(impression) from t_rpt_adv_location a1,t_advertiser b1
|
|
|
- <where>
|
|
|
- a1.advertiser_id = b1.id and a1.date >= #{startDate} and #{endDate} >=a1.date
|
|
|
- <if test="advertiserId ==null">
|
|
|
- and b1.agent_id=#{agentId}
|
|
|
- </if>
|
|
|
- <if test="advertiserId != null">
|
|
|
- and a1.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId !=null">
|
|
|
- and a1.order_id=#{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaignId !=null">
|
|
|
- and a1.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and a1.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- ) as impressionRate, sum(impression) as impression, sum(click) as click, 100 * sum(click) / sum(impression) as clickRate,
|
|
|
- sum(visit) as visit, 100 * sum(visit) / sum(click) as visitRate, 100 * sum(conversion) / sum(visit) as conversionRate,
|
|
|
- sum(conversion) as conversion, sum(ecmp) as eCmp, sum(consume) as consume from t_rpt_adv_location a, t_advertiser b,t_location
|
|
|
- <where>
|
|
|
- a.advertiser_id = b.id and a.location = t_location.location and a.date >= #{startDate} and #{endDate} >=a.date
|
|
|
- <if test="advertiserId ==null">
|
|
|
- and b.agent_id=#{agentId}
|
|
|
- </if>
|
|
|
- <if test="advertiserId != null">
|
|
|
- and a.advertiser_id = #{advertiserId}
|
|
|
- </if>
|
|
|
- <if test="orderId !=null">
|
|
|
- and a.order_id=#{orderId}
|
|
|
- </if>
|
|
|
- <if test="campaignId !=null">
|
|
|
- and a.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and a.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- group by a.location
|
|
|
- </select>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- <select id="findByOsForExcel" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select
|
|
|
- t_advertiser.name as advertiserName, t_order.name as orderName, t_campaign.name as campaignName, t_adgroup.name as adGroupName,
|
|
|
-
|
|
|
- ros.date as reportDate,
|
|
|
- ros.impression,ros.click,visit,ros.conversion,os,
|
|
|
- 100*ros.impression/(select sum(impression) from t_rpt_adv_os) as impressionRate,100*ros.click/ros.impression as clickRate ,
|
|
|
- 100*visit/ros.click as visitRate ,100*ros.conversion/visit as conversionRate,ecmp as eCmp,consume
|
|
|
- from t_rpt_adv_os ros, t_advertiser, t_order, t_campaign, t_adgroup
|
|
|
-
|
|
|
-
|
|
|
- <where>
|
|
|
-
|
|
|
- ros.advertiser_id = t_advertiser.id and ros.order_id = t_order.id and ros.campaign_id = t_campaign.id and ros.adgroup_id = t_adgroup.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and ros.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and ros.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and ros.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and ros.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and ros.date >= #{startDate} and #{endDate} >=ros.date
|
|
|
- </if>
|
|
|
-
|
|
|
- </where>
|
|
|
-
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="findByPlaceNameForExcel" parameterType="map" resultType="com.cloudcross.ssp.advertiser.model.DeliverAnalysis">
|
|
|
- select
|
|
|
- t_place.name as placeName, t_advertiser.name as advertiserName, t_order.name as orderName,
|
|
|
- t_campaign.name as campaignName, t_adgroup.name as adGroupName,
|
|
|
-
|
|
|
- rp.date as reportDate,
|
|
|
- rp.impression,rp.click,visit,rp.conversion,
|
|
|
- 100*rp.impression/(select sum(impression) from t_rpt_adv_place) as impressionRate,100*rp.click/rp.impression as clickRate ,
|
|
|
- 100*visit/rp.click as visitRate ,100*rp.conversion/visit as conversionRate,ecmp as eCmp,consume
|
|
|
- from t_rpt_adv_place rp, t_advertiser, t_order, t_campaign, t_adgroup , t_place
|
|
|
-
|
|
|
-
|
|
|
- <where>
|
|
|
- rp.place_id = t_place.id and rp.advertiser_id = t_advertiser.id
|
|
|
- and rp.order_id = t_order.id and rp.campaign_id = t_campaign.id and rp.adgroup_id = t_adgroup.id
|
|
|
-
|
|
|
- <if test="advertiserId !=null">
|
|
|
- and rp.advertiser_id=#{advertiserId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="orderId !=null">
|
|
|
- and rp.order_id=#{orderId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="campaignId !=null">
|
|
|
- and rp.campaign_id=#{campaignId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="adGroupId !=null">
|
|
|
- and rp.adgroup_id=#{adGroupId}
|
|
|
- </if>
|
|
|
-
|
|
|
- <if test="startDate!=null and endDate!=null">
|
|
|
- and rp.date >= #{startDate} and #{endDate} >=rp.date
|
|
|
- </if>
|
|
|
-
|
|
|
- </where>
|
|
|
- </select>
|
|
|
-
|
|
|
-</mapper>
|