feat(contribution-service): 贡献值明细按 L/T 降序排序

- 同伴下贡献值 (TEAM_LEVEL): 按 levelDepth DESC 排序 (L3, L2, L1)
- 同伴上贡献值 (TEAM_BONUS): 按 bonusTier DESC 排序 (T3, T2, T1)
- 全部/本人: 按 levelDepth DESC, bonusTier DESC, createdAt DESC

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-30 14:20:03 -08:00
parent a31fcaa9b8
commit 17f8a61bcf
1 changed files with 11 additions and 1 deletions

View File

@ -48,12 +48,22 @@ export class ContributionRecordRepository implements IContributionRecordReposito
const page = options?.page ?? 1;
const limit = options?.limit ?? 50;
// 根据 sourceType 动态排序:同伴下按 L 降序,同伴上按 T 降序,全部按 L/T 降序
let orderBy: any;
if (options?.sourceType === 'TEAM_LEVEL') {
orderBy = [{ levelDepth: 'desc' }, { createdAt: 'desc' }];
} else if (options?.sourceType === 'TEAM_BONUS') {
orderBy = [{ bonusTier: 'desc' }, { createdAt: 'desc' }];
} else {
orderBy = [{ levelDepth: 'desc' }, { bonusTier: 'desc' }, { createdAt: 'desc' }];
}
const [records, total] = await Promise.all([
this.client.contributionRecord.findMany({
where,
skip: (page - 1) * limit,
take: limit,
orderBy: { createdAt: 'desc' },
orderBy,
}),
this.client.contributionRecord.count({ where }),
]);