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 })