活动:修改活动的时间配置规则
This commit is contained in:
@@ -59,7 +59,7 @@ export class NewHeroGachaHandler {
|
||||
let activityData: ActivityModelType = await ActivityModel.findActivity(activityId);
|
||||
let playerData = new NewHeroGachaData(activityData);
|
||||
for (let pageData of playerData.list) {
|
||||
await ActivityNewHeroGachaModel.selectedHero(serverId, activityId, roleId, hid, pageData.hid == hid);
|
||||
await ActivityNewHeroGachaModel.selectedHero(serverId, activityId, roleId, pageData.hid, pageData.hid == hid);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
@@ -77,15 +77,17 @@ export class RefreshTaskHandler {
|
||||
//获得点数
|
||||
await ActivityRefreshTaskPointModel.addPoint(serverId, activityId, roleId, dailyItemData.point);
|
||||
|
||||
let addPointActivityId = playerData.addPointActivityId;//点数关联其他活动id
|
||||
if (addPointActivityId) {
|
||||
let activityData = await ActivityModel.findActivity(addPointActivityId);
|
||||
if (activityData) {
|
||||
if (activityData.type === ACTIVITY_TYPE.NEW_HERO_GIFTS) {
|
||||
await newHeroGiftPoint(serverId, addPointActivityId, roleId, dailyItemData.point);
|
||||
}
|
||||
}
|
||||
}
|
||||
// let addPointActivityId = playerData.addPointActivityId;//点数关联其他活动id
|
||||
// if (addPointActivityId) {
|
||||
// let activityData = await ActivityModel.findActivity(addPointActivityId);
|
||||
// if (activityData) {
|
||||
// if (activityData.type === ACTIVITY_TYPE.NEW_HERO_GIFTS) {
|
||||
// await newHeroGiftPoint(serverId, addPointActivityId, roleId, dailyItemData.point);
|
||||
// let uids = [{ uid: roleId, sid }];
|
||||
// this.app.get('channelService').pushMessageByUids('addPoint', resResult(STATUS.SUCCESS, { activityId: addPointActivityId, addPoint: dailyItemData.point }), uids);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
dailyItemData.receiveRewardCount += 1;
|
||||
return resResult(STATUS.SUCCESS, Object.assign(result, {
|
||||
|
||||
@@ -9,8 +9,9 @@ import { nowSeconds, getZeroPointD } from "../../../pubUtils/timeUtil";
|
||||
import { DicDailyTask, DicAchievement, DicMainTask } from "../../../pubUtils/dictionary/DicTask";
|
||||
import { getMainTask, refDailyTaskBox, removeHistoryTask, getCurTask, checkTask } from "../../../services/taskService";
|
||||
import { TASK } from "../../../pubUtils/dicParam";
|
||||
import { newHeroGiftPoint } from "../../../services/activity/newHeroGiftsService";
|
||||
|
||||
export default function(app: Application) {
|
||||
export default function (app: Application) {
|
||||
return new ShopHandler(app);
|
||||
}
|
||||
|
||||
@@ -18,7 +19,7 @@ export class ShopHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
public async getTaskList(msg:{}, session: BackendSession) {
|
||||
public async getTaskList(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
|
||||
const res = await getCurTask(roleId, session);
|
||||
@@ -28,6 +29,7 @@ export class ShopHandler {
|
||||
// 领取主线任务、每日任务、成就单条任务
|
||||
async receiveTask(msg: { type: number, id: number }, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = session.get('serverId');
|
||||
const roleName: string = session.get('roleName');
|
||||
const sid: string = session.get('sid');
|
||||
const { type, id } = msg;
|
||||
@@ -36,32 +38,41 @@ export class ShopHandler {
|
||||
let { group, taskType, taskReward, condition } = dicTask;
|
||||
// 检查
|
||||
let rec = await UserTaskRecModel.findByRoleAndGroup(roleId, type, taskType, group);
|
||||
if(!rec) return resResult(STATUS.TASK_NOT_REACH_CONDITION);
|
||||
if(rec.count < condition) return resResult(STATUS.TASK_NOT_REACH_CONDITION);
|
||||
if(rec.received.includes(id)) return resResult(STATUS.TASK_HAS_RECEIVED);
|
||||
if (!rec) return resResult(STATUS.TASK_NOT_REACH_CONDITION);
|
||||
if (rec.count < condition) return resResult(STATUS.TASK_NOT_REACH_CONDITION);
|
||||
if (rec.received.includes(id)) return resResult(STATUS.TASK_HAS_RECEIVED);
|
||||
|
||||
// 领取记录
|
||||
rec = await UserTaskRecModel.receiveTask(roleId, type, taskType, group, id);
|
||||
|
||||
// 每日、成就增加积分
|
||||
let point = 0, weeklyPoint = 0;
|
||||
if(type == TASK_FUN_TYPE.DAILY) { // 增加积分
|
||||
if (type == TASK_FUN_TYPE.DAILY) { // 增加积分
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
let dic = <DicDailyTask>dicTask;
|
||||
let curWeek = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
|
||||
if(curWeek > userTask.dailyTaskRefWeekly) {
|
||||
if (curWeek > userTask.dailyTaskRefWeekly) {
|
||||
userTask = await UserTaskModel.resetDailyScore(roleId, dic.point, curWeek);
|
||||
} else {
|
||||
userTask = await UserTaskModel.incInfo(roleId, { dailyTaskPoint: dic.point, dailyTaskPointWeekly: dic.point });
|
||||
}
|
||||
point = userTask.dailyTaskPoint;
|
||||
weeklyPoint = userTask.dailyTaskPointWeekly;
|
||||
let addPointActivityId = 0;//点数关联的活动id
|
||||
if (addPointActivityId) {
|
||||
await newHeroGiftPoint(serverId, addPointActivityId, roleId, point);
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
this.app.get('channelService').pushMessageByUids('addPoint', resResult(STATUS.SUCCESS, { activityId: addPointActivityId, addPoint: point }), uids);
|
||||
}
|
||||
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
|
||||
let dic = <DicAchievement>dicTask;
|
||||
let userTask = await UserTaskModel.incInfo(roleId, { achievementPoint: dic.point });
|
||||
point = userTask.achievementPoint;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
@@ -80,17 +91,17 @@ export class ShopHandler {
|
||||
const { stage } = msg;
|
||||
|
||||
let dicMainStage = gameData.mainTaskStage.get(stage);
|
||||
if(!dicMainStage) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicMainStage) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
// 检查
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
if(userTask.mainTaskStage != stage) {
|
||||
if (userTask.mainTaskStage != stage) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
let recs = await UserTaskRecModel.getReceiveRec(roleId, TASK_FUN_TYPE.MAIN);
|
||||
for(let id of dicMainStage.mainTaskId) {
|
||||
for (let id of dicMainStage.mainTaskId) {
|
||||
let curRecs = recs.find(cur => cur.received.includes(id));
|
||||
if(!curRecs) return resResult(STATUS.TASK_NOT_ALL_RECEIVED);
|
||||
if (!curRecs) return resResult(STATUS.TASK_NOT_ALL_RECEIVED);
|
||||
}
|
||||
// 更新数据
|
||||
userTask = await UserTaskModel.incInfo(roleId, { mainTaskStage: 1 });
|
||||
@@ -106,7 +117,7 @@ export class ShopHandler {
|
||||
}
|
||||
|
||||
// 领取每日活跃奖励
|
||||
async receiveActiveReward(msg: { }, session: BackendSession) {
|
||||
async receiveActiveReward(msg: {}, session: BackendSession) {
|
||||
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
@@ -115,12 +126,12 @@ export class ShopHandler {
|
||||
// 检查
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
let { dailyTaskPoint } = userTask;
|
||||
if(dailyTaskPoint < TASK.DAILYTASK_POINT) {
|
||||
if (dailyTaskPoint < TASK.DAILYTASK_POINT) {
|
||||
return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
}
|
||||
// 更新数据
|
||||
userTask = await UserTaskModel.decreaseDailyPoint(roleId, TASK.DAILYTASK_POINT);
|
||||
if(!userTask) return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
if (!userTask) return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
|
||||
let reward = parseGoodStr(TASK.DAILYTASK_POINT_REWARD);
|
||||
let goods = await addItems(roleId, roleName, sid, reward);
|
||||
@@ -141,22 +152,22 @@ export class ShopHandler {
|
||||
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
let dicTaskBox = gameData.taskBox.get(type)?.get(id);
|
||||
if(!dicTaskBox) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicTaskBox) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let point = 0, weeklyPoint = 0, box: number[] = [];
|
||||
// 每日、成就增加积分
|
||||
if(type == TASK_FUN_TYPE.DAILY) { // 增加积分
|
||||
if (type == TASK_FUN_TYPE.DAILY) { // 增加积分
|
||||
let curWeek = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
|
||||
let shouldRefresh = false;
|
||||
let { dailyTaskPointWeekly, dailyTaskBox, dailyTaskRefWeekly } = userTask;
|
||||
|
||||
if(curWeek > dailyTaskRefWeekly) {
|
||||
if (curWeek > dailyTaskRefWeekly) {
|
||||
shouldRefresh = true;
|
||||
dailyTaskPointWeekly = 0;
|
||||
dailyTaskBox = [];
|
||||
}
|
||||
if(dailyTaskPointWeekly < dicTaskBox.point) return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
if(dailyTaskBox.includes(id)) return resResult(STATUS.TASK_BOX_HAS_RECEIVED);
|
||||
if (dailyTaskPointWeekly < dicTaskBox.point) return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
if (dailyTaskBox.includes(id)) return resResult(STATUS.TASK_BOX_HAS_RECEIVED);
|
||||
|
||||
userTask = await UserTaskModel.pushDailyBox(roleId, id, curWeek, shouldRefresh);
|
||||
|
||||
@@ -166,8 +177,8 @@ export class ShopHandler {
|
||||
|
||||
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
|
||||
let { achievementPoint, achievementBox } = userTask;
|
||||
if(achievementPoint > dicTaskBox.point) return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
if(achievementBox.includes(id)) return resResult(STATUS.TASK_BOX_HAS_RECEIVED);
|
||||
if (achievementPoint > dicTaskBox.point) return resResult(STATUS.TASK_ACTIVE_NOT_ENOUGH);
|
||||
if (achievementBox.includes(id)) return resResult(STATUS.TASK_BOX_HAS_RECEIVED);
|
||||
|
||||
userTask = await UserTaskModel.pushAchievementBox(roleId, id);
|
||||
|
||||
@@ -197,12 +208,12 @@ export class ShopHandler {
|
||||
const sid: string = session.get('sid');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
const { type } = msg
|
||||
let tasks: (DicMainTask|DicDailyTask|DicAchievement)[] = [];
|
||||
for(let [_id, task] of gameData.tasks.get(type)) {
|
||||
let tasks: (DicMainTask | DicDailyTask | DicAchievement)[] = [];
|
||||
for (let [_id, task] of gameData.tasks.get(type)) {
|
||||
tasks.push(task);
|
||||
}
|
||||
let task = getRandSingleEelm(tasks);
|
||||
await checkTask(roleId, sid, [1,2,3,4,5], task.taskType, task.condition, false, { isDebug: true });
|
||||
await checkTask(roleId, sid, [1, 2, 3, 4, 5], task.taskType, task.condition, false, { isDebug: true });
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
task
|
||||
});
|
||||
@@ -213,9 +224,9 @@ export class ShopHandler {
|
||||
let sid = session.get('sid');
|
||||
let { type } = msg
|
||||
let userTask;
|
||||
if(type == TASK_FUN_TYPE.DAILY) {
|
||||
let uids = [{uid: roleId, sid}];
|
||||
|
||||
if (type == TASK_FUN_TYPE.DAILY) {
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
|
||||
// 转移每日任务
|
||||
await removeHistoryTask(roleId, type, new Date(nowSeconds() * 1000 + 86400000));
|
||||
pinus.app.get('channelService').pushMessageByUids('onDailyTaskRefresh', resResult(STATUS.SUCCESS, { taskList: [] }), uids);
|
||||
@@ -223,7 +234,7 @@ export class ShopHandler {
|
||||
await refDailyTaskBox(roleId, sid, true);
|
||||
userTask = await UserTaskModel.updateInfo(roleId, { dailyTaskPoint: 0 });
|
||||
|
||||
} else if( type == TASK_FUN_TYPE.MAIN){
|
||||
} else if (type == TASK_FUN_TYPE.MAIN) {
|
||||
await UserTaskModel.updateInfo(roleId, { mainTaskStage: 1 });
|
||||
userTask = await removeHistoryTask(roleId, type, new Date(nowSeconds() * 1000 + 86400000));
|
||||
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
|
||||
@@ -235,24 +246,24 @@ export class ShopHandler {
|
||||
return resResult(STATUS.SUCCESS, curTask);
|
||||
}
|
||||
|
||||
async debugCompleteMainStage(msg: { }, session: BackendSession) {
|
||||
async debugCompleteMainStage(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let sid = session.get('sid');
|
||||
|
||||
|
||||
|
||||
// 检查
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
let stage = userTask.mainTaskStage;
|
||||
|
||||
let dicMainStage = gameData.mainTaskStage.get(stage);
|
||||
if(!dicMainStage) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicMainStage) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let recs = await UserTaskRecModel.getReceiveRec(roleId, TASK_FUN_TYPE.MAIN);
|
||||
for(let id of dicMainStage.mainTaskId) {
|
||||
for (let id of dicMainStage.mainTaskId) {
|
||||
let dicTask = gameData.tasks.get(TASK_FUN_TYPE.MAIN)?.get(id);
|
||||
if(!dicTask) continue;
|
||||
if (!dicTask) continue;
|
||||
let curRecs = recs.find(cur => cur.received.includes(id));
|
||||
if(!curRecs) {
|
||||
if (!curRecs) {
|
||||
await UserTaskRecModel.setTaskRec(roleId, TASK_FUN_TYPE.MAIN, dicTask.taskType, dicTask.group, dicTask.condition);
|
||||
};
|
||||
}
|
||||
@@ -268,10 +279,10 @@ export class ShopHandler {
|
||||
|
||||
// 每日、成就增加积分
|
||||
let point = 0, weeklyPoint = 0;
|
||||
if(type == TASK_FUN_TYPE.DAILY) { // 增加积分
|
||||
if (type == TASK_FUN_TYPE.DAILY) { // 增加积分
|
||||
let userTask = await UserTaskModel.findByRole(roleId);
|
||||
let curWeek = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
|
||||
if(curWeek > userTask.dailyTaskRefWeekly) {
|
||||
if (curWeek > userTask.dailyTaskRefWeekly) {
|
||||
userTask = await UserTaskModel.resetDailyScore(roleId, incPoint, curWeek);
|
||||
} else {
|
||||
userTask = await UserTaskModel.incInfo(roleId, { dailyTaskPoint: incPoint, dailyTaskPointWeekly: incPoint });
|
||||
|
||||
@@ -82,7 +82,6 @@ export async function makeDailyRMBGiftsReward(roleId: string, roleName: string,
|
||||
|
||||
for (let i = 0; i < playerData.day; i++) {
|
||||
let beginTime = playerData.beginTime + 24 * 60 * 60 * 1000 * i;
|
||||
// let beginTime = moment(new Date()).startOf('d').add(i, 'day').add(REFRESH_TIME, 'h').toDate();
|
||||
await ActivityDailyRMBGiftsModel.buyRecord(serverId, activityId, roleId, moment(beginTime).toDate(), true);
|
||||
}
|
||||
let endTime = moment(playerData.endTime).add(playerData.day, 'd').toDate()
|
||||
|
||||
@@ -25,9 +25,13 @@ export default class Activity extends BaseModel {
|
||||
|
||||
|
||||
@prop({ required: true })
|
||||
timeType: number; // 活动时间类型 ACTIVITY_TIME_TYPE
|
||||
timeType: number; // 活动时间类型 ACTIVITY_TIME_TYPE 1.服务器开启时间 2.角色创建时间 3.指定开启时间(beginTime,endTime)
|
||||
@prop({ required: true })
|
||||
days: number; // 活动持续天数 timeType=1、2
|
||||
@prop({ required: true })
|
||||
delayDay: number; // 迟几天开启活动,0表示按照规定时间开启
|
||||
@prop({ required: true })
|
||||
interval: number; // 周期性活动时间间隔,秒
|
||||
|
||||
|
||||
//根据活动类型查询开启的活动数据
|
||||
@@ -70,7 +74,7 @@ export default class Activity extends BaseModel {
|
||||
if (endTime != undefined) {
|
||||
update["endTime"] = endTime;
|
||||
}
|
||||
let rec: ActivityModelType = await ActivityModel.findOneAndUpdate({ activityId }, { $set: {...update, updatedBy: uid}, $setOnInsert: { createdBy: uid } },
|
||||
let rec: ActivityModelType = await ActivityModel.findOneAndUpdate({ activityId }, { $set: { ...update, updatedBy: uid }, $setOnInsert: { createdBy: uid } },
|
||||
{ new: true, upsert: true }).lean(true);
|
||||
result.push(rec);
|
||||
}
|
||||
@@ -102,8 +106,8 @@ export default class Activity extends BaseModel {
|
||||
searchObj['endTime'] = { $gte: new Date };
|
||||
}
|
||||
let sort = {};
|
||||
if(sortField && sortOrder) {
|
||||
if(sortOrder == 'ascend') {
|
||||
if (sortField && sortOrder) {
|
||||
if (sortOrder == 'ascend') {
|
||||
sort[sortField] = 1;
|
||||
} else if (sortOrder == 'descend') {
|
||||
sort[sortField] = -1;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import moment = require('moment');
|
||||
import { ACTIVITY_TIME_TYPE, REFRESH_TIME, SERVER_OPEN_TIME } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { deltaDays } from '../../pubUtils/util';
|
||||
|
||||
@@ -9,6 +10,10 @@ export abstract class ActivityBase {
|
||||
endTime: number = 0;
|
||||
type: number = 0;
|
||||
todayIndex: number = 0;//从1开始
|
||||
delayDay: number = 0;//延迟多少天开启,0表示按照原计划开启
|
||||
|
||||
roundIndex: number = 0;//周期活动第几个周期,从1开始
|
||||
nextRefreshTime: number = 0;//周期活动下次刷新时间
|
||||
|
||||
abstract initData(data: string): void;
|
||||
|
||||
@@ -19,11 +24,52 @@ export abstract class ActivityBase {
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
this.activityId = activityData.activityId;
|
||||
this.beginTime = moment(activityData.beginTime).valueOf();
|
||||
this.endTime = moment(activityData.endTime).valueOf();
|
||||
this.delayDay = activityData.delayDay ? activityData.delayDay : 0;
|
||||
this.beginTime = moment(activityData.beginTime).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.type = activityData.type;
|
||||
// this.data = activityData.data;
|
||||
this.todayIndex = deltaDays(moment(activityData.beginTime).startOf('d').toDate(), new Date) + 1;
|
||||
// console.log('今天是活动第几天', activityData.beginTime, new Date, this.todayIndex)
|
||||
switch (activityData.timeType) {
|
||||
case ACTIVITY_TIME_TYPE.SERVER_OPEN_TIME: {
|
||||
this.beginTime = moment(SERVER_OPEN_TIME).add(this.delayDay, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
if (activityData.days > 0) {
|
||||
this.endTime = moment(this.beginTime).add(activityData.days, 'd').valueOf();
|
||||
} else {
|
||||
this.endTime = moment(this.beginTime).add(1, 'd').valueOf();
|
||||
}
|
||||
this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1;
|
||||
console.log('活动时间数据11...', activityData.timeType, this.beginTime, this.endTime, this.todayIndex, this.roundIndex, this.nextRefreshTime)
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TIME_TYPE.ROLE_REGISTER_TIME: {
|
||||
this.beginTime = moment(SERVER_OPEN_TIME).add(this.delayDay, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
if (activityData.days > 0) {
|
||||
this.endTime = moment(this.beginTime).add(activityData.days, 'd').valueOf();
|
||||
} else {
|
||||
this.endTime = moment(this.beginTime).add(1, 'd').valueOf();
|
||||
}
|
||||
this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1;
|
||||
|
||||
console.log('活动时间数据22...', activityData.timeType, this.beginTime, this.endTime, this.todayIndex, this.roundIndex, this.nextRefreshTime)
|
||||
break;
|
||||
}
|
||||
case ACTIVITY_TIME_TYPE.DATE_TIME: {
|
||||
console.log('活动时间数据33...', activityData.timeType, this.beginTime, this.endTime, this.todayIndex, this.roundIndex, this.nextRefreshTime)
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (activityData.interval > 0) {
|
||||
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 1000));
|
||||
this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * this.roundIndex, 'second').valueOf();
|
||||
this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) % (activityData.interval * 1000)) / 24 * 60 * 60 * 1000);
|
||||
}
|
||||
console.log('活动时间数据...', '活动id:', activityData.activityId, '类型:', activityData.timeType, '开始时间:', this.beginTime, moment(this.beginTime).toDate(),
|
||||
'结束:', this.endTime, moment(this.endTime).toDate(),
|
||||
'今天第几天:', this.todayIndex, '回合:', this.roundIndex, '下次刷新:', this.nextRefreshTime, moment(this.nextRefreshTime).toDate())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,14 +100,16 @@ export class DailyCoinData extends ActivityBase {
|
||||
for (let obj of dataObj.coinRewardFormula) {
|
||||
this.coinRewardFormulaItem.push(new CoinRewardFormulaItem(obj))
|
||||
}
|
||||
let curDate = moment(new Date());
|
||||
if (curDate.hour() < REFRESH_TIME) {
|
||||
this.beginTime = curDate.startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
this.endTime = moment(this.beginTime).add(1, 'd').valueOf();
|
||||
} else {
|
||||
this.beginTime = curDate.startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
this.endTime = moment(this.beginTime).add(1, 'd').valueOf()
|
||||
}
|
||||
// let curDate = moment(new Date());
|
||||
// if (curDate.hour() < REFRESH_TIME) {
|
||||
// this.beginTime = curDate.startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
// this.endTime = moment(this.beginTime).add(1, 'd').valueOf();
|
||||
// } else {
|
||||
// this.beginTime = curDate.startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
// this.endTime = moment(this.beginTime).add(1, 'd').valueOf()
|
||||
// }
|
||||
// console.log('ddddddddddddbbbbbbb')
|
||||
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
|
||||
@@ -56,14 +56,15 @@ export class DailyMealData extends ActivityBase {
|
||||
for (let obj of arr) {
|
||||
this.list.push(new DailyMealItem(obj))
|
||||
}
|
||||
let curDate = moment(new Date());
|
||||
if (curDate.hour() < REFRESH_TIME) {
|
||||
this.beginTime = curDate.startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
this.endTime = moment(this.beginTime).add(1, 'd').valueOf();
|
||||
} else {
|
||||
this.beginTime = curDate.startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
this.endTime = moment(this.beginTime).add(1, 'd').valueOf()
|
||||
}
|
||||
// let curDate = moment(new Date());
|
||||
// if (curDate.hour() < REFRESH_TIME) {
|
||||
// this.beginTime = curDate.startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
// this.endTime = moment(this.beginTime).add(1, 'd').valueOf();
|
||||
// } else {
|
||||
// this.beginTime = curDate.startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
// this.endTime = moment(this.beginTime).add(1, 'd').valueOf()
|
||||
// }
|
||||
// console.log('ddddddddddddbbbbbbb')
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
|
||||
@@ -84,14 +84,16 @@ export class DailyRMBGiftsData extends ActivityBase {
|
||||
this.day = dataObj.day;
|
||||
this.price = dataObj.price;
|
||||
this.productID = dataObj.productID;
|
||||
let curDate = moment(new Date());
|
||||
if (curDate.hour() < REFRESH_TIME) {
|
||||
this.beginTime = moment(new Date()).startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
this.endTime = moment(new Date()).startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
} else {
|
||||
this.beginTime = moment(new Date()).startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
this.endTime = moment(new Date()).startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
}
|
||||
// let curDate = moment(new Date());
|
||||
// if (curDate.hour() < REFRESH_TIME) {
|
||||
// this.beginTime = moment(new Date()).startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
// this.endTime = moment(new Date()).startOf('d').add(-1, 'd').add(REFRESH_TIME, 'h').valueOf();
|
||||
// } else {
|
||||
// this.beginTime = moment(new Date()).startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
// this.endTime = moment(new Date()).startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
// }
|
||||
|
||||
// console.log('ddddddddddddbbbbbbb', this.activityId, this.beginTime, this.endTime)
|
||||
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
|
||||
@@ -80,12 +80,12 @@ export class LimitShopData extends ActivityBase {
|
||||
this.name = dataObj.name;
|
||||
this.interval = dataObj.interval;
|
||||
|
||||
this.beginTime = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'hour').valueOf();
|
||||
if (this.interval > 0) {
|
||||
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000));
|
||||
this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf();
|
||||
}
|
||||
console.log(moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex,)
|
||||
// this.beginTime = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'hour').valueOf();
|
||||
// if (this.interval > 0) {
|
||||
// this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000));
|
||||
// this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf();
|
||||
// }
|
||||
// console.log('ddddddddddddbbbbbbb', moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex,)
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new ShopItem(obj))
|
||||
|
||||
@@ -158,12 +158,12 @@ export class RefreshShopData extends ActivityBase {
|
||||
this.name = dataObj.name;
|
||||
this.interval = dataObj.interval;
|
||||
|
||||
this.beginTime = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'hour').valueOf();
|
||||
if (this.interval > 0) {
|
||||
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000));
|
||||
this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf();
|
||||
}
|
||||
console.log(moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex,)
|
||||
// this.beginTime = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'hour').valueOf();
|
||||
// if (this.interval > 0) {
|
||||
// this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000));
|
||||
// this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf();
|
||||
// }
|
||||
// console.log('ddddddddddddbbbbbbb', moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex,)
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new RefreshShopPage(obj))
|
||||
|
||||
@@ -117,12 +117,12 @@ export class RefreshTaskData extends ActivityBase {
|
||||
this.totalPoint = 0;
|
||||
this.exchangePoint = 0;
|
||||
|
||||
this.beginTime = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'hour').valueOf();
|
||||
if (this.interval > 0) {
|
||||
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000));
|
||||
this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf();
|
||||
}
|
||||
console.log(moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex,)
|
||||
// this.beginTime = moment(this.beginTime).startOf('d').add(REFRESH_TIME, 'hour').valueOf();
|
||||
// if (this.interval > 0) {
|
||||
// this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (this.interval * 1000));
|
||||
// this.nextRefreshTime = moment(this.beginTime).add(this.interval * this.roundIndex, 'second').valueOf();
|
||||
// }
|
||||
// console.log('ddddddddddddbbbbbbb', moment(new Date).valueOf(), moment(this.beginTime).valueOf(), this.roundIndex, this.nextRefreshTime)
|
||||
let arr = dataObj.data;
|
||||
for (let obj of arr) {
|
||||
this.list.push(new RefreshTaskPage(obj))
|
||||
|
||||
@@ -318,14 +318,6 @@ export class SevenDaysData extends ActivityBase {
|
||||
this.growth = new SevenDaysGrowthData(objData.growth)
|
||||
this.dailyGift = new SevenDaysDailyGiftsData(objData.dailyGift)
|
||||
this.dailyChallenge = new SevenDaysDailyChallengesData(objData.dailyChallenge)
|
||||
|
||||
if (this.type === ACTIVITY_TYPE.SEVEN_DAY) {
|
||||
this.todayIndex = deltaDays(moment(SERVER_OPEN_TIME).startOf('d').toDate(), new Date) + 1;
|
||||
} else if (this.type === ACTIVITY_TYPE.FOURTEEN_DAY) {
|
||||
this.todayIndex = deltaDays(moment(SERVER_OPEN_TIME).startOf('d').toDate(), new Date) + 1 - 7;
|
||||
} else if (this.type === ACTIVITY_TYPE.COMMON_SEVEN_DAY) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
constructor(activityData: ActivityModelType) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 任务
|
||||
import { RewardInter } from '../interface';
|
||||
import { readFileAndParse, parseNumberList, parseGoodStr } from '../util';
|
||||
import { FILENAME, TASK_FUN_TYPE} from '../../consts';
|
||||
import { FILENAME, TASK_FUN_TYPE } from '../../consts';
|
||||
const _ = require('lodash');
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
@@ -53,6 +53,8 @@ export interface DicDailyTask extends DicTaskBase {
|
||||
readonly point: number;
|
||||
// 经验基数
|
||||
readonly exp: number;
|
||||
// 获得积分关联的活动id
|
||||
readonly addPointActivityId: number;
|
||||
}
|
||||
|
||||
const DicDailyTaskKeys: KeysEnum<DicDailyTask> = {
|
||||
@@ -63,7 +65,8 @@ const DicDailyTaskKeys: KeysEnum<DicDailyTask> = {
|
||||
condition: true,
|
||||
taskReward: true,
|
||||
point: true,
|
||||
exp: true
|
||||
exp: true,
|
||||
addPointActivityId: true
|
||||
};
|
||||
|
||||
// 成就
|
||||
@@ -89,7 +92,7 @@ export type DicTask = DicTaskBase & { type: number };
|
||||
export const dicMainTask = new Map<number, DicMainTask>(); // 主线任务
|
||||
export const dicDailyTask = new Map<number, DicDailyTask>(); // 每日任务
|
||||
export const dicAchievement = new Map<number, DicAchievement>(); // 成就
|
||||
export const taskMap = new Map<number, Map<number, DicMainTask|DicDailyTask|DicAchievement>>();
|
||||
export const taskMap = new Map<number, Map<number, DicMainTask | DicDailyTask | DicAchievement>>();
|
||||
taskMap.set(TASK_FUN_TYPE.MAIN, dicMainTask);
|
||||
taskMap.set(TASK_FUN_TYPE.DAILY, dicDailyTask);
|
||||
taskMap.set(TASK_FUN_TYPE.ACHIEVEMENT, dicAchievement);
|
||||
@@ -104,7 +107,7 @@ export function loadTask() {
|
||||
dicMainTask.set(o.id, _.pick(o, Object.keys(DicMainTaskKeys)));
|
||||
pushDicTaskType(o.taskType, TASK_FUN_TYPE.MAIN, o);
|
||||
});
|
||||
|
||||
|
||||
const arrDailyTask = readFileAndParse(FILENAME.DIC_DAILY_TASK);
|
||||
arrDailyTask.forEach(o => {
|
||||
o.taskParam = parseNumberList(o.taskParam);
|
||||
@@ -112,7 +115,7 @@ export function loadTask() {
|
||||
dicDailyTask.set(o.id, _.pick(o, Object.keys(DicDailyTaskKeys)));
|
||||
pushDicTaskType(o.taskType, TASK_FUN_TYPE.DAILY, o);
|
||||
});
|
||||
|
||||
|
||||
const arrAchievement = readFileAndParse(FILENAME.DIC_ACHIEVEMENT);
|
||||
arrAchievement.forEach(o => {
|
||||
o.taskParam = parseNumberList(o.taskParam);
|
||||
@@ -120,11 +123,11 @@ export function loadTask() {
|
||||
dicAchievement.set(o.id, _.pick(o, Object.keys(DicAchievementKeys)));
|
||||
pushDicTaskType(o.taskType, TASK_FUN_TYPE.ACHIEVEMENT, o);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function pushDicTaskType(taskType: number, type: number, o: any) {
|
||||
if(!dicTaskType.has(taskType)) {
|
||||
if (!dicTaskType.has(taskType)) {
|
||||
dicTaskType.set(taskType, new Array<DicTask>());
|
||||
}
|
||||
let newObj = _.pick(o, Object.keys(DicTaskKeys));
|
||||
|
||||
Reference in New Issue
Block a user