fix(contribution): 发布过期份额同步事件 + 管理后台/挖矿app状态显示
- contribution-service: swapContributionForMerge 作废旧份额记录后, 立即发布 ContributionRecordSynced outbox 事件(isExpired=true), mining-admin-service 收到后 upsert syncedContributionRecord - mining-admin-web: 算力记录状态列改为绿色"有效"/红色"无效" - mining-app: 贡献值记录卡片始终显示有效/无效状态标签 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a904c8bd42
commit
724fb08be4
|
|
@ -725,6 +725,39 @@ export class PrePlantingContributionService {
|
||||||
`[PRE-PLANTING-MERGE] Expired ${expiredCount.count} portion records for merge ${mergeNo}`,
|
`[PRE-PLANTING-MERGE] Expired ${expiredCount.count} portion records for merge ${mergeNo}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 9b-sync: 查询已作废的记录并发布同步事件(mining-admin-service 需要更新 isExpired 状态)
|
||||||
|
if (expiredCount.count > 0) {
|
||||||
|
const expiredRecords = await tx.contributionRecord.findMany({
|
||||||
|
where: { sourceAdoptionId: { in: portionSourceAdoptionIds }, isExpired: true },
|
||||||
|
});
|
||||||
|
const expiredEvents = expiredRecords.map((record) => {
|
||||||
|
const event = new ContributionRecordSyncedEvent(
|
||||||
|
record.id,
|
||||||
|
record.accountSequence,
|
||||||
|
record.sourceType,
|
||||||
|
record.sourceAdoptionId,
|
||||||
|
record.sourceAccountSequence,
|
||||||
|
record.treeCount,
|
||||||
|
record.baseContribution.toString(),
|
||||||
|
record.distributionRate.toString(),
|
||||||
|
record.levelDepth,
|
||||||
|
record.bonusTier,
|
||||||
|
record.amount.toString(),
|
||||||
|
record.effectiveDate,
|
||||||
|
record.expireDate,
|
||||||
|
true,
|
||||||
|
record.createdAt,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
aggregateType: ContributionRecordSyncedEvent.AGGREGATE_TYPE,
|
||||||
|
aggregateId: record.id.toString(),
|
||||||
|
eventType: ContributionRecordSyncedEvent.EVENT_TYPE,
|
||||||
|
payload: event.toPayload(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
await this.outboxRepository.saveMany(expiredEvents);
|
||||||
|
}
|
||||||
|
|
||||||
// 9c: 从认种人账户扣减旧个人算力(personal_contribution - 和 effective_contribution -)
|
// 9c: 从认种人账户扣减旧个人算力(personal_contribution - 和 effective_contribution -)
|
||||||
if (parseFloat(expiredPersonalStr) > 0) {
|
if (parseFloat(expiredPersonalStr) > 0) {
|
||||||
await tx.contributionAccount.updateMany({
|
await tx.contributionAccount.updateMany({
|
||||||
|
|
|
||||||
|
|
@ -164,9 +164,9 @@ export function ContributionRecordsList({ accountSequence }: ContributionRecords
|
||||||
<TableCell className="text-sm">{formatDate(record.effectiveDate)}</TableCell>
|
<TableCell className="text-sm">{formatDate(record.effectiveDate)}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{record.isExpired ? (
|
{record.isExpired ? (
|
||||||
<Badge variant="destructive">已过期</Badge>
|
<Badge variant="destructive">无效</Badge>
|
||||||
) : (
|
) : (
|
||||||
<Badge variant="secondary">有效</Badge>
|
<Badge className="border-transparent bg-green-500 text-white hover:bg-green-500/80">有效</Badge>
|
||||||
)}
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
|
||||||
|
|
@ -354,20 +354,23 @@ class _ContributionRecordsListPageState extends ConsumerState<ContributionRecord
|
||||||
),
|
),
|
||||||
|
|
||||||
// 状态标签
|
// 状态标签
|
||||||
if (record.isExpired) ...[
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 8),
|
Container(
|
||||||
Container(
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
decoration: BoxDecoration(
|
||||||
decoration: BoxDecoration(
|
color: record.isExpired
|
||||||
color: Colors.red.withOpacity(0.1),
|
? Colors.red.withOpacity(0.1)
|
||||||
borderRadius: BorderRadius.circular(4),
|
: Colors.green.withOpacity(0.1),
|
||||||
),
|
borderRadius: BorderRadius.circular(4),
|
||||||
child: const Text(
|
),
|
||||||
'已过期',
|
child: Text(
|
||||||
style: TextStyle(fontSize: 10, color: Colors.red),
|
record.isExpired ? '无效' : '有效',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
color: record.isExpired ? Colors.red : Colors.green,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue