33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
import ActivityShop from './ActivityShop';
|
|
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 活动系统 - 寻宝猎人-商店
|
|
*/
|
|
@index({ roleId: 1 })
|
|
|
|
export default class Activity_Treasure_Hunt_Shop extends ActivityShop {
|
|
@prop({ required: true })
|
|
dayIndex: number; // 第几天
|
|
|
|
//根据活动id查询活动数据
|
|
public static async findTreasureData(serverId: number, activityId: number, roleId: string, roundIndex: number, dayIndex: number) {
|
|
let result: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findOne({ roleId, activityId, roundIndex, dayIndex }).lean(true);
|
|
return result;
|
|
}
|
|
|
|
//购买领取奖励的记录
|
|
public static async buyShopRecord(activityId: number, roleId: string, roundIndex: number, dayIndex: number, id: number) {
|
|
let result: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findOneAndUpdate({ roleId, activityId, roundIndex, dayIndex },
|
|
{ $push: { records: { id, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
|
return result;
|
|
}
|
|
}
|
|
|
|
export const ActivityTreasureHuntShopModel = getModelForClass(Activity_Treasure_Hunt_Shop);
|
|
|
|
export interface ActivityTreasureHuntShopModelType extends Pick<DocumentType<Activity_Treasure_Hunt_Shop>, keyof Activity_Treasure_Hunt_Shop> { }
|
|
export type ActivityTreasureHuntShopModelTypeParam = Partial<ActivityTreasureHuntShopModelType>; // 将所有字段变成可选项
|