优化支付功能

This commit is contained in:
2026-09-16 14:28:07 +08:00
parent ac14452cae
commit 605c2a569f
19 changed files with 1020 additions and 479 deletions
+23 -8
View File
@@ -20,9 +20,8 @@ const COMMISSION = "/platform/commission";
/**
* 创建支付单
* TODO: 后端实现 POST /api/payment/create
* 约定入参:{ out_trade_no, tenant_id, order_type, amount(分), channel, subject, return_url, client_ip }
* 约定返回:{ pay_no, channel, pay_params } pay_params 交给前端拉起渠道支付
*
* 该接口仅供租户端收银台使用;平台端不直接创建支付单。
* @param {Object} data 下单参数
* @returns {Promise}
*/
@@ -35,17 +34,16 @@ export function createPayment(data) {
}
/**
* 查询支付单(本地库)
* TODO: 后端实现 GET /api/payment/query/:payNo
* 手动查询支付单并同步渠道状态
* @param {string} payNo 支付单号
* @param {Object} [params] { sync: true } 时同步渠道最新状态后再返回
* @returns {Promise}
*/
export function queryPayment(payNo, params = {}) {
return request({
url: `${PAY}/query/${payNo}`,
method: "get",
params,
url: `${PAY}/orders/${payNo}/query`,
method: "post",
data: params,
});
}
@@ -301,6 +299,23 @@ export function toggleCommissionRule(id, status) {
/* ================= 对账 ================= */
export function runReconcile(data) {
return request({
url: `${PAY}/reconcile/run`,
method: "post",
data,
});
}
export function importReconcileBill(data) {
return request({
url: `${PAY}/reconcile/import`,
method: "post",
data,
timeout: 0,
});
}
/**
* 对账差异列表
* TODO: 后端实现 GET /api/payment/reconcile
@@ -25,15 +25,17 @@
</el-col>
<el-col :span="12">
<el-form-item label="价格" prop="price">
<el-input-number
v-model="form.price"
:min="0"
:max="9999999"
:precision="2"
controls-position="right"
class="full"
/>
<span class="suffix">元</span>
<div class="price-input-wrapper">
<el-input-number
v-model="form.price"
:min="0"
:max="9999999"
:precision="2"
controls-position="right"
class="full"
/>
<span class="suffix">元</span>
</div>
</el-form-item>
</el-col>
<el-col :span="12">
@@ -338,10 +340,21 @@ const handleSubmit = async () => {
width: 100%;
}
.price-input-wrapper {
display: flex;
align-items: center;
width: 100%;
.full {
flex: 1;
}
}
.suffix {
margin-left: 8px;
font-size: 13px;
color: var(--el-text-color-secondary);
white-space: nowrap;
}
.feature-box {
@@ -128,7 +128,7 @@
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { onMounted, ref } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { Plus, Refresh } from "@element-plus/icons-vue";
import {
@@ -271,7 +271,8 @@ onMounted(async () => {
<style scoped lang="less">
.container-box {
padding: 4px;
padding: 20px;
border-radius: 8px;
}
.header-bar {
@@ -293,7 +294,7 @@ onMounted(async () => {
}
.tip-alert {
margin-bottom: 8px;
margin-bottom: 16px;
p {
margin: 4px 0;
@@ -303,22 +304,33 @@ onMounted(async () => {
}
.pricing-tabs {
margin-top: 8px;
margin-top: 0;
:deep(.el-tabs__header) {
margin-bottom: 16px;
}
:deep(.el-tabs__nav-wrap::after) {
height: 1px;
}
}
.product-name {
font-weight: 500;
color: var(--el-text-color-primary);
}
.price {
color: #f56c6c;
font-weight: 600;
font-size: 14px;
}
.order-filter {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 12px;
margin-bottom: 16px;
}
.muted {
@@ -144,8 +144,7 @@ import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Refresh, Setting } from '@element-plus/icons-vue'
import StatusTag from '../components/StatusTag.vue'
// TODO: 接口联调时打开
// import { getCommissionList, getCommissionStats, markCommissionPaid } from '@/api/payment'
import { getCommissionList, getCommissionStats, markCommissionPaid } from '@/api/payment'
const router = useRouter()
const loading = ref(false)
@@ -181,24 +180,19 @@ const payMethodMap: Record<string, string> = {
}
const payMethodLabel = (method: string) => payMethodMap[method] || method || '-'
/**
* 统计卡片数据:TODO 换成 getCommissionStats()
* 后端聚合自 yz_platform_commission_order:
* 应付总额 = sum(amount) where status='payable'
* 已付总额 = sum(amount) where status='settled'
* 待处理笔数 = count(*) where status in ('payable','tax_processing')
*/
/** 统计卡片数据。 */
const stats = reactive({
payable_amount: 1288000,
paid_amount: 4560500,
pending_count: 23
payable_amount: 0,
paid_amount: 0,
pending_count: 0
})
/* ---------------- Mock 数据(本地筛选 + 分页) ---------------- */
/* ---------------- 列表数据 ---------------- */
interface CommissionRow {
id: number
commission_no: string
pay_no: string
out_trade_no: string
promoter_name: string
amount: number
@@ -208,57 +202,36 @@ interface CommissionRow {
paid_at: string
}
const ALL_COMMISSIONS: CommissionRow[] = Array.from({ length: 24 }).map((_, index) => {
const promoters = ['云泽渠道-张明', '渠道伙伴-李雷', '服务商-杭州微光', '渠道伙伴-王芳', '服务商-深圳智联']
const statuses = ['payable', 'payable', 'settled', 'settled', 'tax_processing']
const methods = ['bank', 'balance', 'manual', 'offset']
const day = String(15 - Math.floor(index / 8)).padStart(2, '0')
const status = statuses[index % statuses.length]
return {
id: index + 1,
commission_no: `CM202609${day}${String(3000 + index)}`,
out_trade_no: `ORD202609${day}${String(2000 + index)}`,
promoter_name: promoters[index % promoters.length],
amount: [9990, 19990, 29990, 49990][index % 4],
status,
pay_method: methods[index % methods.length],
create_time: `2026-09-${day} 11:${String((index * 5) % 60).padStart(2, '0')}:00`,
paid_at: status === 'settled' ? `2026-09-${day} 16:20:00` : ''
}
})
const tableData = ref<CommissionRow[]>([])
async function fetchStats() {
try {
const res: any = await getCommissionStats()
if (res?.code === 200 && res.data) Object.assign(stats, res.data)
} catch (error: any) {
ElMessage.error(error?.response?.data?.msg || error?.message || '获取佣金统计失败')
}
}
async function fetchList() {
loading.value = true
try {
// TODO: 接口联通后替换为真实请求
// const res = await getCommissionList({
// page: page.current,
// pageSize: page.size,
// promoter: filters.promoter,
// status: filters.status,
// start_time: filters.dateRange?.[0],
// end_time: filters.dateRange?.[1]
// })
// tableData.value = res.data.list || []
// page.total = res.data.total || 0
const [start, end] = filters.dateRange || []
const filtered = ALL_COMMISSIONS.filter((item) => {
if (filters.promoter && !item.promoter_name.includes(filters.promoter)) return false
if (filters.status && item.status !== filters.status) return false
const date = item.create_time.slice(0, 10)
if (start && date < start) return false
if (end && date > end) return false
return true
const res: any = await getCommissionList({
page: page.current,
pageSize: page.size,
promoter: filters.promoter,
status: filters.status,
start_time: filters.dateRange?.[0],
end_time: filters.dateRange?.[1]
})
page.total = filtered.length
const from = (page.current - 1) * page.size
tableData.value = filtered.slice(from, from + page.size)
if (res?.code === 200) {
tableData.value = res.data?.list || []
page.total = Number(res.data?.total || 0)
} else {
ElMessage.error(res?.msg || '获取佣金台账失败')
}
} catch (error: any) {
ElMessage.error(error?.message || '获取佣金台账失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '获取佣金台账失败')
} finally {
loading.value = false
}
@@ -294,11 +267,16 @@ async function handleMarkPaid(row: CommissionRow) {
confirmButtonText: '确认发放'
}
)
// TODO: 接口联通后替换为 markCommissionPaid(row.id, { pay_method: row.pay_method, remark: value })
row.status = 'settled'
row.paid_at = new Date().toLocaleString('zh-CN')
const res: any = await markCommissionPaid(row.id, {
pay_method: row.pay_method || 'manual',
remark: value
})
if (res?.code !== 200) {
ElMessage.error(res?.msg || '标记已付失败')
return
}
ElMessage.success('已标记为已付')
await fetchList()
await Promise.all([fetchList(), fetchStats()])
} catch {
// 取消
}
@@ -309,7 +287,11 @@ function goRules() {
}
function goOrder(row: CommissionRow) {
router.push({ path: ORDER_DETAIL_PATH, query: { outTradeNo: row.out_trade_no } })
if (!row.pay_no) {
ElMessage.warning('该佣金单未关联支付单')
return
}
router.push({ path: ORDER_DETAIL_PATH, query: { payNo: row.pay_no } })
}
/** 金额:分 -> 元 */
@@ -320,7 +302,7 @@ function fenToYuan(fen: number | string | null | undefined): string {
}
onMounted(() => {
fetchList()
Promise.all([fetchList(), fetchStats()])
})
</script>
@@ -196,14 +196,7 @@ import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import { Plus, Edit, Delete, Tickets } from '@element-plus/icons-vue'
// TODO: 接口联调时打开
// import {
// getCommissionRules,
// saveCommissionRule,
// updateCommissionRule,
// deleteCommissionRule,
// toggleCommissionRule
// } from '@/api/payment'
import { getCommissionRules, saveCommissionRule, updateCommissionRule, deleteCommissionRule, toggleCommissionRule } from '@/api/payment'
const router = useRouter()
const loading = ref(false)
@@ -233,51 +226,6 @@ interface RuleRow {
remark: string
}
const ALL_RULES: RuleRow[] = [
{
id: 1,
rule_name: '渠道推广-平台使用费 5%',
calc_type: 'percent',
value: 5,
order_type: 'platform_usage',
status: 1,
remark: '默认规则,适用于全部签约渠道伙伴'
},
{
id: 2,
rule_name: '服务商-模块购买固定 50 元',
calc_type: 'fixed',
value: 5000,
order_type: 'module_shop',
status: 1,
remark: '每笔模块购买订单固定发放'
},
{
id: 3,
rule_name: '阶梯激励-年度大单',
calc_type: 'tiered',
// 阶梯配置入库为 yz_platform_commission_rule.tier_json,接口读出时反序列化为 steps 数组
value: 0,
steps: [
{ min: 0, max: 1000000, rate: 3 },
{ min: 1000000, max: 5000000, rate: 5 },
{ min: 5000000, max: null, rate: 8 }
],
order_type: 'all',
status: 1,
remark: '按订单金额区间取比例'
},
{
id: 4,
rule_name: '老规则-暂停使用',
calc_type: 'percent',
value: 3,
order_type: 'service_fee',
status: 0,
remark: '2025 年规则,已停用'
}
]
const tableData = ref<RuleRow[]>([])
const calcTypeLabel = (type: string) =>
@@ -314,19 +262,19 @@ function valueText(row: RuleRow) {
async function fetchList() {
loading.value = true
try {
// TODO: 接口联通后替换为真实请求
// const res = await getCommissionRules({ page: page.current, pageSize: page.size, keyword: filters.keyword })
// tableData.value = res.data.list || []
// page.total = res.data.total || 0
const filtered = ALL_RULES.filter((item) =>
filters.keyword ? item.rule_name.includes(filters.keyword) : true
)
page.total = filtered.length
const from = (page.current - 1) * page.size
tableData.value = filtered.slice(from, from + page.size)
const res: any = await getCommissionRules({
page: page.current,
pageSize: page.size,
keyword: filters.keyword
})
if (res?.code === 200) {
tableData.value = res.data?.list || []
page.total = Number(res.data?.total || 0)
} else {
ElMessage.error(res?.msg || '获取佣金规则失败')
}
} catch (error: any) {
ElMessage.error(error?.message || '获取佣金规则失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '获取佣金规则失败')
} finally {
loading.value = false
}
@@ -506,10 +454,11 @@ async function handleSubmit() {
}))
}
// TODO: 接口联通后替换为真实请求
// if (isEdit.value && form.id) await updateCommissionRule(form.id, payload)
// else await saveCommissionRule(payload)
await new Promise((resolve) => setTimeout(resolve, 400))
if (isEdit.value && form.id) {
await updateCommissionRule(form.id, payload)
} else {
await saveCommissionRule(payload)
}
ElMessage.success(isEdit.value ? '规则已更新' : '规则已新增')
dialogVisible.value = false
await fetchList()
@@ -522,9 +471,18 @@ async function handleSubmit() {
async function handleStatusChange(row: RuleRow, val: boolean | string | number) {
const next = val ? 1 : 0
// TODO: 接口联通后替换为 toggleCommissionRule(row.id, next)
row.status = next
ElMessage.success(`规则已${next ? '启用' : '停用'}`)
try {
const res: any = await toggleCommissionRule(row.id, next)
if (res?.code !== 200) {
ElMessage.error(res?.msg || '更新规则状态失败')
await fetchList()
return
}
ElMessage.success(`规则已${next ? '启用' : '停用'}`)
} catch (error: any) {
ElMessage.error(error?.response?.data?.msg || error?.message || '更新规则状态失败')
await fetchList()
}
}
async function handleDelete(row: RuleRow) {
@@ -536,11 +494,15 @@ async function handleDelete(row: RuleRow) {
return
}
try {
// TODO: 接口联通后替换为 deleteCommissionRule(row.id)
const res: any = await deleteCommissionRule(row.id)
if (res?.code !== 200) {
ElMessage.error(res?.msg || '删除失败')
return
}
ElMessage.success('删除成功')
await fetchList()
} catch (error: any) {
ElMessage.error(error?.message || '删除失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '删除失败')
}
}
@@ -125,8 +125,7 @@ import { useRoute, useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Refresh } from '@element-plus/icons-vue'
import StatusTag from '../components/StatusTag.vue'
// TODO: 接口联调时打开
// import { getOrderDetail, queryPayment, refundPayment } from '@/api/payment'
import { getOrderDetail, queryPayment, refundPayment } from '@/api/payment'
const route = useRoute()
const router = useRouter()
@@ -194,69 +193,25 @@ const orderTypeLabel = (type: string) => orderTypeMap[type] || type || '-'
/* ---------------- 数据加载 ---------------- */
async function loadDetail() {
const targetPayNo = payNo.value || outTradeNoQuery.value
if (!targetPayNo) {
ElMessage.error('缺少支付单号')
goBack()
return
}
loading.value = true
try {
// TODO: 接口联通后替换为真实请求(后端支持按 payNo 或 outTradeNo 查询)
// const res = await getOrderDetail(payNo.value || outTradeNoQuery.value)
// if (res.success) Object.assign(detail, res.data)
Object.assign(detail, {
pay_no: payNo.value || 'P202609150009',
out_trade_no: outTradeNoQuery.value || 'ORD202609150001',
status: 'paid',
amount: 299900,
currency: 'CNY',
channel: 'wechat',
channel_trade_no: '4200001234202609150987654321',
create_time: '2026-09-15 10:23:12',
paid_at: '2026-09-15 10:24:31',
out_trade_no: 'ORD202609150001',
order_type: 'platform_usage',
tenant_name: '杭州云泽科技有限公司',
tenant_id: 'T10001',
order_amount: 299900,
order_status: 'paid',
subject: '平台使用费 - 2026 年度(标准版)',
merchant_no: '1620888999',
notify_at: '2026-09-15 10:24:33',
notify_url: `${window.location.origin}/api/payment/callback/wechat`,
last_query_at: '2026-09-15 10:25:02',
callback_raw: JSON.stringify(
{
id: 'evt_20260915102431001',
event_type: 'TRANSACTION.SUCCESS',
resource: {
out_trade_no: 'ORD202609150001',
transaction_id: '4200001234202609150987654321',
trade_state: 'SUCCESS',
amount: { total: 299900, payer_total: 299900, currency: 'CNY' }
}
},
null,
2
),
records: [
{
to_status: 'created',
create_time: '2026-09-15 10:23:12',
operator: '租户端下单页',
remark: '创建支付单,渠道:微信支付(Native 扫码)'
},
{
to_status: 'paying',
create_time: '2026-09-15 10:23:35',
operator: '渠道回调',
remark: '用户扫码完成付款,渠道返回支付中'
},
{
to_status: 'paid',
create_time: '2026-09-15 10:24:31',
operator: '渠道回调',
remark: '支付成功,订单金额 299900 分,已同步业务订单状态为已支付'
}
] as RecordItem[]
})
const res: any = await getOrderDetail(targetPayNo)
if (res?.code === 200 && res.data) {
Object.assign(detail, res.data, {
records: res.data.records || []
})
} else {
ElMessage.error(res?.msg || '获取支付单详情失败')
}
} catch (error: any) {
ElMessage.error(error?.message || '获取支付单详情失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '获取支付单详情失败')
} finally {
loading.value = false
}
@@ -266,16 +221,18 @@ async function loadDetail() {
/** 手动查询渠道状态:主动调用渠道查询接口并回写本地状态(兜底回调丢失) */
async function handleQueryChannel() {
if (!detail.pay_no) return
querying.value = true
try {
// TODO: 接口联通后替换为真实请求
// const res = await queryPayment(payNo.value, { sync: true })
await new Promise((resolve) => setTimeout(resolve, 600))
detail.last_query_at = new Date().toLocaleString('zh-CN')
ElMessage.success('渠道状态已查询:SUCCESS(本地状态已同步)')
const res: any = await queryPayment(detail.pay_no, { sync: true })
if (res?.code !== 200) {
ElMessage.error(res?.msg || '查询渠道状态失败')
return
}
ElMessage.success('渠道状态已查询并同步')
await loadDetail()
} catch (error: any) {
ElMessage.error(error?.message || '查询渠道状态失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '查询渠道状态失败')
} finally {
querying.value = false
}
@@ -301,18 +258,19 @@ async function handleManualRefund() {
}
try {
// TODO: 接口联通后替换为真实请求
// await refundPayment({ pay_no: detail.pay_no, amount: detail.amount, reason })
detail.status = 'refunding'
detail.records.unshift({
to_status: 'refunding',
create_time: new Date().toLocaleString('zh-CN'),
operator: '平台管理员',
remark: `手动原路退回:${reason}`
const res: any = await refundPayment({
pay_no: detail.pay_no,
amount: Number(detail.amount),
reason
})
if (res?.code !== 200) {
ElMessage.error(res?.msg || '退回失败')
return
}
ElMessage.success('退回申请已提交,请以渠道退回结果为准')
await loadDetail()
} catch (error: any) {
ElMessage.error(error?.message || '退回失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '退回失败')
}
}
@@ -126,8 +126,8 @@ import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { Refresh } from '@element-plus/icons-vue'
import StatusTag from '../components/StatusTag.vue'
// TODO: 接口联调时打开
// import { getOrders } from '@/api/payment'
import { getOrders } from '@/api/payment'
import { getTenantList } from '@/api/tenant'
const router = useRouter()
const loading = ref(false)
@@ -167,35 +167,30 @@ const statusOptions = [
{ label: '已退款', value: 'refunded' }
]
const tenantOptions = ref([
{ id: 'T10001', name: '杭州云泽科技有限公司' },
{ id: 'T10002', name: '宁波海曙贸易有限公司' },
{ id: 'T10003', name: '上海弘远信息技术有限公司' },
{ id: 'T10004', name: '深圳市博通电子商务有限公司' }
])
const tenantOptions = ref<{ id: string | number; name: string }[]>([])
const channelName = (channel: string) =>
channelOptions.find((i) => i.value === channel)?.label || channel
/** 租户远程搜索:TODO 替换为 getTenantList({ keyword }) */
async function searchTenant(keyword: string) {
tenantLoading.value = true
try {
const all = [
{ id: 'T10001', name: '杭州云泽科技有限公司' },
{ id: 'T10002', name: '宁波海曙贸易有限公司' },
{ id: 'T10003', name: '上海弘远信息技术有限公司' },
{ id: 'T10004', name: '深圳市博通电子商务有限公司' },
{ id: 'T10005', name: '北京中科智联科技有限公司' },
{ id: 'T10006', name: '成都天府软件有限公司' }
]
tenantOptions.value = keyword ? all.filter((i) => i.name.includes(keyword)) : all
const res: any = await getTenantList({ page: 1, pageSize: 50, keyword })
if (res?.code === 200) {
const list = res.data?.list || []
tenantOptions.value = list.map((item: any) => ({
id: item.id,
name: item.name || item.tenant_name || item.company_name || String(item.id)
}))
}
} catch (error: any) {
ElMessage.error(error?.response?.data?.msg || error?.message || '获取租户列表失败')
} finally {
tenantLoading.value = false
}
}
/* ---------------- Mock 数据(本地筛选 + 分页) ---------------- */
/* ---------------- 列表数据 ---------------- */
interface OrderRow {
pay_no: string
@@ -208,68 +203,28 @@ interface OrderRow {
create_time: string
}
const ALL_ORDERS: OrderRow[] = Array.from({ length: 26 }).map((_, index) => {
const channels = ['wechat', 'alipay', 'unionpay', 'cloudpay']
const statuses = ['paid', 'paid', 'paid', 'pending', 'failed', 'closed', 'refunded']
const tenants = [
{ id: 'T10001', name: '杭州云泽科技有限公司' },
{ id: 'T10002', name: '宁波海曙贸易有限公司' },
{ id: 'T10003', name: '上海弘远信息技术有限公司' },
{ id: 'T10004', name: '深圳市博通电子商务有限公司' },
{ id: 'T10005', name: '北京中科智联科技有限公司' },
{ id: 'T10006', name: '成都天府软件有限公司' }
]
const amounts = [99900, 199900, 299900, 499900, 599900]
const tenant = tenants[index % tenants.length]
const day = String(15 - Math.floor(index / 6)).padStart(2, '0')
const hour = String(20 - (index % 12)).padStart(2, '0')
const minute = String((index * 7) % 60).padStart(2, '0')
return {
pay_no: `P202609${day}${String(1000 + index)}`,
out_trade_no: `ORD202609${day}${String(2000 + index)}`,
tenant_id: tenant.id,
tenant_name: tenant.name,
amount: amounts[index % amounts.length],
channel: channels[index % channels.length],
status: statuses[index % statuses.length],
create_time: `2026-09-${day} ${hour}:${minute}:00`
}
})
const tableData = ref<OrderRow[]>([])
async function fetchList() {
loading.value = true
try {
// TODO: 接口联通后替换为真实请求
// const res = await getOrders({
// page: page.current,
// pageSize: page.size,
// tenant_id: filters.tenant_id,
// channel: filters.channel,
// status: filters.status,
// start_time: filters.dateRange?.[0],
// end_time: filters.dateRange?.[1]
// })
// tableData.value = res.data.list || []
// page.total = res.data.total || 0
const [start, end] = filters.dateRange || []
const filtered = ALL_ORDERS.filter((item) => {
if (filters.tenant_id && item.tenant_id !== filters.tenant_id) return false
if (filters.channel && item.channel !== filters.channel) return false
if (filters.status && item.status !== filters.status) return false
const date = item.create_time.slice(0, 10)
if (start && date < start) return false
if (end && date > end) return false
return true
const res: any = await getOrders({
page: page.current,
pageSize: page.size,
tenant_id: filters.tenant_id,
channel: filters.channel,
status: filters.status,
start_time: filters.dateRange?.[0],
end_time: filters.dateRange?.[1]
})
page.total = filtered.length
const from = (page.current - 1) * page.size
tableData.value = filtered.slice(from, from + page.size)
if (res?.code === 200) {
tableData.value = res.data?.list || []
page.total = Number(res.data?.total || 0)
} else {
ElMessage.error(res?.msg || '获取支付订单失败')
}
} catch (error: any) {
ElMessage.error(error?.message || '获取支付订单失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '获取支付订单失败')
} finally {
loading.value = false
}
@@ -151,8 +151,7 @@ import { reactive, ref, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Refresh } from '@element-plus/icons-vue'
import StatusTag from '../components/StatusTag.vue'
// TODO: 接口联调时打开
// import { getReconcileList, markReconcileHandled } from '@/api/payment'
import { getReconcileList, markReconcileHandled } from '@/api/payment'
const loading = ref(false)
@@ -182,7 +181,7 @@ const channelMap: Record<string, string> = {
}
const channelLabel = (channel: string) => channelMap[channel] || channel || '-'
/* ---------------- Mock 数据(本地筛选 + 分页) ---------------- */
/* ---------------- 列表数据 ---------------- */
interface ReconcileRow {
id: number
@@ -197,134 +196,27 @@ interface ReconcileRow {
remark: string
}
const ALL_DIFFS: ReconcileRow[] = [
{
id: 1,
channel: 'wechat',
bill_date: '2026-09-14',
local_trade_no: '',
channel_trade_no: '4200001234202609140011223344',
local_amount: null,
channel_amount: 299900,
diff_type: 'long',
handle_status: 'unhandled',
remark: ''
},
{
id: 2,
channel: 'alipay',
bill_date: '2026-09-14',
local_trade_no: 'P202609140012',
channel_trade_no: '',
local_amount: 99900,
channel_amount: null,
diff_type: 'short',
handle_status: 'unhandled',
remark: ''
},
{
id: 3,
channel: 'wechat',
bill_date: '2026-09-13',
local_trade_no: 'P202609130031',
channel_trade_no: '4200001234202609130055667788',
local_amount: 199900,
channel_amount: 199900,
diff_type: 'status_mismatch',
handle_status: 'handled',
remark: '渠道已成功,本地回调丢失,已手动查询同步为已支付'
},
{
id: 4,
channel: 'unionpay',
bill_date: '2026-09-13',
local_trade_no: 'P202609130028',
channel_trade_no: 'UP2026091300286547',
local_amount: 499900,
channel_amount: 499900,
diff_type: 'status_mismatch',
handle_status: 'handling',
remark: '已联系收单机构核实,等待回复'
},
{
id: 5,
channel: 'alipay',
bill_date: '2026-09-12',
local_trade_no: '',
channel_trade_no: '2026091222001445123456789012',
local_amount: null,
channel_amount: 99900,
diff_type: 'long',
handle_status: 'ignored',
remark: '渠道账单重复记录(已确认同一笔订单),无需处理'
},
{
id: 6,
channel: 'wechat',
bill_date: '2026-09-12',
local_trade_no: 'P202609120009',
channel_trade_no: '',
local_amount: 299900,
channel_amount: null,
diff_type: 'short',
handle_status: 'handled',
remark: '用户超时未支付,本地已置为已关闭'
},
{
id: 7,
channel: 'cloudpay',
bill_date: '2026-09-11',
local_trade_no: 'P202609110004',
channel_trade_no: 'UP2026091100043321',
local_amount: 599900,
channel_amount: 599900,
diff_type: 'status_mismatch',
handle_status: 'handled',
remark: '银联通道时报状态延迟,次日后台查询已一致'
},
{
id: 8,
channel: 'wechat',
bill_date: '2026-09-11',
local_trade_no: 'P202609110002',
channel_trade_no: '4200001234202609110099001122',
local_amount: 199900,
channel_amount: 199800,
diff_type: 'short',
handle_status: 'unhandled',
remark: ''
}
]
const tableData = ref<ReconcileRow[]>([])
async function fetchList() {
loading.value = true
try {
// TODO: 接口联通后替换为真实请求
// const res = await getReconcileList({
// page: page.current,
// pageSize: page.size,
// channel: filters.channel,
// bill_date: filters.bill_date,
// diff_type: filters.diff_type,
// handle_status: filters.handle_status
// })
// tableData.value = res.data.list || []
// page.total = res.data.total || 0
const filtered = ALL_DIFFS.filter((item) => {
if (filters.channel && item.channel !== filters.channel) return false
if (filters.bill_date && item.bill_date !== filters.bill_date) return false
if (filters.diff_type && item.diff_type !== filters.diff_type) return false
if (filters.handle_status && item.handle_status !== filters.handle_status) return false
return true
const res: any = await getReconcileList({
page: page.current,
pageSize: page.size,
channel: filters.channel,
bill_date: filters.bill_date,
diff_type: filters.diff_type,
handle_status: filters.handle_status
})
page.total = filtered.length
const from = (page.current - 1) * page.size
tableData.value = filtered.slice(from, from + page.size)
if (res?.code === 200) {
tableData.value = res.data?.list || []
page.total = Number(res.data?.total || 0)
} else {
ElMessage.error(res?.msg || '获取对账差异失败')
}
} catch (error: any) {
ElMessage.error(error?.message || '获取对账差异失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '获取对账差异失败')
} finally {
loading.value = false
}
@@ -347,13 +239,18 @@ async function handleMarkHandled(row: ReconcileRow) {
}
try {
// TODO: 接口联通后替换为 markReconcileHandled(row.id, { handle_type: 'manual', remark })
row.handle_status = 'handled'
row.remark = remark
const res: any = await markReconcileHandled(row.id, {
handle_status: 'handled',
remark
})
if (res?.code !== 200) {
ElMessage.error(res?.msg || '标记失败')
return
}
ElMessage.success('已标记为已处理')
await fetchList()
} catch (error: any) {
ElMessage.error(error?.message || '标记失败')
ElMessage.error(error?.response?.data?.msg || error?.message || '标记失败')
}
}