feat(任务): VIP赠送金币 添加查询管理员赠送逻辑

This commit is contained in:
tianfeng 2025-09-11 19:27:32 +08:00
parent c9fc842603
commit 9aeb964863
5 changed files with 42 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package com.red.circle.other.app.scheduler;
import com.alibaba.fastjson.JSON;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.enums.SendPropsOrigin;
import com.red.circle.component.redis.annotation.TaskCacheLock;
@ -14,10 +15,12 @@ import com.red.circle.other.infra.database.mongo.service.activity.RoomFanVotesAc
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRuleConfig;
import com.red.circle.other.infra.database.rds.entity.props.PropsBackpack;
import com.red.circle.other.infra.database.rds.entity.props.PropsNobleVipAbility;
import com.red.circle.other.infra.database.rds.entity.props.RunningWaterUserProps;
import com.red.circle.other.infra.database.rds.enums.CacheKeysEnum;
import com.red.circle.other.infra.database.rds.service.activity.PropsActivityRuleConfigService;
import com.red.circle.other.infra.database.rds.service.family.FamilyDailyTaskTriggerRecordService;
import com.red.circle.other.infra.database.rds.service.props.PropsBackpackService;
import com.red.circle.other.infra.database.rds.service.props.RunningWaterUserPropsService;
import com.red.circle.other.infra.utils.ZonedDateTimeUtils;
import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum;
import com.red.circle.other.inner.enums.material.PropsCommodityType;
@ -25,11 +28,11 @@ import com.red.circle.other.inner.model.dto.material.props.PropsStoreCommodity;
import com.red.circle.tool.core.collection.CollectionUtils;
import com.google.common.collect.Lists;
import java.time.Duration;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.red.circle.tool.core.date.LocalDateTimeUtils;
import com.red.circle.tool.core.tuple.ImmutableKeyValuePair;
import com.red.circle.wallet.inner.endpoint.wallet.WalletGoldClient;
import com.red.circle.wallet.inner.model.cmd.GoldReceiptCmd;
@ -56,10 +59,11 @@ public class DailyTask {
private final PropsActivityRuleConfigService propsActivityRuleConfigService;
private final RoomFanVotesActivityCountService roomFanVotesActivityCountService;
private final FamilyDailyTaskTriggerRecordService familyDailyTaskTriggerRecordService;
private final PropsStoreGateway propsStoreGateway;
private final PropsBackpackService propsBackpackService;
private final WalletGoldClient walletGoldClient;
private final PropsPurchasingCmdExe propsPurchasingCmdExe;
private final PropsStoreGateway propsStoreGateway;
private final RunningWaterUserPropsService runningWaterUserPropsService;
private final PropsBackpackService propsBackpackService;
private final WalletGoldClient walletGoldClient;
private final PropsPurchasingCmdExe propsPurchasingCmdExe;
/**
* 每日处理数据.
@ -233,9 +237,17 @@ public class DailyTask {
List<Long> processedUsers = Lists.newArrayList(); // 记录已处理的用户避免重复发放
commodityList.forEach(propsStoreCommodity -> {
List<Long> userIds = propsBackpackService.listUsersByNobleVipAndPropsId(PropsCommodityType.NOBLE_VIP, propsStoreCommodity.getPropsResources().getId());
List<PropsBackpack> propsBackpackList = propsBackpackService.listUsersByNobleVipAndPropsId(PropsCommodityType.NOBLE_VIP, propsStoreCommodity.getPropsResources().getId());
log.info("VIP用户: {}", JSON.toJSONString(propsStoreCommodity));
// 给每个用户发送奖励排除已处理的用户
List<Long> userIds = propsBackpackList.stream().map(e -> {
RunningWaterUserProps runningWaterUserProps = runningWaterUserPropsService.selectRunningWaterUserProps(e.getType(), e.getUserId(), e.getPropsId(),
LocalDateTimeUtils.format(e.getCreateTime().toLocalDateTime(), "yyyy-MM-dd HH:mm"));
return runningWaterUserProps == null ? e.getUserId() : null;
}).filter(Objects::nonNull).toList();
log.info("userIds: {}", JSON.toJSONString(userIds));
// 给每个用户发送奖励排除已处理的用户
for (Long userId : userIds) {
if (!processedUsers.contains(userId)) {
ResultResponse<WalletReceiptResDTO> res = walletGoldClient.changeBalance(GoldReceiptCmd.builder()
@ -260,6 +272,8 @@ public class DailyTask {
}
processedUsers.add(userId); // 标记为已处理
} else {
log.warn("已处理过不再重复处理: {}", userId);
}
}
});

View File

@ -216,6 +216,6 @@ public interface PropsBackpackService extends BaseService<PropsBackpack> {
* @param propsId 道具ID
* @return 用户列表
*/
List<Long> listUsersByNobleVipAndPropsId(PropsCommodityType propsType, Long propsId);
List<PropsBackpack> listUsersByNobleVipAndPropsId(PropsCommodityType propsType, Long propsId);
}

View File

@ -15,4 +15,10 @@ import com.red.circle.other.inner.model.cmd.material.RunningWaterUserPropsQryCmd
public interface RunningWaterUserPropsService extends BaseService<RunningWaterUserProps> {
PageResult<RunningWaterUserProps> pageRunningWaterUserProps(RunningWaterUserPropsQryCmd query);
/**
* 同分钟内赠送的VIP
*/
RunningWaterUserProps selectRunningWaterUserProps(String type, Long userId, Long propsId, String createTime);
}

View File

@ -408,14 +408,14 @@ public class PropsBackpackServiceImpl extends
}
@Override
public List<Long> listUsersByNobleVipAndPropsId(PropsCommodityType propsType, Long propsId) {
public List<PropsBackpack> listUsersByNobleVipAndPropsId(PropsCommodityType propsType, Long propsId) {
return query()
.eq(PropsBackpack::getType, propsType)
.eq(PropsBackpack::getPropsId, propsId)
.eq(PropsBackpack::getUseProps, Boolean.TRUE)
.gt(PropsBackpack::getExpireTime, TimestampUtils.now())
.list()
.stream()
.map(PropsBackpack::getUserId)
.collect(Collectors.toList());
}

View File

@ -44,4 +44,14 @@ public class RunningWaterUserPropsServiceImpl extends
.orderByDesc(RunningWaterUserProps::getCreateTime)
.page(query.getPageQuery());
}
@Override
public RunningWaterUserProps selectRunningWaterUserProps(String type, Long userId, Long propsId, String createTime) {
return query()
.eq(RunningWaterUserProps::getType, type)
.eq(RunningWaterUserProps::getUserId, userId)
.eq(RunningWaterUserProps::getPropsId, propsId)
.apply("DATE_FORMAT(create_time, '%Y-%m-%d %H:%i') = {0}", createTime)
.last("LIMIT 1").getOne();
}
}