diff --git a/game-server/app/servers/activity/handler/popUpShopHandler.ts b/game-server/app/servers/activity/handler/popUpShopHandler.ts index 5806f986b..fe4eb1590 100644 --- a/game-server/app/servers/activity/handler/popUpShopHandler.ts +++ b/game-server/app/servers/activity/handler/popUpShopHandler.ts @@ -109,12 +109,10 @@ 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'); + async showGift(msg: { code: string }, session: BackendSession) { + const { code } = msg; - let rec = await ActivityPopUpShopModel.show(serverId, activityId, roleId, code, id); + let rec = await ActivityPopUpShopModel.show(code); if (!rec) return resResult(STATUS.ACTIVITY_MISSING); return resResult(STATUS.SUCCESS); } diff --git a/shared/db/ActivityPopUpShop.ts b/shared/db/ActivityPopUpShop.ts index 899dbc5e6..3a483a84b 100644 --- a/shared/db/ActivityPopUpShop.ts +++ b/shared/db/ActivityPopUpShop.ts @@ -17,9 +17,6 @@ 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; @@ -30,7 +27,7 @@ export class PopUpShopItem { /** * 活动系统 - 弹出商店 */ -@index({ roleId: 1 }) +@index({ roleId: 1, code: 1 }) export default class Activity_Pop_Up_Shop extends BaseModel { @prop({ required: true }) @@ -69,6 +66,9 @@ export default class Activity_Pop_Up_Shop extends BaseModel { @prop({ required: true }) isLast: boolean; // 是否是最后一个 + @prop({ required: true, default: false}) + hasShown: boolean; // 客户端是否已经展示 + /** * 获取自然日内的次数 * @param roleId @@ -115,10 +115,8 @@ export default class Activity_Pop_Up_Shop extends BaseModel { 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(); + public static async show(code: string) { + let rec: ActivityPopUpShopModelType = await ActivityPopUpShopModel.findOneAndUpdate({ code }, { hasShown: true }).lean(); return rec; } } diff --git a/shared/domain/activityField/popUpShopField.ts b/shared/domain/activityField/popUpShopField.ts index a1b9bb119..a8f4cc702 100644 --- a/shared/domain/activityField/popUpShopField.ts +++ b/shared/domain/activityField/popUpShopField.ts @@ -365,6 +365,7 @@ export class PopShopItem { isPushing: boolean = false; // 是否有推送 hasPushCnt: number = 0; code: string = ''; // 推送唯一code + hasShown: boolean = false; // 客户端是否已经展示 beginTime: number = 0; // 推送开始时间 endTime: number = 0; // 推送结束时间 @@ -389,6 +390,7 @@ export class PopShopItem { public setPlayerRecords(data: ActivityPopUpShopModelType, item: ActivityPopUpShopItem) { this.code = data.code; + this.hasShown = data.hasShown; this.beginTime = data.beginTime.getTime(); this.endTime = data.endTime.getTime(); this.hasBoughtCnt = item.hasBoughtCnt; @@ -547,6 +549,7 @@ export class PopUpShopItemShow { code: string; // 本次推送的code,用于购买中传给param packageId: number; // 礼包类型id endTime: number; // 礼包消失时间 + hasShown: boolean; // 礼包是否已经在客户端展示 id: number; // 档位唯一id,升降档的时候按照id顺序排,升档id+,降档id- name: string; // 礼包 @@ -560,6 +563,7 @@ export class PopUpShopItemShow { constructor(data: PopShopItem) { this.code = data.code; + this.hasShown = data.hasShown; this.packageId = data.parent.id; this.endTime = data.endTime; this.id = data.id;