feat: add smoke tests, agent credit ledger, and player cashback page

Introduce admin smoke-test suite with API probes, agent credit transaction history, and player cashback records; fix SmokeTestModule DI and polish admin/player UI assets.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-09 16:05:48 +08:00
parent 9c6c5e51f3
commit d5e7c8edb3
52 changed files with 3357 additions and 67 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

After

Width:  |  Height:  |  Size: 913 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 771 KiB

View File

@@ -28,7 +28,8 @@ const isDetailPage = computed(() => {
p.startsWith('/bet/') ||
p.startsWith('/bets/') ||
p.startsWith('/wallet/') ||
p === '/profile/edit'
p === '/profile/edit' ||
p === '/profile/cashbacks'
);
});

View File

@@ -92,7 +92,7 @@ const i18n = createI18n({
tx_bet_push: '投注退水',
tx_bet_refund: '投注退款',
tx_bet_void: '投注撤销',
tx_cashback: '返水发放',
tx_cashback: '返水入账',
tx_resettle: '重新结算',
stats_income: '收入',
stats_expense: '支出',
@@ -120,6 +120,23 @@ const i18n = createI18n({
ref_bet: '投注',
ref_deposit: '存款',
ref_withdraw: '提款',
view_cashbacks: '返水明细',
view_cashbacks_detail: '查看返水周期明细',
cashback_filter_hint: '此处为入账流水;周期、比例等详见返水明细。',
detail_cashback_link: '查看返水明细',
ref_cashback: '返水批次',
},
cashback: {
title: '返水明细',
list_title: '发放明细',
total_received: '累计返水',
record_count: '共 {n} 笔',
period: '统计周期',
effective_stake: '有效投注',
bet_count: '{n} 笔注单',
empty: '暂无返水记录',
empty_hint: '返水由后台按周期统计并发放,到账后可在此查看。',
ledger_hint: '每笔返水确认后,账单中会有对应的「返水入账」流水,金额一致。',
},
bet: {
bet_slip: '投注单',
@@ -376,7 +393,7 @@ const i18n = createI18n({
tx_bet_push: 'Bet Push',
tx_bet_refund: 'Bet Refund',
tx_bet_void: 'Bet Voided',
tx_cashback: 'Cashback Distribution',
tx_cashback: 'Cashback credit',
tx_resettle: 'Resettlement',
stats_income: 'Income',
stats_expense: 'Expense',
@@ -404,6 +421,23 @@ const i18n = createI18n({
ref_bet: 'Bet',
ref_deposit: 'Deposit',
ref_withdraw: 'Withdraw',
view_cashbacks: 'Cashback details',
view_cashbacks_detail: 'View cashback details (period/rate)',
cashback_filter_hint: 'This list shows wallet credits; see cashback details for period and rate.',
ref_cashback: 'Cashback batch',
detail_cashback_link: 'View cashback details',
},
cashback: {
title: 'Cashback Details',
list_title: 'Payout details',
total_received: 'Total cashback',
record_count: '{n} record(s)',
period: 'Period',
effective_stake: 'Effective stake',
bet_count: '{n} bet(s)',
empty: 'No cashback records yet',
empty_hint: 'Cashback is issued by the platform after each settlement period.',
ledger_hint: 'Matches wallet entries under the Cashback filter; amounts are the same.',
},
bet: {
bet_slip: 'Bet Slip',
@@ -666,7 +700,7 @@ const i18n = createI18n({
tx_bet_push: 'Pertaruhan Seri',
tx_bet_refund: 'Bayaran Balik',
tx_bet_void: 'Pertaruhan Dibatalkan',
tx_cashback: 'Pembayaran Cashback',
tx_cashback: 'Kredit rebat',
tx_resettle: 'Penyelesaian Semula',
stats_income: 'Pendapatan',
stats_expense: 'Perbelanjaan',
@@ -694,6 +728,23 @@ const i18n = createI18n({
ref_bet: 'Pertaruhan',
ref_deposit: 'Deposit',
ref_withdraw: 'Pengeluaran',
view_cashbacks: 'Butiran rebat',
view_cashbacks_detail: 'Lihat butiran rebat (tempoh/kadar)',
cashback_filter_hint: 'Senarai ini ialah kredit dompet; tempoh dan kadar ada di butiran rebat.',
ref_cashback: 'Batch rebat',
detail_cashback_link: 'Lihat butiran rebat',
},
cashback: {
title: 'Butiran Rebat',
list_title: 'Butiran pembayaran',
total_received: 'Jumlah rebat',
record_count: '{n} rekod',
period: 'Tempoh',
effective_stake: 'Pertaruhan sah',
bet_count: '{n} pertaruhan',
empty: 'Tiada rekod rebat',
empty_hint: 'Rebat dikeluarkan oleh platform mengikut kitaran penyelesaian.',
ledger_hint: 'Sepadan dengan entri dompet di penapis Rebat; jumlah adalah sama.',
},
bet: {
bet_slip: 'Slip Pertaruhan',

View File

@@ -18,8 +18,10 @@ const router = createRouter({
{ path: 'bets/:betNo', component: () => import('../views/BetDetailView.vue') },
{ path: 'wallet', component: () => import('../views/WalletView.vue') },
{ path: 'wallet/detail', component: () => import('../views/WalletDetailView.vue') },
{ path: 'wallet/cashbacks', component: () => import('../views/CashbackRecordsView.vue') },
{ path: 'wallet/transactions/:transactionId', component: () => import('../views/WalletTransactionDetailView.vue') },
{ path: 'profile', component: () => import('../views/ProfileView.vue') },
{ path: 'profile/cashbacks', component: () => import('../views/CashbackRecordsView.vue') },
{ path: 'profile/edit', component: () => import('../views/ProfileEditView.vue') },
],
},

View File

@@ -0,0 +1,354 @@
<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, formatMoneyCompact } from '../utils/localeDisplay';
import GoldSpinner from '../components/GoldSpinner.vue';
import { usePullToRefresh } from '../composables/usePullToRefresh';
import { useOnLocaleChange } from '../composables/useOnLocaleChange';
const route = useRoute();
const router = useRouter();
const { t, locale } = useI18n();
const highlightBatchNo = computed(() => {
const q = route.query.batchNo;
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(true);
const totalAmount = computed(() =>
items.value.reduce((sum, row) => sum + Math.abs(parseFloat(row.amount) || 0), 0),
);
function formatPeriod(start: string, end: string) {
const opts: Intl.DateTimeFormatOptions = { month: '2-digit', day: '2-digit' };
const s = new Date(start).toLocaleDateString(locale.value, opts);
const e = new Date(end).toLocaleDateString(locale.value, opts);
return `${s} ${e}`;
}
function formatRate(rate: string) {
const n = parseFloat(rate);
if (!Number.isFinite(n)) return rate;
return `${(n * 100).toFixed(2)}%`;
}
function formatTime(v: string | null) {
if (!v) return '—';
return new Date(v).toLocaleString(locale.value, {
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
hour12: false,
});
}
async function fetchRecords() {
loading.value = true;
try {
const { data } = await api.get('/player/cashbacks');
items.value = data.data ?? [];
} catch {
items.value = [];
} finally {
loading.value = false;
}
}
useOnLocaleChange(fetchRecords);
const { pullDistance, spinning, progress } = usePullToRefresh({
onRefresh: fetchRecords,
});
onMounted(fetchRecords);
const pullIndicatorStyle = () => ({
height: `${pullDistance.value}px`,
opacity: Math.min(pullDistance.value / 48, 1),
});
</script>
<template>
<div class="cashback-page">
<div class="top-bar">
<button type="button" class="back-btn" @click="router.back()">
&#x2039; {{ t('history.back') }}
</button>
</div>
<div class="pull-indicator" :style="pullIndicatorStyle()">
<GoldSpinner v-if="spinning" :size="28" :progress="progress" :active="spinning" />
</div>
<div v-if="loading" class="state">
<GoldSpinner :size="36" />
<span class="loading-text">{{ t('bet.loading') }}</span>
</div>
<template v-else>
<div class="hero">
<span class="hero-amount">{{ formatMoney(totalAmount, locale) }}</span>
<span class="hero-sub">
{{ t('cashback.total_received') }}
<template v-if="items.length">
· {{ t('cashback.record_count', { n: items.length }) }}
</template>
</span>
</div>
<p class="ledger-hint">{{ t('cashback.ledger_hint') }}</p>
<p v-if="items.length" class="section-title">{{ t('cashback.list_title') }}</p>
<div v-if="items.length" class="list-card">
<article
v-for="row in items"
:key="row.id"
class="record-row"
:class="{ 'record-row--highlight': highlightBatchNo && row.batchNo === highlightBatchNo }"
>
<div class="row-main">
<div class="row-left">
<span class="row-amount">{{ formatMoney(row.amount, locale) }}</span>
<span class="row-period">{{ formatPeriod(row.periodStart, row.periodEnd) }}</span>
</div>
<span class="row-rate">{{ formatRate(row.rate) }}</span>
</div>
<div class="row-detail">
<span>{{ t('cashback.effective_stake') }} {{ formatMoneyCompact(row.effectiveStake, locale) }}</span>
<span>{{ t('cashback.bet_count', { n: row.betCount }) }}</span>
</div>
<div class="row-foot">
<span class="row-batch">{{ row.batchNo }}</span>
<span class="row-time">{{ formatTime(row.confirmedAt ?? row.createdAt) }}</span>
</div>
</article>
</div>
<div v-else class="empty">
<p class="empty-title">{{ t('cashback.empty') }}</p>
<p class="empty-hint">{{ t('cashback.empty_hint') }}</p>
</div>
</template>
</div>
</template>
<style scoped>
.cashback-page {
padding-bottom: 24px;
}
.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;
}
.pull-indicator {
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
transition: height 0.15s ease;
}
.state {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
text-align: center;
color: var(--text-muted);
padding: 56px 20px;
font-weight: 600;
font-size: 14px;
}
.loading-text {
font-size: 13px;
}
.hero {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
padding: 18px 16px 16px;
margin-bottom: 14px;
border-radius: var(--radius, 12px);
background: linear-gradient(135deg, rgba(212, 175, 55, 0.14), rgba(26, 26, 26, 0.92));
border: 1px solid rgba(212, 175, 55, 0.28);
text-align: center;
}
.hero-amount {
font-size: 28px;
font-weight: 800;
color: #f0b90b;
line-height: 1.2;
text-shadow: 0 0 20px rgba(240, 185, 11, 0.2);
}
.hero-sub {
font-size: 12px;
color: var(--text-muted);
line-height: 1.4;
}
.section-title {
font-size: 10.5px;
color: #555;
font-weight: 800;
letter-spacing: 0.08em;
text-transform: uppercase;
margin: 0 0 10px;
}
.list-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius);
overflow: hidden;
backdrop-filter: blur(10px);
}
.record-row {
padding: 12px 16px;
border-bottom: 1px solid var(--border);
}
.record-row:last-child {
border-bottom: none;
}
.record-row--highlight {
background: rgba(212, 175, 55, 0.08);
box-shadow: inset 3px 0 0 #d4af37;
}
.ledger-hint {
margin: 0 0 12px;
font-size: 12px;
line-height: 1.5;
color: #666;
}
.row-main {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
}
.row-left {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
}
.row-amount {
font-size: 17px;
font-weight: 800;
color: var(--primary-light);
}
.row-period {
font-size: 12px;
color: var(--text-muted);
font-weight: 600;
}
.row-rate {
flex-shrink: 0;
font-size: 12px;
font-weight: 700;
color: #f0b90b;
background: rgba(240, 185, 11, 0.1);
border: 1px solid rgba(240, 185, 11, 0.22);
border-radius: 999px;
padding: 3px 10px;
}
.row-detail {
display: flex;
flex-wrap: wrap;
gap: 8px 16px;
margin-top: 8px;
font-size: 12px;
color: var(--text-muted);
}
.row-foot {
display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;
margin-top: 8px;
padding-top: 8px;
border-top: 1px dashed rgba(255, 255, 255, 0.06);
font-size: 11px;
color: #666;
}
.row-batch {
font-family: ui-monospace, monospace;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 58%;
}
.row-time {
flex-shrink: 0;
}
.empty {
text-align: center;
padding: 48px 20px 32px;
}
.empty-title {
margin: 0 0 8px;
font-size: 15px;
font-weight: 700;
color: var(--text-muted);
}
.empty-hint {
margin: 0;
font-size: 13px;
line-height: 1.5;
color: #666;
}
</style>

View File

@@ -115,10 +115,19 @@ function logout() {
</div>
</div>
</div>
<span class="wallet-chevron" aria-hidden="true">&#x203A;</span>
</div>
<section class="settings-group">
<RouterLink to="/wallet/detail" class="settings-cell settings-cell--gold-entry">
<span class="cell-label">{{ t('wallet.view_all') }}</span>
<span class="cell-chevron" aria-hidden="true"></span>
</RouterLink>
<RouterLink to="/profile/cashbacks" class="settings-cell settings-cell--gold-entry">
<span class="cell-label">{{ t('wallet.view_cashbacks') }}</span>
<span class="cell-chevron" aria-hidden="true"></span>
</RouterLink>
<RouterLink to="/profile/edit" class="settings-cell">
<span class="cell-label">{{ t('profile.edit') }}</span>
<span class="cell-chevron" aria-hidden="true"></span>
@@ -197,26 +206,6 @@ function logout() {
transition: filter 0.1s;
}
.wallet-chevron {
position: absolute;
right: 4%;
bottom: 12%;
z-index: 3;
font-size: 28px;
font-weight: 400;
color: rgba(255, 255, 255, 0.85);
background: rgba(0, 0, 0, 0.35);
width: 32px;
height: 32px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
pointer-events: none;
line-height: 1;
backdrop-filter: blur(4px);
}
.wallet-banner-img {
width: 100%;
height: auto;
@@ -378,6 +367,32 @@ function logout() {
background: rgba(255, 255, 255, 0.03);
}
.settings-cell--gold-entry {
position: relative;
min-height: 50px;
border-color: rgba(212, 175, 55, 0.18);
border-bottom-color: rgba(212, 175, 55, 0.18);
background:
linear-gradient(90deg, rgba(212, 175, 55, 0.08), rgba(20, 20, 20, 0.65) 46%, rgba(212, 175, 55, 0.04));
box-shadow:
inset 1px 0 0 rgba(212, 175, 55, 0.22),
inset 0 1px 0 rgba(255, 244, 200, 0.05);
}
.settings-cell--gold-entry:active {
background:
linear-gradient(90deg, rgba(212, 175, 55, 0.12), rgba(20, 20, 20, 0.74) 46%, rgba(212, 175, 55, 0.06));
}
.settings-cell--gold-entry .cell-label {
color: #f4dc8b;
font-weight: 800;
}
.settings-cell--gold-entry .cell-chevron {
color: rgba(240, 216, 117, 0.78);
}
.settings-cell--stack {
flex-direction: column;
align-items: stretch;

View File

@@ -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 } from '../utils/walletTx';
import { txTypeKey, isCashbackType } from '../utils/walletTx';
import GoldSpinner from '../components/GoldSpinner.vue';
import { usePullToRefresh } from '../composables/usePullToRefresh';
@@ -82,7 +82,17 @@ const frozenChanged = computed(() => {
return tx.value.frozenBefore !== tx.value.frozenAfter;
});
const isCashbackTx = computed(
() => !!tx.value && isCashbackType(tx.value.transactionType),
);
const cashbackBatchNo = computed(() => {
if (!isCashbackTx.value || !tx.value?.referenceId) return null;
return tx.value.referenceId;
});
const referenceLabel = computed(() => {
if (isCashbackTx.value) return t('wallet.ref_cashback');
if (!tx.value?.referenceType) return '';
const rt = tx.value.referenceType.toUpperCase();
if (rt === 'BET') return t('wallet.ref_bet');
@@ -95,6 +105,11 @@ function goBetDetail() {
if (!tx.value?.betNo) return;
router.push(`/bets/${tx.value.betNo}`);
}
function goCashbackDetail() {
if (!cashbackBatchNo.value) return;
router.push({ path: '/wallet/cashbacks', query: { batchNo: cashbackBatchNo.value } });
}
</script>
<template>
@@ -169,6 +184,9 @@ function goBetDetail() {
<button v-if="tx.betNo" type="button" class="bet-link" @click="goBetDetail">
{{ t('wallet.detail_bet_link') }} · {{ tx.betNo }}
</button>
<button v-if="cashbackBatchNo" type="button" class="bet-link" @click="goCashbackDetail">
{{ t('wallet.detail_cashback_link') }} · {{ cashbackBatchNo }}
</button>
</section>
<section class="section">

View File

@@ -40,6 +40,10 @@ function goWalletDetail() {
router.push('/wallet/detail');
}
function goCashbacks() {
router.push('/wallet/cashbacks');
}
async function fetchTransactions() {
loading.value = true;
try {
@@ -80,8 +84,12 @@ const pullIndicatorStyle = () => ({
</div>
<template v-else>
<div v-if="items.length" class="top-bar">
<div class="top-bar">
<button type="button" class="more-link secondary" @click="goCashbacks">
{{ t('wallet.view_cashbacks_detail') }} &#x203A;
</button>
<button
v-if="items.length"
type="button"
class="more-link"
@click="goWalletDetail"
@@ -191,12 +199,16 @@ const pullIndicatorStyle = () => ({
.top-bar {
display: flex;
justify-content: flex-end;
justify-content: space-between;
align-items: center;
padding: 0 4px 2px;
margin-top: -8px;
}
.top-bar .more-link.secondary {
color: #f0b90b;
}
.more-link {
background: none;
border: none;