sync(theme-3): 同步 main 最新 API/Admin 与玩家端逻辑

从 main 同步站内信手动发送、媒体库选择、列表子路由重构等 API/Admin 改动;玩家端仅合并 ADMIN_CUSTOM 富文本、消息预览与充值截图压缩逻辑,保留 theme-3 样式。
This commit is contained in:
2026-06-22 14:11:47 +08:00
parent f92c5e8a59
commit d8e08aaed0
50 changed files with 4653 additions and 1186 deletions

View File

@@ -558,6 +558,8 @@ export class MatchesService {
pageSize?: number;
hasBets?: string;
orderBy?: string;
startFrom?: Date;
startTo?: Date;
},
) {
const where: Prisma.MatchWhereInput = {
@@ -566,6 +568,11 @@ export class MatchesService {
isOutright: false,
};
if (opts.status) where.status = opts.status;
if (opts.startFrom || opts.startTo) {
where.startTime = {};
if (opts.startFrom) where.startTime.gte = opts.startFrom;
if (opts.startTo) where.startTime.lte = opts.startTo;
}
const kw = opts.keyword?.trim();
if (kw) {
where.OR = [
@@ -626,6 +633,10 @@ export class MatchesService {
const stakeB = parseFloat(b.totalStake);
return stakeB - stakeA;
});
} else if (opts.orderBy === 'kickoffAsc') {
filteredItems.sort((a, b) => new Date(a.startTime).getTime() - new Date(b.startTime).getTime());
} else if (opts.orderBy === 'kickoffDesc') {
filteredItems.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime());
} else {
filteredItems.sort((a, b) => {
if (a.displayOrder !== b.displayOrder) {
@@ -640,12 +651,19 @@ export class MatchesService {
return { items: paginatedItems, total, page, pageSize };
}
const orderBy =
opts.orderBy === 'kickoffAsc'
? [{ startTime: 'asc' as const }, { displayOrder: 'asc' as const }]
: opts.orderBy === 'kickoffDesc'
? [{ startTime: 'desc' as const }, { displayOrder: 'asc' as const }]
: [{ displayOrder: 'asc' as const }, { startTime: 'desc' as const }];
const [total, rows] = await Promise.all([
this.prisma.match.count({ where }),
this.prisma.match.findMany({
where,
include: { homeTeam: true, awayTeam: true },
orderBy: [{ displayOrder: 'asc' }, { startTime: 'desc' }],
orderBy,
skip: (page - 1) * pageSize,
take: pageSize,
}),
@@ -865,9 +883,32 @@ export class MatchesService {
async getAdminMatchDetail(matchId: bigint) {
const match = await this.requireAdminMatch(matchId);
const scoreRow = await this.prisma.matchScore.findUnique({
let scoreRow = await this.prisma.matchScore.findUnique({
where: { matchId },
});
if (!scoreRow) {
const previewBatch = await this.prisma.settlementBatch.findFirst({
where: { matchId, status: 'PREVIEW' },
orderBy: { createdAt: 'desc' },
});
if (previewBatch) {
scoreRow = {
htHomeScore: previewBatch.htHomeScore,
htAwayScore: previewBatch.htAwayScore,
ftHomeScore: previewBatch.ftHomeScore,
ftAwayScore: previewBatch.ftAwayScore,
homeCorners: previewBatch.homeCorners,
awayCorners: previewBatch.awayCorners,
homeYellowCards: previewBatch.homeYellowCards,
awayYellowCards: previewBatch.awayYellowCards,
homeRedCards: previewBatch.homeRedCards,
awayRedCards: previewBatch.awayRedCards,
homeCards: previewBatch.homeCards,
awayCards: previewBatch.awayCards,
winnerTeamId: null,
} as any;
}
}
const markets = await this.prisma.market.findMany({
where: { matchId },
include: { selections: { orderBy: { sortOrder: 'asc' } } },