获取所有已经有过聊天记录的技师 id
This commit is contained in:
@@ -166,6 +166,13 @@ export class GirlChatData extends BaseData {
|
|||||||
return this.chatRecordIds;
|
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 */
|
/** 获取最新的聊天记录的id */
|
||||||
public getLatestChatRecordId(): number | null {
|
public getLatestChatRecordId(): number | null {
|
||||||
if (this.chatRecordIds.length === 0) return null;
|
if (this.chatRecordIds.length === 0) return null;
|
||||||
|
|||||||
@@ -1279,6 +1279,16 @@ export class GirlData extends BaseData {
|
|||||||
return oneData.getChatRecordIds();
|
return oneData.getChatRecordIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 是否已经有过聊天记录 */
|
||||||
|
public isAlreadyChat(
|
||||||
|
categoryId: string,
|
||||||
|
girlId: number
|
||||||
|
): boolean {
|
||||||
|
let oneData = this.getGrilChat(categoryId, girlId);
|
||||||
|
if (!oneData) return false;
|
||||||
|
return oneData.isAlreadyChat();
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取最新的聊天记录的id */
|
/** 获取最新的聊天记录的id */
|
||||||
public getLatestChatRecordId(
|
public getLatestChatRecordId(
|
||||||
categoryId: string,
|
categoryId: string,
|
||||||
@@ -1380,6 +1390,41 @@ export class GirlData extends BaseData {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取所有已经有过聊天记录的技师 id */
|
||||||
|
public getAllAlreadyChatGirlIds(): number[] {
|
||||||
|
const result: number[] = [];
|
||||||
|
const seen = new Set<number>(); // 用来去重
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/** --------------------------------------------------------- 技师的好感度数据 --------------------------------------------------------- */
|
/** --------------------------------------------------------- 技师的好感度数据 --------------------------------------------------------- */
|
||||||
|
|
||||||
// 创建一个技师好感度数据
|
// 创建一个技师好感度数据
|
||||||
|
|||||||
Reference in New Issue
Block a user