feat(重阳集会): 更新

This commit is contained in:
zhangxk
2023-09-12 20:14:41 +08:00
parent 742d48267a
commit ed8912e440
3 changed files with 24 additions and 13 deletions

View File

@@ -53,13 +53,18 @@ export default class Activity_ChongYang_Rec extends BaseModel {
return result;
}
public static async gameRecord(serverId: number, activityId: number, roundIndex: number, roleId: string, gameRecords: ChongYangGameRecord) {
let result: ActivityChongYangRecModelType = await ActivityChongYangRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $push: { gameRecords }, $setOnInsert: { buyCnt: 0 } }, { new: true, upsert: true }).lean();
public static async gameRecord(serverId: number, activityId: number, roundIndex: number, roleId: string, gameRecord: ChongYangGameRecord) {
let result: ActivityChongYangRecModelType = await ActivityChongYangRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $push: { gameRecords: gameRecord } }, { new: true, upsert: true }).lean();
return result;
}
public static async buyCnt(serverId: number, activityId: number, roundIndex: number, roleId: string, dayIndex: number, count: number) {
let result: ActivityChongYangRecModelType = await ActivityChongYangRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, 'buyRecords.dayIndex': dayIndex }, { $inc: { 'buyRecords.$.buyCnt': count }, $setOnInsert: { gameRecord: [] } }, { new: true, upsert: true }).lean();
public static async buyCnt(serverId: number, activityId: number, roundIndex: number, roleId: string, buyRecord: ChongYangBuyRecord, isPushBuyRecord: boolean) {
let result: ActivityChongYangRecModelType;
if (isPushBuyRecord) {
result = await ActivityChongYangRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex }, { $push: { buyRecords: buyRecord } }, { new: true, upsert: true }).lean();
} else {
result = await ActivityChongYangRecModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, 'buyRecords.dayIndex': buyRecord.dayIndex }, { $inc: { 'buyRecords.$.buyCnt': buyRecord.buyCnt } }, { new: true, upsert: true }).lean();
}
return result;
}