活动:修复每日特惠礼包
This commit is contained in:
@@ -30,12 +30,14 @@ export default class Activity_Daily_RMB_Gifts extends BaseModel {
|
||||
@prop({ required: true })
|
||||
beginTime: Date; // 开始时间
|
||||
@prop({ required: true })
|
||||
todayIndex: number; // 开始时间
|
||||
@prop({ required: true })
|
||||
isBuy: boolean; // 是否已经购买过
|
||||
@prop({ required: true })
|
||||
records: BuyRecord[]; // 领取记录
|
||||
|
||||
//添加领取记录
|
||||
public static async receiveRecord(serverId: number, activityId: number, roleId: string, beginTime: Date, ids: number[]) {
|
||||
public static async receiveRecord(serverId: number, activityId: number, roleId: string, beginTime: Date, todayIndex: number, ids: number[]) {
|
||||
let data = [];
|
||||
for (let id of ids) {
|
||||
data.push({
|
||||
@@ -44,30 +46,30 @@ export default class Activity_Daily_RMB_Gifts extends BaseModel {
|
||||
})
|
||||
}
|
||||
let result = await ActivityDailyRMBGiftsModel.findOneAndUpdate(
|
||||
{ serverId, roleId, activityId, beginTime }, { $push: { records: { $each: data } } }, { upsert: true, new: true }
|
||||
{ serverId, roleId, activityId, beginTime, todayIndex }, { $push: { records: { $each: data } } }, { upsert: true, new: true }
|
||||
).lean(true)
|
||||
return result;
|
||||
}
|
||||
|
||||
//添加购买记录
|
||||
public static async buyRecord(serverId: number, activityId: number, roleId: string, beginTime: Date, isBuy: boolean) {
|
||||
public static async buyRecord(serverId: number, activityId: number, roleId: string, beginTime: Date, todayIndex: number, isBuy: boolean) {
|
||||
let result = await ActivityDailyRMBGiftsModel.findOneAndUpdate(
|
||||
{ serverId, roleId, activityId, beginTime }, { $set: { isBuy } }, { upsert: true, new: true }
|
||||
{ serverId, roleId, activityId, beginTime, todayIndex }, { $set: { isBuy } }, { upsert: true, new: true }
|
||||
).lean(true)
|
||||
return result;
|
||||
}
|
||||
|
||||
//历史领取的记录
|
||||
public static async findRecord(serverId: number, activityId: number, roleId: string, beginTime: Date) {
|
||||
public static async findRecord(serverId: number, activityId: number, roleId: string, beginTime: Date, todayIndex: number) {
|
||||
let result: ActivityDailyRMBGiftsModelType = await ActivityDailyRMBGiftsModel.findOne(
|
||||
{ serverId, roleId, activityId, beginTime }).lean(true);
|
||||
{ serverId, roleId, activityId, beginTime, todayIndex }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//获取已经购买还没有领取的数据
|
||||
public static async findBuyRecord(serverId: number, activityId: number, roleId: string, beginTime: Date) {
|
||||
public static async findBuyRecord(serverId: number, activityId: number, roleId: string, beginTime: Date, todayIndex: number) {
|
||||
let result: ActivityDailyRMBGiftsModelType[] = await ActivityDailyRMBGiftsModel.find(
|
||||
{ serverId, roleId, activityId, beginTime: { $gt: beginTime } }).lean(true);
|
||||
{ serverId, roleId, activityId, beginTime, todayIndex: { $gt: todayIndex } }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user