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

修改首页查询

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