日常任务-新增任务
This commit is contained in:
@@ -18,6 +18,7 @@ public interface DailyTaskConstant {
|
||||
play_game,//游戏种类
|
||||
recv_gold_num,//收礼金币
|
||||
send_gold_num,//送礼金币
|
||||
send_gift_num,//送礼数量
|
||||
task_config,//任务配置
|
||||
up_mic_coin_ip_limit,//主播上麦领取ip限制
|
||||
up_mic_coin_uid_limit,//主播上麦领取ip限制
|
||||
|
@@ -9,14 +9,18 @@ public enum DailyTaskTypeEnum {
|
||||
CHARGE_GOLD_NUM("CHARGE_GOLD_NUM"),//充值7000
|
||||
CHARGE_GOLD_NUM_5("CHARGE_GOLD_NUM"),//充值35000
|
||||
CHARGE_GOLD_NUM_10("CHARGE_GOLD_NUM"),//充值70000
|
||||
CHARGE_GOLD_NUM_50("CHARGE_GOLD_NUM"),//充值350000
|
||||
CHARGE_GOLD_NUM_100("CHARGE_GOLD_NUM"),//充值700000
|
||||
ROOM_SEND_GIFT("ROOM_SEND_GIFT"),//房间送礼
|
||||
RECV_LUCKY_GIFT("RECV_LUCKY_GIFT"),//收到Lucky/Bravo礼物
|
||||
RECV_NOMAL_GIFT("RECV_NOMAL_GIFT"),//收到普通礼物
|
||||
RECV_NOMAL_GIFT_GOLD("RECV_NOMAL_GIFT_GOLD"),//收到礼物(价值超过2w金币)
|
||||
UP_MIC_COIN("UP_MIC_COIN"),//上麦聊天(获得金币)
|
||||
UP_MIC_COIN("UP_MIC_COIN"),//周上麦聊天(获得金币)
|
||||
ROOM_DAY_DIAMOND("ROOM_DAY_DIAMOND"),//房间日流水奖励
|
||||
GUILD_WEEK_REWARD("GUILD_WEEK_REWARD"),//公会周奖励
|
||||
ROOM_SEND_NOMAL_GIFT_GOLD("ROOM_SEND_NOMAL_GIFT_GOLD"),//房间送普通礼物礼对应金币
|
||||
ROOM_SEND_LUCKY_NUM("ROOM_SEND_LUCKY_NUM"),//送出77个lucky礼物
|
||||
ROOM_SEND_BRAVO_NUM("ROOM_SEND_BRAVO_NUM"),//送出77个BRAVO礼物
|
||||
;
|
||||
|
||||
private String handlerType;
|
||||
|
@@ -19,6 +19,7 @@ public class DailyProgressContext {
|
||||
private String gameId;
|
||||
private Long chargeGoldNum;
|
||||
private Byte giftType;
|
||||
private Integer giftNum;
|
||||
private Long recvGoldNum;
|
||||
private Date createTime;
|
||||
|
||||
|
@@ -22,8 +22,10 @@ import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RMap;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.client.codec.IntegerCodec;
|
||||
import org.redisson.client.codec.LongCodec;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -31,8 +33,7 @@ import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.accompany.business.constant.dailytask.DailyTaskConstant.RedisKey.task_receive_status;
|
||||
import static com.accompany.business.constant.dailytask.DailyTaskConstant.RedisKey.task_status;
|
||||
import static com.accompany.business.constant.dailytask.DailyTaskConstant.RedisKey.*;
|
||||
import static com.accompany.core.enumeration.BillObjTypeEnum.DAILY_TASK_DIAMOND;
|
||||
import static com.accompany.core.enumeration.BillObjTypeEnum.DAILY_TASK_GOLD;
|
||||
|
||||
@@ -211,4 +212,8 @@ public abstract class AbstractDailyTaskHandler implements DailyTaskHandler {
|
||||
protected Integer getReceiveExpireDay() {
|
||||
return EXPIRE_DAY;
|
||||
}
|
||||
|
||||
protected RMap<Long, Long> sendGiftNum(DailyTaskTypeEnum dailyTaskTypeEnum, Integer partitionId, String todayDate) {
|
||||
return redissonClient.getMap(send_gift_num.getKey(partitionId.toString(), dailyTaskTypeEnum.name(), todayDate), LongCodec.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
@@ -54,6 +54,22 @@ public class ChargeGoldNumHandler extends AbstractDailyTaskHandler {
|
||||
taskStatus(uid, todayDate, DailyTaskTypeEnum.CHARGE_GOLD_NUM_10).set(1, Duration.ofDays(EXPIRE_DAY));
|
||||
}
|
||||
}
|
||||
|
||||
taskStatus = taskStatus(uid, todayDate, DailyTaskTypeEnum.CHARGE_GOLD_NUM_50);
|
||||
if (!taskStatus.isExists()) {
|
||||
DailyTaskConfig dailyTaskConfig = dailyTaskConfigService.getByPartTaskKey(partitionId, DailyTaskTypeEnum.CHARGE_GOLD_NUM_50.name());
|
||||
if (dailyTaskConfig != null && chargeGold >= dailyTaskConfig.getReachNum()) {
|
||||
taskStatus(uid, todayDate, DailyTaskTypeEnum.CHARGE_GOLD_NUM_50).set(1, Duration.ofDays(EXPIRE_DAY));
|
||||
}
|
||||
}
|
||||
|
||||
taskStatus = taskStatus(uid, todayDate, DailyTaskTypeEnum.CHARGE_GOLD_NUM_100);
|
||||
if (!taskStatus.isExists()) {
|
||||
DailyTaskConfig dailyTaskConfig = dailyTaskConfigService.getByPartTaskKey(partitionId, DailyTaskTypeEnum.CHARGE_GOLD_NUM_100.name());
|
||||
if (dailyTaskConfig != null && chargeGold >= dailyTaskConfig.getReachNum()) {
|
||||
taskStatus(uid, todayDate, DailyTaskTypeEnum.CHARGE_GOLD_NUM_100).set(1, Duration.ofDays(EXPIRE_DAY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,57 @@
|
||||
package com.accompany.business.service.dailytask.handler;
|
||||
|
||||
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
|
||||
import com.accompany.business.model.dailytask.DailyTaskConfig;
|
||||
import com.accompany.business.service.dailytask.AbstractDailyTaskHandler;
|
||||
import com.accompany.business.service.dailytask.annotation.DailyTaskHandlerType;
|
||||
import com.accompany.business.vo.dailytask.DailyProgressContext;
|
||||
import com.accompany.business.vo.dailytask.DailyTaskContext;
|
||||
import com.accompany.business.vo.dailytask.DailyTaskVo;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RMap;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import static com.accompany.business.constant.dailytask.DailyTaskTypeEnum.ROOM_SEND_BRAVO_NUM;
|
||||
|
||||
@Component
|
||||
@DailyTaskHandlerType(ROOM_SEND_BRAVO_NUM)
|
||||
public class RoomSendBravoNumHandler extends AbstractDailyTaskHandler {
|
||||
|
||||
@Override
|
||||
public void doExecuteProgress(DailyProgressContext progressContext) {
|
||||
boolean isBravo = Constant.GiftType.BRAVO_GIFT == progressContext.getGiftType();
|
||||
if (!isBravo) {
|
||||
return;
|
||||
}
|
||||
Long uid = progressContext.getUid();
|
||||
Integer partitionId = progressContext.getPartitionId();
|
||||
String todayDate = getTaskDate(partitionId, progressContext.getCreateTime());
|
||||
RBucket<Integer> taskStatus = taskStatus(uid, todayDate, ROOM_SEND_BRAVO_NUM);
|
||||
if (taskStatus.isExists()) {
|
||||
return;
|
||||
}
|
||||
RMap<Long, Long> sendGoldNum = sendGiftNum(ROOM_SEND_BRAVO_NUM, partitionId, todayDate);
|
||||
Long addAndGet = sendGoldNum.addAndGet(uid, progressContext.getRecvGoldNum());
|
||||
sendGoldNum.expire(Duration.ofDays(EXPIRE_DAY));
|
||||
DailyTaskConfig dailyTaskConfig = dailyTaskConfigService.getByPartTaskKey(partitionId, ROOM_SEND_BRAVO_NUM.name());
|
||||
if (dailyTaskConfig != null && addAndGet != null && addAndGet >= dailyTaskConfig.getReachNum()) {
|
||||
taskStatus(uid, todayDate, DailyTaskTypeEnum.ROOM_SEND_BRAVO_NUM).set(1, Duration.ofDays(EXPIRE_DAY));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyTaskVo doHandle(DailyTaskContext context) {
|
||||
String todayDate = context.getTodayDate();
|
||||
RMap<Long, Long> sendGoldNum = sendGiftNum(context.getDailyTaskTypeEnum(), context.getPartitionId(), todayDate);
|
||||
Long uid = context.getUid();
|
||||
DailyTaskTypeEnum dailyTaskTypeEnum = context.getDailyTaskTypeEnum();
|
||||
return DailyTaskVo.builder()
|
||||
.receiveStatus(computeReceiveStatus(uid, todayDate, dailyTaskTypeEnum))
|
||||
.reachNum(sendGoldNum.getOrDefault(uid, 0L))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package com.accompany.business.service.dailytask.handler;
|
||||
|
||||
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
|
||||
import com.accompany.business.model.dailytask.DailyTaskConfig;
|
||||
import com.accompany.business.service.dailytask.AbstractDailyTaskHandler;
|
||||
import com.accompany.business.service.dailytask.annotation.DailyTaskHandlerType;
|
||||
import com.accompany.business.vo.dailytask.DailyProgressContext;
|
||||
import com.accompany.business.vo.dailytask.DailyTaskContext;
|
||||
import com.accompany.business.vo.dailytask.DailyTaskVo;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RMap;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import static com.accompany.business.constant.dailytask.DailyTaskTypeEnum.ROOM_SEND_LUCKY_NUM;
|
||||
|
||||
@Component
|
||||
@DailyTaskHandlerType(ROOM_SEND_LUCKY_NUM)
|
||||
public class RoomSendLuckyNumHandler extends AbstractDailyTaskHandler {
|
||||
|
||||
@Override
|
||||
public void doExecuteProgress(DailyProgressContext progressContext) {
|
||||
boolean luckyGift = Constant.GiftType.LUCKY_24 == progressContext.getGiftType() ||
|
||||
Constant.GiftType.SUPER_LUCKY == progressContext.getGiftType()
|
||||
|| Constant.GiftType.LUCKY_25 == progressContext.getGiftType();
|
||||
if (!luckyGift) {
|
||||
return;
|
||||
}
|
||||
Long uid = progressContext.getUid();
|
||||
Integer partitionId = progressContext.getPartitionId();
|
||||
String todayDate = getTaskDate(partitionId, progressContext.getCreateTime());
|
||||
RBucket<Integer> taskStatus = taskStatus(uid, todayDate, ROOM_SEND_LUCKY_NUM);
|
||||
if (taskStatus.isExists()) {
|
||||
return;
|
||||
}
|
||||
RMap<Long, Long> sendGoldNum = sendGiftNum(ROOM_SEND_LUCKY_NUM, partitionId, todayDate);
|
||||
Long addAndGet = sendGoldNum.addAndGet(uid, progressContext.getGiftNum());
|
||||
sendGoldNum.expire(Duration.ofDays(EXPIRE_DAY));
|
||||
DailyTaskConfig dailyTaskConfig = dailyTaskConfigService.getByPartTaskKey(partitionId, ROOM_SEND_LUCKY_NUM.name());
|
||||
if (dailyTaskConfig != null && addAndGet != null && addAndGet >= dailyTaskConfig.getReachNum()) {
|
||||
taskStatus(uid, todayDate, DailyTaskTypeEnum.ROOM_SEND_LUCKY_NUM).set(1, Duration.ofDays(EXPIRE_DAY));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyTaskVo doHandle(DailyTaskContext context) {
|
||||
String todayDate = context.getTodayDate();
|
||||
DailyTaskTypeEnum dailyTaskTypeEnum = context.getDailyTaskTypeEnum();
|
||||
RMap<Long, Long> sendGoldNum = sendGiftNum(dailyTaskTypeEnum, context.getPartitionId(), todayDate);
|
||||
Long uid = context.getUid();
|
||||
return DailyTaskVo.builder()
|
||||
.receiveStatus(computeReceiveStatus(uid, todayDate, dailyTaskTypeEnum))
|
||||
.reachNum(sendGoldNum.getOrDefault(uid, 0L))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
@@ -30,6 +30,7 @@ public class DailyTaskGiftListener implements ApplicationListener<GiftMessageEve
|
||||
.uid(giftMessage.getSendUid())
|
||||
.recvUid(giftMessage.getRecvUid())
|
||||
.giftType(giftMessage.getGiftType())
|
||||
.giftNum(giftMessage.getGiftNum())
|
||||
.recvGoldNum(giftMessage.getRealGoldNum())
|
||||
.createTime(new Date(giftMessage.getMessTime()))
|
||||
.partitionId(giftMessage.getPartitionId())
|
||||
|
Reference in New Issue
Block a user