feat(admin): 订单详情展示支付渠道并支持查询退款
- 订单详情展示支付渠道与退款中状态,提供查询退款结果兜底入口 - 操作按钮按取消状态收敛,已申请取消时仅保留同意取消 - 存在未支付流水时锁定金额输入,避免改价与在途支付冲突 - utils/api.js 新增退款查询接口
This commit is contained in:
@@ -19,10 +19,19 @@ const STATUS_DESC_MAP = {
|
||||
cancelled: '订单已取消'
|
||||
}
|
||||
|
||||
// 取消与 status 解耦:展示状态优先取 cancelStatus
|
||||
function resolveDisplayStatus(order) {
|
||||
const cancelStatus = order?.cancelStatus || 'none'
|
||||
if (cancelStatus === 'cancelled') return 'cancelled'
|
||||
if (cancelStatus === 'requested') return 'cancel_requested'
|
||||
return order?.status || 'pending'
|
||||
}
|
||||
|
||||
const PAYMENT_STATUS_MAP = {
|
||||
unpaid: '未支付',
|
||||
partial: '部分支付',
|
||||
paid: '已支付',
|
||||
refunding: '退款中',
|
||||
refunded: '已退款'
|
||||
}
|
||||
|
||||
@@ -33,6 +42,12 @@ const PAYMENT_METHOD_MAP = {
|
||||
offline_transfer: '线下转账'
|
||||
}
|
||||
|
||||
// 支付渠道:用户下单时的选择,历史订单缺失按线下解释
|
||||
const PAY_CHANNEL_MAP = {
|
||||
online_wechat: '微信支付',
|
||||
offline: '线下支付'
|
||||
}
|
||||
|
||||
function formatDate(timestamp) {
|
||||
if (!timestamp) return ''
|
||||
const date = new Date(timestamp)
|
||||
@@ -72,6 +87,9 @@ Page({
|
||||
updatetimeText: '',
|
||||
paymentStatusText: '',
|
||||
paymentMethodText: '',
|
||||
payChannelText: '',
|
||||
showQueryRefundBtn: false,
|
||||
queryingRefund: false,
|
||||
attendantSexText: '',
|
||||
sexRequirementText: '',
|
||||
// 操作按钮配置
|
||||
@@ -121,7 +139,8 @@ Page({
|
||||
},
|
||||
|
||||
applyOrderData(order) {
|
||||
const status = order.status || 'pending'
|
||||
const cancelStatus = order.cancelStatus || 'none'
|
||||
const status = resolveDisplayStatus(order)
|
||||
const attendant = order.attendant || {}
|
||||
const schedule = order.schedule || {}
|
||||
const payment = order.payment || {}
|
||||
@@ -135,6 +154,7 @@ Page({
|
||||
healthProfileId: order.healthProfileId || '',
|
||||
statusText: STATUS_MAP[status] || status,
|
||||
statusDesc: STATUS_DESC_MAP[status] || '',
|
||||
statusClass: status,
|
||||
attendantFirstChar: (attendant.name || '?')[0],
|
||||
scheduleDateText: formatDate(schedule.date),
|
||||
scheduleStartTimeText: schedule.startTime || '',
|
||||
@@ -143,15 +163,20 @@ Page({
|
||||
updatetimeText: formatDateTime(meta.updatetime),
|
||||
paymentStatusText: PAYMENT_STATUS_MAP[payment.status] || payment.status || '未支付',
|
||||
paymentMethodText: PAYMENT_METHOD_MAP[payment.method] || '',
|
||||
payChannelText: PAY_CHANNEL_MAP[payment.payChannel || 'offline'] || '',
|
||||
// 退款回调丢失时由管理端主动查退款补写终态
|
||||
showQueryRefundBtn: payment.status === 'refunding',
|
||||
queryingRefund: false,
|
||||
attendantSexText: attendant.sex === 'male' ? '男' : attendant.sex === 'female' ? '女' : '',
|
||||
sexRequirementText: escort.sexRequirement === 'male' ? '要求男陪诊' : escort.sexRequirement === 'female' ? '要求女陪诊' : '不限',
|
||||
// 操作按钮(任何状态下均可编辑订单信息)
|
||||
showEditBtn: true,
|
||||
showConfirmBtn: status === 'pending',
|
||||
showCancelBtn: status === 'pending' || status === 'confirmed' || status === 'cancel_requested',
|
||||
cancelBtnText: status === 'cancel_requested' ? '同意取消' : '取消订单',
|
||||
showStartBtn: status === 'confirmed',
|
||||
showCompleteBtn: status === 'in_progress'
|
||||
showConfirmBtn: cancelStatus === 'none' && status === 'pending',
|
||||
showCancelBtn: cancelStatus === 'requested'
|
||||
|| (cancelStatus === 'none' && (status === 'pending' || status === 'confirmed')),
|
||||
cancelBtnText: cancelStatus === 'requested' ? '同意取消' : '取消订单',
|
||||
showStartBtn: cancelStatus === 'none' && status === 'confirmed',
|
||||
showCompleteBtn: cancelStatus === 'none' && status === 'in_progress'
|
||||
})
|
||||
},
|
||||
|
||||
@@ -240,6 +265,33 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 主动查询退款结果:退款回调丢失时补写终态
|
||||
async onQueryRefund() {
|
||||
if (this.data.queryingRefund) return
|
||||
this.setData({ queryingRefund: true })
|
||||
wx.showLoading({ title: '查询中...' })
|
||||
try {
|
||||
const res = await API.escort.queryRefund(this.data.orderId)
|
||||
wx.hideLoading()
|
||||
if (res.code !== 0) {
|
||||
wx.showToast({ title: res.msg || '查询失败', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const status = res.data?.refund?.status
|
||||
wx.showToast({
|
||||
title: status === 'success' ? '退款已成功' : '查询完成',
|
||||
icon: status === 'success' ? 'success' : 'none'
|
||||
})
|
||||
this.loadOrderDetail(this.data.orderId)
|
||||
} catch (err) {
|
||||
wx.hideLoading()
|
||||
console.error('查询退款结果失败', err)
|
||||
wx.showToast({ title: '网络错误', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ queryingRefund: false })
|
||||
}
|
||||
},
|
||||
|
||||
async updateStatus(newStatus) {
|
||||
wx.showLoading({ title: '处理中...' })
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user