diff --git a/game-server/app/servers/activity/handler/popUpShopHandler.ts b/game-server/app/servers/activity/handler/popUpShopHandler.ts index 9e24cebcc..5806f986b 100644 --- a/game-server/app/servers/activity/handler/popUpShopHandler.ts +++ b/game-server/app/servers/activity/handler/popUpShopHandler.ts @@ -108,6 +108,17 @@ export class PopUpShopHandler { }); } + // 客户端展示弹出礼包的通知 + async showGift(msg: { activityId: number, code: string, id: number }, session: BackendSession) { + const { activityId, code, id } = msg; + const roleId = session.get('roleId'); + const serverId = session.get('serverId'); + + let rec = await ActivityPopUpShopModel.show(serverId, activityId, roleId, code, id); + if (!rec) return resResult(STATUS.ACTIVITY_MISSING); + return resResult(STATUS.SUCCESS); + } + async debugPushPopUpShop(msg: { conditionType: number, magicWord: string, param: number, needDelete: boolean }, session: BackendSession) { const roleId = session.get('roleId'); let serverId = session.get('serverId'); diff --git a/shared/db/ActivityPopUpShop.ts b/shared/db/ActivityPopUpShop.ts index eb19dc28c..899dbc5e6 100644 --- a/shared/db/ActivityPopUpShop.ts +++ b/shared/db/ActivityPopUpShop.ts @@ -17,6 +17,9 @@ export class PopUpShopItem { @prop({ required: true, _id: false, type: Reward }) rewards: Reward[] = []; // 已购买次数 + @prop({ required: true, default: false}) + hasShown: boolean; // 客户端是否已经展示 + constructor(item: PopShopItem) { this.id = item.id; this.productID = item.productID; @@ -111,6 +114,13 @@ export default class Activity_Pop_Up_Shop extends BaseModel { { new: true} ).lean(); return rec; } + + public static async show(serverId: number, activityId: number, roleId: string, code: string, itemId: number) { + let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate( + { serverId, activityId, roleId, code, 'items.id': itemId }, + { 'items.hasShown': true }).lean(); + return rec; + } } export const ActivityPopUpShopModel = getModelForClass(Activity_Pop_Up_Shop);