feat: 充值订单审计与重新申请,优化赛事展示和余额刷新
- 新增 deposit_order_audit_logs 表,记录提交/审批/拒绝/撤销/重提全链路 - 管理端充值单页增加审计历史;玩家端充值历史支持时间线与重新申请 - 已拒绝订单可原单号重提;撤销入账使用 PLAYER_DEPOSIT_REVERSAL 并加强幂等 - 结算后清除热门标记,允许归档已结算赛事,完善今日赛事时区窗口 - 足球页今日/早盘独立折叠;资料与余额在进入钱包/个人页及下注后自动刷新 - 补充投注玩法、结算返水规则文档;新增 smoke/settlement CLI 脚本 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -87,8 +87,21 @@ const zh: Record<string, string> = {
|
||||
'deposit.confirm_reopen': '订单将恢复为待审核,可再次批准或拒绝。确定继续?',
|
||||
'deposit.delete': '删除',
|
||||
'deposit.confirm_delete': '【仅删除记录】将永久删除本订单记录及截图文件。确定继续?',
|
||||
'deposit.delete_failed': '删除失败',
|
||||
'deposit.prev': '上一页',
|
||||
'deposit.next': '下一页',
|
||||
'deposit.audit_history': '审核记录',
|
||||
'deposit.audit_action': '操作',
|
||||
'deposit.audit_actor': '操作人',
|
||||
'deposit.audit_time': '时间',
|
||||
'deposit.audit_remark': '备注',
|
||||
'deposit.audit_submitted': '提交申请',
|
||||
'deposit.audit_approved': '审核通过',
|
||||
'deposit.audit_rejected': '审核拒绝',
|
||||
'deposit.audit_revoked': '撤销审核',
|
||||
'deposit.audit_reopened': '重新审核',
|
||||
'deposit.audit_deleted': '已删除',
|
||||
'deposit.audit_empty': '暂无审核记录',
|
||||
'deposit.add_method': '+ 添加',
|
||||
'deposit.display_name': '展示名称',
|
||||
'deposit.details': '详情',
|
||||
@@ -357,8 +370,21 @@ const en: Record<string, string> = {
|
||||
'deposit.confirm_reopen': 'The order will return to pending for approve or reject. Continue?',
|
||||
'deposit.delete': 'Delete',
|
||||
'deposit.confirm_delete': '[Records only] Permanently delete this order record and screenshot. Continue?',
|
||||
'deposit.delete_failed': 'Delete failed',
|
||||
'deposit.prev': 'Prev',
|
||||
'deposit.next': 'Next',
|
||||
'deposit.audit_history': 'Review history',
|
||||
'deposit.audit_action': 'Action',
|
||||
'deposit.audit_actor': 'Actor',
|
||||
'deposit.audit_time': 'Time',
|
||||
'deposit.audit_remark': 'Remark',
|
||||
'deposit.audit_submitted': 'Submitted',
|
||||
'deposit.audit_approved': 'Approved',
|
||||
'deposit.audit_rejected': 'Rejected',
|
||||
'deposit.audit_revoked': 'Approval revoked',
|
||||
'deposit.audit_reopened': 'Reopened for review',
|
||||
'deposit.audit_deleted': 'Deleted',
|
||||
'deposit.audit_empty': 'No review history yet',
|
||||
'deposit.add_method': '+ Add',
|
||||
'deposit.display_name': 'Display Name',
|
||||
'deposit.details': 'Details',
|
||||
@@ -625,8 +651,21 @@ const ms: Record<string, string> = {
|
||||
'deposit.confirm_reopen': 'Pesanan kembali menunggu untuk lulus atau tolak. Teruskan?',
|
||||
'deposit.delete': 'Padam',
|
||||
'deposit.confirm_delete': '[Rekod sahaja] Padam rekod pesanan dan tangkapan skrin. Teruskan?',
|
||||
'deposit.delete_failed': 'Gagal memadam',
|
||||
'deposit.prev': 'Sebelum',
|
||||
'deposit.next': 'Seterus',
|
||||
'deposit.audit_history': 'Sejarah semakan',
|
||||
'deposit.audit_action': 'Tindakan',
|
||||
'deposit.audit_actor': 'Pengendali',
|
||||
'deposit.audit_time': 'Masa',
|
||||
'deposit.audit_remark': 'Catatan',
|
||||
'deposit.audit_submitted': 'Dihantar',
|
||||
'deposit.audit_approved': 'Diluluskan',
|
||||
'deposit.audit_rejected': 'Ditolak',
|
||||
'deposit.audit_revoked': 'Kelulusan dibatalkan',
|
||||
'deposit.audit_reopened': 'Dibuka semula',
|
||||
'deposit.audit_deleted': 'Dipadam',
|
||||
'deposit.audit_empty': 'Tiada sejarah semakan',
|
||||
'deposit.add_method': '+ Tambah',
|
||||
'deposit.display_name': 'Nama Paparan',
|
||||
'deposit.details': 'Butiran',
|
||||
|
||||
@@ -4,6 +4,9 @@ import 'element-plus/dist/index.css';
|
||||
import App from './App.vue';
|
||||
import router from './router';
|
||||
import { createAdminI18n } from './i18n';
|
||||
import { applyElementPlusDialogDefaults } from './plugins/element-plus-defaults';
|
||||
|
||||
applyElementPlusDialogDefaults();
|
||||
|
||||
async function bootstrap() {
|
||||
const i18n = await createAdminI18n();
|
||||
|
||||
6
apps/admin/src/plugins/element-plus-defaults.ts
Normal file
6
apps/admin/src/plugins/element-plus-defaults.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ElDialog } from 'element-plus';
|
||||
|
||||
/** Prevent accidental form data loss from mask clicks across admin dialogs. */
|
||||
export function applyElementPlusDialogDefaults() {
|
||||
ElDialog.props.closeOnClickModal.default = false;
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { useAdminLocale } from '../composables/useAdminLocale';
|
||||
import { resolveApiError } from '../i18n/form-validation';
|
||||
import api from '../api';
|
||||
import AdminTableEmpty from '../components/AdminTableEmpty.vue';
|
||||
import { formatAmount } from '../utils/format-amount';
|
||||
@@ -27,6 +28,20 @@ interface DepositOrderRow {
|
||||
paymentMethodName: string | null;
|
||||
}
|
||||
|
||||
interface DepositAuditLogRow {
|
||||
id: string;
|
||||
action: string;
|
||||
actorId: string | null;
|
||||
actorType: string;
|
||||
actorUsername: string | null;
|
||||
statusBefore: string | null;
|
||||
statusAfter: string;
|
||||
amount: string | null;
|
||||
approvedAmount: string | null;
|
||||
remark: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
const items = ref<DepositOrderRow[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
@@ -53,6 +68,12 @@ const rejectReason = ref('');
|
||||
const previewUrl = ref('');
|
||||
const previewVisible = ref(false);
|
||||
|
||||
// Audit history dialog
|
||||
const auditDialogVisible = ref(false);
|
||||
const auditTarget = ref<DepositOrderRow | null>(null);
|
||||
const auditLogs = ref<DepositAuditLogRow[]>([]);
|
||||
const auditLoading = ref(false);
|
||||
|
||||
async function fetchList() {
|
||||
loading.value = true;
|
||||
try {
|
||||
@@ -87,6 +108,32 @@ function openScreenshot(url: string) {
|
||||
previewVisible.value = true;
|
||||
}
|
||||
|
||||
async function openAuditHistory(row: DepositOrderRow) {
|
||||
auditTarget.value = row;
|
||||
auditDialogVisible.value = true;
|
||||
auditLoading.value = true;
|
||||
auditLogs.value = [];
|
||||
try {
|
||||
const { data } = await api.get(`/admin/deposit-orders/${row.id}/audit-logs`);
|
||||
auditLogs.value = data.data?.items ?? [];
|
||||
} catch {
|
||||
auditLogs.value = [];
|
||||
} finally {
|
||||
auditLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function auditActionLabel(action: string) {
|
||||
const key = `deposit.audit_${action.toLowerCase()}`;
|
||||
const translated = t(key);
|
||||
return translated !== key ? translated : action;
|
||||
}
|
||||
|
||||
function auditActorLabel(row: DepositAuditLogRow) {
|
||||
if (row.actorUsername) return row.actorUsername;
|
||||
return row.actorType === 'PLAYER' ? t('deposit.player') : '-';
|
||||
}
|
||||
|
||||
async function confirmDepositAction(message: string, title: string): Promise<boolean> {
|
||||
try {
|
||||
await ElMessageBox.confirm(message, title, {
|
||||
@@ -101,8 +148,7 @@ async function confirmDepositAction(message: string, title: string): Promise<boo
|
||||
}
|
||||
|
||||
function showApiError(e: unknown) {
|
||||
const msg = (e as { response?: { data?: { message?: string } } })?.response?.data?.message;
|
||||
ElMessage.error(msg || 'Error');
|
||||
ElMessage.error(resolveApiError(e, t, 'deposit.delete_failed'));
|
||||
}
|
||||
|
||||
async function handleApprove() {
|
||||
@@ -262,6 +308,7 @@ onMounted(fetchList);
|
||||
<td class="remark-cell">{{ row.remark || row.rejectReason || '-' }}</td>
|
||||
<td class="time-cell">{{ new Date(row.createdAt).toLocaleString() }}</td>
|
||||
<td>
|
||||
<button class="btn-sm btn-audit" @click="openAuditHistory(row)">{{ t('deposit.audit_history') }}</button>
|
||||
<template v-if="row.status === 'PENDING'">
|
||||
<button class="btn-sm btn-approve" @click="openApprove(row)">{{ t('deposit.approve') }}</button>
|
||||
<button class="btn-sm btn-reject" @click="openReject(row)">{{ t('deposit.reject') }}</button>
|
||||
@@ -293,7 +340,7 @@ onMounted(fetchList);
|
||||
</div>
|
||||
|
||||
<!-- Approve Dialog -->
|
||||
<div v-if="approveDialogVisible" class="dialog-overlay" @click.self="approveDialogVisible = false">
|
||||
<div v-if="approveDialogVisible" class="dialog-overlay">
|
||||
<div class="dialog-box">
|
||||
<h3>{{ t('deposit.approve_title') }}</h3>
|
||||
<p class="approve-check-hint">{{ t('deposit.approve_check_hint') }}</p>
|
||||
@@ -325,7 +372,7 @@ onMounted(fetchList);
|
||||
</div>
|
||||
|
||||
<!-- Reject Dialog -->
|
||||
<div v-if="rejectDialogVisible" class="dialog-overlay" @click.self="rejectDialogVisible = false">
|
||||
<div v-if="rejectDialogVisible" class="dialog-overlay">
|
||||
<div class="dialog-box">
|
||||
<h3>{{ t('deposit.reject_title') }}</h3>
|
||||
<div v-if="rejectTarget" class="reject-content">
|
||||
@@ -347,8 +394,41 @@ onMounted(fetchList);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Audit History Dialog -->
|
||||
<div v-if="auditDialogVisible" class="dialog-overlay">
|
||||
<div class="dialog-box audit-dialog">
|
||||
<h3>{{ t('deposit.audit_history') }}</h3>
|
||||
<p v-if="auditTarget" class="audit-order-no">{{ auditTarget.orderNo }} · {{ auditTarget.playerUsername || auditTarget.playerId }}</p>
|
||||
<div v-if="auditLoading" class="audit-loading">{{ t('common.loading') }}</div>
|
||||
<div v-else-if="!auditLogs.length" class="audit-empty">{{ t('deposit.audit_empty') }}</div>
|
||||
<table v-else class="audit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ t('deposit.audit_action') }}</th>
|
||||
<th>{{ t('deposit.audit_actor') }}</th>
|
||||
<th>{{ t('deposit.approved_amount') }}</th>
|
||||
<th>{{ t('deposit.audit_remark') }}</th>
|
||||
<th>{{ t('deposit.audit_time') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="log in auditLogs" :key="log.id">
|
||||
<td>{{ auditActionLabel(log.action) }}</td>
|
||||
<td>{{ auditActorLabel(log) }}</td>
|
||||
<td>{{ log.approvedAmount ? formatAmount(log.approvedAmount) : (log.amount ? formatAmount(log.amount) : '-') }}</td>
|
||||
<td class="remark-cell">{{ log.remark || '-' }}</td>
|
||||
<td class="time-cell">{{ new Date(log.createdAt).toLocaleString() }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="dialog-actions">
|
||||
<button class="btn-cancel" @click="auditDialogVisible = false">{{ t('common.cancel') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Screenshot Preview -->
|
||||
<div v-if="previewVisible" class="dialog-overlay" @click.self="previewVisible = false">
|
||||
<div v-if="previewVisible" class="dialog-overlay">
|
||||
<div class="preview-box">
|
||||
<img :src="previewUrl" class="preview-image" />
|
||||
<button class="close-preview" @click="previewVisible = false">✕</button>
|
||||
@@ -386,6 +466,15 @@ onMounted(fetchList);
|
||||
.btn-reject:hover { background: #4a2525; }
|
||||
.btn-reopen { background: #2a2410; color: #e6a23c; }
|
||||
.btn-reopen:hover { background: #3a3218; }
|
||||
.action-hint {
|
||||
display: inline-block;
|
||||
margin-left: 4px;
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.btn-audit { background: #1f2433; color: #8ab4ff; }
|
||||
.btn-audit:hover { background: #2a3348; }
|
||||
.btn-delete { background: #2a2a2a; color: #aaa; }
|
||||
.btn-delete:hover { background: #3a3a3a; color: #f56c6c; }
|
||||
.actions-cell { white-space: nowrap; }
|
||||
@@ -628,6 +717,13 @@ onMounted(fetchList);
|
||||
background: var(--danger-text);
|
||||
}
|
||||
|
||||
.audit-dialog { min-width: 520px; max-width: 760px; }
|
||||
.audit-order-no { margin: -8px 0 12px; font-size: 12px; color: var(--text-muted); }
|
||||
.audit-loading, .audit-empty { padding: 20px 0; text-align: center; color: var(--text-muted); font-size: 13px; }
|
||||
.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 8px; }
|
||||
.audit-table th, .audit-table td { padding: 8px 6px; border-bottom: 1px solid var(--border-soft); text-align: left; }
|
||||
.audit-table th { color: var(--text-muted); font-weight: 700; }
|
||||
|
||||
.close-preview {
|
||||
background: var(--text);
|
||||
color: #ffffff;
|
||||
|
||||
@@ -238,7 +238,7 @@ async function doUpload() {
|
||||
</div>
|
||||
|
||||
<!-- Upload dialog -->
|
||||
<div v-if="uploadDialogVisible" class="dialog-overlay" @click.self="uploadDialogVisible = false">
|
||||
<div v-if="uploadDialogVisible" class="dialog-overlay">
|
||||
<div class="dialog">
|
||||
<div class="dialog-header">
|
||||
<span>{{ t('media.upload_dialog') }}</span>
|
||||
|
||||
@@ -234,7 +234,7 @@ onMounted(fetchList);
|
||||
</table>
|
||||
|
||||
<!-- Create/Edit Dialog -->
|
||||
<div v-if="dialogVisible" class="dialog-overlay" @click.self="dialogVisible = false">
|
||||
<div v-if="dialogVisible" class="dialog-overlay">
|
||||
<div class="dialog-box">
|
||||
<h3>{{ editingId ? t('deposit.edit_method') : t('deposit.create_method') }}</h3>
|
||||
<div class="form-group" v-if="!editingId">
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
"db:migrate": "prisma migrate dev",
|
||||
"db:migrate:deploy": "prisma migrate deploy && prisma generate",
|
||||
"db:seed": "ts-node prisma/seed.ts",
|
||||
"db:smoke": "ts-node src/infrastructure/database/run-smoke-cli.ts",
|
||||
"audit:settlement": "ts-node src/infrastructure/database/run-settlement-audit.ts",
|
||||
"db:reset": "ts-node src/infrastructure/database/reset-and-seed-cli.ts --yes --production",
|
||||
"db:reset:dev": "ts-node src/infrastructure/database/reset-and-seed-cli.ts --yes --dev",
|
||||
"db:studio": "prisma studio"
|
||||
|
||||
8
apps/api/prisma/migrations/20260615040059/migration.sql
Normal file
8
apps/api/prisma/migrations/20260615040059/migration.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "market_template_items" ALTER COLUMN "updated_at" DROP DEFAULT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "market_template_selections" ALTER COLUMN "updated_at" DROP DEFAULT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "market_templates" ALTER COLUMN "updated_at" DROP DEFAULT;
|
||||
@@ -0,0 +1,25 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "deposit_order_audit_logs" (
|
||||
"id" BIGSERIAL NOT NULL,
|
||||
"deposit_order_id" BIGINT NOT NULL,
|
||||
"action" VARCHAR(32) NOT NULL,
|
||||
"actor_id" BIGINT,
|
||||
"actor_type" VARCHAR(20) NOT NULL,
|
||||
"status_before" VARCHAR(20),
|
||||
"status_after" VARCHAR(20) NOT NULL,
|
||||
"amount" DECIMAL(18,4),
|
||||
"approved_amount" DECIMAL(18,4),
|
||||
"remark" VARCHAR(500),
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "deposit_order_audit_logs_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "deposit_order_audit_logs_deposit_order_id_idx" ON "deposit_order_audit_logs"("deposit_order_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "deposit_order_audit_logs_created_at_idx" ON "deposit_order_audit_logs"("created_at");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "deposit_order_audit_logs" ADD CONSTRAINT "deposit_order_audit_logs_deposit_order_id_fkey" FOREIGN KEY ("deposit_order_id") REFERENCES "deposit_orders"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -785,6 +785,7 @@ model DepositOrder {
|
||||
|
||||
player User @relation("PlayerDepositOrders", fields: [playerId], references: [id])
|
||||
paymentMethod PaymentMethod @relation(fields: [paymentMethodId], references: [id])
|
||||
auditLogs DepositOrderAuditLog[]
|
||||
|
||||
@@index([playerId])
|
||||
@@index([status])
|
||||
@@ -792,6 +793,26 @@ model DepositOrder {
|
||||
@@map("deposit_orders")
|
||||
}
|
||||
|
||||
model DepositOrderAuditLog {
|
||||
id BigInt @id @default(autoincrement())
|
||||
depositOrderId BigInt @map("deposit_order_id")
|
||||
action String @db.VarChar(32)
|
||||
actorId BigInt? @map("actor_id")
|
||||
actorType String @map("actor_type") @db.VarChar(20)
|
||||
statusBefore String? @map("status_before") @db.VarChar(20)
|
||||
statusAfter String @map("status_after") @db.VarChar(20)
|
||||
amount Decimal? @db.Decimal(18, 4)
|
||||
approvedAmount Decimal? @map("approved_amount") @db.Decimal(18, 4)
|
||||
remark String? @db.VarChar(500)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
depositOrder DepositOrder @relation(fields: [depositOrderId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([depositOrderId])
|
||||
@@index([createdAt])
|
||||
@@map("deposit_order_audit_logs")
|
||||
}
|
||||
|
||||
// ============ System Config & Audit ============
|
||||
|
||||
model SystemConfig {
|
||||
|
||||
@@ -2913,6 +2913,13 @@ export class AdminController {
|
||||
return jsonResponse(result);
|
||||
}
|
||||
|
||||
@Get('deposit-orders/:id/audit-logs')
|
||||
@RequirePermissions(P.depositReview)
|
||||
async depositOrderAuditLogs(@Param('id') id: string) {
|
||||
const items = await this.depositService.getDepositOrderAuditLogs(BigInt(id));
|
||||
return jsonResponse({ items });
|
||||
}
|
||||
|
||||
@Post('deposit-orders/:id/approve')
|
||||
@RequirePermissions(P.depositReview)
|
||||
async approveDepositOrder(
|
||||
|
||||
@@ -182,7 +182,9 @@ export class PlayerController {
|
||||
]);
|
||||
const timeZone = safeTimeZone(headerTimeZone);
|
||||
const now = new Date();
|
||||
const hotMatches = (allMatches as Array<{ isHot?: boolean }>).filter((m) => m.isHot);
|
||||
const hotMatches = (allMatches as Array<{ isHot?: boolean; status?: string }>).filter(
|
||||
(m) => m.isHot && m.status !== 'SETTLED',
|
||||
);
|
||||
const todayMatches = (allMatches as Array<{ startTime: string }>).filter((m) => {
|
||||
const kickoff = new Date(m.startTime);
|
||||
return !Number.isNaN(kickoff.getTime()) && isInLocalTodayMatchWindow(kickoff, now, timeZone);
|
||||
@@ -399,4 +401,52 @@ export class PlayerController {
|
||||
);
|
||||
return jsonResponse(result);
|
||||
}
|
||||
|
||||
@Get('deposit-orders/:id/audit-logs')
|
||||
async myDepositOrderAuditLogs(
|
||||
@CurrentUser('id') userId: bigint,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
const items = await this.deposit.getPlayerDepositOrderAuditLogs(BigInt(id), userId);
|
||||
return jsonResponse({ items });
|
||||
}
|
||||
|
||||
@Post('deposit-orders/:id/reapply')
|
||||
@UseInterceptors(FileInterceptor('screenshot', { limits: { fileSize: 5 * 1024 * 1024 } }))
|
||||
async reapplyDepositOrder(
|
||||
@CurrentUser('id') userId: bigint,
|
||||
@Param('id') id: string,
|
||||
@UploadedFile() file: { originalname: string; mimetype: string; buffer: Buffer; size: number } | undefined,
|
||||
@Body() body: { paymentMethodId?: string; amount?: string },
|
||||
) {
|
||||
if (!file) throw appBadRequest('SCREENSHOT_REQUIRED');
|
||||
if (!file.mimetype.startsWith('image/')) throw appBadRequest('FILE_MUST_BE_IMAGE');
|
||||
|
||||
const amount = body.amount != null && body.amount !== '' ? parseFloat(body.amount) : undefined;
|
||||
if (amount != null && (!amount || amount <= 0)) throw appBadRequest('INVALID_AMOUNT');
|
||||
|
||||
const ext = extname(file.originalname || '.jpg').toLowerCase() || '.jpg';
|
||||
const filename = `${Date.now()}-${randomUUID().slice(0, 8)}${ext}`;
|
||||
const root = getUploadRoot();
|
||||
const targetDir = join(root, 'deposits');
|
||||
await mkdir(targetDir, { recursive: true });
|
||||
await writeFile(join(targetDir, filename), file.buffer);
|
||||
const screenshotUrl = `/uploads/deposits/${filename}`;
|
||||
|
||||
const order = await this.deposit.reapplyDepositOrder(
|
||||
userId,
|
||||
BigInt(id),
|
||||
screenshotUrl,
|
||||
amount,
|
||||
body.paymentMethodId ? BigInt(body.paymentMethodId) : undefined,
|
||||
);
|
||||
|
||||
return jsonResponse({
|
||||
id: order!.id.toString(),
|
||||
orderNo: order!.orderNo,
|
||||
amount: order!.amount.toString(),
|
||||
status: order!.status,
|
||||
createdAt: order!.createdAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('CatalogArchiveService', () => {
|
||||
match: { findFirst: jest.Mock; update: jest.Mock; findMany: jest.Mock; updateMany: jest.Mock };
|
||||
league: { findFirst: jest.Mock; update: jest.Mock };
|
||||
bet: { findMany: jest.Mock };
|
||||
settlementBatch: { findFirst: jest.Mock; findMany: jest.Mock };
|
||||
settlementBatch: { findFirst: jest.Mock; findMany: jest.Mock; deleteMany: jest.Mock };
|
||||
market: { updateMany: jest.Mock };
|
||||
marketSelection: { updateMany: jest.Mock };
|
||||
entityTranslation: { findFirst: jest.Mock };
|
||||
@@ -28,7 +28,11 @@ describe('CatalogArchiveService', () => {
|
||||
},
|
||||
league: { findFirst: jest.fn(), update: jest.fn() },
|
||||
bet: { findMany: jest.fn().mockResolvedValue([]) },
|
||||
settlementBatch: { findFirst: jest.fn().mockResolvedValue(null), findMany: jest.fn().mockResolvedValue([]) },
|
||||
settlementBatch: {
|
||||
findFirst: jest.fn().mockResolvedValue(null),
|
||||
findMany: jest.fn().mockResolvedValue([]),
|
||||
deleteMany: jest.fn().mockResolvedValue({ count: 0 }),
|
||||
},
|
||||
market: { updateMany: jest.fn() },
|
||||
marketSelection: { updateMany: jest.fn() },
|
||||
entityTranslation: { findFirst: jest.fn().mockResolvedValue(null) },
|
||||
@@ -71,6 +75,40 @@ describe('CatalogArchiveService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('archives settled match with stale preview batch when force is true', async () => {
|
||||
prisma.match.findFirst.mockResolvedValue({ ...baseMatch, status: 'SETTLED' });
|
||||
prisma.bet.findMany.mockResolvedValue([]);
|
||||
prisma.settlementBatch.findFirst.mockResolvedValue({ id: BigInt(99) });
|
||||
|
||||
const result = await service.archiveMatch(matchId, { force: true });
|
||||
|
||||
expect(result.matchId).toBe(matchId.toString());
|
||||
expect(prisma.settlementBatch.deleteMany).toHaveBeenCalledWith({
|
||||
where: { matchId, status: 'PREVIEW' },
|
||||
});
|
||||
expect(prisma.match.update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
data: expect.objectContaining({
|
||||
deletedAt: expect.any(Date),
|
||||
status: 'SETTLED',
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('archives settled match without force when no warnings', async () => {
|
||||
prisma.match.findFirst.mockResolvedValue({ ...baseMatch, status: 'SETTLED' });
|
||||
prisma.bet.findMany.mockResolvedValue([]);
|
||||
|
||||
await service.archiveMatch(matchId, { force: false });
|
||||
|
||||
expect(prisma.match.update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
data: expect.objectContaining({ status: 'SETTLED' }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('archive with force rejects draft matches', async () => {
|
||||
prisma.match.findFirst.mockResolvedValue({ ...baseMatch, status: 'DRAFT' });
|
||||
|
||||
|
||||
@@ -70,9 +70,6 @@ export class CatalogArchiveService {
|
||||
if (match.status === 'DRAFT') {
|
||||
throw appBadRequest('MATCH_DELETE_DRAFT_ONLY');
|
||||
}
|
||||
if (match.status === 'SETTLED') {
|
||||
throw appBadRequest('ARCHIVE_BLOCKED');
|
||||
}
|
||||
const preview = await this.getMatchArchivePreview(matchId);
|
||||
if (preview.requiresForce && !opts.force) {
|
||||
throw appConflict('ARCHIVE_BLOCKED', preview);
|
||||
@@ -80,6 +77,9 @@ export class CatalogArchiveService {
|
||||
|
||||
const now = new Date();
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.settlementBatch.deleteMany({
|
||||
where: { matchId, status: 'PREVIEW' },
|
||||
});
|
||||
await tx.marketSelection.updateMany({
|
||||
where: { market: { matchId } },
|
||||
data: { status: 'CLOSED' },
|
||||
@@ -92,8 +92,7 @@ export class CatalogArchiveService {
|
||||
where: { id: matchId },
|
||||
data: {
|
||||
deletedAt: now,
|
||||
status:
|
||||
match.status === 'CANCELLED' || match.status === 'VOID' ? match.status : 'CANCELLED',
|
||||
status: TERMINAL_MATCH_STATUSES.has(match.status) ? match.status : 'CANCELLED',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1256,7 +1256,7 @@ export class MatchesService {
|
||||
homeTeamLogoUrl: m.homeTeam?.logoUrl ?? null,
|
||||
awayTeamLogoUrl: m.awayTeam?.logoUrl ?? null,
|
||||
startTime: m.startTime.toISOString(),
|
||||
isHot: m.isHot ?? false,
|
||||
isHot: m.status === 'SETTLED' ? false : (m.isHot ?? false),
|
||||
displayOrder: m.displayOrder ?? 0,
|
||||
matchName: m.matchName ?? null,
|
||||
stage: m.stage ?? null,
|
||||
|
||||
@@ -7,9 +7,13 @@ describe('DepositService', () => {
|
||||
$queryRaw: jest.fn(),
|
||||
depositOrder: {
|
||||
findUnique: jest.fn(),
|
||||
findFirst: jest.fn(),
|
||||
update: jest.fn(),
|
||||
delete: jest.fn(),
|
||||
},
|
||||
paymentMethod: {
|
||||
findUnique: jest.fn(),
|
||||
},
|
||||
bet: {
|
||||
findMany: jest.fn(),
|
||||
},
|
||||
@@ -19,6 +23,9 @@ describe('DepositService', () => {
|
||||
agentProfile: {
|
||||
findUnique: jest.fn(),
|
||||
},
|
||||
depositOrderAuditLog: {
|
||||
create: jest.fn(),
|
||||
},
|
||||
};
|
||||
const prisma = {
|
||||
...tx,
|
||||
@@ -65,6 +72,7 @@ describe('DepositService', () => {
|
||||
reviewedAt: null,
|
||||
screenshotUrl: '/uploads/a.png',
|
||||
});
|
||||
tx.depositOrderAuditLog.create.mockResolvedValue({ id: 501n });
|
||||
tx.user.findFirst.mockResolvedValue({ parentId: 3n });
|
||||
tx.agentProfile.findUnique.mockResolvedValue({
|
||||
creditLimit: new Decimal(1000),
|
||||
@@ -89,7 +97,7 @@ describe('DepositService', () => {
|
||||
remark: 'Bank receipt checked',
|
||||
referenceId: 'DEP-1',
|
||||
transactionType: 'PLAYER_DEPOSIT',
|
||||
businessKey: 'deposit:DEP-1:approve',
|
||||
businessKey: 'deposit:DEP-1:approve:501',
|
||||
tx,
|
||||
}),
|
||||
);
|
||||
@@ -98,6 +106,54 @@ describe('DepositService', () => {
|
||||
expect(credit.recalculateUsedCredit).toHaveBeenNthCalledWith(2, 3n, tx);
|
||||
});
|
||||
|
||||
it('uses a fresh business key when re-approving after revoke', async () => {
|
||||
const reviewedAt = new Date('2026-06-15T14:08:48.000Z');
|
||||
tx.depositOrder.findUnique.mockResolvedValue({
|
||||
id: 1n,
|
||||
orderNo: 'DEP-1',
|
||||
playerId: 7n,
|
||||
amount: new Decimal(2),
|
||||
approvedAmount: null,
|
||||
status: 'PENDING',
|
||||
reviewedAt: null,
|
||||
screenshotUrl: '/uploads/a.png',
|
||||
});
|
||||
tx.depositOrderAuditLog.create.mockResolvedValueOnce({ id: 601n });
|
||||
|
||||
await service.approveDepositOrder(1n, 2n, 2, 'Second approval');
|
||||
|
||||
expect(funds.deposit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
amount: new Decimal(2),
|
||||
businessKey: 'deposit:DEP-1:approve:601',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('uses approval cycle key when revoking a funded deposit for re-review', async () => {
|
||||
const reviewedAt = new Date('2026-06-15T14:08:48.000Z');
|
||||
tx.depositOrder.findUnique.mockResolvedValue({
|
||||
id: 1n,
|
||||
orderNo: 'DEP-1',
|
||||
playerId: 7n,
|
||||
amount: new Decimal(21),
|
||||
approvedAmount: new Decimal(21),
|
||||
status: 'APPROVED',
|
||||
reviewedAt,
|
||||
screenshotUrl: '/uploads/a.png',
|
||||
});
|
||||
tx.depositOrderAuditLog.create.mockResolvedValue({ id: 701n });
|
||||
|
||||
await service.reopenDepositOrderForReview(1n, 2n);
|
||||
|
||||
expect(funds.withdraw).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
amount: new Decimal(21),
|
||||
businessKey: `deposit:DEP-1:reopen-reverse:${reviewedAt.getTime()}`,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('blocks approved deposit revoke when bets exist after approval', async () => {
|
||||
tx.bet.findMany.mockResolvedValue([{ id: 99n }]);
|
||||
|
||||
@@ -116,4 +172,106 @@ describe('DepositService', () => {
|
||||
|
||||
expect(tx.depositOrder.delete).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('reapplies a rejected deposit on the same order for the player', async () => {
|
||||
tx.depositOrder.findUnique
|
||||
.mockResolvedValueOnce({
|
||||
id: 1n,
|
||||
orderNo: 'DEP-1',
|
||||
playerId: 7n,
|
||||
paymentMethodId: 5n,
|
||||
methodType: 'BANK',
|
||||
amount: new Decimal(11),
|
||||
approvedAmount: null,
|
||||
status: 'REJECTED',
|
||||
reviewedAt: new Date(),
|
||||
rejectReason: 'Screenshot unclear',
|
||||
remark: 'Screenshot unclear',
|
||||
screenshotUrl: '/uploads/deposits/old.png',
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
id: 1n,
|
||||
orderNo: 'DEP-1',
|
||||
playerId: 7n,
|
||||
amount: new Decimal(11),
|
||||
status: 'PENDING',
|
||||
createdAt: new Date(),
|
||||
});
|
||||
tx.depositOrder.findFirst.mockResolvedValue(null);
|
||||
tx.paymentMethod.findUnique.mockResolvedValue({
|
||||
id: 5n,
|
||||
methodType: 'BANK',
|
||||
isActive: true,
|
||||
});
|
||||
|
||||
const result = await service.reapplyDepositOrder(
|
||||
7n,
|
||||
1n,
|
||||
'/uploads/deposits/new.png',
|
||||
11,
|
||||
);
|
||||
|
||||
expect(tx.depositOrder.update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: { id: 1n },
|
||||
data: expect.objectContaining({
|
||||
status: 'PENDING',
|
||||
screenshotUrl: '/uploads/deposits/new.png',
|
||||
rejectReason: null,
|
||||
remark: null,
|
||||
reviewerId: null,
|
||||
reviewedAt: null,
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(tx.depositOrderAuditLog.create).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
data: expect.objectContaining({
|
||||
action: 'REOPENED',
|
||||
actorId: 7n,
|
||||
actorType: 'PLAYER',
|
||||
statusBefore: 'REJECTED',
|
||||
statusAfter: 'PENDING',
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(result?.orderNo).toBe('DEP-1');
|
||||
});
|
||||
|
||||
it('blocks reapply when player already has another pending deposit', async () => {
|
||||
tx.depositOrder.findUnique.mockResolvedValue({
|
||||
id: 1n,
|
||||
orderNo: 'DEP-1',
|
||||
playerId: 7n,
|
||||
paymentMethodId: 5n,
|
||||
methodType: 'BANK',
|
||||
amount: new Decimal(11),
|
||||
status: 'REJECTED',
|
||||
screenshotUrl: '/uploads/deposits/old.png',
|
||||
});
|
||||
tx.depositOrder.findFirst.mockResolvedValue({ id: 99n });
|
||||
|
||||
await expect(
|
||||
service.reapplyDepositOrder(7n, 1n, '/uploads/deposits/new.png'),
|
||||
).rejects.toMatchObject(expectAppError('DEPOSIT_PENDING_ORDER_EXISTS'));
|
||||
|
||||
expect(tx.depositOrder.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('blocks reapply for non-rejected deposit orders', async () => {
|
||||
tx.depositOrder.findUnique.mockResolvedValue({
|
||||
id: 1n,
|
||||
orderNo: 'DEP-1',
|
||||
playerId: 7n,
|
||||
paymentMethodId: 5n,
|
||||
methodType: 'BANK',
|
||||
amount: new Decimal(11),
|
||||
status: 'PENDING',
|
||||
screenshotUrl: '/uploads/deposits/old.png',
|
||||
});
|
||||
|
||||
await expect(
|
||||
service.reapplyDepositOrder(7n, 1n, '/uploads/deposits/new.png'),
|
||||
).rejects.toMatchObject(expectAppError('ORDER_NOT_REJECTED'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -17,6 +17,32 @@ function generateOrderNo(): string {
|
||||
/** 已通过充值订单允许撤回的时间窗口 */
|
||||
const DEPOSIT_REVOKE_WINDOW_MS = 5 * 60 * 1000;
|
||||
|
||||
export type DepositOrderAuditAction =
|
||||
| 'SUBMITTED'
|
||||
| 'APPROVED'
|
||||
| 'REJECTED'
|
||||
| 'REVOKED'
|
||||
| 'REOPENED'
|
||||
| 'DELETED';
|
||||
|
||||
type AuditLogWriter = {
|
||||
depositOrderAuditLog: {
|
||||
create: (args: {
|
||||
data: {
|
||||
depositOrderId: bigint;
|
||||
action: DepositOrderAuditAction;
|
||||
actorId?: bigint | null;
|
||||
actorType: string;
|
||||
statusBefore?: string | null;
|
||||
statusAfter: string;
|
||||
amount?: Decimal | null;
|
||||
approvedAmount?: Decimal | null;
|
||||
remark?: string | null;
|
||||
};
|
||||
}) => Promise<{ id: bigint }>;
|
||||
};
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
export class DepositService {
|
||||
constructor(
|
||||
@@ -228,6 +254,156 @@ export class DepositService {
|
||||
|
||||
// ============ Deposit Orders ============
|
||||
|
||||
private async recordDepositAudit(
|
||||
client: AuditLogWriter,
|
||||
data: {
|
||||
depositOrderId: bigint;
|
||||
action: DepositOrderAuditAction;
|
||||
actorId?: bigint | null;
|
||||
actorType: 'PLAYER' | 'ADMIN';
|
||||
statusBefore?: string | null;
|
||||
statusAfter: string;
|
||||
amount?: Decimal | null;
|
||||
approvedAmount?: Decimal | null;
|
||||
remark?: string | null;
|
||||
},
|
||||
) {
|
||||
return client.depositOrderAuditLog.create({
|
||||
data: {
|
||||
depositOrderId: data.depositOrderId,
|
||||
action: data.action,
|
||||
actorId: data.actorId ?? null,
|
||||
actorType: data.actorType,
|
||||
statusBefore: data.statusBefore ?? null,
|
||||
statusAfter: data.statusAfter,
|
||||
amount: data.amount ?? null,
|
||||
approvedAmount: data.approvedAmount ?? null,
|
||||
remark: data.remark ?? null,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private mapAuditLogRow(
|
||||
row: {
|
||||
id: bigint;
|
||||
action: string;
|
||||
actorId: bigint | null;
|
||||
actorType: string;
|
||||
statusBefore: string | null;
|
||||
statusAfter: string;
|
||||
amount: Decimal | null;
|
||||
approvedAmount: Decimal | null;
|
||||
remark: string | null;
|
||||
createdAt: Date;
|
||||
},
|
||||
actorUsername?: string | null,
|
||||
) {
|
||||
return {
|
||||
id: row.id.toString(),
|
||||
action: row.action,
|
||||
actorId: row.actorId?.toString() ?? null,
|
||||
actorType: row.actorType,
|
||||
actorUsername: actorUsername ?? null,
|
||||
statusBefore: row.statusBefore,
|
||||
statusAfter: row.statusAfter,
|
||||
amount: row.amount?.toString() ?? null,
|
||||
approvedAmount: row.approvedAmount?.toString() ?? null,
|
||||
remark: row.remark,
|
||||
createdAt: row.createdAt.toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
async getDepositOrderAuditLogs(orderId: bigint) {
|
||||
const order = await this.prisma.depositOrder.findUnique({
|
||||
where: { id: orderId },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!order) throw appBadRequest('ORDER_NOT_FOUND');
|
||||
|
||||
const rows = await this.prisma.depositOrderAuditLog.findMany({
|
||||
where: { depositOrderId: orderId },
|
||||
orderBy: { createdAt: 'asc' },
|
||||
});
|
||||
|
||||
const actorIds = [...new Set(rows.map((r) => r.actorId).filter((id): id is bigint => id != null))];
|
||||
const actors =
|
||||
actorIds.length > 0
|
||||
? await this.prisma.user.findMany({
|
||||
where: { id: { in: actorIds } },
|
||||
select: { id: true, username: true },
|
||||
})
|
||||
: [];
|
||||
const actorMap = new Map(actors.map((a) => [a.id.toString(), a.username]));
|
||||
|
||||
return rows.map((row) =>
|
||||
this.mapAuditLogRow(
|
||||
row,
|
||||
row.actorId ? actorMap.get(row.actorId.toString()) ?? null : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async getPlayerDepositOrderAuditLogs(orderId: bigint, playerId: bigint) {
|
||||
const order = await this.prisma.depositOrder.findFirst({
|
||||
where: { id: orderId, playerId },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!order) throw appBadRequest('ORDER_NOT_FOUND');
|
||||
|
||||
const rows = await this.prisma.depositOrderAuditLog.findMany({
|
||||
where: { depositOrderId: orderId },
|
||||
orderBy: { createdAt: 'asc' },
|
||||
});
|
||||
|
||||
return rows.map((row) => {
|
||||
const mapped = this.mapAuditLogRow(row);
|
||||
return {
|
||||
id: mapped.id,
|
||||
action: mapped.action,
|
||||
actorType: mapped.actorType,
|
||||
statusBefore: mapped.statusBefore,
|
||||
statusAfter: mapped.statusAfter,
|
||||
amount: mapped.amount,
|
||||
approvedAmount: mapped.approvedAmount,
|
||||
remark: mapped.remark,
|
||||
createdAt: mapped.createdAt,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private async attachPlayerAuditLogs(
|
||||
orders: Array<{ id: bigint }>,
|
||||
) {
|
||||
if (!orders.length) return new Map<string, ReturnType<typeof this.mapAuditLogRow>[]>();
|
||||
|
||||
const orderIds = orders.map((o) => o.id);
|
||||
const rows = await this.prisma.depositOrderAuditLog.findMany({
|
||||
where: { depositOrderId: { in: orderIds } },
|
||||
orderBy: { createdAt: 'asc' },
|
||||
});
|
||||
|
||||
const map = new Map<string, ReturnType<typeof this.mapAuditLogRow>[]>();
|
||||
for (const row of rows) {
|
||||
const key = row.depositOrderId.toString();
|
||||
if (!map.has(key)) map.set(key, []);
|
||||
const mapped = this.mapAuditLogRow(row);
|
||||
map.get(key)!.push({
|
||||
id: mapped.id,
|
||||
action: mapped.action,
|
||||
actorId: null,
|
||||
actorType: mapped.actorType,
|
||||
actorUsername: null,
|
||||
statusBefore: mapped.statusBefore,
|
||||
statusAfter: mapped.statusAfter,
|
||||
amount: mapped.amount,
|
||||
approvedAmount: mapped.approvedAmount,
|
||||
remark: mapped.remark,
|
||||
createdAt: mapped.createdAt,
|
||||
});
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
async createDepositOrder(
|
||||
playerId: bigint,
|
||||
paymentMethodId: bigint,
|
||||
@@ -253,9 +429,87 @@ export class DepositService {
|
||||
},
|
||||
});
|
||||
|
||||
await this.recordDepositAudit(this.prisma, {
|
||||
depositOrderId: order.id,
|
||||
action: 'SUBMITTED',
|
||||
actorId: playerId,
|
||||
actorType: 'PLAYER',
|
||||
statusBefore: null,
|
||||
statusAfter: 'PENDING',
|
||||
amount: order.amount,
|
||||
remark: null,
|
||||
});
|
||||
|
||||
return order;
|
||||
}
|
||||
|
||||
/** 玩家对已拒绝订单重新提交:原订单号不变,状态恢复待审核,需新转账截图。 */
|
||||
async reapplyDepositOrder(
|
||||
playerId: bigint,
|
||||
orderId: bigint,
|
||||
screenshotUrl: string,
|
||||
amount?: number,
|
||||
paymentMethodId?: bigint,
|
||||
) {
|
||||
return this.prisma.$transaction(async (tx) => {
|
||||
const order = await this.lockDepositOrder(tx, orderId);
|
||||
if (order.playerId !== playerId) throw appBadRequest('ORDER_NOT_FOUND');
|
||||
if (order.status !== 'REJECTED') throw appBadRequest('ORDER_NOT_REJECTED');
|
||||
|
||||
const otherPending = await tx.depositOrder.findFirst({
|
||||
where: {
|
||||
playerId,
|
||||
status: 'PENDING',
|
||||
id: { not: orderId },
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
if (otherPending) throw appBadRequest('DEPOSIT_PENDING_ORDER_EXISTS');
|
||||
|
||||
const targetMethodId = paymentMethodId ?? order.paymentMethodId;
|
||||
const method = await tx.paymentMethod.findUnique({ where: { id: targetMethodId } });
|
||||
if (!method || !method.isActive) {
|
||||
throw appBadRequest('PAYMENT_METHOD_NOT_FOUND');
|
||||
}
|
||||
|
||||
const creditAmount = amount != null ? new Decimal(amount) : order.amount;
|
||||
if (creditAmount.lte(0)) throw appBadRequest('INVALID_AMOUNT');
|
||||
|
||||
const oldScreenshotUrl = order.screenshotUrl;
|
||||
|
||||
await tx.depositOrder.update({
|
||||
where: { id: orderId },
|
||||
data: {
|
||||
status: 'PENDING',
|
||||
screenshotUrl,
|
||||
amount: creditAmount,
|
||||
paymentMethodId: targetMethodId,
|
||||
methodType: method.methodType,
|
||||
approvedAmount: null,
|
||||
reviewerId: null,
|
||||
reviewedAt: null,
|
||||
rejectReason: null,
|
||||
remark: null,
|
||||
},
|
||||
});
|
||||
|
||||
await this.recordDepositAudit(tx, {
|
||||
depositOrderId: orderId,
|
||||
action: 'REOPENED',
|
||||
actorId: playerId,
|
||||
actorType: 'PLAYER',
|
||||
statusBefore: order.status,
|
||||
statusAfter: 'PENDING',
|
||||
amount: creditAmount,
|
||||
remark: null,
|
||||
});
|
||||
|
||||
await deleteUploadFileByUrl(oldScreenshotUrl);
|
||||
|
||||
return tx.depositOrder.findUnique({ where: { id: orderId } });
|
||||
});
|
||||
}
|
||||
|
||||
async getPlayerDepositOrders(playerId: bigint, page = 1, pageSize = 20) {
|
||||
const skip = (page - 1) * pageSize;
|
||||
const where = { playerId };
|
||||
@@ -274,11 +528,13 @@ export class DepositService {
|
||||
}),
|
||||
this.prisma.depositOrder.count({ where }),
|
||||
]);
|
||||
const auditMap = await this.attachPlayerAuditLogs(items);
|
||||
|
||||
return {
|
||||
items: items.map((o) => ({
|
||||
id: o.id.toString(),
|
||||
orderNo: o.orderNo,
|
||||
paymentMethodId: o.paymentMethodId.toString(),
|
||||
methodType: o.methodType,
|
||||
amount: o.amount.toString(),
|
||||
screenshotUrl: o.screenshotUrl,
|
||||
@@ -289,6 +545,17 @@ export class DepositService {
|
||||
createdAt: o.createdAt,
|
||||
reviewedAt: o.reviewedAt,
|
||||
paymentMethodName: o.paymentMethod?.displayName ?? o.paymentMethod?.bankName ?? o.paymentMethod?.usdtAddress ?? null,
|
||||
auditLogs: (auditMap.get(o.id.toString()) ?? []).map((log) => ({
|
||||
id: log.id,
|
||||
action: log.action,
|
||||
actorType: log.actorType,
|
||||
statusBefore: log.statusBefore,
|
||||
statusAfter: log.statusAfter,
|
||||
amount: log.amount,
|
||||
approvedAmount: log.approvedAmount,
|
||||
remark: log.remark,
|
||||
createdAt: log.createdAt,
|
||||
})),
|
||||
})),
|
||||
total,
|
||||
page,
|
||||
@@ -428,6 +695,18 @@ export class DepositService {
|
||||
},
|
||||
});
|
||||
|
||||
const auditLog = await this.recordDepositAudit(tx, {
|
||||
depositOrderId: orderId,
|
||||
action: 'APPROVED',
|
||||
actorId: operatorId,
|
||||
actorType: 'ADMIN',
|
||||
statusBefore: order.status,
|
||||
statusAfter: 'APPROVED',
|
||||
amount: order.amount,
|
||||
approvedAmount: creditAmount,
|
||||
remark: remark ?? null,
|
||||
});
|
||||
|
||||
// Credit player wallet
|
||||
await this.funds.deposit({
|
||||
userId: order.playerId,
|
||||
@@ -437,7 +716,7 @@ export class DepositService {
|
||||
referenceId: order.orderNo,
|
||||
transactionType: 'PLAYER_DEPOSIT',
|
||||
tx,
|
||||
businessKey: `deposit:${order.orderNo}:approve`,
|
||||
businessKey: `deposit:${order.orderNo}:approve:${auditLog.id}`,
|
||||
});
|
||||
if (parentAgentId) {
|
||||
await this.credit.recalculateUsedCredit(parentAgentId, tx);
|
||||
@@ -463,6 +742,17 @@ export class DepositService {
|
||||
},
|
||||
});
|
||||
|
||||
await this.recordDepositAudit(this.prisma, {
|
||||
depositOrderId: orderId,
|
||||
action: 'REJECTED',
|
||||
actorId: operatorId,
|
||||
actorType: 'ADMIN',
|
||||
statusBefore: order.status,
|
||||
statusAfter: 'REJECTED',
|
||||
amount: order.amount,
|
||||
remark: reason,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -506,6 +796,16 @@ export class DepositService {
|
||||
remark: null,
|
||||
},
|
||||
});
|
||||
await this.recordDepositAudit(tx, {
|
||||
depositOrderId: orderId,
|
||||
action: 'REOPENED',
|
||||
actorId: operatorId,
|
||||
actorType: 'ADMIN',
|
||||
statusBefore: order.status,
|
||||
statusAfter: 'PENDING',
|
||||
amount: order.amount,
|
||||
remark: null,
|
||||
});
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -534,6 +834,7 @@ export class DepositService {
|
||||
|
||||
const credit = order.approvedAmount ?? order.amount;
|
||||
const parentAgentId = await this.findPlayerParentAgentId(tx, order.playerId);
|
||||
const approvalCycleKey = order.reviewedAt?.getTime();
|
||||
await this.funds.withdraw({
|
||||
userId: order.playerId,
|
||||
amount: credit,
|
||||
@@ -541,8 +842,9 @@ export class DepositService {
|
||||
remark: `Revoke approved deposit ${order.orderNo}`,
|
||||
referenceId: order.orderNo,
|
||||
transactionType: 'PLAYER_DEPOSIT_REVERSAL',
|
||||
referenceType: 'DEPOSIT',
|
||||
tx,
|
||||
businessKey: `deposit:${order.orderNo}:reopen-reverse`,
|
||||
businessKey: `deposit:${order.orderNo}:reopen-reverse:${approvalCycleKey}`,
|
||||
});
|
||||
if (parentAgentId) {
|
||||
await this.credit.recalculateUsedCredit(parentAgentId, tx);
|
||||
@@ -560,6 +862,18 @@ export class DepositService {
|
||||
},
|
||||
});
|
||||
|
||||
await this.recordDepositAudit(tx, {
|
||||
depositOrderId: orderId,
|
||||
action: 'REVOKED',
|
||||
actorId: operatorId,
|
||||
actorType: 'ADMIN',
|
||||
statusBefore: order.status,
|
||||
statusAfter: 'PENDING',
|
||||
amount: order.amount,
|
||||
approvedAmount: credit,
|
||||
remark: `Revoke approved deposit ${order.orderNo}`,
|
||||
});
|
||||
|
||||
return { success: true, voidedBets: 0 };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ export class FundsPostingService {
|
||||
remark?: string;
|
||||
referenceId?: string;
|
||||
transactionType?: string;
|
||||
referenceType?: string;
|
||||
businessKey?: string;
|
||||
tx?: TxClient;
|
||||
}) {
|
||||
@@ -50,6 +51,7 @@ export class FundsPostingService {
|
||||
command.transactionType ?? 'MANUAL_WITHDRAW',
|
||||
command.tx,
|
||||
command.businessKey,
|
||||
command.referenceType,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ export class WalletService {
|
||||
transactionType = 'MANUAL_WITHDRAW',
|
||||
tx?: TxClient,
|
||||
businessKey?: string,
|
||||
referenceType = 'WITHDRAW',
|
||||
) {
|
||||
const amt = new Decimal(amount);
|
||||
if (amt.lte(0)) throw appBadRequest('AMOUNT_MUST_BE_POSITIVE');
|
||||
@@ -143,7 +144,7 @@ export class WalletService {
|
||||
balanceAfter,
|
||||
frozenBefore: w.frozen_balance,
|
||||
frozenAfter: w.frozen_balance,
|
||||
referenceType: 'WITHDRAW',
|
||||
referenceType,
|
||||
referenceId,
|
||||
businessKey,
|
||||
operatorId,
|
||||
@@ -372,6 +373,7 @@ export class WalletService {
|
||||
'ADMIN_WITHDRAW',
|
||||
'AGENT_WITHDRAW',
|
||||
'PLAYER_DEPOSIT',
|
||||
'PLAYER_DEPOSIT_REVERSAL',
|
||||
].includes(type)
|
||||
) {
|
||||
return type;
|
||||
@@ -395,6 +397,7 @@ export class WalletService {
|
||||
if (WalletService.SYSTEM_REMARKS.has(r)) return false;
|
||||
if (r.startsWith('Cashback batch ')) return false;
|
||||
if (r.startsWith('Deposit order ')) return false;
|
||||
if (r.startsWith('Revoke approved deposit ')) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -418,6 +421,9 @@ export class WalletService {
|
||||
const parts = [depositMethodName?.trim(), tx.referenceId?.trim()].filter(Boolean);
|
||||
return parts.length ? parts.join(' · ') : null;
|
||||
}
|
||||
if (type === 'PLAYER_DEPOSIT_REVERSAL' && tx.referenceId) {
|
||||
return tx.referenceId;
|
||||
}
|
||||
if (this.isCustomRemark(tx.remark)) return tx.remark!.trim();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { BetsService } from '../../betting/bets.service';
|
||||
import type { SettlementService } from '../../settlement/settlement.service';
|
||||
import type { WalletService } from '../../ledger/wallet.service';
|
||||
import type { PrismaService } from '../../../shared/prisma/prisma.service';
|
||||
import { expectEqual, expectThrows, expectTrue } from './smoke-test.helpers';
|
||||
import { expectAppErrorThrows, expectEqual, expectTrue } from './smoke-test.helpers';
|
||||
import type { SmokeTestCaseDef } from './smoke-test.cases';
|
||||
import {
|
||||
BetFlowFixtureIds,
|
||||
@@ -175,7 +175,7 @@ export function createBetFlowProbes(deps: BetFlowProbeDeps): SmokeTestCaseDef[]
|
||||
run: async () => {
|
||||
const fx = await createBetFlowFixture(deps.prisma, deps.wallet, { initialBalance: 50 });
|
||||
try {
|
||||
await expectThrows(
|
||||
await expectAppErrorThrows(
|
||||
'placeSingleBet',
|
||||
async () => {
|
||||
await deps.bets.placeSingleBet(
|
||||
@@ -187,7 +187,7 @@ export function createBetFlowProbes(deps: BetFlowProbeDeps): SmokeTestCaseDef[]
|
||||
`smoke-insuf-${fx.runId}`,
|
||||
);
|
||||
},
|
||||
'Insufficient balance',
|
||||
'INSUFFICIENT_BALANCE',
|
||||
);
|
||||
|
||||
const count = await deps.prisma.bet.count({ where: { userId: fx.playerId } });
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
type ScoreInput,
|
||||
} from '../../settlement/domain/settlement-calculator';
|
||||
import { resolveCashbackRateForBet } from '../cashback/cashback-rate.resolver';
|
||||
import { expectEqual, expectFalse, expectThrows, expectTrue } from './smoke-test.helpers';
|
||||
import { expectAppErrorThrows, expectEqual, expectFalse, expectTrue } from './smoke-test.helpers';
|
||||
import type { SmokeTestCaseMeta } from './smoke-test.types';
|
||||
|
||||
export type SmokeTestRunner = () => void | Promise<void>;
|
||||
@@ -547,7 +547,7 @@ export const SMOKE_TEST_CASES: SmokeTestCaseDef[] = [
|
||||
name: '低于最小投注额拒绝',
|
||||
run: async () => {
|
||||
const service = createBettingLimitsService();
|
||||
await expectThrows(
|
||||
await expectAppErrorThrows(
|
||||
'min stake',
|
||||
() =>
|
||||
service.validateBet({
|
||||
@@ -556,7 +556,7 @@ export const SMOKE_TEST_CASES: SmokeTestCaseDef[] = [
|
||||
stake: 0.5,
|
||||
potentialReturn: new Decimal(1),
|
||||
}),
|
||||
'Minimum stake is 1',
|
||||
'MIN_STAKE',
|
||||
{ stake: 0.5, minStake: 1 },
|
||||
);
|
||||
},
|
||||
@@ -567,7 +567,7 @@ export const SMOKE_TEST_CASES: SmokeTestCaseDef[] = [
|
||||
name: '超过单关最大投注额拒绝',
|
||||
run: async () => {
|
||||
const service = createBettingLimitsService();
|
||||
await expectThrows(
|
||||
await expectAppErrorThrows(
|
||||
'max stake',
|
||||
() =>
|
||||
service.validateBet({
|
||||
@@ -576,7 +576,7 @@ export const SMOKE_TEST_CASES: SmokeTestCaseDef[] = [
|
||||
stake: 60000,
|
||||
potentialReturn: new Decimal(70000),
|
||||
}),
|
||||
'Maximum stake is 50000',
|
||||
'MAX_STAKE',
|
||||
{ stake: 60000, maxStakeSingle: 50000 },
|
||||
);
|
||||
},
|
||||
@@ -587,7 +587,7 @@ export const SMOKE_TEST_CASES: SmokeTestCaseDef[] = [
|
||||
name: '超过最高派彩拒绝',
|
||||
run: async () => {
|
||||
const service = createBettingLimitsService();
|
||||
await expectThrows(
|
||||
await expectAppErrorThrows(
|
||||
'max payout',
|
||||
() =>
|
||||
service.validateBet({
|
||||
@@ -596,7 +596,7 @@ export const SMOKE_TEST_CASES: SmokeTestCaseDef[] = [
|
||||
stake: 100,
|
||||
potentialReturn: new Decimal(600000),
|
||||
}),
|
||||
'Potential return exceeds limit',
|
||||
'MAX_PAYOUT',
|
||||
{ potentialReturn: 600000, maxPayoutSingle: 500000 },
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { HttpException } from '@nestjs/common';
|
||||
import type { ApiErrorCode } from '@thebet365/shared';
|
||||
import { isCodedExceptionResponse } from '../../../shared/common/app-error';
|
||||
|
||||
export type SmokeTestStep = {
|
||||
label: string;
|
||||
input?: string;
|
||||
@@ -62,6 +66,18 @@ export function expectFalse(label: string, condition: boolean, input?: unknown,
|
||||
recordStep(label, input, 'false', condition ? failHint ?? 'true' : 'false', !condition);
|
||||
}
|
||||
|
||||
function resolveErrorCode(err: unknown): string | null {
|
||||
if (err instanceof HttpException) {
|
||||
const res = err.getResponse();
|
||||
if (isCodedExceptionResponse(res)) return res.code;
|
||||
}
|
||||
if (typeof err === 'object' && err !== null && 'response' in err) {
|
||||
const res = (err as { response: unknown }).response;
|
||||
if (isCodedExceptionResponse(res)) return res.code;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function expectThrows(
|
||||
label: string,
|
||||
fn: () => void | Promise<void>,
|
||||
@@ -77,6 +93,21 @@ export async function expectThrows(
|
||||
}
|
||||
}
|
||||
|
||||
export async function expectAppErrorThrows(
|
||||
label: string,
|
||||
fn: () => void | Promise<void>,
|
||||
code: ApiErrorCode,
|
||||
input?: unknown,
|
||||
) {
|
||||
try {
|
||||
await fn();
|
||||
recordStep(label, input, `error code ${code}`, 'no error thrown', false);
|
||||
} catch (err) {
|
||||
const actual = resolveErrorCode(err) ?? (err instanceof Error ? err.message : String(err));
|
||||
recordStep(label, input, `error code ${code}`, actual, actual === code);
|
||||
}
|
||||
}
|
||||
|
||||
export function formatStepsForResult(steps: SmokeTestStep[]): string[] {
|
||||
return steps.map((step, index) => {
|
||||
const lines = [`${index + 1}. ${step.label}`];
|
||||
|
||||
@@ -386,6 +386,7 @@ describe('SettlementService outright winner flow', () => {
|
||||
it('confirmSettlement settles outright bets as WON/LOST using stored winnerTeamId', async () => {
|
||||
const txBetUpdate = jest.fn().mockResolvedValue({});
|
||||
const txBetUpdateMany = jest.fn().mockResolvedValue({ count: 1 });
|
||||
const txMatchUpdate = jest.fn().mockResolvedValue({});
|
||||
transaction.mockImplementation(async (fn: (client: unknown) => Promise<void>) => {
|
||||
await fn({
|
||||
team: { findUnique: teamFindUnique },
|
||||
@@ -404,7 +405,7 @@ describe('SettlementService outright winner flow', () => {
|
||||
update: jest.fn().mockResolvedValue({}),
|
||||
updateMany: jest.fn().mockResolvedValue({ count: 1 }),
|
||||
},
|
||||
match: { update: jest.fn().mockResolvedValue({}) },
|
||||
match: { update: txMatchUpdate },
|
||||
});
|
||||
});
|
||||
settlementBatchFindUnique.mockResolvedValue({
|
||||
@@ -464,6 +465,12 @@ describe('SettlementService outright winner flow', () => {
|
||||
data: expect.objectContaining({ status: 'LOST' }),
|
||||
}),
|
||||
);
|
||||
expect(txMatchUpdate).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
where: { id: matchId },
|
||||
data: { status: 'SETTLED', isHot: false },
|
||||
}),
|
||||
);
|
||||
expect(result).toEqual({ success: true, batchId: batchId.toString() });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1099,7 +1099,7 @@ export class SettlementService {
|
||||
|
||||
await tx.match.update({
|
||||
where: { id: currentBatch.matchId },
|
||||
data: { status: 'SETTLED' },
|
||||
data: { status: 'SETTLED', isHot: false },
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
147
apps/api/src/infrastructure/database/run-settlement-audit.ts
Normal file
147
apps/api/src/infrastructure/database/run-settlement-audit.ts
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* Prints concrete settlement / parlay / cashback amounts used in smoke & unit tests.
|
||||
* Run: pnpm --filter @thebet365/api audit:settlement
|
||||
*/
|
||||
import { Decimal } from '@prisma/client/runtime/library';
|
||||
import {
|
||||
calculateParlayPayout,
|
||||
calculatePayout,
|
||||
} from '../../domains/settlement/domain/settlement-calculator';
|
||||
import { resolveCashbackRateForBet } from '../../domains/operations/cashback/cashback-rate.resolver';
|
||||
|
||||
type Row = { scenario: string; stake: number; detail: string; payout: string; netProfit: string };
|
||||
|
||||
function fmt(n: number | string | Decimal) {
|
||||
return new Decimal(n).toFixed(2);
|
||||
}
|
||||
|
||||
function single(
|
||||
scenario: string,
|
||||
stake: number,
|
||||
odds: number,
|
||||
result: Parameters<typeof calculatePayout>[2],
|
||||
): Row {
|
||||
const payout = calculatePayout(stake, odds, result);
|
||||
return {
|
||||
scenario,
|
||||
stake,
|
||||
detail: `odds ${odds}, ${result}`,
|
||||
payout: fmt(payout),
|
||||
netProfit: fmt(payout.sub(stake)),
|
||||
};
|
||||
}
|
||||
|
||||
function parlay(
|
||||
scenario: string,
|
||||
stake: number,
|
||||
legs: Array<{ odds: number; result: Parameters<typeof calculatePayout>[2] }>,
|
||||
): Row {
|
||||
const { betResult, payout, effectiveOdds } = calculateParlayPayout(stake, legs);
|
||||
const legDesc = legs.map((l) => `${l.odds}@${l.result}`).join(' × ');
|
||||
return {
|
||||
scenario,
|
||||
stake,
|
||||
detail: `${betResult} | ${legDesc} | effOdds ${effectiveOdds.toFixed(4)}`,
|
||||
payout: fmt(payout),
|
||||
netProfit: fmt(payout.sub(stake)),
|
||||
};
|
||||
}
|
||||
|
||||
function cashbackExample(stake: number, rate: string, label: string): Row {
|
||||
const r = new Decimal(rate);
|
||||
const amount = new Decimal(stake).mul(r);
|
||||
return {
|
||||
scenario: label,
|
||||
stake,
|
||||
detail: `rate ${rate} → stake × rate`,
|
||||
payout: fmt(amount),
|
||||
netProfit: fmt(amount),
|
||||
};
|
||||
}
|
||||
|
||||
const rows: Row[] = [
|
||||
single('单关 1X2 全赢 (BF001)', 100, 2.0, 'WIN'),
|
||||
single('单关 1X2 全输 (BF002)', 100, 2.0, 'LOSE'),
|
||||
single('让球 -1 全赢 (S009)', 100, 1.85, 'WIN'),
|
||||
single('让球 -1 走水 (S010)', 100, 1.85, 'PUSH'),
|
||||
single('让球 -0.25 半输 (S011)', 100, 1.85, 'HALF_LOSE'),
|
||||
single('半赢派彩 (S011B)', 100, 1.85, 'HALF_WIN'),
|
||||
single('让球 -0.5 全输 (S012)', 100, 1.85, 'LOSE'),
|
||||
single('大小 小球赢 (S015)', 100, 1.95, 'WIN'),
|
||||
parlay('串关全中 (S016)', 100, [
|
||||
{ odds: 1.8, result: 'WIN' },
|
||||
{ odds: 2.0, result: 'WIN' },
|
||||
]),
|
||||
parlay('串关一关输 (S017)', 100, [
|
||||
{ odds: 1.8, result: 'WIN' },
|
||||
{ odds: 2.0, result: 'LOSE' },
|
||||
]),
|
||||
parlay('串关一关走水 (S018)', 100, [
|
||||
{ odds: 1.8, result: 'WIN' },
|
||||
{ odds: 2.0, result: 'PUSH' },
|
||||
{ odds: 1.9, result: 'WIN' },
|
||||
]),
|
||||
parlay('串关全走水/作废 (S019)', 100, [
|
||||
{ odds: 1.8, result: 'PUSH' },
|
||||
{ odds: 2.0, result: 'VOID' },
|
||||
]),
|
||||
];
|
||||
|
||||
const cbRates = [
|
||||
{
|
||||
label: '返水 玩家专属 (CB001)',
|
||||
rate: resolveCashbackRateForBet({
|
||||
userId: BigInt(100),
|
||||
agentId: BigInt(200),
|
||||
marketTypes: ['FT_1X2'],
|
||||
agentDefaultRate: new Decimal('0.01'),
|
||||
rules: [{ targetType: 'USER', targetId: BigInt(100), rate: new Decimal('0.03'), marketType: null }],
|
||||
}).toString(),
|
||||
},
|
||||
{
|
||||
label: '返水 玩法专属 (CB002)',
|
||||
rate: resolveCashbackRateForBet({
|
||||
userId: BigInt(100),
|
||||
agentId: BigInt(200),
|
||||
marketTypes: ['FT_HANDICAP'],
|
||||
agentDefaultRate: new Decimal('0.01'),
|
||||
rules: [
|
||||
{ targetType: 'GLOBAL', targetId: null, rate: new Decimal('0.005'), marketType: 'FT_HANDICAP' },
|
||||
],
|
||||
}).toString(),
|
||||
},
|
||||
{
|
||||
label: '返水 代理默认 (CB003)',
|
||||
rate: resolveCashbackRateForBet({
|
||||
userId: BigInt(100),
|
||||
agentId: BigInt(200),
|
||||
marketTypes: ['FT_1X2'],
|
||||
agentDefaultRate: new Decimal('0.02'),
|
||||
rules: [],
|
||||
}).toString(),
|
||||
},
|
||||
];
|
||||
|
||||
console.log('\n=== 结算派彩金额(stake=100 unless noted)===\n');
|
||||
console.table(rows);
|
||||
|
||||
console.log('\n=== 返水比例 → 到账金额(已结算注单,公式:stake × rate)===\n');
|
||||
for (const { label, rate } of cbRates) {
|
||||
console.log(`${label}: rate=${rate}`);
|
||||
console.table([
|
||||
cashbackExample(100, rate, 'stake 100'),
|
||||
cashbackExample(500, rate, 'stake 500'),
|
||||
cashbackExample(1000, rate, 'stake 1000'),
|
||||
]);
|
||||
}
|
||||
|
||||
console.log('\n=== 端到端钱包(BF001–BF005,smoke bet-flow)===\n');
|
||||
console.table([
|
||||
{ case: 'BF001', flow: '单关赢 100@2.0, 2-1', wallet: '1000 → 900 avail + 100 frozen → 1100 avail', actualReturn: '200' },
|
||||
{ case: 'BF002', flow: '单关输 和局+2-1', wallet: '1000 → 900 avail', actualReturn: '0' },
|
||||
{ case: 'BF003', flow: '幂等 50 注', wallet: '500 → 450 avail + 50 frozen', actualReturn: '—' },
|
||||
{ case: 'BF004', flow: '余额不足', wallet: '50 不变', actualReturn: '—' },
|
||||
{ case: 'BF005', flow: '代理额度 玩家输100', wallet: '玩家 900', agentUsedCredit: '1000 → 900' },
|
||||
]);
|
||||
|
||||
console.log('\n注:dev seed 下 agent1 cashbackRate 默认为 0;需后台配置规则或代理默认比例后才会产生返水批次。\n');
|
||||
30
apps/api/src/infrastructure/database/run-smoke-cli.ts
Normal file
30
apps/api/src/infrastructure/database/run-smoke-cli.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from '../../app.module';
|
||||
import { SmokeTestService } from '../../domains/operations/smoke-tests/smoke-test.service';
|
||||
|
||||
async function main() {
|
||||
const app = await NestFactory.createApplicationContext(AppModule, {
|
||||
logger: ['error', 'warn'],
|
||||
});
|
||||
try {
|
||||
const smoke = app.get(SmokeTestService);
|
||||
smoke.assertAllowed();
|
||||
const summary = await smoke.run();
|
||||
console.log(
|
||||
`Smoke: pass=${summary.passed} fail=${summary.failed} skip=${summary.skipped} total=${summary.total} (${summary.durationMs}ms)`,
|
||||
);
|
||||
if (summary.failed > 0) {
|
||||
for (const r of summary.results.filter((x) => x.status === 'FAIL')) {
|
||||
console.error(`FAIL ${r.id} ${r.name}: ${r.error ?? r.message ?? ''}`);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
} finally {
|
||||
await app.close();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -18,10 +18,28 @@ export async function seedDemoMarkets(prisma: PrismaClient, matchId: bigint) {
|
||||
cfg.marketType.includes('CORRECT_SCORE') &&
|
||||
exists._count.selections < cfg.selectionTemplate.length;
|
||||
if (needRefresh) {
|
||||
await prisma.market.delete({ where: { id: exists.id } });
|
||||
} else {
|
||||
continue;
|
||||
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: {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useAuthStore } from '../stores/auth';
|
||||
import { formatMoney, parseAmount } from '../utils/localeDisplay';
|
||||
import BetSuccessOverlay from './BetSuccessOverlay.vue';
|
||||
import api from '../api';
|
||||
import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
|
||||
const props = defineProps<{ modelValue: boolean }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [boolean] }>();
|
||||
@@ -19,6 +20,7 @@ const emit = defineEmits<{ 'update:modelValue': [boolean] }>();
|
||||
const { t, locale } = useI18n();
|
||||
const slip = useBetSlipStore();
|
||||
const auth = useAuthStore();
|
||||
const { refreshProfile } = usePlayerProfile();
|
||||
const show = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v),
|
||||
@@ -261,7 +263,7 @@ async function placeBet() {
|
||||
}
|
||||
success.value = t('bet.place_success');
|
||||
showSuccess.value = true;
|
||||
await loadBalance();
|
||||
await Promise.all([loadBalance(), refreshProfile()]);
|
||||
setTimeout(() => {
|
||||
if (showSuccess.value) onSuccessDone();
|
||||
}, 2200);
|
||||
|
||||
@@ -6,7 +6,7 @@ import { formatMoney } from '../utils/localeDisplay';
|
||||
import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
|
||||
const { locale, t } = useI18n();
|
||||
const { profileRaw } = usePlayerProfile();
|
||||
const { profileRaw, refreshProfile } = usePlayerProfile();
|
||||
const router = useRouter();
|
||||
const open = ref(false);
|
||||
const root = ref<HTMLElement | null>(null);
|
||||
@@ -38,7 +38,9 @@ const total = computed(() =>
|
||||
);
|
||||
|
||||
function toggle() {
|
||||
open.value = !open.value;
|
||||
const next = !open.value;
|
||||
open.value = next;
|
||||
if (next) void refreshProfile();
|
||||
}
|
||||
|
||||
function close() {
|
||||
|
||||
@@ -64,6 +64,8 @@ const openCount = computed(() => props.matches.filter(m => m.matchPhase === 'ope
|
||||
:src="leagueLogoUrl || saishiImg"
|
||||
alt=""
|
||||
class="league-saishi"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</button>
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ const liveScoreText = computed(() => {
|
||||
class="team-flag"
|
||||
:class="{ 'flag-logo': homeIsLogo }"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -108,6 +110,8 @@ const liveScoreText = computed(() => {
|
||||
class="team-flag"
|
||||
:class="{ 'flag-logo': awayIsLogo }"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import api from '../../api';
|
||||
import { usePlayerProfile } from '../../composables/usePlayerProfile';
|
||||
import { formatMoney, parseAmount } from '../../utils/localeDisplay';
|
||||
import { teamFlagUrl } from '../../utils/teamFlag';
|
||||
import BetSuccessOverlay from '../BetSuccessOverlay.vue';
|
||||
@@ -23,6 +24,7 @@ const props = defineProps<{
|
||||
const emit = defineEmits<{ close: [] }>();
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { refreshProfile } = usePlayerProfile();
|
||||
|
||||
const step = ref<'form' | 'success'>('form');
|
||||
const stake = ref(1);
|
||||
@@ -105,6 +107,7 @@ async function submit() {
|
||||
balance.value = successBalance.value;
|
||||
step.value = 'success';
|
||||
showSuccess.value = true;
|
||||
void refreshProfile();
|
||||
} catch (e: unknown) {
|
||||
error.value =
|
||||
(e as { response?: { data?: { error?: string } } })?.response?.data?.error ||
|
||||
|
||||
@@ -23,6 +23,7 @@ const profileRaw = ref<ProfileData | null>(null);
|
||||
const loading = ref(false);
|
||||
let loadPromise: Promise<void> | null = null;
|
||||
let assigningDefault = false;
|
||||
let visibilityBound = false;
|
||||
|
||||
function profileSeed(profile: ProfileData | null): string {
|
||||
if (!profile) return '';
|
||||
@@ -111,6 +112,20 @@ async function loadProfile(force = false) {
|
||||
return loadPromise;
|
||||
}
|
||||
|
||||
function refreshProfile() {
|
||||
return loadProfile(true);
|
||||
}
|
||||
|
||||
function bindProfileVisibilityRefresh() {
|
||||
if (visibilityBound || typeof document === 'undefined') return;
|
||||
visibilityBound = true;
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'visible' && profileRaw.value) {
|
||||
void loadProfile(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const avatarKey = computed(() => {
|
||||
const saved = profileRaw.value?.preferences?.avatarKey;
|
||||
if (saved && isValidAvatarKey(saved)) return saved;
|
||||
@@ -138,6 +153,8 @@ export function usePlayerProfile() {
|
||||
avatarKey,
|
||||
avatarUrl,
|
||||
loadProfile,
|
||||
refreshProfile,
|
||||
bindProfileVisibilityRefresh,
|
||||
setAvatarKey,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -138,6 +138,7 @@ export default {
|
||||
tx_admin_deposit: 'Admin top-up',
|
||||
tx_agent_deposit: 'Agent top-up',
|
||||
tx_player_deposit: 'Self deposit',
|
||||
tx_player_deposit_reversal: 'Deposit reversal',
|
||||
tx_withdraw: 'Withdrawal',
|
||||
tx_admin_withdraw: 'Admin withdraw',
|
||||
tx_agent_withdraw: 'Agent withdraw',
|
||||
@@ -152,7 +153,8 @@ export default {
|
||||
tx_cashback: 'Cashback credit',
|
||||
tx_resettle: 'Resettlement',
|
||||
summary_bet: 'Bet {betNo}',
|
||||
summary_opening_bonus: 'Opening bonus',
|
||||
remark_deposit_revoke: 'Revoked approved deposit {orderNo}',
|
||||
remark_deposit_revoke_generic: 'Revoked approved deposit',
|
||||
stats_income: 'Income',
|
||||
stats_expense: 'Expense',
|
||||
stats_net: 'Net',
|
||||
@@ -221,6 +223,25 @@ export default {
|
||||
apply_time: 'Apply time',
|
||||
review_time: 'Review time',
|
||||
remark: 'Remark',
|
||||
audit_title: 'Review history',
|
||||
audit_submitted: 'Submitted',
|
||||
audit_approved: 'Approved',
|
||||
audit_rejected: 'Rejected',
|
||||
audit_revoked: 'Approval revoked',
|
||||
audit_reopened: 'Reopened for review',
|
||||
audit_by_player: 'Player',
|
||||
audit_by_admin: 'Platform review',
|
||||
audit_amount: 'Amount',
|
||||
audit_credited: 'Credited amount',
|
||||
audit_remark_label: 'Note',
|
||||
audit_summary: 'Review history · {count} steps',
|
||||
audit_toggle_show: 'Show review history',
|
||||
audit_toggle_hide: 'Hide review history',
|
||||
view_detail: 'View details',
|
||||
order_detail: 'Order details',
|
||||
reapply: 'Re-apply',
|
||||
reapply_hint: 'You are resubmitting this order. Transfer again and upload a new screenshot.',
|
||||
back_to_history: 'Back to history',
|
||||
},
|
||||
cashback: {
|
||||
title: 'Cashback Details',
|
||||
|
||||
@@ -144,6 +144,7 @@ export default {
|
||||
tx_admin_deposit: 'Tambah baki admin',
|
||||
tx_agent_deposit: 'Tambah baki ejen',
|
||||
tx_player_deposit: 'Deposit sendiri',
|
||||
tx_player_deposit_reversal: 'Pembalikan deposit',
|
||||
tx_withdraw: 'Pengeluaran',
|
||||
tx_admin_withdraw: 'Pengeluaran admin',
|
||||
tx_agent_withdraw: 'Pengeluaran ejen',
|
||||
@@ -158,7 +159,8 @@ export default {
|
||||
tx_cashback: 'Kredit rebat',
|
||||
tx_resettle: 'Penyelesaian Semula',
|
||||
summary_bet: 'Pertaruhan {betNo}',
|
||||
summary_opening_bonus: 'Bonus pembukaan',
|
||||
remark_deposit_revoke: 'Deposit diluluskan dibatalkan {orderNo}',
|
||||
remark_deposit_revoke_generic: 'Deposit diluluskan dibatalkan',
|
||||
stats_income: 'Pendapatan',
|
||||
stats_expense: 'Perbelanjaan',
|
||||
stats_net: 'Bersih',
|
||||
@@ -227,6 +229,25 @@ export default {
|
||||
apply_time: 'Masa permohonan',
|
||||
review_time: 'Masa semakan',
|
||||
remark: 'Catatan',
|
||||
audit_title: 'Sejarah semakan',
|
||||
audit_submitted: 'Dihantar',
|
||||
audit_approved: 'Diluluskan',
|
||||
audit_rejected: 'Ditolak',
|
||||
audit_revoked: 'Kelulusan dibatalkan',
|
||||
audit_reopened: 'Dibuka semula untuk semakan',
|
||||
audit_by_player: 'Pemain',
|
||||
audit_by_admin: 'Semakan platform',
|
||||
audit_amount: 'Jumlah',
|
||||
audit_credited: 'Jumlah dikreditkan',
|
||||
audit_remark_label: 'Catatan',
|
||||
audit_summary: 'Sejarah semakan · {count} langkah',
|
||||
audit_toggle_show: 'Lihat sejarah semakan',
|
||||
audit_toggle_hide: 'Sembunyikan sejarah semakan',
|
||||
view_detail: 'Lihat butiran',
|
||||
order_detail: 'Butiran pesanan',
|
||||
reapply: 'Mohon semula',
|
||||
reapply_hint: 'Anda menghantar semula pesanan ini. Buat pindahan baharu dan muat naik tangkapan skrin baharu.',
|
||||
back_to_history: 'Kembali ke sejarah',
|
||||
},
|
||||
cashback: {
|
||||
title: 'Butiran Rebat',
|
||||
|
||||
@@ -138,6 +138,7 @@ export default {
|
||||
tx_admin_deposit: '管理员上分',
|
||||
tx_agent_deposit: '代理上分',
|
||||
tx_player_deposit: '自助充值',
|
||||
tx_player_deposit_reversal: '充值撤销',
|
||||
tx_withdraw: '人工提款',
|
||||
tx_admin_withdraw: '管理员下分',
|
||||
tx_agent_withdraw: '代理下分',
|
||||
@@ -152,7 +153,8 @@ export default {
|
||||
tx_cashback: '返水入账',
|
||||
tx_resettle: '重新结算',
|
||||
summary_bet: '注单 {betNo}',
|
||||
summary_opening_bonus: '开户赠金',
|
||||
remark_deposit_revoke: '撤销已通过充值 {orderNo}',
|
||||
remark_deposit_revoke_generic: '撤销已通过充值',
|
||||
stats_income: '收入',
|
||||
stats_expense: '支出',
|
||||
stats_net: '净额',
|
||||
@@ -221,6 +223,25 @@ export default {
|
||||
apply_time: '申请时间',
|
||||
review_time: '审核时间',
|
||||
remark: '审核备注',
|
||||
audit_title: '审核记录',
|
||||
audit_submitted: '提交申请',
|
||||
audit_approved: '审核通过',
|
||||
audit_rejected: '审核拒绝',
|
||||
audit_revoked: '撤销审核',
|
||||
audit_reopened: '重新审核',
|
||||
audit_by_player: '玩家提交',
|
||||
audit_by_admin: '平台审核',
|
||||
audit_amount: '金额',
|
||||
audit_credited: '入账金额',
|
||||
audit_remark_label: '备注',
|
||||
audit_summary: '审核记录 · {count} 步',
|
||||
audit_toggle_show: '查看审核记录',
|
||||
audit_toggle_hide: '收起审核记录',
|
||||
view_detail: '查看详情',
|
||||
order_detail: '订单详情',
|
||||
reapply: '重新申请',
|
||||
reapply_hint: '将在原订单上重新提交,请重新转账并上传新的截图。',
|
||||
back_to_history: '返回充值记录',
|
||||
},
|
||||
cashback: {
|
||||
title: '返水明细',
|
||||
|
||||
@@ -52,7 +52,7 @@ const showBottomNav = computed(() => {
|
||||
return false;
|
||||
});
|
||||
const { announcements, load: loadPlayerHome } = usePlayerHome();
|
||||
const { loadProfile } = usePlayerProfile();
|
||||
const { loadProfile, refreshProfile, bindProfileVisibilityRefresh } = usePlayerProfile();
|
||||
const mainRef = ref<HTMLElement | null>(null);
|
||||
const tabScrollTops = new Map<string, number>();
|
||||
const customerServiceOpen = ref(false);
|
||||
@@ -71,8 +71,11 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
const balanceRefreshPaths = ['/profile', '/wallet', '/bets'];
|
||||
|
||||
onMounted(() => {
|
||||
if (auth.user?.locale) void initFromUser(auth.user.locale);
|
||||
bindProfileVisibilityRefresh();
|
||||
});
|
||||
|
||||
watch(
|
||||
@@ -87,6 +90,16 @@ watch(
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => route.path,
|
||||
(path) => {
|
||||
if (!auth.token) return;
|
||||
if (balanceRefreshPaths.some((p) => path === p || path.startsWith(`${p}/`))) {
|
||||
void refreshProfile();
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
26
apps/player/src/utils/cashback.ts
Normal file
26
apps/player/src/utils/cashback.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export type CashbackRecord = {
|
||||
id: string;
|
||||
batchNo: string;
|
||||
periodStart: string;
|
||||
periodEnd: string;
|
||||
confirmedAt: string | null;
|
||||
effectiveStake: string;
|
||||
betCount: number;
|
||||
rate: string;
|
||||
amount: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
/** API returns a plain array; older clients may expect { items }. */
|
||||
export function parseCashbackApiData(data: unknown): CashbackRecord[] {
|
||||
if (Array.isArray(data)) return data as CashbackRecord[];
|
||||
if (data && typeof data === 'object' && 'items' in data) {
|
||||
const items = (data as { items?: unknown }).items;
|
||||
return Array.isArray(items) ? (items as CashbackRecord[]) : [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
export function sumCashbackAmount(rows: Array<{ amount: string }>): number {
|
||||
return rows.reduce((sum, row) => sum + Math.abs(parseFloat(row.amount) || 0), 0);
|
||||
}
|
||||
112
apps/player/src/utils/depositAuditDisplay.ts
Normal file
112
apps/player/src/utils/depositAuditDisplay.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
/** Player-facing deposit audit log remark formatting — strips internal order codes & API templates. */
|
||||
|
||||
const ORDER_NO_SUFFIX = /\s+[A-Z0-9]{10,}\s*$/i;
|
||||
|
||||
const INTERNAL_REMARK_EXACT = [
|
||||
/^Revoke approved deposit\s*[A-Z0-9]*\s*$/i,
|
||||
/^撤销已通过充值\s*[A-Z0-9]*\s*$/,
|
||||
/^Deposit order\s+[A-Z0-9]+\s*$/i,
|
||||
];
|
||||
|
||||
export type DepositAuditLogLike = {
|
||||
action: string;
|
||||
remark: string | null;
|
||||
};
|
||||
|
||||
export type DepositAuditRemarkDisplay =
|
||||
| { kind: 'reject'; text: string }
|
||||
| { kind: 'note'; text: string }
|
||||
| null;
|
||||
|
||||
function normalizeRemark(value: string | null | undefined) {
|
||||
return value?.trim() ?? '';
|
||||
}
|
||||
|
||||
/** True when remark is empty or only internal/system text — hide from player UI. */
|
||||
export function isHiddenDepositAuditRemark(log: DepositAuditLogLike): boolean {
|
||||
const remark = normalizeRemark(log.remark);
|
||||
if (!remark) return true;
|
||||
|
||||
if (log.action === 'REVOKED') {
|
||||
return INTERNAL_REMARK_EXACT.some((pattern) => pattern.test(remark));
|
||||
}
|
||||
|
||||
return INTERNAL_REMARK_EXACT.some((pattern) => pattern.test(remark));
|
||||
}
|
||||
|
||||
function sanitizePlayerRemark(raw: string): string | null {
|
||||
let text = raw.trim();
|
||||
if (!text) return null;
|
||||
|
||||
if (/^Revoke approved deposit/i.test(text)) {
|
||||
return null;
|
||||
}
|
||||
if (/^撤销已通过充值/.test(text)) {
|
||||
return null;
|
||||
}
|
||||
if (/^Deposit order\s+/i.test(text)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
text = text.replace(ORDER_NO_SUFFIX, '').trim();
|
||||
return text || null;
|
||||
}
|
||||
|
||||
/** Format remark for timeline; returns null when nothing meaningful to show. */
|
||||
export function formatDepositAuditRemark(
|
||||
log: DepositAuditLogLike,
|
||||
t: (key: string, params?: Record<string, unknown>) => string,
|
||||
): DepositAuditRemarkDisplay {
|
||||
const remark = normalizeRemark(log.remark);
|
||||
if (!remark) return null;
|
||||
|
||||
if (log.action === 'REVOKED' && isHiddenDepositAuditRemark(log)) {
|
||||
return { kind: 'note', text: t('wallet.remark_deposit_revoke_generic') };
|
||||
}
|
||||
|
||||
const sanitized = sanitizePlayerRemark(remark);
|
||||
if (!sanitized) return null;
|
||||
|
||||
if (log.action === 'REJECTED') {
|
||||
return { kind: 'reject', text: sanitized };
|
||||
}
|
||||
|
||||
return { kind: 'note', text: sanitized };
|
||||
}
|
||||
|
||||
/** Skip reject remark in timeline when card-level reject reason already shows the same text. */
|
||||
export function shouldShowAuditRejectInTimeline(
|
||||
log: DepositAuditLogLike,
|
||||
orderRejectReason: string | null | undefined,
|
||||
): boolean {
|
||||
if (log.action !== 'REJECTED') return true;
|
||||
const remark = normalizeRemark(log.remark);
|
||||
if (!remark) return false;
|
||||
const cardReason = normalizeRemark(orderRejectReason);
|
||||
return remark !== cardReason;
|
||||
}
|
||||
|
||||
export function auditActionTone(action: string): 'submitted' | 'approved' | 'rejected' | 'revoked' | 'reopened' | 'default' {
|
||||
switch (action.toUpperCase()) {
|
||||
case 'SUBMITTED':
|
||||
return 'submitted';
|
||||
case 'APPROVED':
|
||||
return 'approved';
|
||||
case 'REJECTED':
|
||||
return 'rejected';
|
||||
case 'REVOKED':
|
||||
return 'revoked';
|
||||
case 'REOPENED':
|
||||
return 'reopened';
|
||||
default:
|
||||
return 'default';
|
||||
}
|
||||
}
|
||||
|
||||
/** Secondary actor line — only when it adds meaning beyond the action title. */
|
||||
export function auditActorSecondary(log: { action: string; actorType: string }, t: (key: string) => string): string | null {
|
||||
if (log.actorType === 'PLAYER' && (log.action === 'SUBMITTED' || log.action === 'REOPENED')) {
|
||||
return t('recharge.audit_by_player');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -22,6 +22,7 @@ export const TX_KEY_MAP: Record<string, string> = {
|
||||
DEPOSIT: 'wallet.tx_deposit',
|
||||
WITHDRAW: 'wallet.tx_withdraw',
|
||||
PLAYER_DEPOSIT: 'wallet.tx_player_deposit',
|
||||
PLAYER_DEPOSIT_REVERSAL: 'wallet.tx_player_deposit_reversal',
|
||||
};
|
||||
|
||||
export function txTypeKey(type: string): string {
|
||||
@@ -53,11 +54,29 @@ export function txSummaryLabel(
|
||||
|
||||
export function isDepositType(type: string): boolean {
|
||||
const t = type.toUpperCase();
|
||||
return (t.includes('DEPOSIT') || t === 'CASHBACK_DEPOSIT') && !isCashbackType(type);
|
||||
return (t.includes('DEPOSIT') || t === 'CASHBACK_DEPOSIT') && !isCashbackType(type) && t !== 'PLAYER_DEPOSIT_REVERSAL';
|
||||
}
|
||||
|
||||
export function isDepositReversalType(type: string): boolean {
|
||||
return type.toUpperCase() === 'PLAYER_DEPOSIT_REVERSAL';
|
||||
}
|
||||
|
||||
export function txRemarkLabel(
|
||||
tx: { transactionType: string; remark?: string | null; referenceId?: string | null },
|
||||
t: (key: string, params?: Record<string, unknown>) => string,
|
||||
): string {
|
||||
const type = tx.transactionType.toUpperCase();
|
||||
const remark = tx.remark?.trim() ?? '';
|
||||
if (type === 'PLAYER_DEPOSIT_REVERSAL') {
|
||||
return t('wallet.remark_deposit_revoke_generic');
|
||||
}
|
||||
return remark;
|
||||
}
|
||||
|
||||
export function isWithdrawType(type: string): boolean {
|
||||
return type.toUpperCase().includes('WITHDRAW');
|
||||
const t = type.toUpperCase();
|
||||
if (t === 'PLAYER_DEPOSIT_REVERSAL') return false;
|
||||
return t.includes('WITHDRAW');
|
||||
}
|
||||
|
||||
export function isBetType(type: string): boolean {
|
||||
|
||||
@@ -8,6 +8,8 @@ import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePullToRefresh } from '../composables/usePullToRefresh';
|
||||
import { useOnLocaleChange } from '../composables/useOnLocaleChange';
|
||||
|
||||
import { parseCashbackApiData, type CashbackRecord } from '../utils/cashback';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
@@ -17,19 +19,6 @@ const highlightBatchNo = computed(() => {
|
||||
return typeof q === 'string' ? q.trim() : '';
|
||||
});
|
||||
|
||||
type CashbackRecord = {
|
||||
id: string;
|
||||
batchNo: string;
|
||||
periodStart: string;
|
||||
periodEnd: string;
|
||||
confirmedAt: string | null;
|
||||
effectiveStake: string;
|
||||
betCount: number;
|
||||
rate: string;
|
||||
amount: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
const items = ref<CashbackRecord[]>([]);
|
||||
const loading = ref(false);
|
||||
const initialLoading = ref(true);
|
||||
@@ -72,8 +61,7 @@ async function fetchRecords(p = 1) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } = await api.get('/player/cashbacks', { params: { page: p } });
|
||||
const result = data.data ?? { items: [], total: 0, pageSize: 20 };
|
||||
const newItems = result.items ?? [];
|
||||
const newItems = parseCashbackApiData(data.data);
|
||||
|
||||
if (p === 1) {
|
||||
items.value = newItems;
|
||||
@@ -81,7 +69,7 @@ async function fetchRecords(p = 1) {
|
||||
items.value = [...items.value, ...newItems];
|
||||
}
|
||||
|
||||
const pageSize = result.pageSize ?? 20;
|
||||
const pageSize = 20;
|
||||
hasMore.value = newItems.length >= pageSize;
|
||||
page.value = p;
|
||||
} catch {
|
||||
|
||||
@@ -68,7 +68,10 @@ const filterNow = ref(new Date());
|
||||
const { summaryMatches, summaryLoading, loadSummary } = usePlayerMatches();
|
||||
const matches = summaryMatches;
|
||||
const loading = summaryLoading;
|
||||
const expandedLeagues = ref<Set<string>>(new Set());
|
||||
const expandedLeagues = ref<Record<TimeTab, Set<string>>>({
|
||||
today: new Set(),
|
||||
early: new Set(),
|
||||
});
|
||||
|
||||
async function loadMatches() {
|
||||
filterNow.value = new Date();
|
||||
@@ -86,23 +89,23 @@ const pullIndicatorStyle = () => ({
|
||||
opacity: Math.min(pullDistance.value / 48, 1),
|
||||
});
|
||||
|
||||
const filteredMatches = computed(() => {
|
||||
function filterMatchesForTab(tab: TimeTab) {
|
||||
if (mainTab.value !== 'matches') return [];
|
||||
const now = filterNow.value;
|
||||
return matches.value.filter((m) => {
|
||||
const timeMatch =
|
||||
timeTab.value === 'today'
|
||||
tab === 'today'
|
||||
? isInTodayMatchWindow(m.startTime, now)
|
||||
: isAfterTodayMatchWindow(m.startTime, now);
|
||||
if (!timeMatch) return false;
|
||||
if (!showAll.value && m.matchPhase !== 'open' && m.matchPhase !== undefined) return false;
|
||||
return true;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const leagueGroups = computed<LeagueGroup[]>(() => {
|
||||
function buildLeagueGroups(source: Match[]): LeagueGroup[] {
|
||||
const map = new Map<string, LeagueGroup>();
|
||||
for (const m of filteredMatches.value) {
|
||||
for (const m of source) {
|
||||
const id = m.leagueId ?? m.leagueName;
|
||||
if (!map.has(id)) {
|
||||
map.set(id, {
|
||||
@@ -127,29 +130,34 @@ const leagueGroups = computed<LeagueGroup[]>(() => {
|
||||
(a.matches[0]?.displayOrder ?? 0) - (b.matches[0]?.displayOrder ?? 0) ||
|
||||
a.leagueName.localeCompare(b.leagueName),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
watch(leagueGroups, (groups) => {
|
||||
const ids = new Set(expandedLeagues.value);
|
||||
const todayLeagueGroups = computed(() => buildLeagueGroups(filterMatchesForTab('today')));
|
||||
const earlyLeagueGroups = computed(() => buildLeagueGroups(filterMatchesForTab('early')));
|
||||
|
||||
function syncExpandedLeagues(groups: LeagueGroup[], tab: TimeTab) {
|
||||
const current = expandedLeagues.value[tab];
|
||||
const ids = new Set(current);
|
||||
for (const id of [...ids]) {
|
||||
if (!groups.some((g) => g.leagueId === id)) ids.delete(id);
|
||||
}
|
||||
if (ids.size !== expandedLeagues.value.size) expandedLeagues.value = ids;
|
||||
// 默认只展开第一个联赛,减少首屏 DOM
|
||||
if (groups.length > 0 && expandedLeagues.value.size === 0) {
|
||||
expandedLeagues.value = new Set([groups[0].leagueId]);
|
||||
if (groups.length > 0 && ids.size === 0) {
|
||||
ids.add(groups[0].leagueId);
|
||||
}
|
||||
if (ids.size !== current.size || [...ids].some((id) => !current.has(id))) {
|
||||
expandedLeagues.value = { ...expandedLeagues.value, [tab]: ids };
|
||||
}
|
||||
});
|
||||
|
||||
function isLeagueExpanded(leagueId: string) {
|
||||
return expandedLeagues.value.has(leagueId);
|
||||
}
|
||||
|
||||
watch(todayLeagueGroups, (groups) => syncExpandedLeagues(groups, 'today'));
|
||||
watch(earlyLeagueGroups, (groups) => syncExpandedLeagues(groups, 'early'));
|
||||
|
||||
function toggleLeague(leagueId: string) {
|
||||
const next = new Set(expandedLeagues.value);
|
||||
const tab = timeTab.value;
|
||||
const next = new Set(expandedLeagues.value[tab]);
|
||||
if (next.has(leagueId)) next.delete(leagueId);
|
||||
else next.add(leagueId);
|
||||
expandedLeagues.value = next;
|
||||
expandedLeagues.value = { ...expandedLeagues.value, [tab]: next };
|
||||
}
|
||||
|
||||
function selectMainTab(tab: MainTab) {
|
||||
@@ -232,24 +240,47 @@ function goMatch(id: string) {
|
||||
<div v-if="loading" class="state">
|
||||
<GoldSpinner :size="36" />
|
||||
</div>
|
||||
<div v-else-if="leagueGroups.length" class="league-list">
|
||||
<LeagueAccordionItem
|
||||
v-for="group in leagueGroups"
|
||||
:key="group.leagueId"
|
||||
:league-id="group.leagueId"
|
||||
:league-name="group.leagueName"
|
||||
:league-logo-url="group.leagueLogoUrl"
|
||||
:matches="group.matches"
|
||||
:expanded="isLeagueExpanded(group.leagueId)"
|
||||
@toggle="toggleLeague(group.leagueId)"
|
||||
@bet="goMatch"
|
||||
/>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div v-show="timeTab === 'today'">
|
||||
<div v-if="todayLeagueGroups.length" class="league-list">
|
||||
<LeagueAccordionItem
|
||||
v-for="group in todayLeagueGroups"
|
||||
:key="`today-${group.leagueId}`"
|
||||
:league-id="group.leagueId"
|
||||
:league-name="group.leagueName"
|
||||
:league-logo-url="group.leagueLogoUrl"
|
||||
:matches="group.matches"
|
||||
:expanded="expandedLeagues.today.has(group.leagueId)"
|
||||
@toggle="toggleLeague(group.leagueId)"
|
||||
@bet="goMatch"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="empty">
|
||||
<img :src="emptyMatchesImg" alt="" class="empty-icon" />
|
||||
<p>{{ t('bet.no_matches') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="empty">
|
||||
<img :src="emptyMatchesImg" alt="" class="empty-icon" />
|
||||
<p>{{ t('bet.no_matches') }}</p>
|
||||
</div>
|
||||
<div v-show="timeTab === 'early'">
|
||||
<div v-if="earlyLeagueGroups.length" class="league-list">
|
||||
<LeagueAccordionItem
|
||||
v-for="group in earlyLeagueGroups"
|
||||
:key="`early-${group.leagueId}`"
|
||||
:league-id="group.leagueId"
|
||||
:league-name="group.leagueName"
|
||||
:league-logo-url="group.leagueLogoUrl"
|
||||
:matches="group.matches"
|
||||
:expanded="expandedLeagues.early.has(group.leagueId)"
|
||||
@toggle="toggleLeague(group.leagueId)"
|
||||
@bet="goMatch"
|
||||
/>
|
||||
</div>
|
||||
<div v-else class="empty">
|
||||
<img :src="emptyMatchesImg" alt="" class="empty-icon" />
|
||||
<p>{{ t('bet.no_matches') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<OutrightPanel v-if="mainTab === 'outright'" class="outright-tab" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { ref, onMounted, onActivated, computed } from 'vue';
|
||||
import { useRouter, RouterLink } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import api from '../api';
|
||||
@@ -7,19 +7,17 @@ import { formatMoney } from '../utils/localeDisplay';
|
||||
import LocaleFlag from '../components/LocaleFlag.vue';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { useAppLocale } from '../composables/useAppLocale';
|
||||
import { usePlayerProfile } from '../composables/usePlayerProfile';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePullToRefresh } from '../composables/usePullToRefresh';
|
||||
import { parseCashbackApiData, sumCashbackAmount } from '../utils/cashback';
|
||||
import walletBg from '../assets/images/wallet-bg.webp';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const router = useRouter();
|
||||
const auth = useAuthStore();
|
||||
const { locales, setLocale, initFromUser } = useAppLocale();
|
||||
|
||||
const profile = ref<{
|
||||
username?: string;
|
||||
wallet?: { availableBalance: string; frozenBalance: string };
|
||||
} | null>(null);
|
||||
const { profileRaw, refreshProfile } = usePlayerProfile();
|
||||
|
||||
const loading = ref(true);
|
||||
const error = ref(false);
|
||||
@@ -33,10 +31,8 @@ async function fetchProfile() {
|
||||
loading.value = true;
|
||||
error.value = false;
|
||||
try {
|
||||
const { data } = await api.get('/player/profile');
|
||||
profile.value = data.data;
|
||||
initFromUser(data.data?.locale);
|
||||
// Fetch cashback total in parallel
|
||||
await refreshProfile();
|
||||
initFromUser(profileRaw.value?.locale);
|
||||
void fetchCashbackTotal();
|
||||
} catch {
|
||||
error.value = true;
|
||||
@@ -47,17 +43,23 @@ async function fetchProfile() {
|
||||
|
||||
async function fetchCashbackTotal() {
|
||||
try {
|
||||
const { data } = await api.get('/player/wallet/transactions/stats');
|
||||
const byType = data.data?.byType ?? [];
|
||||
let sum = 0;
|
||||
for (const g of byType) {
|
||||
if (['CASHBACK', 'CASHBACK_DEPOSIT'].includes(g.transactionType?.toUpperCase())) {
|
||||
sum += Math.abs(parseFloat(g.totalAmount ?? '0'));
|
||||
}
|
||||
}
|
||||
cashbackTotal.value = sum.toString();
|
||||
const { data } = await api.get('/player/cashbacks');
|
||||
cashbackTotal.value = sumCashbackAmount(parseCashbackApiData(data.data)).toString();
|
||||
} catch {
|
||||
// Ignore errors, keep default value
|
||||
// Fallback: sum wallet cashback credits when batch detail API is unavailable.
|
||||
try {
|
||||
const { data } = await api.get('/player/wallet/transactions/stats');
|
||||
const byType = data.data?.byType ?? [];
|
||||
let sum = 0;
|
||||
for (const g of byType) {
|
||||
if (['CASHBACK', 'CASHBACK_DEPOSIT'].includes(g.transactionType?.toUpperCase())) {
|
||||
sum += Math.abs(parseFloat(g.totalAmount ?? '0'));
|
||||
}
|
||||
}
|
||||
cashbackTotal.value = sum.toString();
|
||||
} catch {
|
||||
// Keep default value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +67,10 @@ onMounted(() => {
|
||||
void fetchProfile();
|
||||
});
|
||||
|
||||
onActivated(() => {
|
||||
void fetchProfile();
|
||||
});
|
||||
|
||||
const { pullDistance, refreshing, spinning, progress } = usePullToRefresh({
|
||||
onRefresh: async () => { await fetchProfile(); },
|
||||
});
|
||||
@@ -84,7 +90,7 @@ function logout() {
|
||||
}
|
||||
|
||||
const balanceDisplay = computed(() =>
|
||||
formatMoney(profile.value?.wallet?.availableBalance, locale.value),
|
||||
formatMoney(profileRaw.value?.wallet?.availableBalance, locale.value),
|
||||
);
|
||||
|
||||
const balanceAmountClass = computed(() => {
|
||||
@@ -143,7 +149,7 @@ const balanceAmountClass = computed(() => {
|
||||
<div class="bank-card-footer">
|
||||
<div class="bank-card-field">
|
||||
<span class="bank-card-label">持卡人</span>
|
||||
<span class="bank-card-holder">{{ profile?.username }}</span>
|
||||
<span class="bank-card-holder">{{ profileRaw?.username }}</span>
|
||||
</div>
|
||||
<div class="bank-card-field bank-card-field--center">
|
||||
<span class="bank-card-label">累计返水</span>
|
||||
@@ -151,7 +157,7 @@ const balanceAmountClass = computed(() => {
|
||||
</div>
|
||||
<div class="bank-card-field bank-card-field--right">
|
||||
<span class="bank-card-label">未结算</span>
|
||||
<span class="bank-card-stat">{{ formatMoney(profile?.wallet?.frozenBalance, locale) }}</span>
|
||||
<span class="bank-card-stat">{{ formatMoney(profileRaw?.wallet?.frozenBalance, locale) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,13 +6,32 @@ import api from '../api';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePullToRefresh } from '../composables/usePullToRefresh';
|
||||
import { formatMoney } from '../utils/localeDisplay';
|
||||
import {
|
||||
auditActionTone,
|
||||
auditActorSecondary,
|
||||
formatDepositAuditRemark,
|
||||
shouldShowAuditRejectInTimeline,
|
||||
} from '../utils/depositAuditDisplay';
|
||||
|
||||
const router = useRouter();
|
||||
const { t, locale } = useI18n();
|
||||
|
||||
interface DepositAuditLog {
|
||||
id: string;
|
||||
action: string;
|
||||
actorType: string;
|
||||
statusBefore: string | null;
|
||||
statusAfter: string;
|
||||
amount: string | null;
|
||||
approvedAmount: string | null;
|
||||
remark: string | null;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
interface DepositOrder {
|
||||
id: string;
|
||||
orderNo: string;
|
||||
paymentMethodId?: string;
|
||||
methodType: string;
|
||||
amount: string;
|
||||
status: string;
|
||||
@@ -22,6 +41,7 @@ interface DepositOrder {
|
||||
createdAt: string;
|
||||
reviewedAt: string | null;
|
||||
paymentMethodName: string | null;
|
||||
auditLogs?: DepositAuditLog[];
|
||||
}
|
||||
|
||||
const items = ref<DepositOrder[]>([]);
|
||||
@@ -34,6 +54,8 @@ const hasMore = ref(true);
|
||||
const sentinel = ref<HTMLElement | null>(null);
|
||||
let observer: IntersectionObserver | null = null;
|
||||
|
||||
const selectedOrder = ref<DepositOrder | null>(null);
|
||||
|
||||
async function fetchOrders(p = 1) {
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
@@ -41,13 +63,13 @@ async function fetchOrders(p = 1) {
|
||||
const { data } = await api.get('/player/deposit-orders', { params: { page: p } });
|
||||
const result = data.data ?? { items: [], total: 0, pageSize: 20 };
|
||||
const newItems = result.items ?? [];
|
||||
|
||||
|
||||
if (p === 1) {
|
||||
items.value = newItems;
|
||||
} else {
|
||||
items.value = [...items.value, ...newItems];
|
||||
}
|
||||
|
||||
|
||||
total.value = result.total ?? 0;
|
||||
const pageSize = result.pageSize ?? 20;
|
||||
hasMore.value = newItems.length >= pageSize && items.value.length < total.value;
|
||||
@@ -99,7 +121,107 @@ function goRecharge() {
|
||||
router.push('/wallet/recharge');
|
||||
}
|
||||
|
||||
onMounted(fetchOrders);
|
||||
function openDetail(order: DepositOrder) {
|
||||
selectedOrder.value = order;
|
||||
}
|
||||
|
||||
function closeDetail() {
|
||||
selectedOrder.value = null;
|
||||
}
|
||||
|
||||
function reapply(order: DepositOrder) {
|
||||
const query: Record<string, string> = {
|
||||
orderId: order.id,
|
||||
methodType: order.methodType,
|
||||
amount: order.amount,
|
||||
};
|
||||
if (order.paymentMethodId) {
|
||||
query.methodId = order.paymentMethodId;
|
||||
}
|
||||
router.push({ path: '/wallet/recharge', query });
|
||||
}
|
||||
|
||||
function normalizeText(value: string | null | undefined) {
|
||||
return value?.trim() ?? '';
|
||||
}
|
||||
|
||||
/** Backend sets remark = rejectReason on reject; show one line only. */
|
||||
function orderNote(order: DepositOrder): { label: string; text: string } | null {
|
||||
const rejectReason = normalizeText(order.rejectReason);
|
||||
const remark = normalizeText(order.remark);
|
||||
|
||||
if (order.status === 'REJECTED') {
|
||||
const text = rejectReason || remark;
|
||||
if (!text) return null;
|
||||
return { label: t('recharge.reject_reason'), text };
|
||||
}
|
||||
|
||||
if (remark) {
|
||||
return { label: t('recharge.remark'), text: remark };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function orderNoteLine(order: DepositOrder) {
|
||||
const note = orderNote(order);
|
||||
return note ? `${note.label}: ${note.text}` : null;
|
||||
}
|
||||
|
||||
function auditActionLabel(action: string) {
|
||||
const key = `recharge.audit_${action.toLowerCase()}` as const;
|
||||
const translated = t(key);
|
||||
return translated !== key ? translated : action;
|
||||
}
|
||||
|
||||
function auditStepClass(action: string) {
|
||||
return `audit-step--${auditActionTone(action)}`;
|
||||
}
|
||||
|
||||
function formatAuditTime(iso: string) {
|
||||
return new Date(iso).toLocaleString(undefined, {
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
}
|
||||
|
||||
function formatOrderTime(iso: string) {
|
||||
return new Date(iso).toLocaleString();
|
||||
}
|
||||
|
||||
function auditRemarkForTimeline(log: DepositAuditLog, order: DepositOrder) {
|
||||
if (log.action === 'REJECTED' && !shouldShowAuditRejectInTimeline(log, order.rejectReason)) {
|
||||
return null;
|
||||
}
|
||||
return formatDepositAuditRemark(log, t);
|
||||
}
|
||||
|
||||
function auditLogsForDisplay(order: DepositOrder) {
|
||||
return [...(order.auditLogs ?? [])]
|
||||
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
|
||||
.map((log) => ({
|
||||
log,
|
||||
actor: auditActorSecondary(log, t),
|
||||
remark: auditRemarkForTimeline(log, order),
|
||||
}));
|
||||
}
|
||||
|
||||
function auditNoteLine(text: string) {
|
||||
return `${t('recharge.audit_remark_label')}: ${text}`;
|
||||
}
|
||||
|
||||
function auditNoteDisplayText(remark: { kind: 'note'; text: string }) {
|
||||
if (remark.text === t('wallet.remark_deposit_revoke_generic')) {
|
||||
return remark.text;
|
||||
}
|
||||
return auditNoteLine(remark.text);
|
||||
}
|
||||
|
||||
function auditStepCount(order: DepositOrder) {
|
||||
return order.auditLogs?.length ?? 0;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -117,7 +239,7 @@ onMounted(fetchOrders);
|
||||
<GoldSpinner v-if="spinning" :size="28" :progress="progress" :active="spinning" />
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="state">
|
||||
<div v-if="initialLoading && loading" class="state">
|
||||
<GoldSpinner :size="36" />
|
||||
</div>
|
||||
|
||||
@@ -125,7 +247,16 @@ onMounted(fetchOrders);
|
||||
<div v-if="!items.length" class="empty">{{ t('recharge.no_orders') }}</div>
|
||||
|
||||
<div v-else class="order-list">
|
||||
<div v-for="order in items" :key="order.id" class="order-card" :class="{ rejected: order.status === 'REJECTED' }">
|
||||
<div
|
||||
v-for="order in items"
|
||||
:key="order.id"
|
||||
class="order-card"
|
||||
:class="{ rejected: order.status === 'REJECTED' }"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="openDetail(order)"
|
||||
@keydown.enter="openDetail(order)"
|
||||
>
|
||||
<div class="order-header">
|
||||
<span class="method-badge" :class="order.methodType === 'BANK' ? 'bank' : 'usdt'">{{ order.methodType }}</span>
|
||||
<span :class="['status-badge', statusClass(order.status)]">{{ statusLabel(order.status) }}</span>
|
||||
@@ -141,19 +272,33 @@ onMounted(fetchOrders);
|
||||
<div class="order-times">
|
||||
<div class="time-row">
|
||||
<span class="time-label">{{ t('recharge.apply_time') }}</span>
|
||||
<span class="time-value">{{ new Date(order.createdAt).toLocaleString() }}</span>
|
||||
<span class="time-value">{{ formatOrderTime(order.createdAt) }}</span>
|
||||
</div>
|
||||
<div v-if="order.reviewedAt" class="time-row">
|
||||
<span class="time-label">{{ t('recharge.review_time') }}</span>
|
||||
<span class="time-value">{{ new Date(order.reviewedAt).toLocaleString() }}</span>
|
||||
<span class="time-value">{{ formatOrderTime(order.reviewedAt) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="order.remark" class="order-remark">
|
||||
{{ t('recharge.remark') }}: {{ order.remark }}
|
||||
<div
|
||||
v-if="orderNoteLine(order)"
|
||||
:class="order.status === 'REJECTED' ? 'reject-reason' : 'order-remark'"
|
||||
>
|
||||
{{ orderNoteLine(order) }}
|
||||
</div>
|
||||
<div v-if="order.status === 'REJECTED' && order.rejectReason" class="reject-reason">
|
||||
{{ t('recharge.reject_reason') }}: {{ order.rejectReason }}
|
||||
<div v-if="auditStepCount(order)" class="card-detail-hint">
|
||||
<span class="card-detail-summary">
|
||||
{{ t('recharge.audit_summary', { count: auditStepCount(order) }) }}
|
||||
</span>
|
||||
<span class="card-detail-link">{{ t('recharge.view_detail') }} ›</span>
|
||||
</div>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="card-detail-link-only"
|
||||
@click.stop="openDetail(order)"
|
||||
>
|
||||
{{ t('recharge.view_detail') }} ›
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -168,6 +313,98 @@ onMounted(fetchOrders);
|
||||
{{ t('common.no_more') }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<Teleport to="body">
|
||||
<div v-if="selectedOrder" class="detail-overlay" @click.self="closeDetail">
|
||||
<div class="detail-modal" role="dialog" aria-modal="true" :aria-label="t('recharge.order_detail')">
|
||||
<button type="button" class="detail-close" :aria-label="t('common.close')" @click="closeDetail">✕</button>
|
||||
|
||||
<h3 class="detail-title">{{ t('recharge.order_detail') }}</h3>
|
||||
|
||||
<div class="detail-summary">
|
||||
<div class="detail-summary-head">
|
||||
<span class="method-badge" :class="selectedOrder.methodType === 'BANK' ? 'bank' : 'usdt'">
|
||||
{{ selectedOrder.methodType }}
|
||||
</span>
|
||||
<span :class="['status-badge', statusClass(selectedOrder.status)]">
|
||||
{{ statusLabel(selectedOrder.status) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="detail-amount">{{ formatMoney(selectedOrder.amount, locale) }}</div>
|
||||
<div
|
||||
v-if="selectedOrder.approvedAmount && selectedOrder.approvedAmount !== selectedOrder.amount"
|
||||
class="approved-amount"
|
||||
>
|
||||
{{ t('recharge.credited') }}: {{ formatMoney(selectedOrder.approvedAmount, locale) }}
|
||||
</div>
|
||||
<div class="detail-method-name">{{ selectedOrder.paymentMethodName || '-' }}</div>
|
||||
<div class="detail-row">
|
||||
<span class="detail-label">{{ t('recharge.apply_time') }}</span>
|
||||
<span class="detail-value">{{ formatOrderTime(selectedOrder.createdAt) }}</span>
|
||||
</div>
|
||||
<div v-if="selectedOrder.reviewedAt" class="detail-row">
|
||||
<span class="detail-label">{{ t('recharge.review_time') }}</span>
|
||||
<span class="detail-value">{{ formatOrderTime(selectedOrder.reviewedAt) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="orderNoteLine(selectedOrder)"
|
||||
:class="selectedOrder.status === 'REJECTED' ? 'reject-reason' : 'order-remark'"
|
||||
>
|
||||
{{ orderNoteLine(selectedOrder) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedOrder.auditLogs?.length" class="detail-audit">
|
||||
<h4 class="detail-audit-title">{{ t('recharge.audit_title') }}</h4>
|
||||
<div class="audit-track">
|
||||
<div
|
||||
v-for="(entry, logIdx) in auditLogsForDisplay(selectedOrder)"
|
||||
:key="entry.log.id"
|
||||
class="audit-step"
|
||||
:class="auditStepClass(entry.log.action)"
|
||||
>
|
||||
<div class="audit-step-rail" aria-hidden="true">
|
||||
<span class="audit-dot" />
|
||||
<span v-if="logIdx < auditLogsForDisplay(selectedOrder).length - 1" class="audit-line" />
|
||||
</div>
|
||||
<div class="audit-step-body">
|
||||
<div class="audit-step-head">
|
||||
<span class="audit-step-title">{{ auditActionLabel(entry.log.action) }}</span>
|
||||
<time class="audit-step-time">{{ formatAuditTime(entry.log.createdAt) }}</time>
|
||||
</div>
|
||||
<p v-if="entry.actor" class="audit-step-actor">{{ entry.actor }}</p>
|
||||
<p
|
||||
v-if="entry.log.approvedAmount && entry.log.action === 'APPROVED'"
|
||||
class="audit-step-credited"
|
||||
>
|
||||
{{ t('recharge.audit_credited') }} {{ formatMoney(entry.log.approvedAmount, locale) }}
|
||||
</p>
|
||||
<div
|
||||
v-if="entry.remark?.kind === 'reject'"
|
||||
class="audit-step-box audit-step-box--reject"
|
||||
>
|
||||
<span class="audit-step-box-label">{{ t('recharge.reject_reason') }}</span>
|
||||
<span class="audit-step-box-text">{{ entry.remark.text }}</span>
|
||||
</div>
|
||||
<p v-else-if="entry.remark?.kind === 'note'" class="audit-step-note">
|
||||
{{ auditNoteDisplayText(entry.remark) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="selectedOrder.status === 'REJECTED'"
|
||||
type="button"
|
||||
class="modal-reapply-btn btn-gold-outline"
|
||||
@click.stop="reapply(selectedOrder)"
|
||||
>
|
||||
{{ t('recharge.reapply') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -189,6 +426,11 @@ onMounted(fetchOrders);
|
||||
padding: 16px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
.order-card:active {
|
||||
opacity: 0.92;
|
||||
}
|
||||
.order-card::before {
|
||||
content: '';
|
||||
@@ -198,21 +440,20 @@ onMounted(fetchOrders);
|
||||
background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.6), transparent);
|
||||
}
|
||||
.order-card.rejected {
|
||||
background: linear-gradient(135deg, #1a1a1a 0%, #1f1f1f 40%, #161616 100%);
|
||||
border-color: rgba(100, 100, 100, 0.2);
|
||||
opacity: 0.7;
|
||||
background: #141414;
|
||||
border-color: rgba(245, 108, 108, 0.22);
|
||||
}
|
||||
.order-card.rejected::before {
|
||||
background: linear-gradient(90deg, transparent, rgba(100, 100, 100, 0.4), transparent);
|
||||
background: linear-gradient(90deg, transparent, rgba(245, 108, 108, 0.35), transparent);
|
||||
}
|
||||
.order-card.rejected .order-amount {
|
||||
background: linear-gradient(135deg, #888, #666);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
background: none;
|
||||
-webkit-background-clip: unset;
|
||||
background-clip: unset;
|
||||
color: #bbb;
|
||||
}
|
||||
.order-card.rejected .info-label {
|
||||
color: rgba(150, 150, 150, 0.7);
|
||||
color: #888;
|
||||
}
|
||||
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
|
||||
.method-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
|
||||
@@ -247,8 +488,54 @@ onMounted(fetchOrders);
|
||||
border-radius: 6px;
|
||||
margin-top: 6px;
|
||||
border-left: 2px solid rgba(212, 175, 55, 0.3);
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
.reject-reason {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #c07070;
|
||||
background: transparent;
|
||||
padding: 6px 0 0;
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
border-top: 1px solid rgba(245, 108, 108, 0.18);
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
.card-detail-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid rgba(212, 175, 55, 0.12);
|
||||
}
|
||||
.card-detail-summary {
|
||||
font-size: 11px;
|
||||
color: rgba(212, 175, 55, 0.65);
|
||||
font-weight: 600;
|
||||
}
|
||||
.card-detail-link {
|
||||
font-size: 11px;
|
||||
color: var(--primary-light);
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.card-detail-link-only {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
text-align: right;
|
||||
font-size: 11px;
|
||||
color: var(--primary-light);
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
.reject-reason { margin-top: 8px; font-size: 12px; color: #f56c6c; background: #2a1515; padding: 6px 10px; border-radius: 6px; }
|
||||
|
||||
.sentinel {
|
||||
height: 1px;
|
||||
@@ -268,4 +555,291 @@ onMounted(fetchOrders);
|
||||
padding: 16px 0 4px;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.detail-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 200;
|
||||
background: rgba(0, 0, 0, 0.48);
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.detail-modal {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
max-height: min(88vh, 720px);
|
||||
overflow-y: auto;
|
||||
background: #141414;
|
||||
border: 1px solid #2a2a2a;
|
||||
border-bottom: none;
|
||||
border-radius: 14px 14px 0 0;
|
||||
padding: 16px 16px calc(14px + env(safe-area-inset-bottom, 0px));
|
||||
box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.28);
|
||||
}
|
||||
|
||||
.detail-close {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
color: #777;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
margin: 0 28px 12px 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #e8e8e8;
|
||||
}
|
||||
|
||||
.detail-summary {
|
||||
margin-bottom: 14px;
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
border: 1px solid #222;
|
||||
}
|
||||
|
||||
.detail-summary-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.detail-amount {
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
margin-bottom: 4px;
|
||||
color: var(--primary-light, #d4af37);
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.detail-method-name {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.detail-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
font-size: 12px;
|
||||
color: #ccc;
|
||||
text-align: right;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.detail-summary .order-remark {
|
||||
margin-top: 8px;
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
background: transparent;
|
||||
padding: 6px 0 0;
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
border-top: 1px solid #222;
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.detail-summary .reject-reason {
|
||||
margin-top: 8px;
|
||||
font-size: 11px;
|
||||
color: #b08888;
|
||||
background: transparent;
|
||||
padding: 6px 0 0;
|
||||
border-radius: 0;
|
||||
border: none;
|
||||
border-top: 1px solid rgba(245, 108, 108, 0.15);
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.detail-summary .approved-amount {
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.detail-audit {
|
||||
margin-top: 2px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid #222;
|
||||
}
|
||||
|
||||
.detail-audit-title {
|
||||
margin: 0 0 10px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #888;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.audit-track {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.audit-step {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.audit-step-rail {
|
||||
flex: 0 0 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.audit-dot {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: #555;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.audit-line {
|
||||
flex: 1;
|
||||
width: 1px;
|
||||
min-height: 10px;
|
||||
margin: 3px 0;
|
||||
background: #2a2a2a;
|
||||
}
|
||||
|
||||
.audit-step-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.audit-step:last-child .audit-step-body {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.audit-step-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.audit-step-title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #ccc;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.audit-step-time {
|
||||
font-size: 10px;
|
||||
color: #666;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.audit-step-actor {
|
||||
margin: 2px 0 0;
|
||||
font-size: 11px;
|
||||
color: #999;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.audit-step-credited {
|
||||
margin: 3px 0 0;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
color: #7eb87a;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.audit-step-note {
|
||||
margin: 4px 0 0;
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
line-height: 1.45;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.audit-step-box {
|
||||
margin-top: 4px;
|
||||
padding: 6px 8px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
line-height: 1.4;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.audit-step-box--reject {
|
||||
background: transparent;
|
||||
border: 1px solid rgba(245, 108, 108, 0.22);
|
||||
}
|
||||
|
||||
.audit-step-box-label {
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
color: #c07070;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.audit-step-box-text {
|
||||
font-size: 11px;
|
||||
color: #b08888;
|
||||
}
|
||||
|
||||
.audit-step--submitted .audit-dot {
|
||||
background: #c9a227;
|
||||
}
|
||||
.audit-step--approved .audit-dot {
|
||||
background: #5fad5a;
|
||||
}
|
||||
.audit-step--rejected .audit-dot {
|
||||
background: #d06060;
|
||||
}
|
||||
.audit-step--revoked .audit-dot {
|
||||
background: #777;
|
||||
}
|
||||
.audit-step--reopened .audit-dot {
|
||||
background: #c9a227;
|
||||
}
|
||||
|
||||
.modal-reapply-btn {
|
||||
width: 100%;
|
||||
margin-top: 14px;
|
||||
padding: 11px 16px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import imageCompression from 'browser-image-compression';
|
||||
import api from '../api';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const reapplyOrderId = computed(() => {
|
||||
const id = route.query.orderId;
|
||||
return typeof id === 'string' && id ? id : '';
|
||||
});
|
||||
const isReapply = computed(() => !!reapplyOrderId.value);
|
||||
|
||||
interface PaymentMethod {
|
||||
id: string;
|
||||
methodType: string;
|
||||
@@ -36,13 +43,39 @@ const bankMethods = computed(() => methods.value.filter((m) => m.methodType ===
|
||||
const usdtMethods = computed(() => methods.value.filter((m) => m.methodType === 'USDT'));
|
||||
const currentMethods = computed(() => methodType.value === 'BANK' ? bankMethods.value : usdtMethods.value);
|
||||
|
||||
function applyReapplyQuery() {
|
||||
const type = route.query.methodType;
|
||||
if (type === 'BANK' || type === 'USDT') {
|
||||
methodType.value = type;
|
||||
}
|
||||
|
||||
const methodId = typeof route.query.methodId === 'string' ? route.query.methodId : '';
|
||||
if (methodId) {
|
||||
const match = methods.value.find((m) => m.id === methodId);
|
||||
if (match) {
|
||||
selectedMethod.value = match;
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedMethod.value && currentMethods.value.length) {
|
||||
selectedMethod.value = currentMethods.value[0];
|
||||
}
|
||||
|
||||
const amountQuery = typeof route.query.amount === 'string' ? route.query.amount : '';
|
||||
const parsedAmount = parseFloat(amountQuery);
|
||||
if (amountQuery && parsedAmount > 0) {
|
||||
amount.value = amountQuery;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchMethods() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } = await api.get('/player/payment-methods');
|
||||
methods.value = (data.data ?? []).map((m: any) => ({ ...m, id: String(m.id) }));
|
||||
// Auto-select first available
|
||||
if (currentMethods.value.length) {
|
||||
if (isReapply.value) {
|
||||
applyReapplyQuery();
|
||||
} else if (currentMethods.value.length) {
|
||||
selectedMethod.value = currentMethods.value[0];
|
||||
}
|
||||
} catch { /* */ } finally {
|
||||
@@ -145,10 +178,19 @@ async function handleSubmit() {
|
||||
submitting.value = true;
|
||||
try {
|
||||
const fd = new FormData();
|
||||
fd.append('paymentMethodId', selectedMethod.value.id);
|
||||
fd.append('amount', String(amt));
|
||||
fd.append('screenshot', screenshotFile.value);
|
||||
|
||||
if (isReapply.value) {
|
||||
fd.append('paymentMethodId', selectedMethod.value.id);
|
||||
const { data } = await api.post(`/player/deposit-orders/${reapplyOrderId.value}/reapply`, fd);
|
||||
const result = data.data;
|
||||
orderNo.value = result?.orderNo ?? '';
|
||||
success.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
fd.append('paymentMethodId', selectedMethod.value.id);
|
||||
const { data } = await api.post('/player/deposit-orders', fd);
|
||||
const result = data.data;
|
||||
orderNo.value = result?.orderNo ?? '';
|
||||
@@ -206,10 +248,12 @@ onMounted(fetchMethods);
|
||||
<h3>{{ t('recharge.submitted') }}</h3>
|
||||
<p class="order-no">{{ orderNo }}</p>
|
||||
<p class="success-hint">{{ t('recharge.pending_review') }}</p>
|
||||
<button class="btn-primary" @click="resetForm">{{ t('recharge.new_recharge') }}</button>
|
||||
<button v-if="isReapply" class="btn-primary" @click="goHistory">{{ t('recharge.back_to_history') }}</button>
|
||||
<button v-else class="btn-primary" @click="resetForm">{{ t('recharge.new_recharge') }}</button>
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="isReapply" class="reapply-banner">{{ t('recharge.reapply_hint') }}</div>
|
||||
<div class="type-tabs">
|
||||
<button
|
||||
:class="['tab', methodType === 'BANK' && 'active']"
|
||||
@@ -330,6 +374,17 @@ onMounted(fetchMethods);
|
||||
|
||||
.state { display: flex; justify-content: center; padding: 48px; }
|
||||
|
||||
.reapply-banner {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
color: #ffd0d0;
|
||||
background: rgba(245, 108, 108, 0.12);
|
||||
border: 1px solid rgba(245, 108, 108, 0.25);
|
||||
}
|
||||
|
||||
.type-tabs {
|
||||
display: flex; margin-bottom: 12px;
|
||||
border-radius: 6px; overflow: hidden;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import api from '../api';
|
||||
import { formatMoney } from '../utils/localeDisplay';
|
||||
import { txTypeKey, isCashbackType, txDisplayType, txSummaryLabel } from '../utils/walletTx';
|
||||
import { txTypeKey, isCashbackType, txDisplayType, txSummaryLabel, txRemarkLabel, isDepositReversalType } from '../utils/walletTx';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePullToRefresh } from '../composables/usePullToRefresh';
|
||||
|
||||
@@ -108,6 +108,7 @@ const cashbackBatchNo = computed(() => {
|
||||
const referenceLabel = computed(() => {
|
||||
if (isCashbackTx.value) return t('wallet.ref_cashback');
|
||||
if (!tx.value?.referenceType) return '';
|
||||
if (isDepositReversalType(tx.value.transactionType)) return t('wallet.ref_deposit');
|
||||
const rt = tx.value.referenceType.toUpperCase();
|
||||
if (rt === 'BET') return t('wallet.ref_bet');
|
||||
if (rt === 'DEPOSIT') return t('wallet.ref_deposit');
|
||||
@@ -115,6 +116,11 @@ const referenceLabel = computed(() => {
|
||||
return tx.value.referenceType;
|
||||
});
|
||||
|
||||
const remarkText = computed(() => {
|
||||
if (!tx.value) return '';
|
||||
return txRemarkLabel(tx.value, t);
|
||||
});
|
||||
|
||||
function goBetDetail() {
|
||||
if (!tx.value?.betNo) return;
|
||||
router.push(`/bets/${tx.value.betNo}`);
|
||||
@@ -180,7 +186,7 @@ function goCashbackDetail() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="tx.referenceType || tx.remark" class="section">
|
||||
<section v-if="tx.referenceType || remarkText" class="section">
|
||||
<div class="section-title">{{ t('wallet.detail_reference') }}</div>
|
||||
<div class="summary-rows">
|
||||
<div v-if="tx.referenceType" class="sum-row">
|
||||
@@ -191,9 +197,9 @@ function goCashbackDetail() {
|
||||
<span>{{ t('wallet.detail_reference_id') }}</span>
|
||||
<span class="mono">{{ tx.referenceId }}</span>
|
||||
</div>
|
||||
<div v-if="tx.remark" class="sum-row">
|
||||
<div v-if="remarkText" class="sum-row">
|
||||
<span>{{ t('wallet.detail_remark') }}</span>
|
||||
<span class="remark">{{ tx.remark }}</span>
|
||||
<span class="remark">{{ remarkText }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button v-if="tx.betNo" type="button" class="bet-link" @click="goBetDetail">
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import api from '../api';
|
||||
import { formatMoney, formatMoneyCompact } from '../utils/localeDisplay';
|
||||
import { txTypeKey, txDisplayType, txSummaryLabel } from '../utils/walletTx';
|
||||
import { parseCashbackApiData, sumCashbackAmount } from '../utils/cashback';
|
||||
import GoldSpinner from '../components/GoldSpinner.vue';
|
||||
import { usePullToRefresh } from '../composables/usePullToRefresh';
|
||||
|
||||
@@ -54,12 +55,12 @@ async function fetchData() {
|
||||
try {
|
||||
const [txRes, cbRes] = await Promise.all([
|
||||
api.get('/player/wallet/transactions', { params: { page: 1 } }),
|
||||
api.get('/player/cashbacks').catch(() => ({ data: { data: { items: [], totalAmount: '0' } } })),
|
||||
api.get('/player/cashbacks').catch(() => ({ data: { data: [] } })),
|
||||
]);
|
||||
const result = txRes.data.data ?? { items: [] };
|
||||
items.value = (result.items ?? []).slice(0, PREVIEW_COUNT);
|
||||
const cbData = cbRes.data?.data;
|
||||
cashbackTotal.value = cbData?.totalAmount ?? cbData?.items?.reduce((s: number, r: { amount: string }) => s + Math.abs(parseFloat(r.amount) || 0), 0)?.toString() ?? '0';
|
||||
const cbRows = parseCashbackApiData(cbRes.data?.data);
|
||||
cashbackTotal.value = sumCashbackAmount(cbRows).toString();
|
||||
} catch {
|
||||
/* ignore */
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user