活动:修复限时排行榜
This commit is contained in:
@@ -205,7 +205,7 @@ export async function getActivity(serverId: number, roleId: string, guildCode: s
|
|||||||
activityData = await getTimeLimitRankDataShow(activityId, serverId);
|
activityData = await getTimeLimitRankDataShow(activityId, serverId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTIVITY_TYPE.TASK_PASS: // 限时排行
|
case ACTIVITY_TYPE.TASK_PASS: // 战令、朝花夕拾
|
||||||
{
|
{
|
||||||
activityData = await getTaskPassDataShow(activityId, serverId, roleId);
|
activityData = await getTaskPassDataShow(activityId, serverId, roleId);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -66,25 +66,20 @@ export async function recordGuildFund(serverId: number, guild: GuildType, fund:
|
|||||||
*/
|
*/
|
||||||
export async function sendRankMail(data: TimeLimitRankData, serverId: number) {
|
export async function sendRankMail(data: TimeLimitRankData, serverId: number) {
|
||||||
let redisKey = getRedisKeyByRankType(data.rankType, true);
|
let redisKey = getRedisKeyByRankType(data.rankType, true);
|
||||||
console.log('#### redisKey', redisKey, serverId)
|
|
||||||
if (!redisKey) return null;
|
if (!redisKey) return null;
|
||||||
let r = new Rank(redisKey, { activityId: data.activityId, serverId });
|
let r = new Rank(redisKey, { activityId: data.activityId, serverId });
|
||||||
console.log('#### getRankByRange',r.infoKey, await r.getRankByRange())
|
|
||||||
if(r.infoKey == REDIS_KEY.GUILD_INFO) {
|
if(r.infoKey == REDIS_KEY.GUILD_INFO) {
|
||||||
let allRank = <GuildRankInfo[]>(await r.getRankByRange());
|
let allRank = <GuildRankInfo[]>(await r.getRankByRange());
|
||||||
|
|
||||||
for(let { rank, code, name, leader } of allRank) {
|
for(let { rank, code, name, leader } of allRank) {
|
||||||
let reward = data.getRewardByRank(rank);
|
let reward = data.getRewardByRank(rank);
|
||||||
if(reward) {
|
if(reward) {
|
||||||
if(leader.roleId) {
|
let guild = await GuildModel.findByCode(code, serverId, '+members');
|
||||||
await sendMailByContent(MAIL_TYPE.TIME_LIMIT_RANK, leader.roleId, {
|
console.log(guild.members)
|
||||||
|
for(let roleId of guild.members) {
|
||||||
|
await sendMailByContent(MAIL_TYPE.TIME_LIMIT_RANK, roleId, {
|
||||||
params: [data.tabName,`${rank}`],
|
params: [data.tabName,`${rank}`],
|
||||||
goods: stringWithTypeToRewardInter(reward.rewards)
|
goods: stringWithTypeToRewardInter(roleId == leader.roleId? reward.rewards: reward.guildRewards)
|
||||||
});
|
|
||||||
} else {
|
|
||||||
await sendMailToGuildByContent(MAIL_TYPE.TIME_LIMIT_RANK, code, {
|
|
||||||
params: [data.tabName,`${rank}`],
|
|
||||||
goods: stringWithTypeToRewardInter(reward.guildRewards)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export async function initActivitiesRank(serverId: number) {
|
|||||||
let serverTime = await getServerCreateTime(serverId);
|
let serverTime = await getServerCreateTime(serverId);
|
||||||
let activityGroup = await ActivityGroupModel.findByServerId(serverId);
|
let activityGroup = await ActivityGroupModel.findByServerId(serverId);
|
||||||
let activityGroupId = activityGroup.map(cur => cur.groupId);
|
let activityGroupId = activityGroup.map(cur => cur.groupId);
|
||||||
let activities = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.TIME_LIMIT_RANK, new Date());
|
let activities = await ActivityModel.findOpenActivityByType(activityGroupId, ACTIVITY_TYPE.TIME_LIMIT_RANK);
|
||||||
for(let activity of activities) {
|
for(let activity of activities) {
|
||||||
let data = new TimeLimitRankData(activity, 0, serverTime);
|
let data = new TimeLimitRankData(activity, 0, serverTime);
|
||||||
if(data.beginTime <= Date.now() && data.endTime >= Date.now()) {
|
if(data.beginTime <= Date.now() && data.endTime >= Date.now()) {
|
||||||
|
|||||||
@@ -43,23 +43,22 @@ export default class Activity extends BaseModel {
|
|||||||
|
|
||||||
// 获取正在开启和即将到来的活动列表
|
// 获取正在开启和即将到来的活动列表
|
||||||
public static async findOpenAndComingActivityes() {
|
public static async findOpenAndComingActivityes() {
|
||||||
let now = new Date();
|
let result: ActivityModelType[] = await ActivityModel.find({ isEnable: true }).lean();
|
||||||
let result: ActivityModelType[] = await ActivityModel.find({ endTime: { $gte: now } }).lean();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//根据活动类型查询开启的活动数据
|
//根据活动类型查询开启的活动数据
|
||||||
public static async findOpenActivityByType(activityGroupId: number[], type: number, date: Date) {
|
public static async findOpenActivityByType(activityGroupId: number[], type: number) {
|
||||||
let result: ActivityModelType[] = await ActivityModel.find(
|
let result: ActivityModelType[] = await ActivityModel.find(
|
||||||
{ groupId: { $in: activityGroupId }, type, beginTime: { $lte: date }, endTime: { $gte: date } }
|
{ groupId: { $in: activityGroupId }, type, isEnable: true }
|
||||||
).sort({ activityId: -1 }).lean(true);
|
).sort({ activityId: -1 }).lean(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//根据活动类型查询开启的活动数据
|
//根据活动类型查询开启的活动数据
|
||||||
public static async findOpenActivityByTypes(activityGroupId: number[], types: number[], date: Date) {
|
public static async findOpenActivityByTypes(activityGroupId: number[], types: number[]) {
|
||||||
let result: ActivityModelType[] = await ActivityModel.find(
|
let result: ActivityModelType[] = await ActivityModel.find(
|
||||||
{ groupId: { $in: activityGroupId }, type: { $in: types }, beginTime: { $lte: date }, endTime: { $gte: date } }
|
{ groupId: { $in: activityGroupId }, type: { $in: types }, isEnable: true }
|
||||||
).sort({ activityId: -1 }).lean(true);
|
).sort({ activityId: -1 }).lean(true);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ export abstract class ActivityBase {
|
|||||||
this.endTime = moment(activityData.endTime).add(this.delayDay, 'd').valueOf();
|
this.endTime = moment(activityData.endTime).add(this.delayDay, 'd').valueOf();
|
||||||
this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1;
|
this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1;
|
||||||
this.roundIndex = 1;
|
this.roundIndex = 1;
|
||||||
this.nextRefreshTime = this.endTime;
|
|
||||||
this.name = activityData.name;
|
this.name = activityData.name;
|
||||||
this.isEnable = activityData.isEnable;
|
this.isEnable = activityData.isEnable;
|
||||||
this.interval = activityData.interval * 86400;
|
this.interval = activityData.interval * 86400;
|
||||||
@@ -102,6 +101,8 @@ export abstract class ActivityBase {
|
|||||||
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 86400000));
|
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 86400000));
|
||||||
this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * (this.roundIndex - 1), 'day').add(activityData.effectDay, 'd').valueOf();
|
this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * (this.roundIndex - 1), 'day').add(activityData.effectDay, 'd').valueOf();
|
||||||
this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) / (24 * 60 * 60 * 1000)));
|
this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) / (24 * 60 * 60 * 1000)));
|
||||||
|
} else {
|
||||||
|
this.nextRefreshTime = this.endTime;
|
||||||
}
|
}
|
||||||
if(activityData.hideDayByServer > 0) {
|
if(activityData.hideDayByServer > 0) {
|
||||||
let hidOverTime = moment(serverTime * 1000).add(activityData.hideDayByServer, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
let hidOverTime = moment(serverTime * 1000).add(activityData.hideDayByServer, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export class TimeLimitRankData extends ActivityBase {
|
|||||||
public getRewardByRank(rank: number) {
|
public getRewardByRank(rank: number) {
|
||||||
let result: TimeLimitRankReward;
|
let result: TimeLimitRankReward;
|
||||||
for(let reward of this.rankRewards) {
|
for(let reward of this.rankRewards) {
|
||||||
if(reward.rank > rank) break;
|
|
||||||
result = reward;
|
result = reward;
|
||||||
|
if(reward.rank >= rank) break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -68,8 +68,8 @@ export class TimeLimitRankData extends ActivityBase {
|
|||||||
let dataObj: TimeLimitInDb = JSON.parse(data);
|
let dataObj: TimeLimitInDb = JSON.parse(data);
|
||||||
this.rankType = dataObj.rankType;
|
this.rankType = dataObj.rankType;
|
||||||
this.hid = dataObj.hid;
|
this.hid = dataObj.hid;
|
||||||
this.rankEndTime = new Date(moment(this.beginTime).add(dataObj.rankEndDay, 'd').format(`YYYY-MM-DD ${dataObj.rankEndTime}`)).getTime() ;
|
this.rankEndTime = new Date(moment(this.beginTime).add(dataObj.rankEndDay - 1, 'd').format(`YYYY-MM-DD ${dataObj.rankEndTime}`)).getTime() ;
|
||||||
this.sendMailTime = this.rankEndTime + this.sendMailTime * 1000;
|
this.sendMailTime = this.rankEndTime + dataObj.sendMailTime * 1000;
|
||||||
for(let rank of dataObj.rankRewards) {
|
for(let rank of dataObj.rankRewards) {
|
||||||
this.rankRewards.push(new TimeLimitRankReward(rank));
|
this.rankRewards.push(new TimeLimitRankReward(rank));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user