|
|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
package com.accompany.business.service.guild;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.accompany.business.model.guild.GuildMember;
|
|
|
|
|
import com.accompany.business.model.guild.GuildMemberWeekLevelReward;
|
|
|
|
|
import com.accompany.business.model.guild.GuildMemberWeekLevelRewardRecord;
|
|
|
|
|
import com.accompany.business.mybatismapper.guild.GuildMemberWeekLevelRewardMapper;
|
|
|
|
@@ -11,19 +12,24 @@ import com.accompany.business.service.purse.UserPurseService;
|
|
|
|
|
import com.accompany.business.service.record.BillRecordService;
|
|
|
|
|
import com.accompany.business.vo.guild.GuildMemberWeekLevelRewardItemVo;
|
|
|
|
|
import com.accompany.business.vo.guild.GuildMemberWeekLevelRewardVo;
|
|
|
|
|
import com.accompany.business.vo.guild.GuildWeekLevelRFilterConfigVo;
|
|
|
|
|
import com.accompany.common.constant.Constant;
|
|
|
|
|
import com.accompany.common.redis.RedisKey;
|
|
|
|
|
import com.accompany.common.status.BusiStatus;
|
|
|
|
|
import com.accompany.common.utils.DateTimeUtil;
|
|
|
|
|
import com.accompany.common.utils.StringUtils;
|
|
|
|
|
import com.accompany.core.enumeration.BillObjTypeEnum;
|
|
|
|
|
import com.accompany.core.enumeration.I18nAlertEnum;
|
|
|
|
|
import com.accompany.core.enumeration.PartitionEnum;
|
|
|
|
|
import com.accompany.core.exception.ServiceException;
|
|
|
|
|
import com.accompany.core.service.SysConfService;
|
|
|
|
|
import com.accompany.core.util.I18NMessageSourceUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import org.redisson.api.RMap;
|
|
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
|
|
import org.redisson.codec.TypedJsonJacksonCodec;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
@@ -36,6 +42,8 @@ import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.accompany.common.constant.Constant.SysConfId.GUILD_WEEK_LEVEL_R_FILTER;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMemberWeekLevelRewardMapper, GuildMemberWeekLevelReward> {
|
|
|
|
|
|
|
|
|
@@ -49,32 +57,38 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
private SendSysMsgService sendSysMsgService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private GuildMemberWeekLevelRewardRecordMapper recordMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysConfService sysConfService;
|
|
|
|
|
|
|
|
|
|
private final String startMonday = "2025-09-01";
|
|
|
|
|
|
|
|
|
|
private int micDurationDayMax = 5;
|
|
|
|
|
private int micDurationDayMax = 1;
|
|
|
|
|
private int micDurationMax = 180 * 60;
|
|
|
|
|
private int micDurationMinutes = 180;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public GuildMemberWeekLevelRewardVo getThisWeekLevelRewardVo(Long uid, Integer partitionId) {
|
|
|
|
|
public GuildMemberWeekLevelRewardVo getThisWeekLevelRewardVo(GuildMember guildMember) {
|
|
|
|
|
|
|
|
|
|
Integer partitionId = guildMember.getPartitionId();
|
|
|
|
|
PartitionEnum partitionEnum = PartitionEnum.getByPartitionId(partitionId);
|
|
|
|
|
|
|
|
|
|
List<GuildMemberWeekLevelReward> levelRewardList = lambdaQuery()
|
|
|
|
|
.eq(GuildMemberWeekLevelReward::getPartitionId, partitionId)
|
|
|
|
|
.orderByAsc(GuildMemberWeekLevelReward::getLevel)
|
|
|
|
|
.list();
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)){
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZonedDateTime zdt = DateTimeUtil.getDateTimeByZoneId(partitionEnum.getZoneId());
|
|
|
|
|
return getVo(uid, partitionId, zdt, levelRewardList, true, true);
|
|
|
|
|
return getVo(guildMember, zdt, levelRewardList, true, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private GuildMemberWeekLevelRewardVo getVo(Long guildMemberId, Integer partitionId, ZonedDateTime zdt,
|
|
|
|
|
private GuildMemberWeekLevelRewardVo getVo(GuildMember guildMember, ZonedDateTime zdt,
|
|
|
|
|
List<GuildMemberWeekLevelReward> levelRewardList, boolean needFilter, boolean thisWeek) {
|
|
|
|
|
|
|
|
|
|
Integer partitionId = guildMember.getPartitionId();
|
|
|
|
|
Long guildMemberId = guildMember.getId();
|
|
|
|
|
Long uid = guildMember.getUid();
|
|
|
|
|
GuildMemberWeekLevelRewardVo vo = new GuildMemberWeekLevelRewardVo();
|
|
|
|
|
vo.setCurLevel(null);
|
|
|
|
|
vo.setCurLevelName("-");
|
|
|
|
@@ -86,7 +100,7 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
|
|
|
|
|
ZonedDateTime mondayTime = zdt.with(DayOfWeek.MONDAY).withHour(0).withMinute(0).withSecond(0);
|
|
|
|
|
ZonedDateTime sundayTime = zdt.with(DayOfWeek.SUNDAY).withHour(23).withMinute(59).withSecond(59);
|
|
|
|
|
String dateRange = String.join("-",
|
|
|
|
|
String dateRange = String.join("-" ,
|
|
|
|
|
mondayTime.format(DateTimeUtil.monthWithoutZeroDateFormatter),
|
|
|
|
|
sundayTime.format(DateTimeUtil.monthWithoutZeroDateFormatter));
|
|
|
|
|
vo.setDateRange(dateRange);
|
|
|
|
@@ -102,18 +116,18 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
vo.setCountDownSecond(secondsDiff);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String key = String.join("_", guildMemberId.toString(), "process");
|
|
|
|
|
String key = String.join("_" , guildMemberId.toString(), "process");
|
|
|
|
|
Set<String> keySet = levelRewardList.stream()
|
|
|
|
|
.map(GuildMemberWeekLevelReward::getLevel)
|
|
|
|
|
.map(level->String.join("_", guildMemberId.toString(), level.toString()))
|
|
|
|
|
.map(level -> String.join("_" , guildMemberId.toString(), level.toString()))
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
keySet.add(key);
|
|
|
|
|
Set<String> bonusKeySet = levelRewardList.stream()
|
|
|
|
|
.map(GuildMemberWeekLevelReward::getLevel)
|
|
|
|
|
.map(level->String.join("_", guildMemberId.toString(), level.toString(), "bonus"))
|
|
|
|
|
.map(level -> String.join("_" , guildMemberId.toString(), level.toString(), "bonus"))
|
|
|
|
|
.collect(Collectors.toSet());
|
|
|
|
|
keySet.addAll(bonusKeySet);
|
|
|
|
|
String bonusKey = String.join("_", guildMemberId.toString(), "bonus", "process");
|
|
|
|
|
String bonusKey = String.join("_" , guildMemberId.toString(), "bonus" , "process");
|
|
|
|
|
keySet.add(bonusKey);
|
|
|
|
|
|
|
|
|
|
String mondayDateStr = mondayTime.format(DateTimeUtil.dateFormatter);
|
|
|
|
@@ -122,47 +136,58 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
int userBonusProcess = Math.min(userProcessMap.getOrDefault(bonusKey, 0).intValue(), micDurationDayMax);
|
|
|
|
|
|
|
|
|
|
vo.setBonusPreMaxNum(0);
|
|
|
|
|
vo.setBonusProcessNum(userBonusProcess);
|
|
|
|
|
vo.setBonusMaxNum(micDurationDayMax);
|
|
|
|
|
String dayDurationKey = String.join("_" , guildMemberId.toString(), zdt.format(DateTimeUtil.dateFormatter));
|
|
|
|
|
Integer micSeconds = getDayDurationMap(partitionId, mondayDateStr).getOrDefault(dayDurationKey, 0);
|
|
|
|
|
vo.setBonusProcessNum(micSeconds / 60);
|
|
|
|
|
vo.setBonusMaxNum(micDurationMinutes);
|
|
|
|
|
|
|
|
|
|
List<GuildMemberWeekLevelRewardItemVo> itemVoList = new ArrayList<>();
|
|
|
|
|
vo.setItemList(itemVoList);
|
|
|
|
|
|
|
|
|
|
Integer curLevel = null, preLevel = null;
|
|
|
|
|
String curLevelName = "-", preLevelName = "-";
|
|
|
|
|
String curLevelName = "-" , preLevelName = "-";
|
|
|
|
|
|
|
|
|
|
BigDecimal preLevelMaxNum = BigDecimal.ZERO;
|
|
|
|
|
BigDecimal remainUserProcess = userProcess;
|
|
|
|
|
|
|
|
|
|
if(needFilter) {//公会首页过滤R档位
|
|
|
|
|
GuildMemberWeekLevelRewardRecord record = recordMapper.selectOne(Wrappers.<GuildMemberWeekLevelRewardRecord>lambdaQuery()
|
|
|
|
|
.eq(GuildMemberWeekLevelRewardRecord::getUid, uid)
|
|
|
|
|
.eq(GuildMemberWeekLevelRewardRecord::getMonday, mondayDateStr)
|
|
|
|
|
.eq(GuildMemberWeekLevelRewardRecord::getLevel, 0));
|
|
|
|
|
|
|
|
|
|
boolean filterLevelR = record != null && !record.getGuildMemberId().equals(guildMemberId);//过滤R档位(防薅羊毛)
|
|
|
|
|
filterLevelR = filterLevelR || this.calFilterLevelR(guildMember);
|
|
|
|
|
|
|
|
|
|
if (needFilter || filterLevelR) {//公会首页过滤R档位
|
|
|
|
|
levelRewardList.removeIf(levelReward -> levelReward.getLevel() == 0);
|
|
|
|
|
}
|
|
|
|
|
for (GuildMemberWeekLevelReward levelReward: levelRewardList) {
|
|
|
|
|
|
|
|
|
|
for (GuildMemberWeekLevelReward levelReward : levelRewardList) {
|
|
|
|
|
String levelId = levelReward.getLevel().toString();
|
|
|
|
|
String id = String.join("_", guildMemberId.toString(), mondayDateStr, levelId);
|
|
|
|
|
String statusId = String.join("_", guildMemberId.toString(), levelId);
|
|
|
|
|
String id = String.join("_" , guildMemberId.toString(), mondayDateStr, levelId);
|
|
|
|
|
String statusId = String.join("_" , guildMemberId.toString(), levelId);
|
|
|
|
|
|
|
|
|
|
BigDecimal processNum = remainUserProcess.compareTo(levelReward.getProcessNum()) >= 0?
|
|
|
|
|
levelReward.getProcessNum() : remainUserProcess.compareTo(BigDecimal.ZERO) < 0?
|
|
|
|
|
BigDecimal.ZERO: remainUserProcess;
|
|
|
|
|
Byte status = userProcessMap.containsKey(statusId)?
|
|
|
|
|
userProcessMap.get(statusId).byteValue():
|
|
|
|
|
processNum.compareTo(levelReward.getProcessNum()) >= 0? Constant.status.valid: Constant.status.delete;
|
|
|
|
|
BigDecimal processNum = remainUserProcess.compareTo(levelReward.getProcessNum()) >= 0 ?
|
|
|
|
|
levelReward.getProcessNum() : remainUserProcess.compareTo(BigDecimal.ZERO) < 0 ?
|
|
|
|
|
BigDecimal.ZERO : remainUserProcess;
|
|
|
|
|
Byte status = userProcessMap.containsKey(statusId) ?
|
|
|
|
|
userProcessMap.get(statusId).byteValue() :
|
|
|
|
|
processNum.compareTo(levelReward.getProcessNum()) >= 0 ? Constant.status.valid : Constant.status.delete;
|
|
|
|
|
|
|
|
|
|
String bonusStatusId = String.join("_", guildMemberId.toString(), levelId, "bonus");
|
|
|
|
|
Byte bonusStatus = userProcessMap.containsKey(bonusStatusId)?
|
|
|
|
|
userProcessMap.get(bonusStatusId).byteValue():
|
|
|
|
|
userBonusProcess >= levelReward.getMicValidDay() && !status.equals(Constant.status.delete)?
|
|
|
|
|
Constant.status.valid: Constant.status.delete;
|
|
|
|
|
String bonusStatusId = String.join("_" , guildMemberId.toString(), levelId, "bonus");
|
|
|
|
|
Byte bonusStatus = userProcessMap.containsKey(bonusStatusId) ?
|
|
|
|
|
userProcessMap.get(bonusStatusId).byteValue() :
|
|
|
|
|
userBonusProcess >= levelReward.getMicValidDay() && !status.equals(Constant.status.delete) ?
|
|
|
|
|
Constant.status.valid : Constant.status.delete;
|
|
|
|
|
|
|
|
|
|
if (!needFilter && !thisWeek
|
|
|
|
|
&& !CollectionUtils.isEmpty(itemVoList)
|
|
|
|
|
&& !Constant.status.valid.equals(status)
|
|
|
|
|
&& !Constant.status.invalid.equals(status)){
|
|
|
|
|
&& !Constant.status.invalid.equals(status)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (remainUserProcess.compareTo(BigDecimal.ZERO) >= 0){
|
|
|
|
|
if (remainUserProcess.compareTo(BigDecimal.ZERO) >= 0) {
|
|
|
|
|
curLevel = levelReward.getLevel();
|
|
|
|
|
curLevelName = levelReward.getLevelName();
|
|
|
|
|
} else if (needFilter) {
|
|
|
|
@@ -186,6 +211,9 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
itemVo.setBonusPreMaxNum(0);
|
|
|
|
|
itemVo.setBonusRewardNum(levelReward.getBonusNum());
|
|
|
|
|
itemVo.setBonusStatus(bonusStatus);
|
|
|
|
|
if (bonusStatus.equals(Constant.status.valid) || bonusStatus.equals(Constant.status.invalid)) {
|
|
|
|
|
vo.setBonusProcessNum(micDurationMinutes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
itemVoList.add(itemVo);
|
|
|
|
|
|
|
|
|
@@ -195,21 +223,21 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
preLevel = levelReward.getLevel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(vo.getItemList())){
|
|
|
|
|
if (CollectionUtils.isEmpty(vo.getItemList())) {
|
|
|
|
|
return vo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GuildMemberWeekLevelRewardItemVo curLevelReward = null;
|
|
|
|
|
vo.setCurLevel(curLevel);
|
|
|
|
|
vo.setCurLevelName(curLevelName);
|
|
|
|
|
for (GuildMemberWeekLevelRewardItemVo voItem: vo.getItemList()){
|
|
|
|
|
if (!voItem.getLevel().equals(curLevel)){
|
|
|
|
|
for (GuildMemberWeekLevelRewardItemVo voItem : vo.getItemList()) {
|
|
|
|
|
if (!voItem.getLevel().equals(curLevel)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
curLevelReward = voItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (null == curLevelReward){
|
|
|
|
|
if (null == curLevelReward) {
|
|
|
|
|
curLevelReward = itemVoList.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -241,33 +269,33 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GuildMemberWeekLevelReward levelReward = levelRewardList.stream().filter(item -> item.getLevel().equals(level)).findFirst().orElse(null);
|
|
|
|
|
if (null == levelReward){
|
|
|
|
|
if (null == levelReward) {
|
|
|
|
|
throw new ServiceException(BusiStatus.PARAMERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BigDecimal needProcessNum = levelRewardList.stream().map(GuildMemberWeekLevelReward::getProcessNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
String levelId = levelReward.getLevel().toString();
|
|
|
|
|
String userProcessKey = String.join("_", guildMemberId.toString(), "process");
|
|
|
|
|
String statusId = String.join("_", guildMemberId.toString(), levelId);
|
|
|
|
|
String bonusStatusId = String.join("_", guildMemberId.toString(), levelId, "bonus");
|
|
|
|
|
String userProcessKey = String.join("_" , guildMemberId.toString(), "process");
|
|
|
|
|
String statusId = String.join("_" , guildMemberId.toString(), levelId);
|
|
|
|
|
String bonusStatusId = String.join("_" , guildMemberId.toString(), levelId, "bonus");
|
|
|
|
|
|
|
|
|
|
Set<String> keySet = Set.of(userProcessKey, statusId, bonusStatusId);
|
|
|
|
|
|
|
|
|
|
RMap<String, Number> processMap = getWeekMap(monday, partitionId);
|
|
|
|
|
Map<String, Number> userProcessMap = processMap.getAll(keySet);
|
|
|
|
|
BigDecimal userProcess = new BigDecimal(userProcessMap.getOrDefault(userProcessKey, BigDecimal.ZERO).toString());
|
|
|
|
|
if (needProcessNum.compareTo(userProcess) > 0){
|
|
|
|
|
if (needProcessNum.compareTo(userProcess) > 0) {
|
|
|
|
|
throw new ServiceException(BusiStatus.PARAMERROR);
|
|
|
|
|
}
|
|
|
|
|
Byte status = userProcessMap.getOrDefault(statusId, Constant.status.delete).byteValue();
|
|
|
|
|
if (!isBonus){
|
|
|
|
|
if (!Constant.status.delete.equals(status) || !processMap.fastPutIfAbsent(statusId, Constant.status.invalid)){
|
|
|
|
|
if (!isBonus) {
|
|
|
|
|
if (!Constant.status.delete.equals(status) || !processMap.fastPutIfAbsent(statusId, Constant.status.invalid)) {
|
|
|
|
|
throw new ServiceException(BusiStatus.CHARGE_RECEICVE_REPEAT);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Byte bonusStatus = userProcessMap.getOrDefault(bonusStatusId, Constant.status.delete).byteValue();
|
|
|
|
|
if (Constant.status.delete.equals(status) || !Constant.status.delete.equals(bonusStatus) || !processMap.fastPutIfAbsent(bonusStatusId, Constant.status.invalid)){
|
|
|
|
|
if (Constant.status.delete.equals(status) || !Constant.status.delete.equals(bonusStatus) || !processMap.fastPutIfAbsent(bonusStatusId, Constant.status.invalid)) {
|
|
|
|
|
throw new ServiceException(BusiStatus.CHARGE_RECEICVE_REPEAT);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -279,7 +307,7 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
.eq(GuildMemberWeekLevelRewardRecord::getGuildMemberId, guildMemberId)
|
|
|
|
|
.eq(GuildMemberWeekLevelRewardRecord::getMonday, monday)
|
|
|
|
|
.eq(GuildMemberWeekLevelRewardRecord::getLevel, levelReward.getLevel()));
|
|
|
|
|
if (null == record){
|
|
|
|
|
if (null == record) {
|
|
|
|
|
record = new GuildMemberWeekLevelRewardRecord();
|
|
|
|
|
record.setGuildMemberId(guildMemberId);
|
|
|
|
|
record.setUid(uid);
|
|
|
|
@@ -292,7 +320,7 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
isInsert = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isBonus){
|
|
|
|
|
if (isBonus) {
|
|
|
|
|
record.setMicValidDay(levelReward.getMicValidDay());
|
|
|
|
|
record.setBonusNum(levelReward.getBonusNum());
|
|
|
|
|
} else {
|
|
|
|
@@ -300,7 +328,7 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
record.setRewardNum(levelReward.getRewardNum());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isInsert){
|
|
|
|
|
if (isInsert) {
|
|
|
|
|
record.setCreateTime(new Date());
|
|
|
|
|
recordMapper.insert(record);
|
|
|
|
|
} else {
|
|
|
|
@@ -317,13 +345,12 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
processMap.expireAsync(30L, TimeUnit.DAYS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<GuildMemberWeekLevelRewardVo> listHistory(Long familyMemberId, Integer partitionId) {
|
|
|
|
|
|
|
|
|
|
public List<GuildMemberWeekLevelRewardVo> listHistory(GuildMember guildMember, Integer partitionId) {
|
|
|
|
|
List<GuildMemberWeekLevelReward> levelRewardList = lambdaQuery()
|
|
|
|
|
.eq(GuildMemberWeekLevelReward::getPartitionId, partitionId)
|
|
|
|
|
.orderByAsc(GuildMemberWeekLevelReward::getLevel)
|
|
|
|
|
.list();
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)){
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -338,27 +365,27 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String mondayDate = t.with(DayOfWeek.MONDAY).format(DateTimeUtil.dateFormatter);
|
|
|
|
|
if (mondayDate.compareTo(startMonday) < 0){
|
|
|
|
|
if (mondayDate.compareTo(startMonday) < 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String monday = t.with(DayOfWeek.MONDAY).format(DateTimeUtil.monthWithoutZeroDateFormatter);
|
|
|
|
|
String sunday = t.with(DayOfWeek.SUNDAY).format(DateTimeUtil.monthWithoutZeroDateFormatter);
|
|
|
|
|
String dateRange = String.join("-", monday, sunday);
|
|
|
|
|
String dateRange = String.join("-" , monday, sunday);
|
|
|
|
|
dateRangeList.add(dateRange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, GuildMemberWeekLevelRewardVo> map = timeList.parallelStream().map(t->
|
|
|
|
|
getVo(familyMemberId, partitionId, t, levelRewardList, false, t.equals(zdt)))
|
|
|
|
|
.collect(Collectors.toMap(GuildMemberWeekLevelRewardVo::getDateRange, t->t));
|
|
|
|
|
Map<String, GuildMemberWeekLevelRewardVo> map = timeList.parallelStream().map(t ->
|
|
|
|
|
getVo(guildMember, t, levelRewardList, false, t.equals(zdt)))
|
|
|
|
|
.collect(Collectors.toMap(GuildMemberWeekLevelRewardVo::getDateRange, t -> t));
|
|
|
|
|
|
|
|
|
|
return dateRangeList.stream()
|
|
|
|
|
.map(map::get).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void sendReward(Long uid, GuildMemberWeekLevelReward levelReward, Boolean isBonus){
|
|
|
|
|
double rewardNum = !isBonus? levelReward.getRewardNum().doubleValue(): levelReward.getBonusNum().doubleValue();
|
|
|
|
|
String objId = !isBonus? levelReward.getLevel().toString(): String.join("_", levelReward.getLevel().toString(), "bonus");
|
|
|
|
|
public void sendReward(Long uid, GuildMemberWeekLevelReward levelReward, Boolean isBonus) {
|
|
|
|
|
double rewardNum = !isBonus ? levelReward.getRewardNum().doubleValue() : levelReward.getBonusNum().doubleValue();
|
|
|
|
|
String objId = !isBonus ? levelReward.getLevel().toString() : String.join("_" , levelReward.getLevel().toString(), "bonus");
|
|
|
|
|
userPurseService.addDiamond(uid, levelReward.getRewardNum().doubleValue(), BillObjTypeEnum.GUILD_MEMBER_WEEK_LEVEL_REWARD,
|
|
|
|
|
(userPurse -> billRecordService.insertGeneralBillRecord(uid, objId, BillObjTypeEnum.GUILD_MEMBER_WEEK_LEVEL_REWARD, rewardNum, userPurse)));
|
|
|
|
|
}
|
|
|
|
@@ -368,11 +395,11 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
.eq(GuildMemberWeekLevelReward::getPartitionId, partitionId)
|
|
|
|
|
.orderByAsc(GuildMemberWeekLevelReward::getLevel)
|
|
|
|
|
.list();
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)){
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String key = String.join("_", guildMemberId.toString(), "process");
|
|
|
|
|
String key = String.join("_" , guildMemberId.toString(), "process");
|
|
|
|
|
RMap<String, Number> processMap = getWeekMap(monday, partitionId);
|
|
|
|
|
BigDecimal num = new BigDecimal(totalNum.toString());
|
|
|
|
|
BigDecimal after = new BigDecimal(processMap.addAndGet(key, num).toString());
|
|
|
|
@@ -382,12 +409,12 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
processMap.expireAsync(Duration.ofDays(45L));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RMap<String, Number> getWeekMap(String monday, Integer partitionId){
|
|
|
|
|
public RMap<String, Number> getWeekMap(String monday, Integer partitionId) {
|
|
|
|
|
return redissonClient.getMap(RedisKey.guild_member_week_level_reward.getKey(monday, partitionId.toString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addBonusProcess(String monday, Integer partitionId, Long guildMemberId, Integer before, Integer after) {
|
|
|
|
|
if (before >= micDurationMax || after < micDurationMax){
|
|
|
|
|
if (before >= micDurationMax || after < micDurationMax) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -395,11 +422,11 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
.eq(GuildMemberWeekLevelReward::getPartitionId, partitionId)
|
|
|
|
|
.orderByAsc(GuildMemberWeekLevelReward::getLevel)
|
|
|
|
|
.list();
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)){
|
|
|
|
|
if (CollectionUtils.isEmpty(levelRewardList)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String key = String.join("_", guildMemberId.toString(), "bonus", "process");
|
|
|
|
|
String key = String.join("_" , guildMemberId.toString(), "bonus" , "process");
|
|
|
|
|
RMap<String, Number> processMap = getWeekMap(monday, partitionId);
|
|
|
|
|
Integer bonusAfter = processMap.addAndGet(key, 1).intValue();
|
|
|
|
|
Integer bonusBefore = bonusAfter - 1;
|
|
|
|
@@ -412,10 +439,9 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
|
|
|
|
|
public void addDayDuration(Integer partitionId, String date, Long guildMemberId, Integer seconds) {
|
|
|
|
|
String monday = DateUtil.formatDate(DateUtil.beginOfWeek(DateUtil.parseDate(date)));
|
|
|
|
|
String cacheKey = RedisKey.guild_member_room_mic_day_duration.getKey(monday, partitionId.toString());
|
|
|
|
|
RMap<String, Integer> countMap = redissonClient.getMap(cacheKey);
|
|
|
|
|
RMap<String, Integer> countMap = getDayDurationMap(partitionId, monday);
|
|
|
|
|
|
|
|
|
|
String key = String.join("_", guildMemberId.toString(), date);
|
|
|
|
|
String key = String.join("_" , guildMemberId.toString(), date);
|
|
|
|
|
Integer after = countMap.addAndGet(key, seconds);
|
|
|
|
|
Integer before = after - seconds;
|
|
|
|
|
|
|
|
|
@@ -425,4 +451,29 @@ public class GuildMemberWeekLevelRewardV2Service extends ServiceImpl<GuildMember
|
|
|
|
|
countMap.expireAsync(Duration.ofDays(14));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private RMap<String, Integer> getDayDurationMap(Integer partitionId, String monday) {
|
|
|
|
|
String cacheKey = RedisKey.guild_member_room_mic_day_duration.getKey(monday, partitionId.toString());
|
|
|
|
|
return redissonClient.getMap(cacheKey, new TypedJsonJacksonCodec(String.class, Integer.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GuildWeekLevelRFilterConfigVo getFilterConfig(Integer partitionId) {
|
|
|
|
|
String confValueById = sysConfService.getSysConfValueById(GUILD_WEEK_LEVEL_R_FILTER);
|
|
|
|
|
if (StringUtils.isEmpty(confValueById)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return JSONObject.parseObject(confValueById, GuildWeekLevelRFilterConfigVo.class).getByPartitionId(partitionId);
|
|
|
|
|
}
|
|
|
|
|
private Boolean calFilterLevelR(GuildMember guildMember) {
|
|
|
|
|
GuildWeekLevelRFilterConfigVo filterConfig = this.getFilterConfig(guildMember.getPartitionId());
|
|
|
|
|
if (filterConfig == null){
|
|
|
|
|
return Boolean.FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtils.isEmpty(filterConfig.getGuildIds()) || !filterConfig.getGuildIds().contains(guildMember.getGuildId())) {
|
|
|
|
|
return Boolean.FALSE;
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtils.isEmpty(filterConfig.getUids()) || !filterConfig.getUids().contains(guildMember.getUid())) {
|
|
|
|
|
}
|
|
|
|
|
return Boolean.TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|