Files
thebet365/apps/api/src/infrastructure/database/seed-demo-markets.ts
Mars afb5c5437e feat: 充值订单审计与重新申请,优化赛事展示和余额刷新
- 新增 deposit_order_audit_logs 表,记录提交/审批/拒绝/撤销/重提全链路
- 管理端充值单页增加审计历史;玩家端充值历史支持时间线与重新申请
- 已拒绝订单可原单号重提;撤销入账使用 PLAYER_DEPOSIT_REVERSAL 并加强幂等
- 结算后清除热门标记,允许归档已结算赛事,完善今日赛事时区窗口
- 足球页今日/早盘独立折叠;资料与余额在进入钱包/个人页及下注后自动刷新
- 补充投注玩法、结算返水规则文档;新增 smoke/settlement CLI 脚本

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 14:52:05 +08:00

67 lines
2.1 KiB
TypeScript

import type { PrismaClient } from '@prisma/client';
import { DEFAULT_MARKET_TYPES, buildMarketTemplate } from '@thebet365/shared';
/** 为演示赛事补齐详情页玩法(与后台 markets 模板一致) */
export async function seedDemoMarkets(prisma: PrismaClient, matchId: bigint) {
const configs = DEFAULT_MARKET_TYPES.map((marketType) => ({
marketType,
...buildMarketTemplate(marketType),
}));
for (const cfg of configs) {
const exists = await prisma.market.findFirst({
where: { matchId, marketType: cfg.marketType },
include: { _count: { select: { selections: true } } },
});
if (exists) {
const needRefresh =
cfg.marketType.includes('CORRECT_SCORE') &&
exists._count.selections < cfg.selectionTemplate.length;
if (needRefresh) {
const existing = await prisma.marketSelection.findMany({
where: { marketId: exists.id },
select: { selectionCode: true },
});
const existingCodes = new Set(existing.map((s) => s.selectionCode));
const missing = cfg.selectionTemplate
.map((s, i) => ({ ...s, sortOrder: i }))
.filter((s) => !existingCodes.has(s.code));
if (missing.length > 0) {
await prisma.marketSelection.createMany({
data: missing.map((s) => ({
marketId: exists.id,
selectionCode: s.code,
selectionName: s.name,
odds: s.odds,
sortOrder: s.sortOrder,
status: 'OPEN',
})),
});
}
}
continue;
}
await prisma.market.create({
data: {
matchId,
marketType: cfg.marketType,
period: cfg.period,
lineValue: cfg.defaultLineValue,
allowSingle: cfg.allowSingle,
allowParlay: cfg.allowParlay,
sortOrder: cfg.sortOrder,
status: 'OPEN',
selections: {
create: cfg.selectionTemplate.map((s, i) => ({
selectionCode: s.code,
selectionName: s.name,
odds: s.odds,
sortOrder: i,
status: 'OPEN',
})),
},
},
});
}
}