From 92d223314b7c909c88e670dda3684c329e100f4c Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 23 Feb 2021 15:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=BD=E5=8F=8B=EF=BC=9A=E5=BD=93=E5=A4=A9?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E8=BF=87=E5=A5=BD=E5=8F=8B=E7=9A=84=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E5=9C=A8=E9=82=80=E8=AF=B7=E5=88=97=E8=A1=A8=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/servers/role/handler/friendHandler.ts | 8 +++++++- shared/db/FriendApply.ts | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/game-server/app/servers/role/handler/friendHandler.ts b/game-server/app/servers/role/handler/friendHandler.ts index 97ab80371..26f223608 100644 --- a/game-server/app/servers/role/handler/friendHandler.ts +++ b/game-server/app/servers/role/handler/friendHandler.ts @@ -1,5 +1,5 @@ import { Application, BackendSession, ChannelService } from "pinus"; -import { resResult, getRandEelm, getResStr, shouldRefresh } from "../../../pubUtils/util"; +import { resResult, getRandEelm, getResStr, shouldRefresh, getRefTime } from "../../../pubUtils/util"; import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, EQUIP_SELECT, REDIS_KEY } from "../../../consts"; import { RoleModel, RoleType } from "../../../db/Role"; import { getBeforeHourSeconds } from "../../../pubUtils/timeUtil"; @@ -43,6 +43,12 @@ export class FriendHandler { const { lv, serverId: myServerId, userInfo: { serverType: myServerType } } = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_MY_SERVER); let allList = await RoleModel.getRecommedList(lv - FRIEND.FRIEND_RECONMMEND_LEVEL, lv + FRIEND.FRIEND_RECONMMEND_LEVEL, day); + // 筛掉自己今天申请过的人 + let applyList = await FriendApplyModel.getSentApplyList(roleId, getRefTime(new Date(), 0)); + allList = allList.filter(cur => { + return !applyList.find(ccur => ccur.roleId == cur.roleId); + }); + let myFriendRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.NOT); let myServerList = new Array(); diff --git a/shared/db/FriendApply.ts b/shared/db/FriendApply.ts index 375e5defa..3de443929 100644 --- a/shared/db/FriendApply.ts +++ b/shared/db/FriendApply.ts @@ -42,6 +42,13 @@ export default class FriendApply extends BaseModel { return list; } + // 获取自己发出的申请列表 + public static async getSentApplyList(roleId: string, time: Date) { + const list: FriendApplyType[] = await FriendApplyModel.find({ frdRoleId: roleId, createdAt: { $gt: time } }, { _id: 0 }) + .lean({ getters: true }); + return list; + } + // 根据applyCode获得申请 public static async getApplyListByCode(applyCodeList: string[]) { const list: FriendApplyType[] = await FriendApplyModel.find({ applyCode: { $in: applyCodeList } }, { _id: 0 })