活动:新手限定礼包
This commit is contained in:
@@ -8,7 +8,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
|
||||
|
||||
export default class ActivityThirtyDays extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
activityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
@@ -23,47 +23,47 @@ export default class ActivityThirtyDays extends BaseModel {
|
||||
isReceive: boolean; // 是否领取过奖励
|
||||
|
||||
//添加领取记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex },
|
||||
public static async addRecord(activityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, activityId, pageIndex, cellIndex },
|
||||
{ $set: { isReceive: true } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async addTaskCount(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex, type },
|
||||
public static async addTaskCount(activityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, activityId, pageIndex, cellIndex, type },
|
||||
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动统计完成任务次数
|
||||
public static async setTaskCount(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, acvitityId, pageIndex, cellIndex, type },
|
||||
public static async setTaskCount(activityId: number, roleId: string, pageIndex: number, cellIndex: number, type: number, count: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ roleId, activityId, pageIndex, cellIndex, type },
|
||||
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动id查询活动数据
|
||||
public static async findData(acvitityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, acvitityId }).lean(lean);
|
||||
public static async findData(activityId: number, roleId: string, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, activityId }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第几页的活动数据
|
||||
public static async findDataBypageIndex(acvitityId: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, acvitityId, pageIndex }).lean(lean);
|
||||
public static async findDataBypageIndex(activityId: number, roleId: string, pageIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, activityId, pageIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//查询第*页的某个的活动数据
|
||||
public static async findDataByCellIndex(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, acvitityId, pageIndex, cellIndex }).lean(lean);
|
||||
public static async findDataByCellIndex(activityId: number, roleId: string, pageIndex: number, cellIndex: number, lean = true) {
|
||||
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ roleId, activityId, pageIndex, cellIndex }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityThirtyDaysModel.deleteMany({ roleId, acvitityId, pageIndex, cellIndex });
|
||||
public static async deleteActivity(activityId: number, roleId: string, pageIndex: number, cellIndex: number) {
|
||||
await ActivityThirtyDaysModel.deleteMany({ roleId, activityId, pageIndex, cellIndex });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user