后台-修复福袋记录合并后的统计问题
This commit is contained in:
@@ -6,8 +6,9 @@
|
|||||||
<resultMap id="BaseResultMap2" type="com.accompany.admin.vo.luckybag.LuckyBagStatsAdminVo">
|
<resultMap id="BaseResultMap2" type="com.accompany.admin.vo.luckybag.LuckyBagStatsAdminVo">
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<select id="getList" resultMap="BaseResultMap">
|
<select id="getList" resultMap="BaseResultMap">
|
||||||
select a.id,a.lucky_bag_id,a.total_gold_num,a.create_time,b.erban_no,b.nick,c.erban_no receive_erban_no,c.nick
|
select a.id,a.lucky_bag_id,a.total_gold_num / lucky_bag_num as total_gold_num,a.create_time,b.erban_no,b.nick,
|
||||||
receive_nick,d.gift_name,d.gold_price gift_value from lucky_bag_record as a
|
c.erban_no receive_erban_no,c.nick receive_nick,
|
||||||
|
a.gift_name,a.platform_value gift_value from lucky_bag_record as a
|
||||||
join users as b
|
join users as b
|
||||||
join users as c
|
join users as c
|
||||||
join gift as d
|
join gift as d
|
||||||
@@ -35,20 +36,19 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="getCount" resultType="java.lang.Integer">
|
<select id="getCount" resultType="java.lang.Integer">
|
||||||
select count(1) from lucky_bag_record as a
|
select sum(gift_num) from lucky_bag_record as a
|
||||||
join users as b
|
join users as b
|
||||||
join users as c
|
join users as c
|
||||||
join gift as d
|
on a.uid=b.uid and a.receive_uid=c.uid
|
||||||
on a.uid=b.uid and a.receive_uid=c.uid and a.gift_id=d.gift_id
|
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="luckyBagId != null">
|
<if test="luckyBagId != null">
|
||||||
and lucky_bag_id = #{luckyBagId}
|
and a.lucky_bag_id = #{luckyBagId}
|
||||||
</if>
|
</if>
|
||||||
<if test="erbanNo != null">
|
<if test="erbanNo != null">
|
||||||
and b.erban_no = #{erbanNo}
|
and b.erban_no = #{erbanNo}
|
||||||
</if>
|
</if>
|
||||||
<if test="giftName != null and giftName != ''">
|
<if test="giftName != null and giftName != ''">
|
||||||
and gift_name like concat('%',#{giftName},'%')
|
and a.gift_name like concat('%',#{giftName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="startDate != null">
|
<if test="startDate != null">
|
||||||
and a.create_time >= #{startDate}
|
and a.create_time >= #{startDate}
|
||||||
@@ -59,12 +59,13 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="luckyBagStats" resultMap="BaseResultMap2">
|
<select id="luckyBagStats" resultMap="BaseResultMap2">
|
||||||
SELECT count(1) num,ifnull(sum(total_gold_num),0) input_value,ifnull(sum(b.gold_price),0) AS
|
SELECT c.erban_no,c.nick,sum(gift_num) num,
|
||||||
output_value,ifnull(sum(b.gold_price),0)/ifnull(sum(total_gold_num),1) AS ratio
|
ifnull(sum((total_gold_num/lucky_bag_num) * gift_num),0) input_value,
|
||||||
|
ifnull(sum(total_platform_value),0) AS output_value,
|
||||||
|
ifnull(sum(total_platform_value),0)/ifnull(sum(total_gold_num),1) AS ratio
|
||||||
FROM lucky_bag_record AS a
|
FROM lucky_bag_record AS a
|
||||||
JOIN gift AS b
|
|
||||||
JOIN users as c
|
JOIN users as c
|
||||||
ON a.gift_id=b.gift_id and a.uid=c.uid
|
ON a.uid=c.uid
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="luckyBagId != null">
|
<if test="luckyBagId != null">
|
||||||
and a.lucky_bag_id = #{luckyBagId}
|
and a.lucky_bag_id = #{luckyBagId}
|
||||||
@@ -80,12 +81,13 @@
|
|||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
<select id="luckyBagStatsList" resultMap="BaseResultMap2">
|
<select id="luckyBagStatsList" resultMap="BaseResultMap2">
|
||||||
SELECT c.erban_no,c.nick,count(1) num,ifnull(sum(total_gold_num),0) input_value,ifnull(sum(b.gold_price),0) AS
|
SELECT c.erban_no,c.nick,sum(gift_num) num,
|
||||||
output_value,ifnull(sum(b.gold_price),0)/ifnull(sum(total_gold_num),1) AS ratio
|
ifnull(sum((total_gold_num/lucky_bag_num) * gift_num),0) input_value,
|
||||||
|
ifnull(sum(total_platform_value),0) AS output_value,
|
||||||
|
ifnull(sum(total_platform_value),0)/ifnull(sum(total_gold_num),1) AS ratio
|
||||||
FROM lucky_bag_record AS a
|
FROM lucky_bag_record AS a
|
||||||
JOIN gift AS b
|
|
||||||
JOIN users as c
|
JOIN users as c
|
||||||
ON a.gift_id=b.gift_id and a.uid=c.uid
|
ON a.uid=c.uid
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="luckyBagId != null">
|
<if test="luckyBagId != null">
|
||||||
and a.lucky_bag_id = #{luckyBagId}
|
and a.lucky_bag_id = #{luckyBagId}
|
||||||
@@ -108,9 +110,8 @@
|
|||||||
<select id="luckyBagStatsCount" resultType="java.lang.Integer">
|
<select id="luckyBagStatsCount" resultType="java.lang.Integer">
|
||||||
SELECT count(distinct(c.erban_no))
|
SELECT count(distinct(c.erban_no))
|
||||||
FROM lucky_bag_record AS a
|
FROM lucky_bag_record AS a
|
||||||
JOIN gift AS b
|
|
||||||
JOIN users as c
|
JOIN users as c
|
||||||
ON a.gift_id=b.gift_id and a.uid=c.uid
|
ON a.uid=c.uid
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="luckyBagId != null">
|
<if test="luckyBagId != null">
|
||||||
and a.lucky_bag_id = #{luckyBagId}
|
and a.lucky_bag_id = #{luckyBagId}
|
||||||
@@ -130,10 +131,10 @@
|
|||||||
SELECT
|
SELECT
|
||||||
DATE_FORMAT( lbr.create_time, '%Y-%m-%d' ) AS countDate,
|
DATE_FORMAT( lbr.create_time, '%Y-%m-%d' ) AS countDate,
|
||||||
COUNT( DISTINCT lbr.uid ) AS luckyBagUv,
|
COUNT( DISTINCT lbr.uid ) AS luckyBagUv,
|
||||||
COUNT( lbr.lucky_bag_id ) AS luckyBagNum,
|
sum( lbr.gift_num ) AS luckyBagNum,
|
||||||
SUM( lbr.total_gold_num ) AS luckyBagInputValue,
|
SUM( (lbr.total_gold_num/lbr.lucky_bag_num) * lbr.gift_num ) AS luckyBagInputValue,
|
||||||
SUM( lbr.platform_value ) AS luckyBagOutputValue,
|
SUM( lbr.total_platform_value ) AS luckyBagOutputValue,
|
||||||
(SUM( lbr.total_gold_num ) - SUM( lbr.platform_value )) AS subValue
|
(SUM( (lbr.total_gold_num/lbr.lucky_bag_num) * lbr.gift_num ) - SUM( lbr.total_platform_value )) AS subValue
|
||||||
FROM
|
FROM
|
||||||
lucky_bag_record lbr
|
lucky_bag_record lbr
|
||||||
WHERE
|
WHERE
|
||||||
@@ -182,14 +183,14 @@
|
|||||||
u2.nick as receiverNick,
|
u2.nick as receiverNick,
|
||||||
lbr.lucky_bag_id,
|
lbr.lucky_bag_id,
|
||||||
g1.gift_name as luckyBagName,
|
g1.gift_name as luckyBagName,
|
||||||
lbr.total_gold_num,
|
(lbr.total_gold_num / lbr.lucky_bag_num) * lbr.gift_num total_gold_num,
|
||||||
g2.gift_name,
|
lbr.gift_name,
|
||||||
g2.gold_price as giftValue
|
lbr.gift_num,
|
||||||
|
lbr.total_platform_value as giftValue
|
||||||
from lucky_bag_record as lbr
|
from lucky_bag_record as lbr
|
||||||
LEFT JOIN users u1 ON lbr.uid = u1.uid
|
LEFT JOIN users u1 ON lbr.uid = u1.uid
|
||||||
LEFT JOIN users u2 ON lbr.receive_uid = u2.uid
|
LEFT JOIN users u2 ON lbr.receive_uid = u2.uid
|
||||||
LEFT JOIN gift g1 ON lbr.lucky_bag_id = g1.gift_id
|
LEFT JOIN gift g1 ON lbr.lucky_bag_id = g1.gift_id
|
||||||
LEFT JOIN gift g2 ON lbr.gift_id = g2.gift_id
|
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="luckyBagId != null">
|
<if test="luckyBagId != null">
|
||||||
and lbr.lucky_bag_id = #{luckyBagId}
|
and lbr.lucky_bag_id = #{luckyBagId}
|
||||||
|
Reference in New Issue
Block a user