feat: gift card breakdown - migrations, fdw queries, finance recharge task, board-finance page updates
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
// 财务看板页 — 忠于 H5 原型结构,内联 mock 数据
|
||||
// TODO: 联调时替换 mock 数据为真实 API 调用
|
||||
// 财务看板页 — 忠于 H5 原型结构
|
||||
// CHANGE 2026-07-22 | Prompt: gift-card-breakdown Task 9.1 | 直接原因: 赠送卡矩阵 giftRows 从 mock 替换为真实 API 数据
|
||||
|
||||
import { getRandomAiColor } from '../../utils/ai-color'
|
||||
import { fetchBoardFinance } from '../../services/api'
|
||||
import { formatMoney } from '../../utils/money'
|
||||
|
||||
/** 目录板块定义 */
|
||||
interface TocItem {
|
||||
@@ -154,26 +156,12 @@ Page({
|
||||
consumedCompare: '5.2%',
|
||||
cardBalance: '¥642,600',
|
||||
cardBalanceCompare: '11.4%',
|
||||
giftRows: [
|
||||
{
|
||||
label: '新增', total: '¥108,600', totalCompare: '9.8%',
|
||||
wine: '¥43,200', wineCompare: '11.2%',
|
||||
table: '¥54,100', tableCompare: '8.5%',
|
||||
coupon: '¥11,300', couponCompare: '6.3%',
|
||||
},
|
||||
{
|
||||
label: '消费', total: '¥75,800', totalCompare: '7.2%',
|
||||
wine: '¥32,100', wineCompare: '8.1%',
|
||||
table: '¥32,800', tableCompare: '6.5%',
|
||||
coupon: '¥10,900', couponCompare: '5.8%',
|
||||
},
|
||||
{
|
||||
label: '余额', total: '¥243,900', totalCompare: '4.5%',
|
||||
wine: '¥118,500', wineCompare: '5.2%',
|
||||
table: '¥109,200', tableCompare: '3.8%',
|
||||
coupon: '¥16,200', couponCompare: '2.5%',
|
||||
},
|
||||
],
|
||||
giftRows: [] as Array<{
|
||||
label: string; total: string; totalCompare: string;
|
||||
wine: string; wineCompare: string;
|
||||
table: string; tableCompare: string;
|
||||
coupon: string; couponCompare: string;
|
||||
}>,
|
||||
allCardBalance: '¥586,500',
|
||||
allCardBalanceCompare: '6.2%',
|
||||
},
|
||||
@@ -299,7 +287,8 @@ Page({
|
||||
// 同步 custom-tab-bar 选中态
|
||||
const tabBar = this.getTabBar?.()
|
||||
if (tabBar) tabBar.setData({ active: 'board' })
|
||||
// TODO: 联调时在此刷新看板数据
|
||||
// 加载赠送卡矩阵真实数据
|
||||
this._loadGiftRows()
|
||||
},
|
||||
|
||||
onReady() {
|
||||
@@ -395,7 +384,42 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 从 Finance_Board_API 加载赠送卡矩阵数据
|
||||
* 字段映射:liquor→wine、tableFee→table、voucher→coupon
|
||||
*/
|
||||
async _loadGiftRows() {
|
||||
try {
|
||||
const data = await fetchBoardFinance({
|
||||
time: this.data.selectedTime,
|
||||
area: this.data.selectedArea,
|
||||
compare: this.data.compareEnabled ? 1 : 0,
|
||||
})
|
||||
// API 返回 camelCase:giftRows[].liquor/tableFee/voucher,每个是 GiftCell {value, compare?, down?, flat?}
|
||||
const rechargePanel = data.rechargePanel || data
|
||||
const apiRows = rechargePanel.giftRows || []
|
||||
const giftRows = apiRows.map((row: any) => ({
|
||||
label: row.label || '',
|
||||
total: formatMoney(row.total?.value),
|
||||
totalCompare: row.total?.compare || '',
|
||||
wine: formatMoney(row.liquor?.value),
|
||||
wineCompare: row.liquor?.compare || '',
|
||||
table: formatMoney(row.tableFee?.value),
|
||||
tableCompare: row.tableFee?.compare || '',
|
||||
coupon: formatMoney(row.voucher?.value),
|
||||
couponCompare: row.voucher?.compare || '',
|
||||
}))
|
||||
this.setData({ 'recharge.giftRows': giftRows })
|
||||
} catch (err) {
|
||||
console.error('[board-finance] 赠送卡数据加载失败', err)
|
||||
// 加载失败时清空 giftRows,不显示 mock 数据
|
||||
this.setData({ 'recharge.giftRows': [] })
|
||||
wx.showToast({ title: '赠送卡数据加载失败', icon: 'none', duration: 2000 })
|
||||
}
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this._loadGiftRows()
|
||||
setTimeout(() => wx.stopPullDownRefresh(), 500)
|
||||
},
|
||||
|
||||
@@ -489,5 +513,6 @@ Page({
|
||||
/** P4: 错误态重试 */
|
||||
onRetry() {
|
||||
this.setData({ pageState: 'normal' })
|
||||
this._loadGiftRows()
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user