活动:首充活动接口
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
|
||||
/**
|
||||
* 首个礼包
|
||||
*/
|
||||
@index({ roleId: 1 })
|
||||
|
||||
export default class ActivityFirstGift extends BaseModel {
|
||||
@prop({ required: true })
|
||||
acvitityId: number; // 活动Id
|
||||
@prop({ required: true })
|
||||
roleId: string; // 用户Id
|
||||
@prop({ required: true })
|
||||
days: Array<number>; // 领取过的奖励
|
||||
|
||||
|
||||
//添加领取记录
|
||||
public static async addRecord(acvitityId: number, roleId: string, index: number) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOneAndUpdate({ roleId, acvitityId, },
|
||||
{ $push: { days: index } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//可以领取首充礼包,充值时间记录
|
||||
public static async begin(acvitityId: number, roleId: string) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOneAndUpdate({ roleId, acvitityId },
|
||||
{}, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findData(acvitityId: number, roleId: string) {
|
||||
let result: ActivityFirstGiftModelType = await ActivityFirstGiftModel.findOne({ roleId, acvitityId }, {}).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//删除活动领取记录
|
||||
public static async deleteActivity(acvitityId: number, roleId: string, roundIndex: number, index: number,) {
|
||||
await ActivityFirstGiftModel.deleteMany({ roleId, acvitityId, index, roundIndex });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityFirstGiftModel = getModelForClass(ActivityFirstGift);
|
||||
|
||||
export interface ActivityFirstGiftModelType extends Pick<DocumentType<ActivityFirstGift>, keyof ActivityFirstGift> { }
|
||||
export type ActivityFirstGiftModelTypeParam = Partial<ActivityFirstGiftModelType>; // 将所有字段变成可选项
|
||||
Reference in New Issue
Block a user