Commit ba14e85e authored by 罗林杰's avatar 罗林杰

修改首页查询

parent e7285e0d
......@@ -112,7 +112,7 @@
</select>
<select id="statistics" resultType="org.rcisoft.business.sysunit.entity.SysUnit">
SELECT su.*,
IFNULL(suu.agentNum, 0) as agentNum,
IFNULL(suuv.agentNum + suun.agentNum, 0) as agentNum,
IFNULL(cunvv.videoNum, 0) as videoNum,
IFNULL(cunvv.videoViews, 0) as videoViews,
IFNULL(cunvn.articleNum, 0) as articleNum,
......@@ -124,15 +124,32 @@
IFNULL( COUNT( DISTINCT cpc.user_id ), 0 ) AS agentNum
FROM
cms_price_click cpc
LEFT JOIN cms_video cv ON cpc.news_video_id = cv.business_id
WHERE
1 = 1
and del_flag = 0
and cpc.type = 1
and cpc.del_flag = 0
AND cpc.unit_id = #{entity.businessId}
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cpc.update_date >= #{entity.startTime}
AND cpc.update_date &lt;= #{entity.endTime}
AND cv.release_time >= #{entity.startTime}
AND cv.release_time &lt;= #{entity.endTime}
</if>
) suuv ON suuv.unit_id = su.business_id
LEFT JOIN (SELECT
cpc.unit_id,
IFNULL( COUNT( DISTINCT cpc.user_id ), 0 ) AS agentNum
FROM
cms_price_click cpc
LEFT JOIN cms_news cn ON cpc.news_video_id = cn.business_id
WHERE
cpc.unit_id = #{entity.businessId}
AND cpc.type = 0
and cpc.del_flag = 0
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cn.release_date >= #{entity.startTime}
AND cn.release_date &lt;= #{entity.endTime}
</if>
) suu ON suu.unit_id = su.business_id
) suun ON suun.unit_id = su.business_id
LEFT JOIN (SELECT
cpc.unit_id,
COUNT( DISTINCT cpc.news_video_id ) AS videoNum,
......@@ -140,13 +157,14 @@
IFNULL( cpc.click_through_rate, 0 )) AS videoViews
FROM
cms_price_click cpc
LEFT JOIN cms_video cv ON cpc.news_video_id = cv.business_id
WHERE
cpc.unit_id = #{entity.businessId}
AND cpc.type = 1
and cpc.del_flag = 0
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cpc.update_date >= #{entity.startTime}
AND cpc.update_date &lt;= #{entity.endTime}
AND cv.release_time >= #{entity.startTime}
AND cv.release_time &lt;= #{entity.endTime}
</if>
) cunvv ON cunvv.unit_id = su.business_id
LEFT JOIN (SELECT
......@@ -156,13 +174,14 @@
IFNULL( cpc.click_through_rate, 0 )) AS articleViews
FROM
cms_price_click cpc
LEFT JOIN cms_news cn ON cpc.news_video_id = cn.business_id
WHERE
cpc.unit_id = #{entity.businessId}
AND cpc.type = 0
and cpc.del_flag = 0
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cpc.update_date >= #{entity.startTime}
AND cpc.update_date &lt;= #{entity.endTime}
AND cn.release_date >= #{entity.startTime}
AND cn.release_date &lt;= #{entity.endTime}
</if>
) cunvn ON cunvn.unit_id = su.business_id
WHERE 1 = 1
......@@ -201,20 +220,40 @@
</select>
<select id="statisticsByTypeBarChart" resultType="org.rcisoft.business.sysunit.dto.StatisticsDto">
SELECT su.`name`,
SUM(CASE WHEN cpc.type = 0 THEN cpc.click_through_rate ELSE 0 END) AS newsRate,
SUM(CASE WHEN cpc.type = 1 THEN cpc.click_through_rate ELSE 0 END) AS videoRate
SUM(CASE WHEN cpc.type = 0
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cn.release_date >= #{entity.startTime}
AND cn.release_date &lt;= #{entity.endTime}
</if>
THEN cpc.click_through_rate ELSE 0 END) AS newsRate,
SUM(CASE WHEN cpc.type = 1
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cv.release_time >= #{entity.startTime}
AND cv.release_time &lt;= #{entity.endTime}
</if>
THEN cpc.click_through_rate ELSE 0 END) AS videoRate
FROM cms_price_click cpc
LEFT JOIN sys_user su ON su.business_id = cpc.user_id
LEFT JOIN cms_news cn ON cpc.news_video_id = cn.business_id
LEFT JOIN cms_video cv ON cpc.news_video_id = cv.business_id
WHERE 1 = 1
AND cpc.del_flag = 0
AND cpc.flag = 1
and cpc.unit_id = #{entity.businessId}
GROUP BY su.business_id
ORDER BY
SUM(CASE WHEN cpc.type = 1
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cpc.update_date >= #{entity.startTime}
AND cpc.update_date &lt;= #{entity.endTime}
AND cv.release_time >= #{entity.startTime}
AND cv.release_time &lt;= #{entity.endTime}
</if>
GROUP BY su.business_id
ORDER BY SUM(cpc.click_through_rate + cpc.click_through_rate) DESC
THEN cpc.click_through_rate ELSE 0 END) +
SUM(CASE WHEN cpc.type = 0
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cn.release_date >= #{entity.startTime}
AND cn.release_date &lt;= #{entity.endTime}
</if>
THEN cpc.click_through_rate ELSE 0 END) DESC
limit 0 ,10
</select>
<select id="statisticsByTypePieChart" resultType="org.rcisoft.business.sysunit.dto.StatisticsDto">
......@@ -274,8 +313,8 @@
AND cpc.del_flag = 0
AND cpc.flag = 1
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cpc.update_date >= #{entity.startTime}
AND cpc.update_date &lt;= #{entity.endTime}
AND cn.release_date >= #{entity.startTime}
AND cn.release_date &lt;= #{entity.endTime}
</if>
GROUP BY cn.business_id
order by SUM(cpc.click_through_rate)
......@@ -294,8 +333,8 @@
AND cpc.del_flag = 0
AND cpc.flag = 1
<if test="entity.startTime !=null and entity.startTime != '' and entity.endTime !=null and entity.endTime != '' ">
AND cpc.update_date >= #{entity.startTime}
AND cpc.update_date &lt;= #{entity.endTime}
AND cv.release_time >= #{entity.startTime}
AND cv.release_time &lt;= #{entity.endTime}
</if>
GROUP BY cv.business_id
order by SUM(cpc.click_through_rate)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment