获取可聊天的技师数据

This commit is contained in:
chen wei bo
2025-09-22 18:42:28 +08:00
parent 4712f853e3
commit bfa55f52da
2 changed files with 58 additions and 5 deletions
+42 -5
View File
@@ -1014,15 +1014,52 @@ export class GirlData extends BaseData {
for (const [categoryId, bucket] of cats.entries()) {
for (const girlId of bucket.girlIds) {
if (this.getIsRelease(categoryId, girlId)) {
if (this.isCanChat(categoryId, girlId)) {
result.push(girlId);
}
}
}
// 排序
// 1,都存在聊天记录,按照聊天时间从近到远,否则,有聊天记录的排在前面
// 2,都没有聊天记录
// 2.1,付费类型角色排在前面,免费类型角色排在后面
// 2.2,如果角色都是付费类型,则角色id越大,排在前面
// 2.3,如果角色都是免费类型,则角色id越大,排在前面
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 if (tsA && !tsB) {
// a 有聊天记录,优先
return -1;
} else if (!tsA && tsB) {
// b 有聊天记录,优先
return 1;
} else {
// 都没有聊天记录 → 解锁排前,最后是免费类型
const isPayTypeA = this.isGirlPayType(categoryIdA.toString(), a);
const isFreeTypeA = this.isGirlFreeType(categoryIdA.toString(), a);
const isPayTypeB = this.isGirlPayType(categoryIdB.toString(), b);
const isFreeTypeB = this.isGirlFreeType(categoryIdB.toString(), b);
if (isPayTypeA && isFreeTypeB) {
// A 付费,B 免费 → A 前
return -1;
} else if (isFreeTypeA && isPayTypeB) {
// B 付费,A 免费 → B 前
return 1;
} else {
// 都是付费 or 都是免费 → 按 id 倒序
return b - a;
}
}
});
// 返回结果
return result;
}