幸运24-统计-poolType分组汇总
This commit is contained in:
@@ -18,6 +18,8 @@ public class Lucky24PersonalStat {
|
||||
private String date;
|
||||
@ApiModelProperty("分区id")
|
||||
private Integer partitionId;
|
||||
@ApiModelProperty("分区描述")
|
||||
private Integer poolType;
|
||||
@ApiModelProperty("uid")
|
||||
private Long uid;
|
||||
@ApiModelProperty("erbanNO")
|
||||
|
@@ -18,6 +18,8 @@ public class Lucky24PlatformStat {
|
||||
private String date;
|
||||
@ApiModelProperty("分区id")
|
||||
private Integer partitionId;
|
||||
@ApiModelProperty("数组类型")
|
||||
private Integer poolType;
|
||||
@ApiModelProperty("送礼金币总额")
|
||||
private Long totalInput;
|
||||
@ApiModelProperty("送礼返币总额")
|
||||
|
@@ -14,9 +14,18 @@ public interface Lucky24RecordMapper extends BaseMapper<Lucky24Record> {
|
||||
List<Lucky24PlatformStat> listPlatform(@Param("partitionId") Integer partitionId, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("zoneIdHour") long zoneIdHour);
|
||||
|
||||
List<Lucky24PlatformStat> listPlatformByPoolType(@Param("partitionId") Integer partitionId, @Param("poolType") Integer poolType,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("zoneIdHour") long zoneIdHour);
|
||||
|
||||
List<Lucky24PersonalStat> listPersonal(@Param("partitionId") Integer partitionId,
|
||||
@Param("uid") Long uid,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("zoneIdHour") long zoneIdHour);
|
||||
|
||||
List<Lucky24PersonalStat> listPersonalByPoolType(@Param("partitionId") Integer partitionId,
|
||||
@Param("uid") Long uid, @Param("poolType") Integer poolType,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("zoneIdHour") long zoneIdHour);
|
||||
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<mapper namespace="com.accompany.sharding.mapper.Lucky24RecordMapper">
|
||||
|
||||
<select id="listPlatform" resultType="com.accompany.sharding.vo.Lucky24PlatformStat">
|
||||
select `date`, partition_id,
|
||||
select `date`, partition_id, 0 as pool_type,
|
||||
sum(`totalInput`) `totalInput`, sum(`totalOutput`) `totalOutput`,
|
||||
sum(`totalOutput`) / sum(`totalInput`) `productionRatio`,
|
||||
count(*) `count`, count((IF(`maxOutput` > 0, 1, null))) `winCount`,
|
||||
@@ -23,9 +23,34 @@
|
||||
group by `date`
|
||||
</select>
|
||||
|
||||
<select id="listPlatformByPoolType" resultType="com.accompany.sharding.vo.Lucky24PlatformStat">
|
||||
select `date`, partition_id, pool_type,
|
||||
sum(`totalInput`) `totalInput`, sum(`totalOutput`) `totalOutput`,
|
||||
sum(`totalOutput`) / sum(`totalInput`) `productionRatio`,
|
||||
count(*) `count`, count((IF(`maxOutput` > 0, 1, null))) `winCount`,
|
||||
sum(`num`) `num`, sum(`winNum`) `winNum`, sum(`winNum`) / sum(`num`) `winRate`
|
||||
from (
|
||||
select date(date_add(r.create_time, INTERVAL #{zoneIdHour} HOUR)) `date`,
|
||||
partition_id,
|
||||
pool_type,
|
||||
sum(gift_num * gift_gold_price) `totalInput`,
|
||||
sum(win_gold_num) `totalOutput`,
|
||||
count(*) `num`,
|
||||
count((case when win_gold_num > 0 then 1 end)) `winNum`,
|
||||
max(win_gold_num) `maxOutput`
|
||||
from lucky_24_record r
|
||||
where r.create_time >= #{startTime} and r.create_time <= #{endTime}
|
||||
and r.partition_id = #{partitionId}
|
||||
<if test="null != poolType">
|
||||
and r.pool_type = #{poolType}
|
||||
</if>
|
||||
group by `date`, uid, pool_type) l
|
||||
group by `date`, pool_type
|
||||
</select>
|
||||
|
||||
<select id="listPersonal" resultType="com.accompany.sharding.vo.Lucky24PersonalStat">
|
||||
select date(date_add(r.create_time, INTERVAL #{zoneIdHour} HOUR)) `date`, partition_id,
|
||||
r.uid,
|
||||
r.uid, 0 as pool_type,
|
||||
sum(gift_num * gift_gold_price) `totalInput`,
|
||||
sum(win_gold_num) `totalOutput`,
|
||||
sum(gift_num * gift_gold_price) - sum(win_gold_num) `production`,
|
||||
@@ -43,4 +68,27 @@
|
||||
group by `date`, r.uid
|
||||
</select>
|
||||
|
||||
<select id="listPersonalByPoolType" resultType="com.accompany.sharding.vo.Lucky24PersonalStat">
|
||||
select date(date_add(r.create_time, INTERVAL #{zoneIdHour} HOUR)) `date`, partition_id,
|
||||
r.uid, r.pool_type,
|
||||
sum(gift_num * gift_gold_price) `totalInput`,
|
||||
sum(win_gold_num) `totalOutput`,
|
||||
sum(gift_num * gift_gold_price) - sum(win_gold_num) `production`,
|
||||
sum(win_gold_num) / sum(gift_num * gift_gold_price) `productionRatio`,
|
||||
sum(gift_num * gift_gold_price) / count(*) `avgInput`,
|
||||
count(*) `num`,
|
||||
count((case when win_gold_num > 0 then r.uid else null end)) `winNum`,
|
||||
ifnull(count((case when win_gold_num > 0 then r.uid else null end)) / count(*),0) `winRate`
|
||||
from lucky_24_record r
|
||||
where r.create_time >= #{startTime} and r.create_time <= #{endTime}
|
||||
<if test="null != uid">
|
||||
and r.uid = #{uid}
|
||||
</if>
|
||||
<if test="null != poolType">
|
||||
and r.pool_type = #{poolType}
|
||||
</if>
|
||||
and r.partition_id = #{partitionId}
|
||||
group by `date`, r.uid, pool_type
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user