fix(order): 支持客服跨站处理订单与退款
This commit is contained in:
@@ -59,3 +59,13 @@ export async function fetchAdminPayments(query: AdminPaymentQuery = {}) {
|
||||
page_size: Number(result?.page_size ?? query.page_size ?? 20),
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchAdminOrderPayments(orderID: string | number, silent = false) {
|
||||
const { data } = await apiClient.get<ApiResponse<{ items: AdminPayment[] }>>(
|
||||
`/admin/orders/${orderID}/payments`,
|
||||
{ silent }
|
||||
)
|
||||
return {
|
||||
items: Array.isArray(data.data?.items) ? data.data.items : [],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
type RefundStatus,
|
||||
} from '@/features/orders'
|
||||
import { adminCreateOrderDispute } from '@/features/disputes'
|
||||
import { fetchAdminPayments, type AdminPayment } from '@/features/admin/api/adminPayments'
|
||||
import { fetchAdminOrderPayments, type AdminPayment } from '@/features/admin/api/adminPayments'
|
||||
import {
|
||||
fetchDisbursementOperators,
|
||||
type ManualEntryOption,
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
} from '@/shared/utils/statusLabels'
|
||||
import { formatDateTime } from '@/shared/utils/time'
|
||||
import { formatGameName, formatListingNo } from '@/shared/utils/listingDisplay'
|
||||
import { useAdminSessionStore } from '@/stores/adminSession'
|
||||
import AdminOrderMetrics, { type AdminOrderMetric } from '../components/AdminOrderMetrics.vue'
|
||||
import AdminOrderPaymentRecords from '../components/AdminOrderPaymentRecords.vue'
|
||||
import OfflineSettlementDialog from '../components/OfflineSettlementDialog.vue'
|
||||
@@ -68,6 +69,7 @@ import {
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const adminSession = useAdminSessionStore()
|
||||
const loading = ref(false)
|
||||
const submitting = ref(false)
|
||||
const order = ref<Order | null>(null)
|
||||
@@ -183,21 +185,19 @@ const platformCheckoutDisputeAction = computed(
|
||||
const offlineSettlementAction = computed(
|
||||
() => order.value?.admin_actions?.platform_offline_settlement
|
||||
)
|
||||
const hasBuyerRole = computed(
|
||||
() => !order.value?.site_role || ['buyer', 'both'].includes(order.value.site_role)
|
||||
)
|
||||
const hasSourceRole = computed(
|
||||
() => !order.value?.site_role || ['source', 'both'].includes(order.value.site_role)
|
||||
)
|
||||
const isSourceOnlyOrder = computed(() => order.value?.site_role === 'source')
|
||||
const canManageBuyerSide = computed(() => adminSession.hasPermission('order:close'))
|
||||
const canMarkAbnormal = computed(() => adminSession.hasPermission('order:mark_abnormal'))
|
||||
const resetActionLabel = computed(() => {
|
||||
return resetAction.value?.label || '重置'
|
||||
})
|
||||
const canResetHandoff = computed(() => hasSourceRole.value && resetAction.value?.enabled === true)
|
||||
const canResetHandoff = computed(() => canMarkAbnormal.value && resetAction.value?.enabled === true)
|
||||
const canPlatformHandoff = computed(
|
||||
() => hasSourceRole.value && platformHandoffAction.value?.enabled === true
|
||||
() => canMarkAbnormal.value && platformHandoffAction.value?.enabled === true
|
||||
)
|
||||
const canForceHandoff = computed(
|
||||
() => hasSourceRole.value && forceHandoffAction.value?.enabled === true
|
||||
() =>
|
||||
adminSession.hasPermission('order:force_handoff') && forceHandoffAction.value?.enabled === true
|
||||
)
|
||||
const forceHandoffNeedsContent = computed(
|
||||
() =>
|
||||
@@ -205,19 +205,22 @@ const forceHandoffNeedsContent = computed(
|
||||
order.value?.handoff_status === 'owner_timeout'
|
||||
)
|
||||
const canPlatformCheckoutConfirm = computed(
|
||||
() => hasBuyerRole.value && platformCheckoutConfirmAction.value?.enabled === true
|
||||
() => canMarkAbnormal.value && platformCheckoutConfirmAction.value?.enabled === true
|
||||
)
|
||||
const canPlatformCheckoutCounter = computed(
|
||||
() => hasBuyerRole.value && platformCheckoutCounterAction.value?.enabled === true
|
||||
() => canMarkAbnormal.value && platformCheckoutCounterAction.value?.enabled === true
|
||||
)
|
||||
const canPlatformCheckoutDispute = computed(
|
||||
() => hasBuyerRole.value && platformCheckoutDisputeAction.value?.enabled === true
|
||||
() => canMarkAbnormal.value && platformCheckoutDisputeAction.value?.enabled === true
|
||||
)
|
||||
const canOfflineSettlement = computed(
|
||||
() => hasSourceRole.value && offlineSettlementAction.value?.enabled === true
|
||||
() => canMarkAbnormal.value && offlineSettlementAction.value?.enabled === true
|
||||
)
|
||||
const canAdminCreateDispute = computed(
|
||||
() => hasBuyerRole.value && canOperate.value && !order.value?.active_dispute
|
||||
() =>
|
||||
adminSession.hasPermission('dispute:arbitrate') &&
|
||||
canOperate.value &&
|
||||
!order.value?.active_dispute
|
||||
)
|
||||
const isPlatformManaged = computed(
|
||||
() =>
|
||||
@@ -236,13 +239,16 @@ const depositHoldAmountCent = computed(() => Number(order.value?.deposit_hold_am
|
||||
const isDepositHeld = computed(() => depositHoldStatus.value === 'held')
|
||||
const canHoldDeposit = computed(
|
||||
() =>
|
||||
hasBuyerRole.value &&
|
||||
adminSession.hasPermission('order:deposit_hold') &&
|
||||
canOperate.value &&
|
||||
depositHoldStatus.value === 'none' &&
|
||||
Number(order.value?.deposit_amount_cent || 0) > 0
|
||||
)
|
||||
const canReleaseDeposit = computed(
|
||||
() => hasBuyerRole.value && isDepositHeld.value && depositHoldAmountCent.value > 0
|
||||
() =>
|
||||
adminSession.hasPermission('order:deposit_hold') &&
|
||||
isDepositHeld.value &&
|
||||
depositHoldAmountCent.value > 0
|
||||
)
|
||||
const depositHoldStatusLabel = computed(() => {
|
||||
switch (depositHoldStatus.value) {
|
||||
@@ -402,7 +408,7 @@ const hasOwnerRentBreakdown = computed(() => ownerCoinBasePriceCent.value !== nu
|
||||
const platformFeeBreakdown = computed(() => orderPlatformFeeBreakdown(order.value))
|
||||
const fundSplitRows = computed(() => {
|
||||
if (!order.value) return []
|
||||
if (!hasBuyerRole.value && hasSourceRole.value) {
|
||||
if (!canManageBuyerSide.value && isSourceOnlyOrder.value) {
|
||||
return [
|
||||
{
|
||||
label: '本站货源结算金额',
|
||||
@@ -487,15 +493,16 @@ async function loadOrder() {
|
||||
loading.value = true
|
||||
try {
|
||||
order.value = await fetchAdminOrder(String(route.params.id))
|
||||
const [handoffs, events] = await Promise.all([
|
||||
const [handoffs, events, payments] = await Promise.all([
|
||||
fetchAdminHandoffRecords(String(route.params.id)),
|
||||
fetchAdminOrderProcessEvents(String(route.params.id)),
|
||||
fetchAdminOrderPayments(String(route.params.id), true).catch(() => ({
|
||||
items: [] as AdminPayment[],
|
||||
})),
|
||||
])
|
||||
handoffRecords.value = handoffs
|
||||
processEvents.value = events
|
||||
paymentRecords.value = hasBuyerRole.value
|
||||
? (await fetchAdminPayments({ order_id: String(route.params.id) })).items
|
||||
: []
|
||||
paymentRecords.value = payments.items
|
||||
await loadRefundStatus()
|
||||
} finally {
|
||||
loading.value = false
|
||||
@@ -503,10 +510,6 @@ async function loadOrder() {
|
||||
}
|
||||
|
||||
async function loadRefundStatus() {
|
||||
if (!hasBuyerRole.value) {
|
||||
refundStatus.value = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
refundStatus.value = await adminRefundStatus(Number(route.params.id))
|
||||
} catch {
|
||||
@@ -1086,17 +1089,21 @@ function formatRatioNumber(value: number) {
|
||||
<el-button v-if="canAdminCreateDispute" type="warning" plain @click="openAdminDispute">
|
||||
发起申诉
|
||||
</el-button>
|
||||
<el-button type="warning" :disabled="!canOperate" @click="openAction('abnormal')"
|
||||
<el-button
|
||||
v-if="canMarkAbnormal"
|
||||
type="warning"
|
||||
:disabled="!canOperate"
|
||||
@click="openAction('abnormal')"
|
||||
>标记异常</el-button
|
||||
>
|
||||
<el-tooltip v-if="hasBuyerRole" :content="closeActionTip" placement="top">
|
||||
<el-tooltip v-if="canManageBuyerSide" :content="closeActionTip" placement="top">
|
||||
<span>
|
||||
<el-button type="danger" :disabled="!canOperate" @click="confirmCloseAction"
|
||||
>客服关闭</el-button
|
||||
>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="hasBuyerRole" :content="sealActionTip" placement="top">
|
||||
<el-tooltip v-if="canManageBuyerSide" :content="sealActionTip" placement="top">
|
||||
<span>
|
||||
<el-button type="danger" plain :disabled="!canOperate" @click="confirmSealAction"
|
||||
>封存订单</el-button
|
||||
@@ -1109,7 +1116,7 @@ function formatRatioNumber(value: number) {
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
v-if="isDepositHeld && hasBuyerRole"
|
||||
v-if="isDepositHeld && canReleaseDeposit"
|
||||
:content="depositReleaseActionTip"
|
||||
placement="top"
|
||||
>
|
||||
@@ -1124,7 +1131,7 @@ function formatRatioNumber(value: number) {
|
||||
</el-button>
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="hasBuyerRole" :content="refundActionTip" placement="top">
|
||||
<el-tooltip v-if="canManageBuyerSide" :content="refundActionTip" placement="top">
|
||||
<span>
|
||||
<el-button
|
||||
type="primary"
|
||||
@@ -1306,7 +1313,7 @@ function formatRatioNumber(value: number) {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="hasBuyerRole" class="dashboard-panel detail-panel">
|
||||
<section v-if="canManageBuyerSide" class="dashboard-panel detail-panel">
|
||||
<div class="panel-heading">
|
||||
<h2>退款概况</h2>
|
||||
<el-tag :type="refundStatusType(refundStatus?.refund_status || '')" effect="light">
|
||||
@@ -1462,7 +1469,7 @@ function formatRatioNumber(value: number) {
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<AdminOrderPaymentRecords v-if="hasBuyerRole" :records="paymentRecords" />
|
||||
<AdminOrderPaymentRecords :records="paymentRecords" />
|
||||
|
||||
<section class="dashboard-panel detail-panel order-wide-panel">
|
||||
<div class="panel-heading">
|
||||
|
||||
Reference in New Issue
Block a user