活动:幸运转盘循环记录

This commit is contained in:
luying
2022-10-17 16:04:34 +08:00
parent 35ceef87b4
commit ddff18eb20
3 changed files with 18 additions and 15 deletions

View File

@@ -28,6 +28,9 @@ export default class Activity_Turntable_Rec extends BaseModel {
@prop({ required: true })
roleId: string; // 用户id
@prop({ required: true })
roundIndex: number; // 循环次数
@prop({ required: true })
count: number; // 抽卡次数
@@ -46,23 +49,23 @@ export default class Activity_Turntable_Rec extends BaseModel {
@prop({ required: true, type: Number })
box: number[]; // 宝箱已领取次数
public static async findByActivityId(serverId: number, activityId: number, roleId: string) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOne({ roleId, activityId, serverId }).lean();
public static async findByActivityId(serverId: number, activityId: number, roleId: string, roundIndex: number) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOne({ roleId, activityId, serverId, roundIndex }).lean();
return rec;
}
public static async updateData(serverId: number, activityId: number, roleId: string, update: ActivityTurntableModelTypeParam) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOneAndUpdate({ roleId, activityId, serverId }, { $set: update }, { upsert: true, new: true }).lean();
public static async updateData(serverId: number, activityId: number, roleId: string, roundIndex: number, update: ActivityTurntableModelTypeParam) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOneAndUpdate({ roleId, activityId, serverId, roundIndex }, { $set: update }, { upsert: true, new: true }).lean();
return rec;
}
public static async refreshTodayCount(serverId: number, activityId: number, roleId: string) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOneAndUpdate({ roleId, activityId, serverId }, {$set: { todayCount: 0, refTodayCount: new Date() }}).lean();
public static async refreshTodayCount(serverId: number, activityId: number, roleId: string, roundIndex: number) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOneAndUpdate({ roleId, activityId, serverId, roundIndex }, {$set: { todayCount: 0, refTodayCount: new Date() }}).lean();
return rec;
}
public static async receiveBox(serverId: number, activityId: number, roleId: string, boxCount: number) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOneAndUpdate({ roleId, activityId, serverId }, {$addToSet: { box: boxCount }}, { new: true }).lean();
public static async receiveBox(serverId: number, activityId: number, roleId: string, roundIndex: number, boxCount: number) {
let rec: ActivityTurntableModelType = await ActivityTurntableModel.findOneAndUpdate({ roleId, activityId, serverId, roundIndex }, {$addToSet: { box: boxCount }}, { new: true }).lean();
return rec;
}
}