From 43815acef2c365914c3d98001df0e42a6a7e02b4 Mon Sep 17 00:00:00 2001 From: chen wei bo <1025839511@qq.com> Date: Mon, 13 Oct 2025 17:17:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=89=80=E6=9C=89=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E6=9C=89=E8=BF=87=E8=81=8A=E5=A4=A9=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E6=8A=80=E5=B8=88=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/Scripts/chat18x/data/GirlChatData.ts | 7 ++++ assets/Scripts/chat18x/data/GirlData.ts | 45 +++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/assets/Scripts/chat18x/data/GirlChatData.ts b/assets/Scripts/chat18x/data/GirlChatData.ts index c731604e..3a04520a 100644 --- a/assets/Scripts/chat18x/data/GirlChatData.ts +++ b/assets/Scripts/chat18x/data/GirlChatData.ts @@ -166,6 +166,13 @@ export class GirlChatData extends BaseData { return this.chatRecordIds; } + /** 是否已经有过聊天记录 */ + public isAlreadyChat(): boolean { + const hasIds = this.chatRecordIds && this.chatRecordIds.length > 0; + const hasRecords = this.chatRecord && this.chatRecord.size > 0; + return hasIds || hasRecords; + } + /** 获取最新的聊天记录的id */ public getLatestChatRecordId(): number | null { if (this.chatRecordIds.length === 0) return null; diff --git a/assets/Scripts/chat18x/data/GirlData.ts b/assets/Scripts/chat18x/data/GirlData.ts index 3539882a..4bde1a47 100644 --- a/assets/Scripts/chat18x/data/GirlData.ts +++ b/assets/Scripts/chat18x/data/GirlData.ts @@ -1279,6 +1279,16 @@ export class GirlData extends BaseData { return oneData.getChatRecordIds(); } + /** 是否已经有过聊天记录 */ + public isAlreadyChat( + categoryId: string, + girlId: number + ): boolean { + let oneData = this.getGrilChat(categoryId, girlId); + if (!oneData) return false; + return oneData.isAlreadyChat(); + } + /** 获取最新的聊天记录的id */ public getLatestChatRecordId( categoryId: string, @@ -1380,6 +1390,41 @@ export class GirlData extends BaseData { return result; } + /** 获取所有已经有过聊天记录的技师 id */ + public getAllAlreadyChatGirlIds(): number[] { + const result: number[] = []; + const seen = new Set(); // 用来去重 + const cats = this.ensureCategories(); + // 遍历 + for (const [categoryId, bucket] of cats.entries()) { + for (const girlId of bucket.girlIds) { + if (this.isAlreadyChat(categoryId, girlId) && !seen.has(girlId)) { + seen.add(girlId); // 标记已加入 + result.push(girlId); + } + } + } + // 排序 + // 1,按照聊天时间从近到远 + result.sort((a, b) => { + const categoryIdA = this.getGrilCategoryById(a); + const categoryIdB = this.getGrilCategoryById(b); + // 先取最新聊天时间戳 + const tsA = this.getLatestChatRecordTimestamp(categoryIdA.toString(), a); + const tsB = this.getLatestChatRecordTimestamp(categoryIdB.toString(), b); + + if (tsA && tsB) { + // 都有聊天记录,按时间倒序 + return tsB - tsA; + } else { + return -1; + } + }); + + // 返回结果 + return result; + } + /** --------------------------------------------------------- 技师的好感度数据 --------------------------------------------------------- */ // 创建一个技师好感度数据