feat(admin,api,player): 返水流程优化、账单详情与数据库重置

优化返水预览/确认/作废,新增玩家账变详情与后台一键重置为 seed 数据,并修复 dev 启动时 3000 端口占用。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-08 11:14:22 +08:00
parent 24fa1b275c
commit b2216abd0c
24 changed files with 2253 additions and 849 deletions

View File

@@ -101,6 +101,22 @@ const i18n = createI18n({
filter_deposit: '存款',
filter_withdraw: '提款',
filter_bet: '投注',
detail_summary: '账务明细',
detail_amount: '变动金额',
detail_balance_before: '变动前余额',
detail_balance_after: '变动后余额',
detail_frozen_before: '变动前冻结',
detail_frozen_after: '变动后冻结',
detail_reference: '关联信息',
detail_reference_type: '业务类型',
detail_reference_id: '关联编号',
detail_remark: '备注',
detail_bet_link: '查看注单',
detail_tx_id: '流水号',
detail_not_found: '账单不存在',
ref_bet: '投注',
ref_deposit: '存款',
ref_withdraw: '提款',
},
bet: {
bet_slip: '投注单',
@@ -366,6 +382,22 @@ const i18n = createI18n({
filter_deposit: 'Deposit',
filter_withdraw: 'Withdraw',
filter_bet: 'Bet',
detail_summary: 'Details',
detail_amount: 'Amount',
detail_balance_before: 'Balance Before',
detail_balance_after: 'Balance After',
detail_frozen_before: 'Frozen Before',
detail_frozen_after: 'Frozen After',
detail_reference: 'Reference',
detail_reference_type: 'Type',
detail_reference_id: 'Reference ID',
detail_remark: 'Remark',
detail_bet_link: 'View Bet',
detail_tx_id: 'Transaction ID',
detail_not_found: 'Transaction not found',
ref_bet: 'Bet',
ref_deposit: 'Deposit',
ref_withdraw: 'Withdraw',
},
bet: {
bet_slip: 'Bet Slip',
@@ -637,6 +669,22 @@ const i18n = createI18n({
filter_deposit: 'Deposit',
filter_withdraw: 'Pengeluaran',
filter_bet: 'Pertaruhan',
detail_summary: 'Butiran',
detail_amount: 'Jumlah',
detail_balance_before: 'Baki Sebelum',
detail_balance_after: 'Baki Selepas',
detail_frozen_before: 'Beku Sebelum',
detail_frozen_after: 'Beku Selepas',
detail_reference: 'Rujukan',
detail_reference_type: 'Jenis',
detail_reference_id: 'ID Rujukan',
detail_remark: 'Catatan',
detail_bet_link: 'Lihat Pertaruhan',
detail_tx_id: 'ID Transaksi',
detail_not_found: 'Rekod tidak dijumpai',
ref_bet: 'Pertaruhan',
ref_deposit: 'Deposit',
ref_withdraw: 'Pengeluaran',
},
bet: {
bet_slip: 'Slip Pertaruhan',

View File

@@ -17,6 +17,7 @@ const router = createRouter({
{ path: 'bets', component: () => import('../views/MyBetsView.vue') },
{ path: 'bets/:betNo', component: () => import('../views/BetDetailView.vue') },
{ path: 'wallet', component: () => import('../views/WalletView.vue') },
{ path: 'wallet/transactions/:transactionId', component: () => import('../views/WalletTransactionDetailView.vue') },
{ path: 'profile', component: () => import('../views/ProfileView.vue') },
{ path: 'profile/edit', component: () => import('../views/ProfileEditView.vue') },
],

View File

@@ -0,0 +1,36 @@
export const TX_KEY_MAP: Record<string, string> = {
MANUAL_DEPOSIT: 'wallet.tx_deposit',
MANUAL_WITHDRAW: 'wallet.tx_withdraw',
MANUAL_ADJUST: 'wallet.tx_adjust',
BET_FREEZE: 'wallet.tx_bet_freeze',
BET_DEDUCT: 'wallet.tx_bet_deduct',
BET_SETTLE_WIN: 'wallet.tx_bet_win',
BET_SETTLE_LOSE: 'wallet.tx_bet_lose',
BET_SETTLE_PUSH: 'wallet.tx_bet_push',
BET_WIN: 'wallet.tx_bet_win',
BET_REFUND: 'wallet.tx_bet_refund',
BET_VOID: 'wallet.tx_bet_void',
BET_VOID_REFUND: 'wallet.tx_bet_void',
CASHBACK: 'wallet.tx_cashback',
CASHBACK_DEPOSIT: 'wallet.tx_cashback',
RESETTLE_REVERSE: 'wallet.tx_resettle',
DEPOSIT: 'wallet.tx_deposit',
WITHDRAW: 'wallet.tx_withdraw',
};
export function txTypeKey(type: string): string {
return TX_KEY_MAP[type.toUpperCase()] ?? '';
}
export function isDepositType(type: string): boolean {
const t = type.toUpperCase();
return t.includes('DEPOSIT') || t === 'CASHBACK_DEPOSIT';
}
export function isWithdrawType(type: string): boolean {
return type.toUpperCase().includes('WITHDRAW');
}
export function isBetType(type: string): boolean {
return type.toUpperCase().startsWith('BET_') || type.toUpperCase() === 'RESETTLE_REVERSE';
}

View File

@@ -0,0 +1,309 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import api from '../api';
import { formatMoney } from '../utils/localeDisplay';
import { txTypeKey } from '../utils/walletTx';
import GoldSpinner from '../components/GoldSpinner.vue';
type TransactionDetail = {
transactionId: string;
transactionType: string;
amount: string;
balanceBefore: string;
balanceAfter: string;
frozenBefore: string;
frozenAfter: string;
referenceType: string | null;
referenceId: string | null;
remark: string | null;
createdAt: string;
betNo: string | null;
};
const route = useRoute();
const router = useRouter();
const { t, locale } = useI18n();
const tx = ref<TransactionDetail | null>(null);
const loading = ref(true);
const notFound = ref(false);
onMounted(async () => {
try {
const { data } = await api.get(`/player/wallet/transactions/${route.params.transactionId}`);
if (!data.data) {
notFound.value = true;
return;
}
tx.value = data.data;
} catch {
notFound.value = true;
} finally {
loading.value = false;
}
});
function txLabel(type: string): string {
const key = txTypeKey(type);
if (key) {
const translated = t(key);
if (translated !== key) return translated;
}
return type;
}
const amountClass = computed(() => {
if (!tx.value) return '';
return parseFloat(tx.value.amount) >= 0 ? 'pos' : 'neg';
});
const formattedTime = computed(() => {
if (!tx.value) return '';
return new Date(tx.value.createdAt).toLocaleString(locale.value);
});
const frozenChanged = computed(() => {
if (!tx.value) return false;
return tx.value.frozenBefore !== tx.value.frozenAfter;
});
const referenceLabel = computed(() => {
if (!tx.value?.referenceType) return '';
const rt = tx.value.referenceType.toUpperCase();
if (rt === 'BET') return t('wallet.ref_bet');
if (rt === 'DEPOSIT') return t('wallet.ref_deposit');
if (rt === 'WITHDRAW') return t('wallet.ref_withdraw');
return tx.value.referenceType;
});
function goBetDetail() {
if (!tx.value?.betNo) return;
router.push(`/bets/${tx.value.betNo}`);
}
</script>
<template>
<div class="detail-page">
<div class="top-bar">
<button class="back-btn" type="button" @click="router.back()"> {{ t('history.back') }}</button>
</div>
<div v-if="loading" class="state">
<GoldSpinner :size="36" />
</div>
<div v-else-if="notFound || !tx" class="state">{{ t('wallet.detail_not_found') }}</div>
<template v-else>
<div class="hero" :class="amountClass">
<span class="hero-type">{{ txLabel(tx.transactionType) }}</span>
<span class="hero-amount">{{ formatMoney(tx.amount, locale) }}</span>
<span class="hero-time">{{ formattedTime }}</span>
</div>
<section class="section">
<div class="section-title">{{ t('wallet.detail_summary') }}</div>
<div class="summary-rows">
<div class="sum-row">
<span>{{ t('wallet.detail_amount') }}</span>
<span :class="amountClass">{{ formatMoney(tx.amount, locale) }}</span>
</div>
<div class="sum-row">
<span>{{ t('wallet.detail_balance_before') }}</span>
<span>{{ formatMoney(tx.balanceBefore, locale) }}</span>
</div>
<div class="sum-row">
<span>{{ t('wallet.detail_balance_after') }}</span>
<span>{{ formatMoney(tx.balanceAfter, locale) }}</span>
</div>
<template v-if="frozenChanged">
<div class="sum-row">
<span>{{ t('wallet.detail_frozen_before') }}</span>
<span>{{ formatMoney(tx.frozenBefore, locale) }}</span>
</div>
<div class="sum-row">
<span>{{ t('wallet.detail_frozen_after') }}</span>
<span>{{ formatMoney(tx.frozenAfter, locale) }}</span>
</div>
</template>
</div>
</section>
<section v-if="tx.referenceType || tx.remark" class="section">
<div class="section-title">{{ t('wallet.detail_reference') }}</div>
<div class="summary-rows">
<div v-if="tx.referenceType" class="sum-row">
<span>{{ t('wallet.detail_reference_type') }}</span>
<span>{{ referenceLabel }}</span>
</div>
<div v-if="tx.referenceId && !tx.betNo" class="sum-row">
<span>{{ t('wallet.detail_reference_id') }}</span>
<span class="mono">{{ tx.referenceId }}</span>
</div>
<div v-if="tx.remark" class="sum-row">
<span>{{ t('wallet.detail_remark') }}</span>
<span class="remark">{{ tx.remark }}</span>
</div>
</div>
<button v-if="tx.betNo" type="button" class="bet-link" @click="goBetDetail">
{{ t('wallet.detail_bet_link') }} · {{ tx.betNo }}
</button>
</section>
<section class="section">
<div class="section-title">{{ t('wallet.detail_tx_id') }}</div>
<div class="tx-id">{{ tx.transactionId }}</div>
</section>
</template>
</div>
</template>
<style scoped>
.detail-page {
padding-bottom: 32px;
}
.top-bar {
margin-bottom: 4px;
}
.back-btn {
background: none;
border: none;
color: var(--primary-light, #d4af37);
font-size: 15px;
font-weight: 700;
padding: 4px 0 8px;
cursor: pointer;
display: flex;
align-items: center;
gap: 2px;
}
.state {
text-align: center;
padding: 60px 20px;
color: #666;
font-size: 14px;
font-weight: 600;
}
.hero {
border-radius: 14px;
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
margin-bottom: 12px;
text-align: center;
background: #141414;
border: 1px solid #222;
}
.hero.pos {
border-color: rgba(212, 175, 55, 0.25);
background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.03));
}
.hero.neg {
border-color: rgba(224, 80, 80, 0.2);
background: linear-gradient(135deg, rgba(224, 80, 80, 0.1), rgba(224, 80, 80, 0.03));
}
.hero-type {
font-size: 12px;
font-weight: 800;
letter-spacing: 0.06em;
text-transform: uppercase;
color: #888;
}
.hero-amount {
font-size: 34px;
font-weight: 900;
line-height: 1.1;
}
.hero.pos .hero-amount { color: var(--primary-light); }
.hero.neg .hero-amount { color: var(--danger); }
.hero-time {
font-size: 11px;
color: #555;
font-weight: 600;
}
.section {
background: #141414;
border: 1px solid #222;
border-radius: 12px;
padding: 14px 16px;
margin-bottom: 10px;
}
.section-title {
font-size: 12px;
font-weight: 800;
color: #888;
letter-spacing: 0.04em;
margin-bottom: 10px;
}
.summary-rows {
display: flex;
flex-direction: column;
gap: 10px;
}
.sum-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
font-size: 13px;
color: #aaa;
}
.sum-row span:last-child {
color: #f0f0f0;
font-weight: 700;
text-align: right;
word-break: break-all;
}
.pos { color: var(--primary-light) !important; }
.neg { color: var(--danger) !important; }
.mono {
font-family: ui-monospace, monospace;
font-size: 12px;
}
.remark {
max-width: 60%;
line-height: 1.4;
}
.bet-link {
width: 100%;
margin-top: 12px;
padding: 10px 14px;
border-radius: 10px;
border: 1px solid var(--border-gold-soft, rgba(212, 175, 55, 0.35));
background: rgba(212, 175, 55, 0.08);
color: var(--primary-light);
font-size: 13px;
font-weight: 700;
cursor: pointer;
}
.tx-id {
font-family: ui-monospace, monospace;
font-size: 12px;
color: #ccc;
word-break: break-all;
line-height: 1.5;
}
</style>

View File

@@ -1,19 +1,22 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import api from '../api';
import { formatMoney } from '../utils/localeDisplay';
import { isBetType, isDepositType, isWithdrawType, txTypeKey } from '../utils/walletTx';
import GoldSpinner from '../components/GoldSpinner.vue';
import WalletStatsPanel from '../components/WalletStatsPanel.vue';
import { usePullToRefresh } from '../composables/usePullToRefresh';
const router = useRouter();
const { t, locale } = useI18n();
type Transaction = {
transactionType: string;
amount: string;
createdAt: string;
transactionId?: string;
transactionId: string;
};
const items = ref<Transaction[]>([]);
@@ -27,26 +30,6 @@ const typeFilter = ref('');
const sentinel = ref<HTMLElement | null>(null);
let observer: IntersectionObserver | null = null;
const TX_KEY_MAP: Record<string, string> = {
MANUAL_DEPOSIT: 'wallet.tx_deposit',
MANUAL_WITHDRAW: 'wallet.tx_withdraw',
MANUAL_ADJUST: 'wallet.tx_adjust',
BET_FREEZE: 'wallet.tx_bet_freeze',
BET_DEDUCT: 'wallet.tx_bet_deduct',
BET_SETTLE_WIN: 'wallet.tx_bet_win',
BET_SETTLE_LOSE: 'wallet.tx_bet_lose',
BET_SETTLE_PUSH: 'wallet.tx_bet_push',
BET_WIN: 'wallet.tx_bet_win',
BET_REFUND: 'wallet.tx_bet_refund',
BET_VOID: 'wallet.tx_bet_void',
BET_VOID_REFUND: 'wallet.tx_bet_void',
CASHBACK: 'wallet.tx_cashback',
CASHBACK_DEPOSIT: 'wallet.tx_cashback',
RESETTLE_REVERSE: 'wallet.tx_resettle',
DEPOSIT: 'wallet.tx_deposit',
WITHDRAW: 'wallet.tx_withdraw',
};
const FILTERS = [
{ key: '', label: 'wallet.filter_all' },
{ key: 'deposit', label: 'wallet.filter_deposit' },
@@ -55,7 +38,7 @@ const FILTERS = [
];
function txLabel(type: string): string {
const key = TX_KEY_MAP[type.toUpperCase()];
const key = txTypeKey(type);
if (key) {
const translated = t(key);
if (translated !== key) return translated;
@@ -63,21 +46,6 @@ function txLabel(type: string): string {
return type;
}
function isDepositType(type: string): boolean {
const t = type.toUpperCase();
return t.includes('DEPOSIT') || t === 'CASHBACK_DEPOSIT';
}
function isWithdrawType(type: string): boolean {
const t = type.toUpperCase();
return t.includes('WITHDRAW');
}
function isBetType(type: string): boolean {
const t = type.toUpperCase();
return t.startsWith('BET_');
}
function matchesFilter(tx: Transaction): boolean {
if (!typeFilter.value) return true;
if (typeFilter.value === 'deposit') return isDepositType(tx.transactionType) || tx.transactionType === 'MANUAL_ADJUST';
@@ -86,6 +54,11 @@ function matchesFilter(tx: Transaction): boolean {
return true;
}
function goDetail(tx: Transaction) {
if (!tx.transactionId) return;
router.push(`/wallet/transactions/${tx.transactionId}`);
}
async function loadPage(p: number) {
if (loading.value) return;
loading.value = true;
@@ -181,17 +154,24 @@ const pullIndicatorStyle = () => ({
</div>
<div v-if="items.length" class="tx-list">
<div
<button
v-for="tx in items"
:key="tx.transactionId ?? tx.createdAt + Math.random()"
:key="tx.transactionId"
type="button"
class="tx-row"
@click="goDetail(tx)"
>
<span class="tx-type">{{ txLabel(tx.transactionType) }}</span>
<span :class="parseFloat(tx.amount) >= 0 ? 'pos' : 'neg'">
{{ formatMoney(tx.amount, locale) }}
</span>
<span class="tx-time">{{ new Date(tx.createdAt).toLocaleString() }}</span>
</div>
<div class="tx-main">
<span class="tx-type">{{ txLabel(tx.transactionType) }}</span>
<span :class="parseFloat(tx.amount) >= 0 ? 'pos' : 'neg'">
{{ formatMoney(tx.amount, locale) }}
</span>
</div>
<div class="tx-meta">
<span class="tx-time">{{ new Date(tx.createdAt).toLocaleString() }}</span>
<span class="tx-arrow"></span>
</div>
</button>
</div>
<div ref="sentinel" class="sentinel" />
@@ -274,22 +254,44 @@ const pullIndicatorStyle = () => ({
}
.tx-row {
display: flex;
justify-content: space-between;
display: block;
width: 100%;
text-align: left;
font-size: 14px;
padding: 12px 16px;
border: none;
border-bottom: 1px solid var(--border);
flex-wrap: wrap;
background: transparent;
cursor: pointer;
}
.tx-row:last-child {
border-bottom: none;
}
.tx-row:active {
background: rgba(255, 255, 255, 0.03);
}
.tx-main {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
}
.tx-meta {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 4px;
}
.tx-type { font-weight: 700; color: var(--text); }
.pos { color: var(--primary-light); font-weight: 800; font-size: 15px; }
.neg { color: var(--danger); font-weight: 700; }
.tx-time { width: 100%; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.tx-time { font-size: 11px; color: var(--text-muted); }
.tx-arrow { font-size: 16px; color: #555; font-weight: 700; line-height: 1; }
.sentinel {
height: 1px;