接入订单结账确认流程
This commit is contained in:
@@ -21,6 +21,30 @@ export interface Order {
|
||||
status: string
|
||||
handoff_status: string
|
||||
settlement_status: string
|
||||
checkout?: Checkout
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface Checkout {
|
||||
id: number
|
||||
order_id: number
|
||||
initiated_by: number
|
||||
status: string
|
||||
rent_amount: number
|
||||
deposit_amount: number
|
||||
consumable_amount: number
|
||||
coin_consumed_m: number
|
||||
other_amount: number
|
||||
deposit_deduct_amount: number
|
||||
renter_refund_amount: number
|
||||
owner_income_amount: number
|
||||
content: string
|
||||
evidence_urls: string[]
|
||||
owner_adjustment_reason: string
|
||||
owner_adjusted_at?: string
|
||||
renter_confirmed_at?: string
|
||||
renter_rejected_at?: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
@@ -37,6 +61,23 @@ export interface HandoffRecord {
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface SubmitCheckoutPayload {
|
||||
content: string
|
||||
consumable_amount: number
|
||||
coin_consumed_m: number
|
||||
other_amount: number
|
||||
evidence_urls: string[]
|
||||
}
|
||||
|
||||
export interface CounterCheckoutPayload {
|
||||
consumable_amount: number
|
||||
coin_consumed_m: number
|
||||
other_amount: number
|
||||
deposit_deduct_amount: number
|
||||
reason: string
|
||||
evidence_urls: string[]
|
||||
}
|
||||
|
||||
interface ApiResponse<T> {
|
||||
code: string
|
||||
message: string
|
||||
@@ -119,3 +160,23 @@ export async function confirmReturn(id: number) {
|
||||
const { data } = await apiClient.post<ApiResponse<{ completed: boolean }>>(`/orders/${id}/confirm-return`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function submitCheckout(id: number, payload: SubmitCheckoutPayload) {
|
||||
const { data } = await apiClient.post<ApiResponse<HandoffRecord>>(`/orders/${id}/checkout`, payload)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function confirmCheckout(id: number) {
|
||||
const { data } = await apiClient.post<ApiResponse<{ completed: boolean }>>(`/orders/${id}/checkout/confirm`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function counterCheckout(id: number, payload: CounterCheckoutPayload) {
|
||||
const { data } = await apiClient.post<ApiResponse<Checkout>>(`/orders/${id}/checkout/counter`, payload)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function acceptCheckout(id: number) {
|
||||
const { data } = await apiClient.post<ApiResponse<{ completed: boolean }>>(`/orders/${id}/checkout/accept`)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ const orderStatusMap: Record<string, string> = {
|
||||
pending_handoff: '待交接',
|
||||
renting: '使用中',
|
||||
overdue: '已逾期',
|
||||
pending_return_confirm: '待归还确认',
|
||||
pending_return_confirm: '待结账确认',
|
||||
pending_checkout_confirm: '待号主确认结账',
|
||||
pending_checkout_accept: '待租客确认修正',
|
||||
checkout_disputing: '结账争议中',
|
||||
completed: '已完成',
|
||||
cancelled: '已取消',
|
||||
closed: '已关闭',
|
||||
@@ -31,13 +34,17 @@ const handoffStatusMap: Record<string, string> = {
|
||||
pending_owner: '待号主交接',
|
||||
pending_renter_confirm: '待租客确认',
|
||||
received: '已确认收号',
|
||||
pending_owner_return_confirm: '待号主确认归还',
|
||||
pending_owner_return_confirm: '待号主确认结账',
|
||||
pending_owner_checkout: '待号主确认结账',
|
||||
pending_renter_checkout: '待租客确认修正',
|
||||
checkout_disputed: '结账争议中',
|
||||
returned: '已归还',
|
||||
cancelled: '已取消',
|
||||
owner_timeout: '号主交接超时',
|
||||
renter_confirm_timeout: '租客确认超时',
|
||||
return_overdue: '归还逾期',
|
||||
owner_return_confirm_timeout: '号主确认归还超时',
|
||||
owner_return_confirm_timeout: '号主确认结账超时',
|
||||
owner_checkout_confirm_timeout: '号主确认结账超时',
|
||||
admin_closed: '客服关闭',
|
||||
admin_abnormal: '客服标记异常',
|
||||
arbitrated: '已仲裁',
|
||||
@@ -51,6 +58,7 @@ const settlementStatusMap: Record<string, string> = {
|
||||
refunded: '已退款',
|
||||
cancelled: '已取消',
|
||||
closed: '已关闭',
|
||||
disputed: '争议中',
|
||||
arbitrated: '已仲裁',
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,16 @@ import { useRoute, useRouter } from 'vue-router'
|
||||
import { createDispute } from '@/api/disputes'
|
||||
import { uploadFile } from '@/api/files'
|
||||
import {
|
||||
acceptCheckout,
|
||||
cancelOrder,
|
||||
confirmCheckout,
|
||||
confirmReceive,
|
||||
confirmReturn,
|
||||
counterCheckout,
|
||||
fetchHandoffRecords,
|
||||
fetchOrder,
|
||||
payOrder,
|
||||
submitCheckout,
|
||||
submitHandoff,
|
||||
submitReturn,
|
||||
type HandoffRecord,
|
||||
type Order,
|
||||
} from '@/api/orders'
|
||||
@@ -31,12 +33,30 @@ const handoffing = ref(false)
|
||||
const confirming = ref(false)
|
||||
const returning = ref(false)
|
||||
const completing = ref(false)
|
||||
const countering = ref(false)
|
||||
const acceptingCheckout = ref(false)
|
||||
const rejectingCheckout = ref(false)
|
||||
const disputing = ref(false)
|
||||
const uploadingEvidence = ref(false)
|
||||
const order = ref<Order | null>(null)
|
||||
const handoffRecords = ref<HandoffRecord[]>([])
|
||||
const handoffContent = ref('')
|
||||
const returnContent = ref('')
|
||||
const checkoutForm = ref({
|
||||
content: '',
|
||||
consumable_amount: 0,
|
||||
coin_consumed_m: 0,
|
||||
other_amount: 0,
|
||||
evidenceText: '',
|
||||
})
|
||||
const counterForm = ref({
|
||||
consumable_amount: 0,
|
||||
coin_consumed_m: 0,
|
||||
other_amount: 0,
|
||||
deposit_deduct_amount: 0,
|
||||
reason: '',
|
||||
evidenceText: '',
|
||||
})
|
||||
const rejectReason = ref('')
|
||||
const disputeType = ref('cannot_login')
|
||||
const disputeDescription = ref('')
|
||||
const disputeEvidenceText = ref('')
|
||||
@@ -45,7 +65,10 @@ const isOwner = computed(() => order.value?.owner_id === session.userId)
|
||||
const isRenter = computed(() => order.value?.renter_id === session.userId)
|
||||
const canOpenDispute = computed(() => {
|
||||
if (!order.value || (!isOwner.value && !isRenter.value)) return false
|
||||
return !['completed', 'cancelled', 'closed', 'disputing'].includes(order.value.status)
|
||||
return !['completed', 'cancelled', 'closed', 'disputing', 'checkout_disputing', 'abnormal'].includes(order.value.status)
|
||||
})
|
||||
const isCheckoutDisputeStage = computed(() => {
|
||||
return !!order.value && ['pending_checkout_confirm', 'pending_checkout_accept'].includes(order.value.status)
|
||||
})
|
||||
|
||||
onMounted(loadOrder)
|
||||
@@ -55,6 +78,7 @@ async function loadOrder() {
|
||||
try {
|
||||
order.value = await fetchOrder(String(route.params.id))
|
||||
handoffRecords.value = await fetchHandoffRecords(String(route.params.id))
|
||||
hydrateCounterForm()
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
@@ -117,45 +141,108 @@ async function handleConfirmReceive() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSubmitReturn() {
|
||||
async function handleSubmitCheckout() {
|
||||
if (!order.value) return
|
||||
returning.value = true
|
||||
try {
|
||||
await submitReturn(order.value.id, returnContent.value)
|
||||
returnContent.value = ''
|
||||
ElMessage.success('归还申请已提交,等待号主确认')
|
||||
await submitCheckout(order.value.id, {
|
||||
content: checkoutForm.value.content,
|
||||
consumable_amount: checkoutForm.value.consumable_amount,
|
||||
coin_consumed_m: checkoutForm.value.coin_consumed_m,
|
||||
other_amount: checkoutForm.value.other_amount,
|
||||
evidence_urls: linesToList(checkoutForm.value.evidenceText),
|
||||
})
|
||||
checkoutForm.value = {
|
||||
content: '',
|
||||
consumable_amount: 0,
|
||||
coin_consumed_m: 0,
|
||||
other_amount: 0,
|
||||
evidenceText: '',
|
||||
}
|
||||
ElMessage.success('结账已发起,等待号主确认')
|
||||
await loadOrder()
|
||||
} catch (error) {
|
||||
ElMessage.error(readError(error, '提交归还失败'))
|
||||
ElMessage.error(readError(error, '发起结账失败'))
|
||||
} finally {
|
||||
returning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleConfirmReturn() {
|
||||
async function handleConfirmCheckout() {
|
||||
if (!order.value) return
|
||||
completing.value = true
|
||||
try {
|
||||
await confirmReturn(order.value.id)
|
||||
ElMessage.success('归还已确认,订单完成')
|
||||
await confirmCheckout(order.value.id)
|
||||
ElMessage.success('结账已确认,订单完成')
|
||||
await loadOrder()
|
||||
} catch (error) {
|
||||
ElMessage.error(readError(error, '确认归还失败'))
|
||||
ElMessage.error(readError(error, '确认结账失败'))
|
||||
} finally {
|
||||
completing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCounterCheckout() {
|
||||
if (!order.value) return
|
||||
countering.value = true
|
||||
try {
|
||||
await counterCheckout(order.value.id, {
|
||||
consumable_amount: counterForm.value.consumable_amount,
|
||||
coin_consumed_m: counterForm.value.coin_consumed_m,
|
||||
other_amount: counterForm.value.other_amount,
|
||||
deposit_deduct_amount: counterForm.value.deposit_deduct_amount,
|
||||
reason: counterForm.value.reason,
|
||||
evidence_urls: linesToList(counterForm.value.evidenceText),
|
||||
})
|
||||
ElMessage.success('结账修正已提交,等待租客确认')
|
||||
await loadOrder()
|
||||
} catch (error) {
|
||||
ElMessage.error(readError(error, '修改结账失败'))
|
||||
} finally {
|
||||
countering.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAcceptCheckout() {
|
||||
if (!order.value) return
|
||||
acceptingCheckout.value = true
|
||||
try {
|
||||
await acceptCheckout(order.value.id)
|
||||
ElMessage.success('已确认修正结账,订单完成')
|
||||
await loadOrder()
|
||||
} catch (error) {
|
||||
ElMessage.error(readError(error, '确认修正失败'))
|
||||
} finally {
|
||||
acceptingCheckout.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRejectCheckout() {
|
||||
if (!order.value) return
|
||||
rejectingCheckout.value = true
|
||||
try {
|
||||
await createDispute(order.value.id, {
|
||||
type: 'checkout_dispute',
|
||||
description: rejectReason.value,
|
||||
evidence_urls: [],
|
||||
})
|
||||
rejectReason.value = ''
|
||||
ElMessage.success('已拒绝修正结账,订单进入争议处理')
|
||||
await loadOrder()
|
||||
} catch (error) {
|
||||
ElMessage.error(readError(error, '拒绝修正失败'))
|
||||
} finally {
|
||||
rejectingCheckout.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCreateDispute() {
|
||||
if (!order.value) return
|
||||
disputing.value = true
|
||||
try {
|
||||
const evidence_urls = disputeEvidenceText.value
|
||||
.split('\n')
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
const evidence_urls = linesToList(disputeEvidenceText.value)
|
||||
await createDispute(order.value.id, {
|
||||
type: disputeType.value,
|
||||
type: isCheckoutDisputeStage.value ? 'checkout_dispute' : disputeType.value,
|
||||
description: disputeDescription.value,
|
||||
evidence_urls,
|
||||
})
|
||||
@@ -194,6 +281,22 @@ function readError(error: unknown, fallback: string) {
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
function hydrateCounterForm() {
|
||||
if (!order.value?.checkout) return
|
||||
const checkout = order.value.checkout
|
||||
counterForm.value.consumable_amount = checkout.consumable_amount
|
||||
counterForm.value.coin_consumed_m = checkout.coin_consumed_m
|
||||
counterForm.value.other_amount = checkout.other_amount
|
||||
counterForm.value.deposit_deduct_amount = checkout.deposit_deduct_amount
|
||||
}
|
||||
|
||||
function linesToList(value: string) {
|
||||
return value
|
||||
.split('\n')
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -261,20 +364,59 @@ function readError(error: unknown, fallback: string) {
|
||||
</div>
|
||||
|
||||
<div v-if="order && isRenter && ['renting', 'overdue'].includes(order.status)" class="order-panel">
|
||||
<h2>提交归还</h2>
|
||||
<el-input v-model="returnContent" type="textarea" :rows="4" placeholder="填写归还说明、租后资产状态或注意事项" />
|
||||
<el-button class="panel-action" type="primary" :loading="returning" @click="handleSubmitReturn">提交归还</el-button>
|
||||
<h2>发起结账</h2>
|
||||
<el-input v-model="checkoutForm.content" type="textarea" :rows="4" placeholder="填写结账说明、租后资产状态或注意事项" />
|
||||
<div class="form-grid panel-action">
|
||||
<el-input-number v-model="checkoutForm.consumable_amount" class="full-control" :min="0" :precision="2" controls-position="right" placeholder="消耗扣款" />
|
||||
<el-input-number v-model="checkoutForm.coin_consumed_m" class="full-control" :min="0" :precision="2" controls-position="right" placeholder="消耗哈夫币 M" />
|
||||
<el-input-number v-model="checkoutForm.other_amount" class="full-control" :min="0" :precision="2" controls-position="right" placeholder="其他扣款" />
|
||||
</div>
|
||||
<el-input
|
||||
v-model="checkoutForm.evidenceText"
|
||||
class="panel-action"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="结账证据链接,一行一个。可填写截图地址或备注链接"
|
||||
/>
|
||||
<el-button class="panel-action" type="primary" :loading="returning" @click="handleSubmitCheckout">发起结账</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="order && isOwner && order.status === 'pending_return_confirm'" class="order-panel">
|
||||
<h2>确认归还</h2>
|
||||
<p>确认账号状态无误后,订单会完成,账号重新上架。</p>
|
||||
<el-button type="primary" :loading="completing" @click="handleConfirmReturn">确认归还并完成订单</el-button>
|
||||
<div v-if="order && order.checkout && ['pending_checkout_confirm', 'pending_checkout_accept'].includes(order.status)" class="order-panel">
|
||||
<h2>结账明细</h2>
|
||||
<p>租金:¥{{ order.checkout.rent_amount }},押金:¥{{ order.checkout.deposit_amount }}</p>
|
||||
<p>扣除:¥{{ order.checkout.deposit_deduct_amount }},退还租客:¥{{ order.checkout.renter_refund_amount }},号主收入:¥{{ order.checkout.owner_income_amount }}</p>
|
||||
<p v-if="order.checkout.content">说明:{{ order.checkout.content }}</p>
|
||||
<p v-if="order.checkout.owner_adjustment_reason">修正原因:{{ order.checkout.owner_adjustment_reason }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="order && isOwner && order.status === 'pending_checkout_confirm'" class="order-panel">
|
||||
<h2>确认结账</h2>
|
||||
<p>确认账号状态和扣款金额无误后,订单会完成,账号重新上架。</p>
|
||||
<el-button type="primary" :loading="completing" @click="handleConfirmCheckout">确认结账并完成订单</el-button>
|
||||
|
||||
<h2 class="panel-action">修改结账</h2>
|
||||
<div class="form-grid">
|
||||
<el-input-number v-model="counterForm.consumable_amount" class="full-control" :min="0" :precision="2" controls-position="right" placeholder="消耗扣款" />
|
||||
<el-input-number v-model="counterForm.coin_consumed_m" class="full-control" :min="0" :precision="2" controls-position="right" placeholder="消耗哈夫币 M" />
|
||||
<el-input-number v-model="counterForm.other_amount" class="full-control" :min="0" :precision="2" controls-position="right" placeholder="其他扣款" />
|
||||
<el-input-number v-model="counterForm.deposit_deduct_amount" class="full-control" :min="0" :max="order.deposit_amount" :precision="2" controls-position="right" placeholder="押金扣除" />
|
||||
</div>
|
||||
<el-input v-model="counterForm.reason" class="panel-action" type="textarea" :rows="3" placeholder="填写修改原因" />
|
||||
<el-input v-model="counterForm.evidenceText" class="panel-action" type="textarea" :rows="3" placeholder="修正证据链接,一行一个" />
|
||||
<el-button class="panel-action" type="warning" :loading="countering" @click="handleCounterCheckout">提交修正给租客确认</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="order && isRenter && order.status === 'pending_checkout_accept'" class="order-panel">
|
||||
<h2>确认修正结账</h2>
|
||||
<p>同意后订单会完成结算;不同意会进入争议,由客服仲裁。</p>
|
||||
<el-button type="primary" :loading="acceptingCheckout" @click="handleAcceptCheckout">同意修正并完成订单</el-button>
|
||||
<el-input v-model="rejectReason" class="panel-action" type="textarea" :rows="3" placeholder="不同意时填写原因,会进入争议处理" />
|
||||
<el-button class="panel-action" type="danger" :loading="rejectingCheckout" @click="handleRejectCheckout">拒绝修正并发起争议</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="order && canOpenDispute" class="order-panel">
|
||||
<h2>发起申诉</h2>
|
||||
<el-select v-model="disputeType" class="full-control" placeholder="选择申诉类型">
|
||||
<h2>{{ isCheckoutDisputeStage ? '发起结账争议' : '发起申诉' }}</h2>
|
||||
<el-select v-if="!isCheckoutDisputeStage" v-model="disputeType" class="full-control" placeholder="选择申诉类型">
|
||||
<el-option label="无法登录" value="cannot_login" />
|
||||
<el-option label="虚假描述" value="false_description" />
|
||||
<el-option label="账号被封" value="account_banned" />
|
||||
@@ -300,7 +442,9 @@ function readError(error: unknown, fallback: string) {
|
||||
<div class="panel-action upload-line">
|
||||
<input type="file" accept="image/jpeg,image/png,image/webp,application/pdf" :disabled="uploadingEvidence" @change="handleEvidenceUpload" />
|
||||
</div>
|
||||
<el-button class="panel-action" type="warning" :loading="disputing" @click="handleCreateDispute">提交申诉</el-button>
|
||||
<el-button class="panel-action" type="warning" :loading="disputing" @click="handleCreateDispute">
|
||||
{{ isCheckoutDisputeStage ? '提交结账争议' : '提交申诉' }}
|
||||
</el-button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -40,7 +40,10 @@ async function loadOrders() {
|
||||
<el-option label="待交接" value="pending_handoff" />
|
||||
<el-option label="使用中" value="renting" />
|
||||
<el-option label="逾期中" value="overdue" />
|
||||
<el-option label="待归还确认" value="pending_return_confirm" />
|
||||
<el-option label="待结账确认" value="pending_return_confirm" />
|
||||
<el-option label="待号主确认结账" value="pending_checkout_confirm" />
|
||||
<el-option label="待租客确认修正" value="pending_checkout_accept" />
|
||||
<el-option label="结账争议中" value="checkout_disputing" />
|
||||
<el-option label="申诉中" value="disputing" />
|
||||
<el-option label="异常" value="abnormal" />
|
||||
<el-option label="已完成" value="completed" />
|
||||
|
||||
@@ -38,7 +38,7 @@ const statusTabs = [
|
||||
{ key: "pending_payment", label: "待支付" },
|
||||
{ key: "pending_handoff", label: "待交接" },
|
||||
{ key: "renting", label: "使用中" },
|
||||
{ key: "pending_return_confirm", label: "待归还" },
|
||||
{ key: "pending_checkout_confirm", label: "待结账" },
|
||||
{ key: "completed", label: "已完成" },
|
||||
];
|
||||
|
||||
@@ -55,6 +55,9 @@ function statusColor(status: string) {
|
||||
renting: "#1477ff",
|
||||
overdue: "#e91e63",
|
||||
pending_return_confirm: "#e91e63",
|
||||
pending_checkout_confirm: "#e91e63",
|
||||
pending_checkout_accept: "#9c27b0",
|
||||
checkout_disputing: "#f44336",
|
||||
completed: "#4caf50",
|
||||
cancelled: "#999",
|
||||
disputing: "#f44336",
|
||||
@@ -70,7 +73,10 @@ function statusLabel(status: string) {
|
||||
pending_handoff: "待交接",
|
||||
renting: "使用中",
|
||||
overdue: "已逾期",
|
||||
pending_return_confirm: "待归还",
|
||||
pending_return_confirm: "待结账",
|
||||
pending_checkout_confirm: "待号主确认结账",
|
||||
pending_checkout_accept: "待租客确认修正",
|
||||
checkout_disputing: "结账争议中",
|
||||
completed: "已完成",
|
||||
cancelled: "已取消",
|
||||
disputing: "申诉中",
|
||||
|
||||
Reference in New Issue
Block a user