fix(settlement): 要求封盘后才能结算并优化预览流程
封盘前禁止录入比分与生成预览;待结算未确认前可解除封盘。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1104,11 +1104,21 @@ export class MatchesService {
|
||||
async reopenMatch(matchId: bigint, startTime?: Date) {
|
||||
const match = await this.requireAdminMatch(matchId);
|
||||
if (match.isOutright) throw appBadRequest('OUTRIGHT_EDIT_VIA_MARKETS');
|
||||
if (match.status !== 'CLOSED') throw appBadRequest('MATCH_NOT_REOPENABLE');
|
||||
|
||||
const scoreRow = await this.prisma.matchScore.findUnique({ where: { matchId } });
|
||||
if (scoreRow) throw appBadRequest('MATCH_NOT_REOPENABLE');
|
||||
|
||||
const reopenable =
|
||||
match.status === 'CLOSED' ||
|
||||
(match.status === 'PENDING_SETTLEMENT' && !scoreRow);
|
||||
if (!reopenable) throw appBadRequest('MATCH_NOT_REOPENABLE');
|
||||
|
||||
if (match.status === 'PENDING_SETTLEMENT') {
|
||||
await this.prisma.settlementBatch.deleteMany({
|
||||
where: { matchId, status: 'PREVIEW' },
|
||||
});
|
||||
}
|
||||
|
||||
const effectiveStart = startTime ?? match.startTime;
|
||||
if (!isPreMatchKickoff(effectiveStart)) {
|
||||
throw appBadRequest('MATCH_REOPEN_KICKOFF_REQUIRED');
|
||||
|
||||
Reference in New Issue
Block a user