日常任务-公会活动
This commit is contained in:
@@ -8,6 +8,7 @@ public interface DailyTaskConstant {
|
|||||||
UNCOMPLETED,
|
UNCOMPLETED,
|
||||||
AVAILABLE,
|
AVAILABLE,
|
||||||
RECEIVED,
|
RECEIVED,
|
||||||
|
EXPIRE
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RedisKey implements BaseRedisKey {
|
enum RedisKey implements BaseRedisKey {
|
||||||
@@ -22,6 +23,7 @@ public interface DailyTaskConstant {
|
|||||||
task_config,//任务配置
|
task_config,//任务配置
|
||||||
ip_limit,//主播上麦领取ip限制
|
ip_limit,//主播上麦领取ip限制
|
||||||
device_limit,//主播上麦领取设备限制
|
device_limit,//主播上麦领取设备限制
|
||||||
|
guild_diamod,//公会日流水
|
||||||
;
|
;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -23,6 +23,9 @@ public enum DailyTaskTypeEnum {
|
|||||||
ROOM_SEND_BRAVO_NUM("ROOM_SEND_BRAVO_NUM"),//送出77个BRAVO礼物
|
ROOM_SEND_BRAVO_NUM("ROOM_SEND_BRAVO_NUM"),//送出77个BRAVO礼物
|
||||||
GM_UP_MIC("GM_UP_MIC"),//每日任务新主播上麦(薅羊毛)
|
GM_UP_MIC("GM_UP_MIC"),//每日任务新主播上麦(薅羊毛)
|
||||||
GUILD_SALARY("GUILD_SALARY"),//公会长薪资
|
GUILD_SALARY("GUILD_SALARY"),//公会长薪资
|
||||||
|
GUILD_CREATE("GUILD_CREATE"),//公会开业仪式
|
||||||
|
GUILD_MIC("GUILD_MIC"),//周上麦活跃时长1
|
||||||
|
GUILD_MIC_ONE("GUILD_MIC"),//周上麦活跃时长2
|
||||||
;
|
;
|
||||||
|
|
||||||
private String handlerType;
|
private String handlerType;
|
||||||
|
@@ -0,0 +1,11 @@
|
|||||||
|
package com.accompany.business.constant.guild;
|
||||||
|
|
||||||
|
public class GuildTaskConstant {
|
||||||
|
|
||||||
|
public static class TaskStatus {
|
||||||
|
public static final byte UNCOMPLETED = 0;
|
||||||
|
public static final byte AVAILABLE = 1;
|
||||||
|
public static final byte RECEIVED = 2;
|
||||||
|
public static final byte EXPIRE = 3;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,63 @@
|
|||||||
|
package com.accompany.business.model.guildtask;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式配置实体类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GuildTaskLevelInfo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "guild_task_id", type = IdType.AUTO)
|
||||||
|
private Integer guildTaskId;
|
||||||
|
/**
|
||||||
|
* 分区id
|
||||||
|
*/
|
||||||
|
private Integer partitionId;
|
||||||
|
/**
|
||||||
|
* GUILD_CREATE-公会开业, GUILD_MIC-麦上活跃1,GUILD_MIC_TWO-麦上活跃2
|
||||||
|
*/
|
||||||
|
private String taskKey;
|
||||||
|
/**
|
||||||
|
* 等级
|
||||||
|
*/
|
||||||
|
private Integer level;
|
||||||
|
/**
|
||||||
|
* 等级描述
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
/**
|
||||||
|
* 经验(金钱时 单位 美分)
|
||||||
|
*/
|
||||||
|
private BigDecimal diamondNum;
|
||||||
|
/**
|
||||||
|
* 主播人数
|
||||||
|
*/
|
||||||
|
private Integer anchorNum;
|
||||||
|
/**
|
||||||
|
* 主播人数
|
||||||
|
*/
|
||||||
|
private Integer anchorMicReachMinutes;
|
||||||
|
/**
|
||||||
|
* 主播人数
|
||||||
|
*/
|
||||||
|
private Integer anchorMicReachNum;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,65 @@
|
|||||||
|
package com.accompany.business.model.guildtask;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式奖励配置实体类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GuildTaskLevelReward implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Integer id;
|
||||||
|
/**
|
||||||
|
* 公户开业仪式配置ID
|
||||||
|
*/
|
||||||
|
private Integer guildTaskId;
|
||||||
|
/**
|
||||||
|
* 等级
|
||||||
|
*/
|
||||||
|
private Integer level;
|
||||||
|
/**
|
||||||
|
* 奖品类型:8.金币 6.礼物 5.座驾 1.头饰 3.气泡, 10vip 11勋章 13.金豆,根据RewardTypeEnum来的
|
||||||
|
*/
|
||||||
|
private Integer awardType;
|
||||||
|
/**
|
||||||
|
* 奖品id,这里指对应表的主键id
|
||||||
|
*/
|
||||||
|
private Long awardId;
|
||||||
|
/**
|
||||||
|
* 奖品数量
|
||||||
|
*/
|
||||||
|
private Long awardNum;
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer awardSeq;
|
||||||
|
/**
|
||||||
|
* 奖励对象,1-公会长,3-主播
|
||||||
|
*/
|
||||||
|
private Integer awardRole;
|
||||||
|
/**
|
||||||
|
* 奖励状态
|
||||||
|
*/
|
||||||
|
private Integer awardStatus;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,73 @@
|
|||||||
|
package com.accompany.business.model.guildtask;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式奖励奖励记录实体类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GuildTaskLevelRewardRecord implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 分区id
|
||||||
|
*/
|
||||||
|
private Integer partitionId;
|
||||||
|
private Long uid;
|
||||||
|
private Integer guildId;
|
||||||
|
private Long guildMemberId;
|
||||||
|
/**
|
||||||
|
* 公户开业仪式配置ID
|
||||||
|
*/
|
||||||
|
private Integer guildTaskId;
|
||||||
|
/**
|
||||||
|
* 等级
|
||||||
|
*/
|
||||||
|
private Integer level;
|
||||||
|
/**
|
||||||
|
* 周期
|
||||||
|
*/
|
||||||
|
private String cycleDate;
|
||||||
|
/**
|
||||||
|
* 领取日期
|
||||||
|
*/
|
||||||
|
private String statDate;
|
||||||
|
/**
|
||||||
|
* 奖品类型:8.金币 6.礼物 5.座驾 1.头饰 3.气泡, 10vip 11勋章 ,根据RewardTypeEnum来的
|
||||||
|
*/
|
||||||
|
private Integer awardType;
|
||||||
|
/**
|
||||||
|
* 奖品id
|
||||||
|
*/
|
||||||
|
private Long awardId;
|
||||||
|
/**
|
||||||
|
* 奖品数量
|
||||||
|
*/
|
||||||
|
private Long awardNum;
|
||||||
|
/**
|
||||||
|
* 登录ip
|
||||||
|
*/
|
||||||
|
private String loginIp;
|
||||||
|
/**
|
||||||
|
* 设备号
|
||||||
|
*/
|
||||||
|
private String deviceId;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,76 @@
|
|||||||
|
package com.accompany.business.model.guildtask;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新公会达标任务信息表实体类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GuildTaskReachRecord implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id" , type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 周期
|
||||||
|
*/
|
||||||
|
private String cycleDate;
|
||||||
|
/**
|
||||||
|
* 统计日期
|
||||||
|
*/
|
||||||
|
private String statDate;
|
||||||
|
/**
|
||||||
|
* 分区id
|
||||||
|
*/
|
||||||
|
private Integer partitionId;
|
||||||
|
private Integer guildId;
|
||||||
|
private Integer guildTaskId;
|
||||||
|
/**
|
||||||
|
* GUILD_CREATE-公会开业, GUILD_MIC-麦上活跃1,GUILD_MIC_TWO-麦上活跃2
|
||||||
|
*/
|
||||||
|
private String taskKey;
|
||||||
|
/**
|
||||||
|
* 等级
|
||||||
|
*/
|
||||||
|
private Integer level;
|
||||||
|
/**
|
||||||
|
* 经验(金钱时 单位 美分)
|
||||||
|
*/
|
||||||
|
private BigDecimal diamondNum;
|
||||||
|
/**
|
||||||
|
* 主播人数
|
||||||
|
*/
|
||||||
|
private Integer anchorNum;
|
||||||
|
/**
|
||||||
|
* 主播人数
|
||||||
|
*/
|
||||||
|
private Integer anchorMicReachNum;
|
||||||
|
/**
|
||||||
|
* 达标状态0-未达标,1-已经达标
|
||||||
|
*/
|
||||||
|
private Integer reachStatus;
|
||||||
|
/**
|
||||||
|
* 达标状态0-未领取,1-已领取
|
||||||
|
*/
|
||||||
|
private Integer receiveStatus;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -24,7 +24,7 @@ public class DailyTaskVo {
|
|||||||
private Integer partitionId;
|
private Integer partitionId;
|
||||||
@ApiModelProperty("任务类型")
|
@ApiModelProperty("任务类型")
|
||||||
private DailyTaskTypeEnum taskType;
|
private DailyTaskTypeEnum taskType;
|
||||||
@ApiModelProperty("UNCOMPLETED-完成, AVAILABLE-可领取,RECEIVED-已领取")
|
@ApiModelProperty("UNCOMPLETED-完成, AVAILABLE-可领取,RECEIVED-已领取,EXPIRE-已过期")
|
||||||
private DailyTaskConstant.ReceiveStatus receiveStatus;
|
private DailyTaskConstant.ReceiveStatus receiveStatus;
|
||||||
@ApiModelProperty("到达数量")
|
@ApiModelProperty("到达数量")
|
||||||
private Long reachNum;
|
private Long reachNum;
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
package com.accompany.business.vo.guild;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GuildTaskLevelInfoVo {
|
||||||
|
private Integer guildTaskId;
|
||||||
|
/**
|
||||||
|
* 分区id
|
||||||
|
*/
|
||||||
|
private Integer partitionId;
|
||||||
|
@ApiModelProperty("1-公会开业, 2-麦上活跃1,3-麦上活跃2")
|
||||||
|
private Byte type;
|
||||||
|
@ApiModelProperty("等级")
|
||||||
|
private Integer level;
|
||||||
|
@ApiModelProperty("等级描述")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty("当前钻石流水")
|
||||||
|
private BigDecimal curDiamondNum;
|
||||||
|
@ApiModelProperty("档位-达标钻石流水")
|
||||||
|
private BigDecimal diamondNum;
|
||||||
|
@ApiModelProperty("当前主播人数")
|
||||||
|
private Integer curAnchorNum;
|
||||||
|
@ApiModelProperty("档位-主播人数")
|
||||||
|
private Integer anchorNum;
|
||||||
|
@ApiModelProperty("档位-主播上麦达标最少上麦分钟数")
|
||||||
|
private Integer anchorMicReachMinutes;
|
||||||
|
@ApiModelProperty("当前主播上麦达标人数")
|
||||||
|
private Integer curAnchorMicReachNum;
|
||||||
|
@ApiModelProperty("档位-主播上麦达标人数")
|
||||||
|
private Integer anchorMicReachNum;
|
||||||
|
}
|
@@ -5,6 +5,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class GuildMemberMicDayVo {
|
public class GuildMemberMicDayVo {
|
||||||
private String statDate;
|
private String statDate;
|
||||||
|
private Integer guildId;
|
||||||
private Long guildMemberId;
|
private Long guildMemberId;
|
||||||
private Integer micMinutes;
|
private Integer micMinutes;
|
||||||
private Integer micDay;
|
private Integer micDay;
|
||||||
|
@@ -33,4 +33,7 @@ public interface GuildMicStatisticsPolicy2Mapper extends BaseMapper<GuildMicStat
|
|||||||
Integer getMinutes(@Param("partitionId") Integer partitionId, @Param("guildMemberId") Long guildMemberId, @Param("statDate") String statDate);
|
Integer getMinutes(@Param("partitionId") Integer partitionId, @Param("guildMemberId") Long guildMemberId, @Param("statDate") String statDate);
|
||||||
|
|
||||||
Integer countByPartitionDate(@Param("statDate")String statDate, @Param("partitionId") Integer partitionId, @Param("reachMinutes") Integer reachMinutes);
|
Integer countByPartitionDate(@Param("statDate")String statDate, @Param("partitionId") Integer partitionId, @Param("reachMinutes") Integer reachMinutes);
|
||||||
|
|
||||||
|
List<GuildMemberMicDayVo> groupByPartitionGuildDate(@Param("statDate")String statDate, @Param("partitionId") Integer partitionId,
|
||||||
|
@Param("reachMinutes") Integer reachMinutes, @Param("guildIds") List<Integer> guildIds);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,14 @@
|
|||||||
|
package com.accompany.business.mybatismapper.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskLevelInfo;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式配置 Mapper 接口
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
public interface GuildTaskLevelInfoMapper extends BaseMapper<GuildTaskLevelInfo> {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,14 @@
|
|||||||
|
package com.accompany.business.mybatismapper.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskLevelReward;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式奖励配置 Mapper 接口
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
public interface GuildTaskLevelRewardMapper extends BaseMapper<GuildTaskLevelReward> {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,14 @@
|
|||||||
|
package com.accompany.business.mybatismapper.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskLevelRewardRecord;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式奖励奖励记录 Mapper 接口
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
public interface GuildTaskLevelRewardRecordMapper extends BaseMapper<GuildTaskLevelRewardRecord> {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,14 @@
|
|||||||
|
package com.accompany.business.mybatismapper.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskReachRecord;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新公会达标任务信息表 Mapper 接口
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
public interface GuildTaskReachRecordMapper extends BaseMapper<GuildTaskReachRecord> {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,54 @@
|
|||||||
|
package com.accompany.business.service.dailytask.handler;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.accompany.business.constant.dailytask.DailyTaskConstant;
|
||||||
|
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
|
||||||
|
import com.accompany.business.model.guild.Guild;
|
||||||
|
import com.accompany.business.service.dailytask.AbstractDailyTaskHandler;
|
||||||
|
import com.accompany.business.service.dailytask.annotation.DailyTaskHandlerType;
|
||||||
|
import com.accompany.business.service.guild.GuildMemberService;
|
||||||
|
import com.accompany.business.service.guild.GuildService;
|
||||||
|
import com.accompany.business.service.guildtask.GuildTaskLevelInfoService;
|
||||||
|
import com.accompany.business.vo.dailytask.DailyProgressContext;
|
||||||
|
import com.accompany.business.vo.dailytask.DailyTaskContext;
|
||||||
|
import com.accompany.business.vo.dailytask.DailyTaskVo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@DailyTaskHandlerType(DailyTaskTypeEnum.GUILD_CREATE)
|
||||||
|
public class GuildCreateHandler extends AbstractDailyTaskHandler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GuildMemberService guildMemberService;
|
||||||
|
@Autowired
|
||||||
|
private GuildService guildService;
|
||||||
|
@Autowired
|
||||||
|
private GuildTaskLevelInfoService guildTaskLevelInfoService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DailyTaskVo doHandle(DailyTaskContext context) {
|
||||||
|
Guild guild = guildService.getVaildGuildByOwnerUid(context.getUid());
|
||||||
|
if (guild == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Date now = new Date();
|
||||||
|
DailyTaskVo dailyTaskVo = new DailyTaskVo();
|
||||||
|
Date createAfter14Day = DateUtil.offsetDay(guild.getCreateTime(), 14);
|
||||||
|
if (now.after(createAfter14Day)) {
|
||||||
|
dailyTaskVo.setReceiveStatus(DailyTaskConstant.ReceiveStatus.EXPIRE);
|
||||||
|
return dailyTaskVo;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doExecuteProgress(DailyProgressContext progressContext) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,23 @@
|
|||||||
|
package com.accompany.business.service.dailytask.handler;
|
||||||
|
|
||||||
|
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
|
||||||
|
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 org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@DailyTaskHandlerType(DailyTaskTypeEnum.GUILD_MIC)
|
||||||
|
public class GuildMicHandler extends AbstractDailyTaskHandler {
|
||||||
|
@Override
|
||||||
|
public DailyTaskVo doHandle(DailyTaskContext context) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doExecuteProgress(DailyProgressContext progressContext) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -8,6 +8,7 @@ import com.accompany.business.vo.guild.GuildMemberDiamondStatisticsDayVo;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.redisson.api.RMap;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -37,4 +38,6 @@ public interface GuildDiamondStatisticsDayService extends IService<GuildDiamondS
|
|||||||
IPage<GuildInfoVo> listBdGuildInfo(IPage<GuildInfoVo> page, Long bdId, Integer orderBy);
|
IPage<GuildInfoVo> listBdGuildInfo(IPage<GuildInfoVo> page, Long bdId, Integer orderBy);
|
||||||
|
|
||||||
Map<Integer, Double> mapByStatDate(String statDate, String endDate, int partitionId, List<Integer> guildIds);
|
Map<Integer, Double> mapByStatDate(String statDate, String endDate, int partitionId, List<Integer> guildIds);
|
||||||
|
|
||||||
|
RMap<Integer, BigDecimal> guildStatDateDiamondMap(Integer partitionId, String statDate);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.accompany.business.service.guild;
|
package com.accompany.business.service.guild;
|
||||||
|
|
||||||
|
import com.accompany.business.constant.dailytask.DailyTaskConstant;
|
||||||
import com.accompany.business.model.guild.GuildDiamondStatisticsDay;
|
import com.accompany.business.model.guild.GuildDiamondStatisticsDay;
|
||||||
import com.accompany.business.model.guild.GuildMember;
|
import com.accompany.business.model.guild.GuildMember;
|
||||||
import com.accompany.business.mybatismapper.guild.GuildDiamondStatisticsDayMapper;
|
import com.accompany.business.mybatismapper.guild.GuildDiamondStatisticsDayMapper;
|
||||||
@@ -11,6 +12,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
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.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -31,10 +36,16 @@ import java.util.stream.Collectors;
|
|||||||
public class GuildDiamondStatisticsDayServiceImpl extends ServiceImpl<GuildDiamondStatisticsDayMapper, GuildDiamondStatisticsDay> implements GuildDiamondStatisticsDayService {
|
public class GuildDiamondStatisticsDayServiceImpl extends ServiceImpl<GuildDiamondStatisticsDayMapper, GuildDiamondStatisticsDay> implements GuildDiamondStatisticsDayService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedissonClient redissonClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateDayDiamondStatistics(String cycleDate, String statDate, GuildMember guildMember, double diamond) {
|
public int updateDayDiamondStatistics(String cycleDate, String statDate, GuildMember guildMember, double diamond) {
|
||||||
Date time = new Date();
|
Date time = new Date();
|
||||||
return baseMapper.updateDayDiamondStatistics(cycleDate, statDate, guildMember.getId(), guildMember.getPartitionId(), guildMember.getGuildId(), guildMember.getUid(), diamond, time);
|
int updated = baseMapper.updateDayDiamondStatistics(cycleDate, statDate, guildMember.getId(), guildMember.getPartitionId(), guildMember.getGuildId(), guildMember.getUid(), diamond, time);
|
||||||
|
this.guildStatDateDiamondMap(guildMember.getPartitionId(), statDate)
|
||||||
|
.put(guildMember.getGuildId(), BigDecimal.valueOf(diamond));
|
||||||
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -81,4 +92,9 @@ public class GuildDiamondStatisticsDayServiceImpl extends ServiceImpl<GuildDiamo
|
|||||||
return guildDiamondStatisticsDayVos.stream().collect(Collectors.toMap(GuildDiamondStatisticsDayVo::getGuildId, x -> x.getDiamondNum()));
|
return guildDiamondStatisticsDayVos.stream().collect(Collectors.toMap(GuildDiamondStatisticsDayVo::getGuildId, x -> x.getDiamondNum()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RMap<Integer, BigDecimal> guildStatDateDiamondMap(Integer partitionId, String statDate) {
|
||||||
|
return redissonClient.getMap(DailyTaskConstant.RedisKey.guild_diamod.getKey(statDate, partitionId.toString()),
|
||||||
|
new TypedJsonJacksonCodec(Integer.class, BigDecimal.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -94,4 +94,11 @@ public class GuildService extends ServiceImpl<GuildMapper, Guild> {
|
|||||||
return guildMemberNumMapByGuildIds.stream().collect(Collectors.toMap(AgencyOwnerVo::getGuildId, AgencyOwnerVo::getMemberNum));
|
return guildMemberNumMapByGuildIds.stream().collect(Collectors.toMap(AgencyOwnerVo::getGuildId, AgencyOwnerVo::getMemberNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Guild> listGreaterCreateTime(Integer partitionId, Date createTime) {
|
||||||
|
return this.lambdaQuery()
|
||||||
|
.eq(Guild::getPartitionId, partitionId)
|
||||||
|
.ge(Guild::getCreateTime, createTime)
|
||||||
|
.eq(Guild::getEnable, Boolean.TRUE)
|
||||||
|
.list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,10 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,4 +61,13 @@ public class GuildMicStatisticsPolicy2Service extends ServiceImpl<GuildMicStatis
|
|||||||
public Integer countByPartitionDate(String statDate, Integer partitionId, Integer reachMinutes) {
|
public Integer countByPartitionDate(String statDate, Integer partitionId, Integer reachMinutes) {
|
||||||
return baseMapper.countByPartitionDate(statDate, partitionId, reachMinutes);
|
return baseMapper.countByPartitionDate(statDate, partitionId, reachMinutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Map<Integer, Integer> mapByPartitionGuildDate(String statDate, Integer partitionId, Integer reachMinutes, List<Integer> guildIds) {
|
||||||
|
List<GuildMemberMicDayVo> memberMicDayVos = baseMapper.groupByPartitionGuildDate(statDate, partitionId, reachMinutes, guildIds);
|
||||||
|
if (CollectionUtils.isEmpty(memberMicDayVos)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
return memberMicDayVos.stream().collect(Collectors.toMap(GuildMemberMicDayVo::getGuildId, GuildMemberMicDayVo::getMicDay));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,43 @@
|
|||||||
|
package com.accompany.business.service.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskLevelInfo;
|
||||||
|
import com.accompany.business.mybatismapper.guildtask.GuildTaskLevelInfoMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式配置 服务实现类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GuildTaskLevelInfoService extends ServiceImpl<GuildTaskLevelInfoMapper, GuildTaskLevelInfo> {
|
||||||
|
|
||||||
|
public List<GuildTaskLevelInfo> listGuildTask(Integer partitionId, String taskKey) {
|
||||||
|
LambdaQueryWrapper<GuildTaskLevelInfo> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(GuildTaskLevelInfo::getPartitionId, partitionId);
|
||||||
|
wrapper.eq(GuildTaskLevelInfo::getTaskKey, taskKey)
|
||||||
|
.orderByAsc(GuildTaskLevelInfo::getLevel);
|
||||||
|
return baseMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GuildTaskLevelInfo> listGuildTaskList(Integer partitionId, List<String> taskKeys) {
|
||||||
|
LambdaQueryWrapper<GuildTaskLevelInfo> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(GuildTaskLevelInfo::getPartitionId, partitionId);
|
||||||
|
wrapper.in(GuildTaskLevelInfo::getTaskKey, taskKeys)
|
||||||
|
.orderByAsc(GuildTaskLevelInfo::getLevel);
|
||||||
|
return baseMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GuildTaskLevelInfo> listGuildTasks(Integer partitionId) {
|
||||||
|
LambdaQueryWrapper<GuildTaskLevelInfo> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(GuildTaskLevelInfo::getPartitionId, partitionId)
|
||||||
|
.orderByAsc(GuildTaskLevelInfo::getLevel);
|
||||||
|
return baseMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,18 @@
|
|||||||
|
package com.accompany.business.service.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskLevelRewardRecord;
|
||||||
|
import com.accompany.business.mybatismapper.guildtask.GuildTaskLevelRewardRecordMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式奖励奖励记录 服务实现类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GuildTaskLevelRewardRecordService extends ServiceImpl<GuildTaskLevelRewardRecordMapper, GuildTaskLevelRewardRecord> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,18 @@
|
|||||||
|
package com.accompany.business.service.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskLevelReward;
|
||||||
|
import com.accompany.business.mybatismapper.guildtask.GuildTaskLevelRewardMapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公户开业仪式奖励配置 服务实现类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GuildTaskLevelRewardService extends ServiceImpl<GuildTaskLevelRewardMapper, GuildTaskLevelReward> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,36 @@
|
|||||||
|
package com.accompany.business.service.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskReachRecord;
|
||||||
|
import com.accompany.business.mybatismapper.guildtask.GuildTaskReachRecordMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新公会达标任务信息表 服务实现类
|
||||||
|
*
|
||||||
|
* @author
|
||||||
|
* @since 2025-09-01
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class GuildTaskReachRecordService extends ServiceImpl<GuildTaskReachRecordMapper, GuildTaskReachRecord> {
|
||||||
|
|
||||||
|
public List<GuildTaskReachRecord> list(Integer partitionId, Integer guildId, String taskKey) {
|
||||||
|
LambdaQueryWrapper<GuildTaskReachRecord> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(GuildTaskReachRecord::getPartitionId, partitionId)
|
||||||
|
.eq(GuildTaskReachRecord::getGuildId, guildId)
|
||||||
|
.eq(GuildTaskReachRecord::getTaskKey, taskKey);
|
||||||
|
return baseMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GuildTaskReachRecord> listByCycle(String cycleDate, Integer partitionId, Integer guildId, String taskKey) {
|
||||||
|
LambdaQueryWrapper<GuildTaskReachRecord> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(GuildTaskReachRecord::getPartitionId, partitionId)
|
||||||
|
.eq(GuildTaskReachRecord::getGuildId, guildId)
|
||||||
|
.eq(GuildTaskReachRecord::getTaskKey, taskKey);
|
||||||
|
return baseMapper.selectList(wrapper);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,236 @@
|
|||||||
|
package com.accompany.business.service.guildtask;
|
||||||
|
|
||||||
|
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
|
||||||
|
import com.accompany.business.model.guild.Guild;
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskLevelInfo;
|
||||||
|
import com.accompany.business.model.guildtask.GuildTaskReachRecord;
|
||||||
|
import com.accompany.business.service.guild.GuildDiamondStatisticsDayService;
|
||||||
|
import com.accompany.business.service.guild.GuildMemberService;
|
||||||
|
import com.accompany.business.service.guild.GuildService;
|
||||||
|
import com.accompany.business.service.guildpolicy2.GuildMicStatisticsPolicy2Service;
|
||||||
|
import com.accompany.business.vo.guild.GuildTaskLevelInfoVo;
|
||||||
|
import com.accompany.common.utils.DateTimeUtil;
|
||||||
|
import com.accompany.core.enumeration.PartitionEnum;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.redisson.api.RMap;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GuildTaskService {
|
||||||
|
@Autowired
|
||||||
|
private GuildTaskLevelInfoService guildTaskLevelInfoService;
|
||||||
|
@Autowired
|
||||||
|
private GuildTaskReachRecordService guildTaskReachRecordService;
|
||||||
|
@Autowired
|
||||||
|
private GuildService guildService;
|
||||||
|
@Autowired
|
||||||
|
private GuildMemberService guildMemberService;
|
||||||
|
@Autowired
|
||||||
|
private GuildDiamondStatisticsDayService guildDiamondStatisticsDayService;
|
||||||
|
@Autowired
|
||||||
|
private GuildMicStatisticsPolicy2Service guildMicStatisticsPolicy2Service;
|
||||||
|
|
||||||
|
public void updateTaskCreateProgress(Date now, PartitionEnum partitionEnum) {
|
||||||
|
int partitionId = partitionEnum.getId();
|
||||||
|
|
||||||
|
String taskKey = DailyTaskTypeEnum.GUILD_CREATE.name();
|
||||||
|
List<GuildTaskLevelInfo> taskLevelInfos = guildTaskLevelInfoService.listGuildTask(partitionId, taskKey);
|
||||||
|
if (CollectionUtils.isEmpty(taskLevelInfos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZonedDateTime nowzonedDateTime = DateTimeUtil.convertWithZoneId(now, partitionEnum.getZoneId());
|
||||||
|
if (nowzonedDateTime.getHour() == 0 && nowzonedDateTime.getMinute() == 0) {//0点0分统计前一天的数据
|
||||||
|
nowzonedDateTime = nowzonedDateTime.minusDays(1);
|
||||||
|
}
|
||||||
|
String statDate = nowzonedDateTime.format(DateTimeUtil.dateFormatter);
|
||||||
|
|
||||||
|
ZonedDateTime before14DayBegin = nowzonedDateTime.minusDays(14).withHour(0).withMinute(0).withSecond(0);
|
||||||
|
Date before14DayBeginEastEightDate = DateTimeUtil.convertToEastEightZone(before14DayBegin
|
||||||
|
.format(DateTimeUtil.datetimeFormatter), partitionEnum.getZoneId());
|
||||||
|
|
||||||
|
List<Guild> guilds = guildService.listGreaterCreateTime(partitionId, before14DayBeginEastEightDate);
|
||||||
|
if (CollectionUtils.isEmpty(guilds)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Integer> guildIds = guilds.stream().map(Guild::getId).collect(Collectors.toSet());
|
||||||
|
Map<Integer, Long> guildMemberNumMap = guildMemberService.mapGuildMemberNum(guildIds);
|
||||||
|
RMap<Integer, BigDecimal> guildStatDateDiamondMap = guildDiamondStatisticsDayService.guildStatDateDiamondMap(partitionId, statDate);
|
||||||
|
guildStatDateDiamondMap.expire(Duration.ofDays(1));
|
||||||
|
Map<Integer, BigDecimal> diamondMap = guildStatDateDiamondMap
|
||||||
|
.getAll(guildIds);
|
||||||
|
|
||||||
|
List<GuildTaskReachRecord> resultList = new ArrayList<>();
|
||||||
|
Integer maxReachMinutes = taskLevelInfos.stream().max(Comparator.comparing(GuildTaskLevelInfo::getAnchorMicReachMinutes))
|
||||||
|
.map(GuildTaskLevelInfo::getAnchorMicReachMinutes).get();
|
||||||
|
Map<Integer, Integer> reachAnchorNumMap = new HashMap<>();
|
||||||
|
if (maxReachMinutes > 0) {
|
||||||
|
reachAnchorNumMap = guildMicStatisticsPolicy2Service.mapByPartitionGuildDate(statDate, partitionId, maxReachMinutes, new ArrayList<>(guildIds));
|
||||||
|
}
|
||||||
|
for (Guild guild : guilds) {
|
||||||
|
Integer guildId = guild.getId();
|
||||||
|
List<GuildTaskReachRecord> existRecords = guildTaskReachRecordService.list(partitionId, guildId, taskKey);
|
||||||
|
String cycleDate = DateTimeUtil.convertWithZoneId(guild.getCreateTime(), partitionEnum.getZoneId())
|
||||||
|
.format(DateTimeUtil.dateFormatter);
|
||||||
|
this.calProgress(partitionEnum, guild, taskLevelInfos, existRecords, resultList, cycleDate, statDate,
|
||||||
|
guildMemberNumMap, diamondMap, reachAnchorNumMap, now);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(resultList)) {
|
||||||
|
guildTaskReachRecordService.saveOrUpdateBatch(resultList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calProgress(PartitionEnum partitionEnum, Guild guild, List<GuildTaskLevelInfo> taskLevelInfos,
|
||||||
|
List<GuildTaskReachRecord> existRecords, List<GuildTaskReachRecord> resultList,
|
||||||
|
String cycleDate, String statDate, Map<Integer, Long> guildMemberNumMap,
|
||||||
|
Map<Integer, BigDecimal> diamondMap, Map<Integer, Integer> reachAnchorNumMap, Date now) {
|
||||||
|
Integer guildId = guild.getId();
|
||||||
|
int partitionId = partitionEnum.getId();
|
||||||
|
BigDecimal diamond = diamondMap.getOrDefault(guildId, BigDecimal.ZERO);
|
||||||
|
Integer anchorReachNum = reachAnchorNumMap.getOrDefault(guildId, 0);
|
||||||
|
Long memberNum = guildMemberNumMap.getOrDefault(guildId, 0L);
|
||||||
|
for (GuildTaskLevelInfo levelInfo : taskLevelInfos) {
|
||||||
|
if (CollectionUtils.isEmpty(existRecords)) {
|
||||||
|
boolean calNext = this.addNewGuildReachRecord(cycleDate, resultList, levelInfo, guildId, partitionId,
|
||||||
|
statDate, diamond, anchorReachNum, memberNum.intValue());
|
||||||
|
if (!calNext) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Map<Integer, GuildTaskReachRecord> existRecordMap = existRecords.stream()
|
||||||
|
.collect(Collectors.toMap(GuildTaskReachRecord::getLevel, x -> x));
|
||||||
|
|
||||||
|
GuildTaskReachRecord existOne = existRecordMap.get(levelInfo.getLevel());
|
||||||
|
if (existOne != null) {
|
||||||
|
//不是当天并且等级已经达标,计算下一级
|
||||||
|
if (!statDate.equals(existOne.getStatDate()) && existOne.getReachStatus() <= 0){
|
||||||
|
this.addNewGuildReachRecord(cycleDate, resultList, levelInfo, guildId, partitionId, statDate,
|
||||||
|
diamond, anchorReachNum, memberNum.intValue());
|
||||||
|
} else if (statDate.equals(existOne.getStatDate())) {
|
||||||
|
existOne.setDiamondNum(levelInfo.getDiamondNum());
|
||||||
|
existOne.setAnchorNum(levelInfo.getAnchorNum());
|
||||||
|
existOne.setAnchorMicReachNum(levelInfo.getAnchorMicReachNum());
|
||||||
|
existOne.setLevel(levelInfo.getLevel());
|
||||||
|
existOne.setGuildTaskId(levelInfo.getGuildTaskId());
|
||||||
|
boolean calNext = diamond.doubleValue() >= levelInfo.getDiamondNum().doubleValue()
|
||||||
|
&& memberNum >= levelInfo.getAnchorNum()
|
||||||
|
&& anchorReachNum >= levelInfo.getAnchorMicReachNum();
|
||||||
|
existOne.setReachStatus(calNext ? 1 : 0);
|
||||||
|
existOne.setUpdateTime(now);
|
||||||
|
resultList.add(existOne);
|
||||||
|
if (!calNext) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
boolean calNext = this.addNewGuildReachRecord(cycleDate, resultList, levelInfo, guildId, partitionId,
|
||||||
|
statDate, diamond, anchorReachNum, memberNum.intValue());
|
||||||
|
if (!calNext) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addNewGuildReachRecord(String cycleDate, List<GuildTaskReachRecord> resultList, GuildTaskLevelInfo levelInfo, Integer guildId,
|
||||||
|
Integer partitionId, String statDate, BigDecimal diamond, Integer anchorReachNum, Integer memberNum) {
|
||||||
|
GuildTaskReachRecord reachRecord = new GuildTaskReachRecord();
|
||||||
|
reachRecord.setId(null);
|
||||||
|
reachRecord.setCycleDate(cycleDate);
|
||||||
|
reachRecord.setGuildTaskId(levelInfo.getGuildTaskId());
|
||||||
|
reachRecord.setPartitionId(partitionId);
|
||||||
|
reachRecord.setStatDate(statDate);
|
||||||
|
reachRecord.setGuildId(guildId);
|
||||||
|
reachRecord.setTaskKey(levelInfo.getTaskKey());
|
||||||
|
reachRecord.setLevel(levelInfo.getLevel());
|
||||||
|
reachRecord.setDiamondNum(diamond);
|
||||||
|
reachRecord.setAnchorNum(memberNum);
|
||||||
|
reachRecord.setAnchorMicReachNum(anchorReachNum);
|
||||||
|
boolean calNext = diamond.doubleValue() >= levelInfo.getDiamondNum().doubleValue()
|
||||||
|
&& memberNum >= levelInfo.getAnchorNum()
|
||||||
|
&& anchorReachNum >= levelInfo.getAnchorMicReachNum();
|
||||||
|
reachRecord.setReachStatus(calNext ? 1 : 0);
|
||||||
|
reachRecord.setCreateTime(new Date());
|
||||||
|
resultList.add(reachRecord);
|
||||||
|
if (!calNext) { //当前登记未达到,不再计算下一登记
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateWeekTaskProgress(Date now, PartitionEnum partitionEnum) {
|
||||||
|
|
||||||
|
int partitionId = partitionEnum.getId();
|
||||||
|
|
||||||
|
List<GuildTaskLevelInfo> taskLevelInfos = guildTaskLevelInfoService.listGuildTaskList(partitionId,
|
||||||
|
Arrays.asList(DailyTaskTypeEnum.GUILD_MIC.name(), DailyTaskTypeEnum.GUILD_MIC_ONE.name()));
|
||||||
|
if (CollectionUtils.isEmpty(taskLevelInfos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZonedDateTime nowzonedDateTime = DateTimeUtil.convertWithZoneId(now, partitionEnum.getZoneId());
|
||||||
|
if (nowzonedDateTime.getHour() == 0 && nowzonedDateTime.getMinute() == 0) {//0点0分统计前一天的数据
|
||||||
|
nowzonedDateTime = nowzonedDateTime.minusDays(1);
|
||||||
|
}
|
||||||
|
String statDate = nowzonedDateTime.format(DateTimeUtil.dateFormatter);
|
||||||
|
|
||||||
|
ZonedDateTime weekBegin = nowzonedDateTime.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
||||||
|
String cycleDate = weekBegin.format(DateTimeUtil.datetimeFormatter);
|
||||||
|
|
||||||
|
List<Guild> guilds = guildService.listVaildGuildByPartitionId(partitionId);
|
||||||
|
if (CollectionUtils.isEmpty(guilds)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<Integer> guildIds = guilds.stream().map(Guild::getId).collect(Collectors.toSet());
|
||||||
|
Map<Integer, Long> guildMemberNumMap = guildMemberService.mapGuildMemberNum(guildIds);
|
||||||
|
RMap<Integer, BigDecimal> guildStatDateDiamondMap = guildDiamondStatisticsDayService.guildStatDateDiamondMap(partitionId, statDate);
|
||||||
|
guildStatDateDiamondMap.expire(Duration.ofDays(1));
|
||||||
|
Map<Integer, BigDecimal> diamondMap = guildStatDateDiamondMap.getAll(guildIds);
|
||||||
|
|
||||||
|
List<GuildTaskReachRecord> resultList = new ArrayList<>();
|
||||||
|
|
||||||
|
Map<String, List<GuildTaskLevelInfo>> groupByTaksLevelMap = taskLevelInfos.stream().collect(Collectors.groupingBy(GuildTaskLevelInfo::getTaskKey));
|
||||||
|
for (Map.Entry<String, List<GuildTaskLevelInfo>> entry : groupByTaksLevelMap.entrySet()) {
|
||||||
|
String taskKey = entry.getKey();
|
||||||
|
List<GuildTaskLevelInfo> levelInfos = entry.getValue();
|
||||||
|
Integer maxReachMinutes = levelInfos.stream().max(Comparator.comparing(GuildTaskLevelInfo::getAnchorMicReachMinutes))
|
||||||
|
.map(GuildTaskLevelInfo::getAnchorMicReachMinutes).get();
|
||||||
|
Map<Integer, Integer> reachAnchorNumMap = new HashMap<>();
|
||||||
|
if (maxReachMinutes > 0) {
|
||||||
|
reachAnchorNumMap = guildMicStatisticsPolicy2Service.mapByPartitionGuildDate(statDate, partitionId, maxReachMinutes, new ArrayList<>(guildIds));
|
||||||
|
}
|
||||||
|
levelInfos.sort(Comparator.comparing(GuildTaskLevelInfo::getLevel));
|
||||||
|
for (Guild guild : guilds) {
|
||||||
|
Integer guildId = guild.getId();
|
||||||
|
List<GuildTaskReachRecord> existRecords = guildTaskReachRecordService.listByCycle(cycleDate, partitionId, guildId, taskKey);
|
||||||
|
this.calProgress(partitionEnum, guild, taskLevelInfos, existRecords, resultList, cycleDate, statDate,
|
||||||
|
guildMemberNumMap, diamondMap, reachAnchorNumMap, now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(resultList)) {
|
||||||
|
guildTaskReachRecordService.saveOrUpdateBatch(resultList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<GuildTaskLevelInfoVo> getGuildTaskLevelInfoList(Integer partitionId, Integer guildId, Byte type) {
|
||||||
|
List<GuildTaskLevelInfoVo> resultList = new ArrayList<>();
|
||||||
|
// List<GuildTaskLevelInfo> guildTaskLevelInfos = guildTaskLevelInfoService.listGuildTasks(partitionId, type);
|
||||||
|
// if (CollectionUtils.isEmpty(guildTaskLevelInfos)) {
|
||||||
|
// return resultList;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
}
|
@@ -66,6 +66,20 @@
|
|||||||
where stat_date = #{statDate} and partition_id = #{partitionId}
|
where stat_date = #{statDate} and partition_id = #{partitionId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="groupByPartitionGuildDate" resultType="com.accompany.business.vo.guildpolicy.GuildMemberMicDayVo">
|
||||||
|
select
|
||||||
|
gmp.guild_id guildId,
|
||||||
|
count(mic_minutes > #{reachMinutes}) micDay
|
||||||
|
from guild_mic_statistics_policy2 gmp
|
||||||
|
left join guild_member gm on gm.id = gmp.guild_member_id
|
||||||
|
where gm.`enable` = 1
|
||||||
|
and gmp.stat_date = #{statDate}
|
||||||
|
and gmp.partition_id = #{partitionId}
|
||||||
|
<foreach collection="guildIds" item="g" open="and gmp.guild_id in(" close=")" separator=",">
|
||||||
|
#{g}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.accompany.business.mybatismapper.guildtask.GuildTaskLevelInfoMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.accompany.business.mybatismapper.guildtask.GuildTaskLevelRewardMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.accompany.business.mybatismapper.guildtask.GuildTaskLevelRewardRecordMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.accompany.business.mybatismapper.guildtask.GuildTaskReachRecordMapper">
|
||||||
|
|
||||||
|
</mapper>
|
@@ -1,8 +1,10 @@
|
|||||||
package com.accompany.business.controller.activity.dailytask;
|
package com.accompany.business.controller.activity.dailytask;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
|
import com.accompany.business.constant.dailytask.DailyTaskTypeEnum;
|
||||||
import com.accompany.business.service.dailytask.DailyTaskService;
|
import com.accompany.business.service.dailytask.DailyTaskService;
|
||||||
import com.accompany.business.service.dailytask.DailyTaskShopService;
|
import com.accompany.business.service.dailytask.DailyTaskShopService;
|
||||||
|
import com.accompany.business.service.guildtask.GuildTaskService;
|
||||||
import com.accompany.business.vo.dailytask.DailyTaskShopCenterVo;
|
import com.accompany.business.vo.dailytask.DailyTaskShopCenterVo;
|
||||||
import com.accompany.business.vo.dailytask.DailyTaskTabVo;
|
import com.accompany.business.vo.dailytask.DailyTaskTabVo;
|
||||||
import com.accompany.business.vo.dailytask.DailyTaskVo;
|
import com.accompany.business.vo.dailytask.DailyTaskVo;
|
||||||
@@ -10,6 +12,7 @@ import com.accompany.business.vo.dailytask.UserGoldBeanBillVo;
|
|||||||
import com.accompany.common.annotation.Authorization;
|
import com.accompany.common.annotation.Authorization;
|
||||||
import com.accompany.common.result.BusiResult;
|
import com.accompany.common.result.BusiResult;
|
||||||
import com.accompany.common.utils.IPUtils;
|
import com.accompany.common.utils.IPUtils;
|
||||||
|
import com.accompany.core.enumeration.PartitionEnum;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
@@ -31,6 +34,8 @@ public class DailyTaskController {
|
|||||||
private DailyTaskService dailyTaskService;
|
private DailyTaskService dailyTaskService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DailyTaskShopService dailyTaskShopService;
|
private DailyTaskShopService dailyTaskShopService;
|
||||||
|
@Autowired
|
||||||
|
private GuildTaskService guildTaskService;
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "任务列表-tab", httpMethod = "GET")
|
@ApiOperation(value = "任务列表-tab", httpMethod = "GET")
|
||||||
@@ -88,4 +93,15 @@ public class DailyTaskController {
|
|||||||
return dailyTaskShopService.bill(uid, billType, pageNo, pageSize);
|
return dailyTaskShopService.bill(uid, billType, pageNo, pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "任务执行", ignoreJsonView = true)
|
||||||
|
@GetMapping("/executeTaskCreate")
|
||||||
|
public void executeTaskCreate(String date, Integer partitionId) {
|
||||||
|
guildTaskService.updateTaskCreateProgress(DateUtil.parseDateTime(date), PartitionEnum.getByPartitionId(partitionId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "每周任务执行", ignoreJsonView = true)
|
||||||
|
@GetMapping("/executeTaskWeek")
|
||||||
|
public void executeTaskWeek(String date, Integer partitionId) {
|
||||||
|
guildTaskService.updateTaskCreateProgress(DateUtil.parseDateTime(date), PartitionEnum.getByPartitionId(partitionId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,45 @@
|
|||||||
|
package com.accompany.scheduler.task.dailytask;
|
||||||
|
|
||||||
|
import com.accompany.business.service.guildtask.GuildTaskService;
|
||||||
|
import com.accompany.core.enumeration.PartitionEnum;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class GuildCreateTask {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GuildTaskService guildTaskService;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/10 * * * ?")
|
||||||
|
public void guildCreateTaskByMinutes() {
|
||||||
|
Date now = new Date();
|
||||||
|
log.info("GuildCreateTaskByMinutes start");
|
||||||
|
PartitionEnum[] values = PartitionEnum.values();
|
||||||
|
for (PartitionEnum partitionEnum : values) {
|
||||||
|
try {
|
||||||
|
guildTaskService.updateTaskCreateProgress(now, partitionEnum);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("GuildCreateTaskByMinutes error:{}" , e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("GuildCreateTaskByMinutes end");
|
||||||
|
|
||||||
|
log.info("GuildWeekTaskByMinutes start");
|
||||||
|
|
||||||
|
for (PartitionEnum partitionEnum : values) {
|
||||||
|
try {
|
||||||
|
guildTaskService.updateWeekTaskProgress(now, partitionEnum);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("GuildWeekTaskByMinutes error:{}" , e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("GuildWeekTaskByMinutes end");
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user