活动:添加弹出礼包每日弹出的逻辑
This commit is contained in:
55
shared/db/ActivityPopUpShopRecord.ts
Normal file
55
shared/db/ActivityPopUpShopRecord.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
|
||||
/**
|
||||
* 活动系统 - 弹出商店数据统计
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class Activity_Pop_Up_Shop_Record extends BaseModel {
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服id
|
||||
@prop({ required: true })
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
beginTime: Date; // 开始统计时间
|
||||
@prop({ required: true })
|
||||
id: number; // 任务id
|
||||
@prop({ required: true })
|
||||
type: number; // 任务类型
|
||||
@prop({ required: true })
|
||||
count: number; // 统计次数
|
||||
|
||||
|
||||
//添加统计
|
||||
public static async addRecord(serverId: number, activityId: number, roleId: string, id: number, type: number, beginTime: Date, count: number) {
|
||||
let result: ActivityPopUpShopRecordModelType = await ActivityPopUpShopRecordModel.findOneAndUpdate({
|
||||
serverId, roleId, activityId, id, type, beginTime,
|
||||
},
|
||||
{ $inc: { count: count } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询统计数据
|
||||
public static async findRecordData(serverId: number, activityId: number, roleId: string, id: number, type: number, beginTime: Date) {
|
||||
let result: ActivityPopUpShopRecordModelType = await ActivityPopUpShopRecordModel.findOne({
|
||||
serverId, roleId, activityId, id, type, beginTime,
|
||||
}).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动统计记录
|
||||
public static async deleteActivity(serverId: number, activityId: number, roleId: string, id: number, type: number,) {
|
||||
await ActivityPopUpShopRecordModel.deleteMany({
|
||||
roleId, activityId, id, type
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityPopUpShopRecordModel = getModelForClass(Activity_Pop_Up_Shop_Record);
|
||||
|
||||
export interface ActivityPopUpShopRecordModelType extends Pick<DocumentType<Activity_Pop_Up_Shop_Record>, keyof Activity_Pop_Up_Shop_Record> { }
|
||||
export type ActivityPopUpShopRecordModelTypeParam = Partial<ActivityPopUpShopRecordModelType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user