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; + } + /** --------------------------------------------------------- 技师的好感度数据 --------------------------------------------------------- */ // 创建一个技师好感度数据