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:
parent
a31fcaa9b8
commit
17f8a61bcf
|
|
@ -48,12 +48,22 @@ export class ContributionRecordRepository implements IContributionRecordReposito
|
||||||
const page = options?.page ?? 1;
|
const page = options?.page ?? 1;
|
||||||
const limit = options?.limit ?? 50;
|
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([
|
const [records, total] = await Promise.all([
|
||||||
this.client.contributionRecord.findMany({
|
this.client.contributionRecord.findMany({
|
||||||
where,
|
where,
|
||||||
skip: (page - 1) * limit,
|
skip: (page - 1) * limit,
|
||||||
take: limit,
|
take: limit,
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy,
|
||||||
}),
|
}),
|
||||||
this.client.contributionRecord.count({ where }),
|
this.client.contributionRecord.count({ where }),
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue