🎈 perf(活动): 神州探秘购买添加次数参数
This commit is contained in:
@@ -30,9 +30,13 @@ export default class Activity_Shop extends BaseModel {
|
||||
records: BuyRecord[]; // 购买记录
|
||||
|
||||
//购买领取奖励的记录
|
||||
public static async addRecord(activityId: number, roleId: string, roundIndex: number, id: number) {
|
||||
public static async addRecord(activityId: number, roleId: string, roundIndex: number, id: number, count: number) {
|
||||
let records = [];
|
||||
for(let i = 0; i < count; i++) {
|
||||
records.push({ id, time: new Date() });
|
||||
}
|
||||
let result: ActivityShopModelType = await ActivityShopModel.findOneAndUpdate({ roleId, activityId, roundIndex },
|
||||
{ $push: { records: { id, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
||||
{ $push: { records: { $each: records } } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,13 @@ export default class Activity_Treasure_Hunt_Shop extends ActivityShop {
|
||||
}
|
||||
|
||||
//购买领取奖励的记录
|
||||
public static async buyShopRecord(activityId: number, roleId: string, roundIndex: number, dayIndex: number, id: number) {
|
||||
public static async buyShopRecord(activityId: number, roleId: string, roundIndex: number, dayIndex: number, id: number, count: number) {
|
||||
let records = [];
|
||||
for(let i = 0; i < count; i++) {
|
||||
records.push({ id, time: new Date() });
|
||||
}
|
||||
let result: ActivityTreasureHuntShopModelType = await ActivityTreasureHuntShopModel.findOneAndUpdate({ roleId, activityId, roundIndex, dayIndex },
|
||||
{ $push: { records: { id, time: new Date() } } }, { upsert: true, new: true }).lean(true);
|
||||
{ $push: { records: { $each: records } } }, { upsert: true, new: true }).lean(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,9 +160,13 @@ export class TreasureHuntShopItem {
|
||||
}
|
||||
}
|
||||
|
||||
public getConsume() {
|
||||
let index = this.consume.findIndex(obj => { return obj && obj.count === this.buyCount + 1 });
|
||||
return (index != -1) ? this.consume[index].consume : '';
|
||||
public getConsume(count: number) {
|
||||
let consumes: string[] = [];
|
||||
for(let cnt = 1; cnt <= count; cnt ++) {
|
||||
let index = this.consume.findIndex(obj => { return obj && obj.count === this.buyCount + cnt });
|
||||
if (index != -1) consumes.push(this.consume[index].consume);
|
||||
}
|
||||
return consumes;
|
||||
}
|
||||
|
||||
public setBuyCount(record: ActivityTreasureHuntShopModelType) {
|
||||
|
||||
Reference in New Issue
Block a user