幸运24-统计-强制使用索引
This commit is contained in:
@@ -8,7 +8,6 @@ import com.accompany.admin.service.UserLevelExperienceExportService;
|
||||
import com.accompany.business.constant.guild.GuildConstant;
|
||||
import com.accompany.business.dto.WeekActiveGuildStat;
|
||||
import com.accompany.business.model.*;
|
||||
import com.accompany.business.model.guild.AgencyMonthSettleDetail;
|
||||
import com.accompany.business.model.guild.GuildMember;
|
||||
import com.accompany.business.model.relation.RelationUser;
|
||||
import com.accompany.business.mybatismapper.*;
|
||||
@@ -33,7 +32,6 @@ import com.accompany.common.constant.EmailConstant;
|
||||
import com.accompany.common.device.DeviceInfo;
|
||||
import com.accompany.common.netease.ErBanNetEaseService;
|
||||
import com.accompany.common.netease.neteaseacc.result.RoomMemberRet;
|
||||
import com.accompany.common.netease.util.NetEaseConstant;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.CommonUtil;
|
||||
@@ -447,7 +445,7 @@ public class MyApiService {
|
||||
log.info("[lucky24Stat] start partitionId {} startTime {} endTime {} zoneIdHour {}",
|
||||
partition.getId(), DateTimeUtil.convertDate(startTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN),
|
||||
DateTimeUtil.convertDate(endTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN), zoneIdHour);
|
||||
lucky24RecordService.statDate(partition.getId(), startTime, endTime, zoneIdHour);
|
||||
lucky24RecordService.statDate(partition.getId(), startTime, endTime, zoneIdHour, dateStr);
|
||||
log.info("[lucky24Stat] end partitionId {} startTime {} endTime {} zoneIdHour {}",
|
||||
partition.getId(), DateTimeUtil.convertDate(startTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN),
|
||||
DateTimeUtil.convertDate(endTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN), zoneIdHour);
|
||||
|
@@ -81,6 +81,9 @@ public class Lucky24RecordAdminService {
|
||||
String startDate = minStartDate;
|
||||
String endDate = DateTimeUtil.getZonedTodayStr(partitionInfo.getZoneId());
|
||||
|
||||
List<Integer> poolTypeList = null == poolType? Arrays.stream(Lucky24PoolTypeEnum.values()).map(Lucky24PoolTypeEnum::getType).sorted().toList():
|
||||
Collections.singletonList(poolType);
|
||||
|
||||
List<String> dateStrList = DateTimeUtil.getDateListBetweenTwoDates(startDate, endDate, endDate);
|
||||
Map<String, Lucky24PlatformStat> statMap = new HashMap<>(dateStrList.size());
|
||||
|
||||
@@ -91,13 +94,13 @@ public class Lucky24RecordAdminService {
|
||||
Date startTime = DateTimeUtil.getBeginTimeOfDay(DateTimeUtil.convertStrToDate(endDate, DateTimeUtil.DEFAULT_DATE_PATTERN));
|
||||
ZonedDateTime zonedStartTime = startTime.toInstant().atZone(ZoneId.systemDefault());
|
||||
Date systemStartTime = Date.from(zonedStartTime.withZoneSameLocal(ZoneId.of(partitionInfo.getZoneId())).toInstant());
|
||||
long zoneIdHour = Duration.between(systemStartTime.toInstant(), startTime.toInstant()).toHours();
|
||||
|
||||
Date endTime = DateTimeUtil.getEndTimeOfDay(DateTimeUtil.convertStrToDate(endDate, DateTimeUtil.DEFAULT_DATE_PATTERN));
|
||||
ZonedDateTime zonedEndTime = endTime.toInstant().atZone(ZoneId.systemDefault());
|
||||
Date systemEndTime = Date.from(zonedEndTime.withZoneSameLocal(ZoneId.of(partitionInfo.getZoneId())).toInstant());
|
||||
List<Lucky24PlatformStat> list = null == poolType?
|
||||
recordMapper.listPlatform(partitionId, systemStartTime, systemEndTime, zoneIdHour):
|
||||
recordMapper.listPlatformByPoolType(partitionId, poolType, systemStartTime, systemEndTime, zoneIdHour);
|
||||
recordMapper.listPlatform(endDate, partitionId, poolTypeList, systemStartTime, systemEndTime):
|
||||
recordMapper.listPlatformByPoolType(endDate, partitionId, poolTypeList, systemStartTime, systemEndTime);
|
||||
for (Lucky24PlatformStat stat: list) {
|
||||
statMap.put(stat.getDate(), stat);
|
||||
}
|
||||
@@ -284,17 +287,20 @@ public class Lucky24RecordAdminService {
|
||||
}
|
||||
|
||||
private List<Lucky24PersonalStat> listPersonal(int partitionId, String zonedId, Long uid, String date, String userRechargeLevel, Integer poolType) {
|
||||
List<Integer> poolTypeList = null == poolType ?
|
||||
Arrays.stream(Lucky24PoolTypeEnum.values()).map(Lucky24PoolTypeEnum::getType).sorted().toList(): Collections.singletonList(poolType);
|
||||
|
||||
ZoneId zoneId = ZoneId.of(zonedId);
|
||||
Date startTime = DateTimeUtil.getBeginTimeOfDay(DateTimeUtil.convertStrToDate(date, DateTimeUtil.DEFAULT_DATE_PATTERN));
|
||||
ZonedDateTime zonedStartTime = startTime.toInstant().atZone(ZoneId.systemDefault());
|
||||
Date systemStartTime = Date.from(zonedStartTime.withZoneSameLocal(zoneId).toInstant());
|
||||
long zoneIdHour = Duration.between(systemStartTime.toInstant(), startTime.toInstant()).toHours();
|
||||
|
||||
Date endTime = DateTimeUtil.getEndTimeOfDay(DateTimeUtil.convertStrToDate(date, DateTimeUtil.DEFAULT_DATE_PATTERN));
|
||||
ZonedDateTime zonedEndTime = endTime.toInstant().atZone(ZoneId.systemDefault());
|
||||
Date systemEndTime = Date.from(zonedEndTime.withZoneSameLocal(zoneId).toInstant());
|
||||
return null == poolType?
|
||||
recordMapper.listPersonal(partitionId, uid, userRechargeLevel, systemStartTime, systemEndTime, zoneIdHour):
|
||||
recordMapper.listPersonalByPoolType(partitionId, uid, userRechargeLevel, poolType, systemStartTime, systemEndTime, zoneIdHour);
|
||||
recordMapper.listPersonal(date, partitionId, poolTypeList, systemStartTime, systemEndTime, uid, userRechargeLevel):
|
||||
recordMapper.listPersonalByPoolType(date, partitionId, poolTypeList, systemStartTime, systemEndTime, uid, userRechargeLevel);
|
||||
}
|
||||
|
||||
public Page<Lucky24RecordAdminVo> pageRecord(Long uid, String date, Integer poolType, int pageNo, int pageSize) {
|
||||
@@ -310,12 +316,16 @@ public class Lucky24RecordAdminService {
|
||||
ZonedDateTime zonedEndTime = endTime.toInstant().atZone(ZoneId.systemDefault());
|
||||
Date systemEndTime = Date.from(zonedEndTime.withZoneSameLocal(zoneId).toInstant());
|
||||
|
||||
List<Integer> poolTypeList = null == poolType ?
|
||||
Arrays.stream(Lucky24PoolTypeEnum.values()).map(Lucky24PoolTypeEnum::getType).sorted().toList(): Collections.singletonList(poolType);
|
||||
|
||||
Page<Lucky24RecordAdminVo> voPage = new Page<>(pageNo, pageSize);
|
||||
Page<Lucky24Record> poPage = new Page<>(pageNo, pageSize);
|
||||
recordMapper.selectPage(poPage, Wrappers.<Lucky24Record>lambdaQuery()
|
||||
.eq(Lucky24Record::getUid, uid)
|
||||
.between(Lucky24Record::getCreateTime, systemStartTime, systemEndTime)
|
||||
.eq(null != poolType, Lucky24Record::getPoolType, poolType));
|
||||
.eq(Lucky24Record::getPartitionId, partitionEnum.getId())
|
||||
.in(Lucky24Record::getPoolType, poolTypeList)
|
||||
.between(Lucky24Record::getCreateTime, systemStartTime, systemEndTime)
|
||||
.eq(Lucky24Record::getUid, uid));
|
||||
|
||||
if (CollectionUtils.isEmpty(poPage.getRecords())){
|
||||
return voPage;
|
||||
|
@@ -1,11 +1,6 @@
|
||||
package com.accompany.sharding.config;
|
||||
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.common.utils.EnvComponent;
|
||||
import com.accompany.common.utils.ResourceUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||
import org.apache.ibatis.plugin.Interceptor;
|
||||
import org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory;
|
||||
import org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
|
||||
import org.apache.shardingsphere.infra.config.mode.ModeConfiguration;
|
||||
@@ -19,15 +14,10 @@ import org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleC
|
||||
import org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
|
||||
import org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
|
||||
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
@@ -42,9 +32,6 @@ import java.util.*;
|
||||
@Configuration
|
||||
public class ShardingSphereConfig {
|
||||
|
||||
@Autowired
|
||||
private EnvComponent envComponent;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("masterDataSource")
|
||||
private DataSource masterDataSource;
|
||||
|
@@ -11,21 +11,22 @@ import java.util.List;
|
||||
|
||||
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> listPlatform(@Param("zoneDate")String zoneDate, @Param("partitionId") Integer partitionId,
|
||||
@Param("poolTypeList")List<Integer> poolTypeList,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
List<Lucky24PlatformStat> listPlatformByPoolType(@Param("partitionId") Integer partitionId, @Param("poolType") Integer poolType,
|
||||
List<Lucky24PlatformStat> listPlatformByPoolType(@Param("zoneDate")String zonedDate, @Param("partitionId") Integer partitionId,
|
||||
@Param("poolTypeList")List<Integer> poolTypeList,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
List<Lucky24PersonalStat> listPersonal(@Param("zoneDate")String zoneDate, @Param("partitionId") Integer partitionId,
|
||||
@Param("poolTypeList")List<Integer> poolTypeList,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("uid") Long uid, @Param("userRechargeLevel") String userRechargeLevel);
|
||||
|
||||
List<Lucky24PersonalStat> listPersonalByPoolType(@Param("zoneDate")String zoneDate, @Param("partitionId") Integer partitionId,
|
||||
@Param("poolTypeList")List<Integer> poolTypeList,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("zoneIdHour") long zoneIdHour);
|
||||
|
||||
List<Lucky24PersonalStat> listPersonal(@Param("partitionId") Integer partitionId,
|
||||
@Param("uid") Long uid,
|
||||
@Param("userRechargeLevel") String userRechargeLevel, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("zoneIdHour") long zoneIdHour);
|
||||
|
||||
List<Lucky24PersonalStat> listPersonalByPoolType(@Param("partitionId") Integer partitionId,
|
||||
@Param("uid") Long uid, @Param("userRechargeLevel") String userRechargeLevel, @Param("poolType") Integer poolType,
|
||||
@Param("startTime") Date startTime, @Param("endTime") Date endTime,
|
||||
@Param("zoneIdHour") long zoneIdHour);
|
||||
@Param("uid") Long uid, @Param("userRechargeLevel") String userRechargeLevel);
|
||||
|
||||
}
|
||||
|
@@ -3,100 +3,112 @@
|
||||
<mapper namespace="com.accompany.sharding.mapper.Lucky24RecordMapper">
|
||||
|
||||
<select id="listPlatform" resultType="com.accompany.sharding.vo.Lucky24PlatformStat">
|
||||
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`,
|
||||
sum(`num`) `num`, sum(`winNum`) `winNum`, sum(`winNum`) / sum(`num`) `winRate`
|
||||
select #{zoneDate} as `date`,
|
||||
#{partitionId} as partition_id,
|
||||
0 as pool_type,
|
||||
ifnull(sum(`totalInput`),0) `totalInput`,
|
||||
ifnull(sum(`totalOutput`),0) `totalOutput`,
|
||||
ifnull(sum(`totalOutput`) / sum(`totalInput`),0) `productionRatio`,
|
||||
count(*) `count`,
|
||||
count((IF(`maxOutput` > 0, 1, null))) `winCount`,
|
||||
ifnull(sum(`num`),0) `num`,
|
||||
ifnull(sum(`winNum`),0) `winNum`,
|
||||
ifnull(sum(`winNum`) / sum(`num`),0) `winRate`
|
||||
from (
|
||||
select date(date_add(r.create_time, INTERVAL #{zoneIdHour} HOUR)) `date`,
|
||||
partition_id,
|
||||
select
|
||||
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 force index (lucky_24_record_partition_id_pool_type_create_time_uid_index)
|
||||
where r.partition_id = #{partitionId}
|
||||
and r.pool_type in <foreach collection="poolTypeList" item="poolType" separator="," open="(" close=")">#{poolType}</foreach>
|
||||
and r.create_time >= #{startTime} and r.create_time <= #{endTime}
|
||||
group by r.uid) r
|
||||
</select>
|
||||
|
||||
<select id="listPlatformByPoolType" resultType="com.accompany.sharding.vo.Lucky24PlatformStat">
|
||||
select #{zoneDate} as `date`,
|
||||
#{partitionId} as partition_id,
|
||||
pool_type,
|
||||
ifnull(sum(`totalInput`),0) `totalInput`,
|
||||
ifnull(sum(`totalOutput`),0) `totalOutput`,
|
||||
ifnull(sum(`totalOutput`) / sum(`totalInput`),0) `productionRatio`,
|
||||
count(*) `count`,
|
||||
count((IF(`maxOutput` > 0, 1, null))) `winCount`,
|
||||
ifnull(sum(`num`),0) `num`,
|
||||
ifnull(sum(`winNum`),0) `winNum`,
|
||||
ifnull(sum(`winNum`) / sum(`num`),0) `winRate`
|
||||
from (
|
||||
select
|
||||
r.pool_type,
|
||||
r.uid,
|
||||
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}
|
||||
group by `date`, uid) l
|
||||
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
|
||||
from lucky_24_record r force index (lucky_24_record_partition_id_pool_type_create_time_uid_index)
|
||||
where r.partition_id = #{partitionId}
|
||||
and r.pool_type in <foreach collection="poolTypeList" item="poolType" separator="," open="(" close=")">#{poolType}</foreach>
|
||||
and r.create_time >= #{startTime} and r.create_time <= #{endTime}
|
||||
group by r.pool_type, r.uid) r
|
||||
group by r.pool_type
|
||||
</select>
|
||||
|
||||
<select id="listPersonal" resultType="com.accompany.sharding.vo.Lucky24PersonalStat">
|
||||
select date(date_add(r.create_time, INTERVAL #{zoneIdHour} HOUR)) `date`, r.partition_id,
|
||||
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`,
|
||||
sum(win_gold_num) / sum(gift_num * gift_gold_price) `productionRatio`,
|
||||
sum(gift_num * gift_gold_price) / count(*) `avgInput`,
|
||||
select #{zoneDate} as `date`,
|
||||
#{partitionId} as partition_id,
|
||||
0 as pool_type,
|
||||
r.uid,
|
||||
ifnull(sum(gift_num * gift_gold_price),0) `totalInput`,
|
||||
ifnull(sum(win_gold_num),0) `totalOutput`,
|
||||
ifnull(sum(gift_num * gift_gold_price) - sum(win_gold_num),0) `production`,
|
||||
ifnull(sum(win_gold_num) / sum(gift_num * gift_gold_price),0) `productionRatio`,
|
||||
ifnull(sum(gift_num * gift_gold_price) / count(*),0) `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
|
||||
from lucky_24_record r force index (lucky_24_record_partition_id_pool_type_create_time_uid_index)
|
||||
<if test="null != userRechargeLevel and '' != userRechargeLevel">
|
||||
inner join users u on r.uid = u.uid
|
||||
inner join user_recharge_level url on u.uid = url.uid and url.level = #{userRechargeLevel}
|
||||
</if>
|
||||
where r.create_time >= #{startTime} and r.create_time <= #{endTime}
|
||||
<if test="null != uid">
|
||||
and r.uid = #{uid}
|
||||
</if>
|
||||
and r.partition_id = #{partitionId}
|
||||
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`, r.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
|
||||
<if test="null != userRechargeLevel and '' != userRechargeLevel">
|
||||
inner join users u on r.uid = u.uid
|
||||
inner join user_recharge_level url on u.uid = url.uid and url.level = #{userRechargeLevel}
|
||||
</if>
|
||||
where r.create_time >= #{startTime} and r.create_time <= #{endTime}
|
||||
where r.partition_id = #{partitionId}
|
||||
and r.pool_type in <foreach collection="poolTypeList" item="poolType" separator="," open="(" close=")">#{poolType}</foreach>
|
||||
and 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}
|
||||
group by r.uid
|
||||
</select>
|
||||
|
||||
<select id="listPersonalByPoolType" resultType="com.accompany.sharding.vo.Lucky24PersonalStat">
|
||||
select #{zoneDate} as `date`,
|
||||
#{partitionId} as partition_id,
|
||||
r.pool_type,
|
||||
r.uid,
|
||||
ifnull(sum(gift_num * gift_gold_price),0) `totalInput`,
|
||||
ifnull(sum(win_gold_num),0) `totalOutput`,
|
||||
ifnull(sum(gift_num * gift_gold_price) - sum(win_gold_num),0) `production`,
|
||||
ifnull(sum(win_gold_num) / sum(gift_num * gift_gold_price),0) `productionRatio`,
|
||||
ifnull(sum(gift_num * gift_gold_price) / count(*),0) `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 force index (lucky_24_record_partition_id_pool_type_create_time_uid_index)
|
||||
<if test="null != userRechargeLevel and '' != userRechargeLevel">
|
||||
inner join users u on r.uid = u.uid
|
||||
inner join user_recharge_level url on u.uid = url.uid and url.level = #{userRechargeLevel}
|
||||
</if>
|
||||
and r.partition_id = #{partitionId}
|
||||
group by `date`, r.uid, pool_type
|
||||
where r.partition_id = #{partitionId}
|
||||
and r.pool_type in <foreach collection="poolTypeList" item="poolType" separator="," open="(" close=")">#{poolType}</foreach>
|
||||
and r.create_time >= #{startTime} and r.create_time <= #{endTime}
|
||||
<if test="null != uid">
|
||||
and r.uid = #{uid}
|
||||
</if>
|
||||
group by r.pool_type, r.uid
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.accompany.business.service.lucky;
|
||||
|
||||
import com.accompany.business.constant.Lucky24PoolTypeEnum;
|
||||
import com.accompany.business.model.Gift;
|
||||
import com.accompany.business.mybatismapper.lucky.Lucky24StatMapper;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
@@ -73,8 +75,10 @@ public class Lucky24RecordService extends ServiceImpl<Lucky24RecordMapper, Lucky
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
|
||||
public void statDate(Integer partitionId, Date startTime, Date endTime, long zoneIdHour) {
|
||||
List<Lucky24PlatformStat> platformList = this.baseMapper.listPlatform(partitionId, startTime, endTime, zoneIdHour);
|
||||
public void statDate(Integer partitionId, Date startTime, Date endTime, long zoneIdHour, String zoneDate) {
|
||||
List<Integer> poolTypeList = Arrays.stream(Lucky24PoolTypeEnum.values()).map(Lucky24PoolTypeEnum::getType).sorted().toList();
|
||||
|
||||
List<Lucky24PlatformStat> platformList = this.baseMapper.listPlatform(zoneDate, partitionId, poolTypeList, startTime, endTime);
|
||||
log.info("[lucky24RecordStat] platform partitionId {} startTime {} endTime {} zoneIdHour {} platformList: {}",
|
||||
partitionId, DateTimeUtil.convertDate(startTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN),
|
||||
DateTimeUtil.convertDate(endTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN), zoneIdHour, JSON.toJSONString(platformList));
|
||||
@@ -86,7 +90,7 @@ public class Lucky24RecordService extends ServiceImpl<Lucky24RecordMapper, Lucky
|
||||
});
|
||||
}
|
||||
|
||||
List<Lucky24PlatformStat> platformByPoolTypeList = this.baseMapper.listPlatformByPoolType(partitionId, null, startTime, endTime, zoneIdHour);
|
||||
List<Lucky24PlatformStat> platformByPoolTypeList = this.baseMapper.listPlatformByPoolType(zoneDate, partitionId, poolTypeList, startTime, endTime);
|
||||
log.info("[lucky24RecordStat] platformByPoolType partitionId {} startTime {} endTime {} zoneIdHour {} platformByPoolTypeList: {}",
|
||||
partitionId, DateTimeUtil.convertDate(startTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN),
|
||||
DateTimeUtil.convertDate(endTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN), zoneIdHour, JSON.toJSONString(platformByPoolTypeList));
|
||||
@@ -98,7 +102,7 @@ public class Lucky24RecordService extends ServiceImpl<Lucky24RecordMapper, Lucky
|
||||
});
|
||||
}
|
||||
|
||||
List<Lucky24PersonalStat> personalList = this.baseMapper.listPersonal(partitionId, null, null, startTime, endTime, zoneIdHour);
|
||||
List<Lucky24PersonalStat> personalList = this.baseMapper.listPersonal(zoneDate, partitionId, poolTypeList, startTime, endTime, null, null);
|
||||
log.info("[lucky24RecordStat] personal partitionId {} startTime {} endTime {} zoneIdHour {} personalList: {}",
|
||||
partitionId, DateTimeUtil.convertDate(startTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN),
|
||||
DateTimeUtil.convertDate(endTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN), zoneIdHour, JSON.toJSONString(personalList));
|
||||
@@ -113,7 +117,7 @@ public class Lucky24RecordService extends ServiceImpl<Lucky24RecordMapper, Lucky
|
||||
}
|
||||
}
|
||||
|
||||
List<Lucky24PersonalStat> personalByPoolTypeList = this.baseMapper.listPersonalByPoolType(partitionId, null, null, null, startTime, endTime, zoneIdHour);
|
||||
List<Lucky24PersonalStat> personalByPoolTypeList = this.baseMapper.listPersonalByPoolType(zoneDate, partitionId, poolTypeList, startTime, endTime, null, null);
|
||||
log.info("[lucky24RecordStat] personalByPoolType partitionId {} startTime {} endTime {} zoneIdHour {} personalByPoolTypeList: {}",
|
||||
partitionId, DateTimeUtil.convertDate(startTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN),
|
||||
DateTimeUtil.convertDate(endTime, DateTimeUtil.DEFAULT_DATETIME_PATTERN), zoneIdHour, JSON.toJSONString(personalByPoolTypeList));
|
||||
|
@@ -17,14 +17,14 @@ public class DiamondStatTask extends BaseTask {
|
||||
@Autowired
|
||||
private DiamondStatService service;
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?")
|
||||
@Scheduled(cron = "0 10 0 * * ?")
|
||||
public void statEn() {
|
||||
List<Integer> partitionIds = List.of(PartitionEnum.ENGLISH.getId(), PartitionEnum.CHINESE.getId(), PartitionEnum.ENGLISH2.getId());
|
||||
Date now = new Date();
|
||||
service.stat(partitionIds, now);
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 5 * * ?")
|
||||
@Scheduled(cron = "0 10 0 * * ?", zone = "Asia/Riyadh")
|
||||
public void statAr() {
|
||||
List<Integer> partitionIds = List.of(PartitionEnum.ARAB.getId(), PartitionEnum.TURKEY.getId());
|
||||
Date now = new Date();
|
||||
|
@@ -79,6 +79,9 @@ public class Lucky24Task {
|
||||
if (zdt.getDayOfYear() == hourAgo.getDayOfYear()){
|
||||
continue;
|
||||
}
|
||||
|
||||
String zoneDate = hourAgo.format(DateTimeUtil.dateFormatter);
|
||||
|
||||
bizExecutor.execute(() -> {
|
||||
// 获取当天的第一秒
|
||||
ZonedDateTime startOfDay = hourAgo.withHour(0)
|
||||
@@ -94,10 +97,10 @@ public class Lucky24Task {
|
||||
ZonedDateTime endOfDay = hourAgo.withHour(23)
|
||||
.withMinute(59)
|
||||
.withSecond(59)
|
||||
.withNano(999999999);
|
||||
.withNano(999);
|
||||
Date systemEndTime = DateTimeUtil.converLocalDateTimeToDate(endOfDay.withZoneSameInstant(ZoneId.systemDefault()).toLocalDateTime());
|
||||
|
||||
service.statDate(partitionInfo.getId(), systemStartTime, systemEndTime, zoneIdHour);
|
||||
service.statDate(partitionInfo.getId(), systemStartTime, systemEndTime, zoneIdHour, zoneDate);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user