活动:修改活动bug
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
export enum ACTIVITY_TYPE {
|
||||
SEVEN_DAY = 0, // 七天乐活动(虚)
|
||||
DAILY_DISCOUNT_GIFT = 1, // 七天乐活动,每日特惠礼包
|
||||
TASK_GROWTH = 2, // 成长任务活动
|
||||
TASK_DAILY_CHALLENGES = 3, // 今日挑战活动
|
||||
@@ -97,4 +98,4 @@ export const DAILYRMBGIFTS_DAYS = 7;//一次性购买*天
|
||||
|
||||
//签到活动开启时间
|
||||
export const SIGNIN_OPEN = 5;//*号0点开启
|
||||
export const SIGNIN_CLOSE = 24;//*号晚上24点结束
|
||||
export const SIGNIN_CLOSE = 30;//*号晚上24点结束
|
||||
@@ -359,6 +359,7 @@ export const STATUS = {
|
||||
ACTIVITY_POP_UP_SHOP_EXPIRE: { code: 50022, simStr: '弹出商店过期' },
|
||||
ACTIVITY_NEED_PAY: { code: 50023, simStr: '客户端调错接口了' },
|
||||
ACTIVITY_GOLD_RESOURCE: { code: 50024, simStr: '元宝资源' },
|
||||
ACTIVITY_ID_ERROR: { code: 50025, simStr: 'id错误' },
|
||||
// GM后台相关状态 60000 - 69999
|
||||
GM_ERR_PASSWORD: { code: 60001, simStr: '账号或密码错误' },
|
||||
GM_MISS_API: { code: 60002, simStr: '未找到该接口' },
|
||||
|
||||
@@ -23,8 +23,8 @@ export default class Activity extends BaseModel {
|
||||
data: string; // 活动表中的数据
|
||||
|
||||
//根据活动类型查询开启的活动数据
|
||||
public static async findOpenActivityByType(serverId: number, type: number, date: Date, lean = true) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ serverId, type, beginTime: { $lte: date }, endTime: { $gte: date } }).sort({ activityId: -1 }).lean(lean);
|
||||
public static async findOpenActivityByType(serverId: number, type: number, date: Date) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ serverId, type, beginTime: { $lte: date }, endTime: { $gte: date } }).sort({ activityId: -1 }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ export default class Activity extends BaseModel {
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findActivity(serverId: number, activityId: number, lean = true) {
|
||||
let result: ActivityModelType = await ActivityModel.findOne({ serverId, activityId }).lean(lean);
|
||||
public static async findActivity(serverId: number, activityId: number) {
|
||||
let result: ActivityModelType = await ActivityModel.findOne({ serverId, activityId }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增活动
|
||||
public static async addActivity(aids: number[], serverId: number, beginTime: Date, endTime: Date, type: number, data: string, lean = true) {
|
||||
public static async addActivity(aids: number[], serverId: number, beginTime: Date, endTime: Date, type: number, data: string) {
|
||||
let result: ActivityModelType[] = [];
|
||||
for (let activityId of aids) {
|
||||
if (!activityId) activityId = await CounterModel.getNewCounter(COUNTER.ACTIVITY);
|
||||
@@ -56,7 +56,7 @@ export default class Activity extends BaseModel {
|
||||
update["endTime"] = endTime;
|
||||
}
|
||||
let rec: ActivityModelType = await ActivityModel.findOneAndUpdate({ activityId }, { $set: update },
|
||||
{ new: true, upsert: true }).lean(lean);
|
||||
{ new: true, upsert: true }).lean(true);
|
||||
result.push(rec);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -23,15 +23,13 @@ export default class Activity_Growth extends BaseModel {
|
||||
totalCount: number; // 累计达成次数
|
||||
@prop({ required: true })
|
||||
receiveRewardCount: number; // 领取奖励次数
|
||||
@prop({ required: true, default: 0 })
|
||||
addPointCount: number; // 获得奖章个数
|
||||
@prop({ required: true, default: false })
|
||||
getPointReward: boolean; // 是否兑换领取奖章奖励
|
||||
|
||||
//任务领取记录
|
||||
public static async addCellRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, addPointCount: number, lean = true) {
|
||||
public static async addCellRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number,) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { receiveRewardCount: count, addPointCount: addPointCount } }, { upsert: true, new: true }).lean(lean);
|
||||
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,6 @@ export abstract class ActivityBase {
|
||||
this.type = activityData.type;
|
||||
// this.data = activityData.data;
|
||||
this.todayIndex = deltaDays(activityData.beginTime, new Date) + 1;
|
||||
console.log('今天是活动第几天', activityData.beginTime, new Date, this.todayIndex)
|
||||
// console.log('今天是活动第几天', activityData.beginTime, new Date, this.todayIndex)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { TASK_TYPE, ACTIVITY_RESOURCES_TYPE } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
|
||||
import { ActivityGrowthPointModelType } from '../../db/ActivityGrowthPoint';
|
||||
import { RoleModel } from '../../db/Role';
|
||||
import { RewardInter } from '../../pubUtils/interface';
|
||||
import { parseGoodStrWithType, parseHeroStrWithType, splitString } from '../../pubUtils/util';
|
||||
import { CreateHeroParam } from '../roleField/hero';
|
||||
@@ -174,12 +175,17 @@ export class GrowthData extends ActivityBase {
|
||||
}
|
||||
|
||||
//解析玩家领取记录
|
||||
public setPlayerRecords(data: ActivityGrowthModelType[]) {
|
||||
public async setPlayerRecords(data: ActivityGrowthModelType[], roleId: string) {
|
||||
let { heroNum } = await RoleModel.findByRoleId(roleId);
|
||||
for (let obj of this.list) {
|
||||
let index = data.findIndex(record => { return obj.dayIndex == record.dayIndex && obj.cellIndex == record.cellIndex })
|
||||
if (index != -1) {
|
||||
obj.totalCount = data[index].totalCount ? data[index].totalCount : 0;
|
||||
obj.receiveRewardCount = data[index].receiveRewardCount ? data[index].receiveRewardCount : 0;
|
||||
} else {
|
||||
if (obj.taskType === TASK_TYPE.HERO_NUM) {
|
||||
obj.totalCount = heroNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
|
||||
let addCount: number = 0; // 条件是否满足
|
||||
switch (taskType) {
|
||||
case TASK_TYPE.ROLE_LV://重置数据
|
||||
addCount = param[0] <= count ? count : 0;
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.GUILD_JOIN:
|
||||
addCount = count;
|
||||
@@ -642,6 +642,9 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
|
||||
case TASK_TYPE.HERO_TRAIN_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
case TASK_TYPE.EQUIP_SUM:
|
||||
addCount = count;
|
||||
break;
|
||||
default:
|
||||
addCount = 0;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user