活动:成长活动、今日挑战奖励接口返回数据添加字段
This commit is contained in:
+19
-19
@@ -27,62 +27,62 @@ export default class ActivityGrowth extends BaseModel {
|
||||
getPointReward: boolean; // 是否兑换领取奖章奖励
|
||||
|
||||
//任务领取记录
|
||||
public static async addCellRecord(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
public static async addCellRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, addPointCount: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { receiveRewardCount: count, addPointCount: addPointCount } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//当日奖章领取记录
|
||||
public static async addDayRecord(activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex },
|
||||
public static async addDayRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
|
||||
{ $set: { getPointReward: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async addTaskCount(activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex, type },
|
||||
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
|
||||
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, activityId }).lean(lean);
|
||||
public static async findData(serverId: number, activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ serverId, roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天的活动数据
|
||||
public static async findDataByDayIndex(activityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, activityId, dayIndex }).lean(lean);
|
||||
public static async findDataByDayIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ serverId, roleId, activityId, dayIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几天某个的活动数据
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ roleId, activityId, dayIndex, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ serverId, roleId, activityId, dayIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//新增领取记录
|
||||
public static async addData(activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ roleId, activityId, dayIndex, cellIndex },
|
||||
public static async addData(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
|
||||
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
|
||||
{ $: { count: count } },
|
||||
{ upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(activityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityGrowthModel.deleteMany({ roleId, activityId, dayIndex, cellIndex });
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number) {
|
||||
await ActivityGrowthModel.deleteMany({ serverId, roleId, activityId, dayIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,17 +2,6 @@ import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
/**
|
||||
* 购买记录
|
||||
*/
|
||||
|
||||
export class BuyRecord {
|
||||
@prop({ required: true })
|
||||
id: number; //物品id标识
|
||||
@prop({ required: true })
|
||||
time: Date; //购买时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动系统 - 弹出商店
|
||||
*/
|
||||
@@ -30,18 +19,18 @@ export default class ActivityPopUpShop extends BaseModel {
|
||||
@prop({ required: true })
|
||||
endTime: Date; // 结束时间
|
||||
@prop({ required: true })
|
||||
taskId: number; // 任务id
|
||||
id: number; // 任务id
|
||||
@prop({ required: true })
|
||||
records: BuyRecord[]; // 购买记录
|
||||
isBuy: boolean; // 是否购买
|
||||
|
||||
//购买奖励的记录
|
||||
public static async addRecord(serverId: number, activityId: number, roleId: string, taskId: number, id: number) {
|
||||
public static async addRecord(serverId: number, activityId: number, roleId: string, id: number) {
|
||||
let nowDate = new Date();
|
||||
let result: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate({
|
||||
serverId, roleId, activityId, taskId,
|
||||
serverId, roleId, activityId, id,
|
||||
beginTime: { $lt: nowDate }, endTime: { $gt: nowDate }
|
||||
},
|
||||
{ $push: { records: { id, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
||||
{ $set: { isBuy: true } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -56,20 +45,20 @@ export default class ActivityPopUpShop extends BaseModel {
|
||||
}
|
||||
|
||||
//根据活动taskId查询现在正在进行的活动数据
|
||||
public static async findOpenDataByTaskId(serverId: number, activityId: number, roleId: string, taskId: number) {
|
||||
public static async findOpenDataByTaskId(serverId: number, activityId: number, roleId: string, id: number) {
|
||||
let nowDate = new Date();
|
||||
let result: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOne({
|
||||
serverId, roleId, activityId, taskId,
|
||||
serverId, roleId, activityId, id,
|
||||
beginTime: { $lt: nowDate }, endTime: { $gt: nowDate }
|
||||
}).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string, taskId: number) {
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string, id: number) {
|
||||
let nowDate = new Date();
|
||||
await ActivityPopUpShopModel.deleteMany({
|
||||
roleId, activityId, taskId,
|
||||
roleId, activityId, id,
|
||||
beginTime: { $lt: nowDate }, endTime: { $gt: nowDate }
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user