FundReconciliation.vue
15.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<template>
<div>
<a-card title="资金对账" :bordered="false" class="list-table-card">
<div class="soft-page-stack">
<div class="soft-note-card">
<strong>对账说明</strong>
<p>本页仅提供商户账单与自营骑手账单查询,不包含第三方运力账单与骑手提现审核。</p>
</div>
<div class="fund-tabs">
<button
v-for="item in tabs"
:key="item.key"
type="button"
class="fund-tab"
:class="{ 'is-active': activeTab === item.key }"
@click="switchTab(item.key)"
>
{{ item.label }}
</button>
</div>
<div class="list-toolbar">
<div class="list-toolbar-left">
<a-select
v-if="isAdmin"
v-model:value="filterCityId"
placeholder="租户"
allowClear
class="list-filter"
@change="handleFilterChange"
>
<a-select-option v-for="item in cityList" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
</a-select>
<a-date-picker
v-model:value="startDate"
value-format="YYYY-MM-DD"
placeholder="开始日期"
class="list-filter"
@change="handleFilterChange"
/>
<a-date-picker
v-model:value="endDate"
value-format="YYYY-MM-DD"
placeholder="结束日期"
class="list-filter"
@change="handleFilterChange"
/>
<a-input-search
v-model:value="keyword"
:placeholder="activeTab === 'merchant' ? '搜索店铺名' : '搜索骑手姓名/手机号'"
class="list-search"
@search="handleKeywordSearch"
/>
</div>
</div>
<a-table
v-if="activeTab === 'merchant'"
:dataSource="merchantList"
:columns="merchantColumns"
:loading="loading"
rowKey="outStoreId"
:pagination="pagination"
@change="handleTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'cityName'">
{{ getCityName(record.cityId) }}
</template>
<template v-else-if="column.key === 'orderAmount'">
¥{{ formatMoney(record.orderAmount) }}
</template>
<template v-else-if="column.key === 'deliveryAmount'">
¥{{ formatMoney(record.deliveryAmount) }}
</template>
<template v-else-if="column.key === 'refundAmount'">
¥{{ formatMoney(record.refundAmount) }}
</template>
<template v-else-if="column.key === 'merchantReceivableAmount'">
¥{{ formatMoney(record.merchantReceivableAmount) }}
</template>
<template v-else-if="column.key === 'action'">
<a @click="openMerchantDetail(record)">查看明细</a>
</template>
</template>
</a-table>
<a-table
v-else
:dataSource="riderList"
:columns="riderColumns"
:loading="loading"
rowKey="riderId"
:pagination="pagination"
@change="handleTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'deliveryAmount'">
¥{{ formatMoney(record.deliveryAmount) }}
</template>
<template v-else-if="column.key === 'riderIncomeAmount'">
¥{{ formatMoney(record.riderIncomeAmount) }}
</template>
<template v-else-if="column.key === 'refundAdjustAmount'">
¥{{ formatMoney(record.refundAdjustAmount) }}
</template>
<template v-else-if="column.key === 'settleableAmount'">
¥{{ formatMoney(record.settleableAmount) }}
</template>
<template v-else-if="column.key === 'action'">
<a @click="openRiderDetail(record)">查看明细</a>
</template>
</template>
</a-table>
</div>
</a-card>
<a-modal v-model:open="detailVisible" :title="detailTitle" :footer="null" width="1120px">
<div class="soft-page-stack">
<div class="soft-note-card">
<strong>{{ detailTitle }}</strong>
<p>{{ activeDetailTab === 'merchant' ? '展示商户账单关联订单明细。' : '展示骑手账单关联订单明细。' }}</p>
</div>
<a-table
:dataSource="detailList"
:columns="detailColumns"
:loading="detailLoading"
rowKey="orderId"
:pagination="detailPagination"
:scroll="detailTableScroll"
@change="handleDetailTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<a-tag :color="statusColor[record.status] || 'default'">{{ statusMap[record.status] || `状态${record.status}` }}</a-tag>
</template>
<template v-else-if="column.key === 'payTime'">
{{ formatTime(record.payTime) }}
</template>
<template v-else-if="column.key === 'completeTime'">
{{ formatTime(record.completeTime) }}
</template>
<template v-else-if="column.key === 'orderAmount' || column.key === 'deliveryAmount' || column.key === 'refundAmount' || column.key === 'riderIncomeAmount' || column.key === 'settleableAmount'">
¥{{ formatMoney(record[column.key]) }}
</template>
</template>
</a-table>
</div>
</a-modal>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import type { TablePaginationConfig } from 'ant-design-vue'
import { merchantApi } from '@/api'
import { useRoleCityList } from '@/composables/useRoleCityList'
const PAGE_SIZE = 20
const tabs = [
{ key: 'merchant', label: '商户账单' },
{ key: 'rider', label: '自营骑手账单' },
] as const
const activeTab = ref<'merchant' | 'rider'>('merchant')
const activeDetailTab = ref<'merchant' | 'rider'>('merchant')
const loading = ref(false)
const detailLoading = ref(false)
const detailVisible = ref(false)
const detailTitle = ref('账单明细')
const merchantList = ref<any[]>([])
const riderList = ref<any[]>([])
const detailList = ref<any[]>([])
const total = ref(0)
const currentPage = ref(1)
const pageSize = ref(PAGE_SIZE)
const detailTotal = ref(0)
const detailPage = ref(1)
const detailPageSize = ref(PAGE_SIZE)
const filterCityId = ref<number | undefined>()
const keyword = ref('')
const startDate = ref('2026-04-01')
const endDate = ref('2026-04-30')
const currentOutStoreId = ref('')
const currentDetailCityId = ref<number | undefined>()
const currentRiderId = ref<number | undefined>()
const { isAdmin, managedCityId, cityList, loadCities, getCityName } = useRoleCityList()
const statusMap: Record<number, string> = {
2: '已支付',
3: '已接单',
4: '服务中',
6: '已完成',
7: '退款申请',
8: '退款成功',
9: '退款拒绝',
}
const statusColor: Record<number, string> = {
2: 'blue',
3: 'cyan',
4: 'processing',
6: 'green',
7: 'orange',
8: 'green',
9: 'red',
}
const merchantColumns = computed(() => {
const base = [
{ title: '店铺ID', dataIndex: 'storeId', width: 100 },
{ title: '店铺名称', dataIndex: 'storeName', ellipsis: true },
{ title: '外部门店编号', dataIndex: 'outStoreId', ellipsis: true },
{ title: '完成订单数', dataIndex: 'orderCount', width: 120 },
{ title: '订单金额合计', key: 'orderAmount', width: 130 },
{ title: '配送费合计', key: 'deliveryAmount', width: 130 },
{ title: '已退款金额', key: 'refundAmount', width: 130 },
{ title: '商户应收参考金额', key: 'merchantReceivableAmount', width: 160 },
{ title: '操作', key: 'action', width: 100 },
]
return isAdmin.value ? [{ title: '租户', key: 'cityName', width: 120 }, ...base] : base
})
const riderColumns = [
{ title: '骑手ID', dataIndex: 'riderId', width: 100 },
{ title: '骑手姓名', dataIndex: 'riderName', width: 120 },
{ title: '手机号', dataIndex: 'mobile', width: 140 },
{ title: '完成订单数', dataIndex: 'orderCount', width: 120 },
{ title: '配送费合计', key: 'deliveryAmount', width: 130 },
{ title: '骑手收入合计', key: 'riderIncomeAmount', width: 140 },
{ title: '退款影响参考金额', key: 'refundAdjustAmount', width: 150 },
{ title: '可结算参考金额', key: 'settleableAmount', width: 150 },
{ title: '操作', key: 'action', width: 100 },
]
const detailColumns = computed(() => {
if (activeDetailTab.value === 'merchant') {
return [
{ title: '订单ID', dataIndex: 'orderId', width: 90 },
{ title: '订单号', dataIndex: 'orderNo', ellipsis: true, width: 180 },
{ title: '支付时间', key: 'payTime', width: 160 },
{ title: '完成时间', key: 'completeTime', width: 160 },
{ title: '状态', key: 'status', width: 100 },
{ title: '订单金额', key: 'orderAmount', width: 110 },
{ title: '配送费', key: 'deliveryAmount', width: 110 },
{ title: '退款金额', key: 'refundAmount', width: 110 },
]
}
return [
{ title: '订单ID', dataIndex: 'orderId', width: 90 },
{ title: '订单号', dataIndex: 'orderNo', ellipsis: true, width: 180 },
{ title: '完成时间', key: 'completeTime', width: 160 },
{ title: '状态', key: 'status', width: 100 },
{ title: '配送费', key: 'deliveryAmount', width: 110 },
{ title: '骑手收入', key: 'riderIncomeAmount', width: 110 },
{ title: '退款影响金额', key: 'refundAmount', width: 120 },
{ title: '可结算参考金额', key: 'settleableAmount', width: 130 },
]
})
const detailTableScroll = computed(() => ({ x: activeDetailTab.value === 'merchant' ? 1020 : 1000 }))
const pagination = computed<TablePaginationConfig>(() => ({
current: currentPage.value,
pageSize: pageSize.value,
total: total.value,
showSizeChanger: false,
showTotal: (count) => `共 ${count} 条`,
}))
const detailPagination = computed<TablePaginationConfig>(() => ({
current: detailPage.value,
pageSize: detailPageSize.value,
total: detailTotal.value,
showSizeChanger: false,
showTotal: (count) => `共 ${count} 条`,
}))
function switchTab(tab: 'merchant' | 'rider') {
if (activeTab.value === tab) {
return
}
detailVisible.value = false
activeTab.value = tab
currentPage.value = 1
loadList()
}
function handleFilterChange() {
detailVisible.value = false
currentPage.value = 1
loadList()
}
function handleKeywordSearch() {
detailVisible.value = false
currentPage.value = 1
loadList()
}
function handleTableChange(page: TablePaginationConfig) {
const nextPage = page.current ?? 1
if (nextPage === currentPage.value) {
return
}
currentPage.value = nextPage
loadList()
}
function handleDetailTableChange(page: TablePaginationConfig) {
const nextPage = page.current ?? 1
if (nextPage === detailPage.value) {
return
}
detailPage.value = nextPage
loadDetail()
}
function getQueryParams() {
return {
cityId: isAdmin.value ? filterCityId.value : managedCityId.value,
keyword: keyword.value || undefined,
startDate: startDate.value,
endDate: endDate.value,
page: currentPage.value,
}
}
async function loadList() {
loading.value = true
try {
if (activeTab.value === 'merchant') {
const res: any = await merchantApi.merchantBillList(getQueryParams())
const data = res?.data ?? {}
merchantList.value = Array.isArray(data.list) ? data.list : []
total.value = Number(data.total ?? 0)
currentPage.value = Number(data.page ?? currentPage.value)
pageSize.value = Number(data.pageSize ?? PAGE_SIZE)
} else {
const res: any = await merchantApi.riderBillList(getQueryParams())
const data = res?.data ?? {}
riderList.value = Array.isArray(data.list) ? data.list : []
total.value = Number(data.total ?? 0)
currentPage.value = Number(data.page ?? currentPage.value)
pageSize.value = Number(data.pageSize ?? PAGE_SIZE)
}
} finally {
loading.value = false
}
}
async function openMerchantDetail(record: any) {
activeDetailTab.value = 'merchant'
detailTitle.value = `${record.storeName} 账单明细`
currentOutStoreId.value = record.outStoreId
currentDetailCityId.value = record.cityId
detailPage.value = 1
detailVisible.value = true
await loadDetail()
}
async function openRiderDetail(record: any) {
activeDetailTab.value = 'rider'
detailTitle.value = `${record.riderName} 账单明细`
currentDetailCityId.value = isAdmin.value ? filterCityId.value : managedCityId.value
currentRiderId.value = record.riderId
detailPage.value = 1
detailVisible.value = true
await loadDetail()
}
async function loadDetail() {
detailLoading.value = true
try {
if (activeDetailTab.value === 'merchant') {
const res: any = await merchantApi.merchantBillDetail({
cityId: currentDetailCityId.value ?? (isAdmin.value ? filterCityId.value : managedCityId.value),
outStoreId: currentOutStoreId.value,
startDate: startDate.value,
endDate: endDate.value,
page: detailPage.value,
})
const data = res?.data ?? {}
detailList.value = Array.isArray(data.list) ? data.list : []
detailTotal.value = Number(data.total ?? 0)
detailPage.value = Number(data.page ?? detailPage.value)
detailPageSize.value = Number(data.pageSize ?? PAGE_SIZE)
} else {
const res: any = await merchantApi.riderBillDetail({
cityId: currentDetailCityId.value ?? (isAdmin.value ? filterCityId.value : managedCityId.value),
riderId: currentRiderId.value,
startDate: startDate.value,
endDate: endDate.value,
page: detailPage.value,
})
const data = res?.data ?? {}
detailList.value = Array.isArray(data.list) ? data.list : []
detailTotal.value = Number(data.total ?? 0)
detailPage.value = Number(data.page ?? detailPage.value)
detailPageSize.value = Number(data.pageSize ?? PAGE_SIZE)
}
} finally {
detailLoading.value = false
}
}
function formatMoney(value: number | string | null | undefined) {
const amount = Number(value ?? 0)
return amount.toFixed(2)
}
function formatTime(value: number | null | undefined) {
if (!value) {
return '-'
}
return new Date(Number(value) * 1000).toLocaleString('zh-CN', { hour12: false })
}
onMounted(async () => {
await loadCities()
if (!isAdmin.value) {
filterCityId.value = managedCityId.value
}
currentDetailCityId.value = isAdmin.value ? filterCityId.value : managedCityId.value
await loadList()
})
</script>
<style scoped>
.fund-tabs {
display: flex;
gap: 12px;
margin-bottom: 4px;
}
.fund-tab {
border: 1px solid var(--line);
background: var(--panel-strong);
color: var(--text-main);
border-radius: 999px;
padding: 8px 18px;
font-size: 13px;
font-weight: 700;
cursor: pointer;
transition: all 0.2s ease;
}
.fund-tab:hover {
border-color: rgba(140, 124, 240, 0.48);
}
.fund-tab.is-active {
color: #fff;
border-color: transparent;
background: linear-gradient(135deg, #8c7cf0 0%, #c995ea 100%);
box-shadow: 0 12px 24px rgba(140, 124, 240, 0.24);
}
</style>