弹出礼包:购买

This commit is contained in:
陆莹
2022-03-15 21:01:21 +08:00
parent 319d4cf454
commit d9b907e80b
4 changed files with 72 additions and 67 deletions
+13
View File
@@ -91,6 +91,11 @@ export default class Activity_Pop_Up_Shop extends BaseModel {
return rec;
}
public static async findByCode(serverId: number, activityId: number, roleId: string, code: string) {
let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOne({ serverId, activityId, roleId, code }).lean();
return rec;
}
public static async addRecord(serverId: number, activityId: number, roleId: string, code: string, productID: string) {
let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate(
{ serverId, activityId, roleId, code, 'items.productID': productID },
@@ -98,6 +103,14 @@ export default class Activity_Pop_Up_Shop extends BaseModel {
{ new: true} ).lean();
return rec;
}
public static async addRecordById(serverId: number, activityId: number, roleId: string, code: string, itemid: number) {
let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate(
{ serverId, activityId, roleId, code, 'items.id': itemid },
{ $set: { hasBought: true }, $inc: { 'items.$.hasBoughtCnt': 1 } },
{ new: true} ).lean();
return rec;
}
}
export const ActivityPopUpShopModel = getModelForClass(Activity_Pop_Up_Shop);