fix(order): 修复超时与异常过渡态下的状态机流转及权限断层

This commit is contained in:
yml2213
2026-09-09 16:15:21 +08:00
parent 17d4f7be9e
commit 8b7a0c8059
9 changed files with 267 additions and 43 deletions
@@ -189,13 +189,13 @@ export function useOrderActions(options: UseOrderActionsOptions) {
)
const canOpenDispute = computed(() => {
if (!order.value || (!isOwner.value && !isRenter.value)) return false
if (order.value.active_dispute) return false
return ![
'completed',
'cancelled',
'closed',
'disputing',
'checkout_disputing',
'abnormal',
].includes(order.value.status)
})
const canCounterCheckout = computed(() => {
@@ -208,8 +208,15 @@ export function useOrderActions(options: UseOrderActionsOptions) {
if (typeof order.value.checkout.can_accept === 'boolean') {
return order.value.checkout.can_accept
}
const isOwnerPending =
isOwner.value &&
(order.value.status === 'pending_checkout_confirm' ||
(order.value.status === 'abnormal' &&
(order.value.handoff_status === 'owner_checkout_confirm_timeout' ||
order.value.handoff_status === 'owner_return_confirm_timeout' ||
order.value.handoff_status === 'pending_owner_checkout')))
return (
(isOwner.value && order.value.status === 'pending_checkout_confirm') ||
isOwnerPending ||
(isRenter.value && order.value.status === 'pending_checkout_accept')
)
})
@@ -121,11 +121,21 @@ const {
const showDisputePopup = ref(false)
const showCounterPopup = ref(false)
const showRejectPopup = ref(false)
const isOwnerCheckoutPending = computed(() => {
if (!order.value || !isOwner.value) return false
return (
order.value.status === 'pending_checkout_confirm' ||
(order.value.status === 'abnormal' &&
(order.value.handoff_status === 'owner_checkout_confirm_timeout' ||
order.value.handoff_status === 'owner_return_confirm_timeout' ||
order.value.handoff_status === 'pending_owner_checkout'))
)
})
const showCheckoutCounterAction = computed(
() =>
!!order.value &&
canCounterCheckout.value &&
((isOwner.value && order.value.status === 'pending_checkout_confirm') ||
(isOwnerCheckoutPending.value ||
(isRenter.value && order.value.status === 'pending_checkout_accept'))
)
@@ -263,12 +273,21 @@ async function copyListingCode() {
<!-- Handoff Panel: Owner Handoff Info Submission -->
<section
v-if="
isOwner && order.status === 'pending_handoff' && order.handoff_status === 'pending_owner'
isOwner &&
(order.status === 'pending_handoff' || order.status === 'abnormal') &&
(order.handoff_status === 'pending_owner' || order.handoff_status === 'owner_timeout')
"
class="card-section action-card"
>
<h3 class="section-title">提交交接说明</h3>
<p class="action-hint">提交登录所需的账号密码、密保注意事项或扫码交接联系方式。</p>
<p
v-if="order.handoff_status === 'owner_timeout'"
class="action-hint"
style="color: #e6a23c; font-weight: 500"
>
当前交接已超时,请尽快补提交交接说明避免订单被关闭。
</p>
<p v-else class="action-hint">提交登录所需的账号密码、密保注意事项或扫码交接联系方式。</p>
<van-field
v-model="handoffContent"
rows="3"
@@ -354,12 +373,14 @@ async function copyListingCode() {
<OrderCheckoutSummary
v-if="
order.checkout &&
[
'pending_checkout_confirm',
'pending_checkout_accept',
'checkout_disputing',
'completed',
].includes(order.status)
(
[
'pending_checkout_confirm',
'pending_checkout_accept',
'checkout_disputing',
'completed',
].includes(order.status) || order.status === 'abnormal'
)
"
variant="mobile"
:order="order"
@@ -369,11 +390,18 @@ async function copyListingCode() {
<!-- Owner Action: Confirm Checkout / Make Counter Adjustment Proposal -->
<section
v-if="isOwner && order.status === 'pending_checkout_confirm'"
v-if="isOwnerCheckoutPending"
class="card-section action-card"
>
<h3 class="section-title">结账处理</h3>
<p class="action-hint">
<p
v-if="order.handoff_status === 'owner_checkout_confirm_timeout'"
class="action-hint"
style="color: #e6a23c; font-weight: 500"
>
结账确认已超时,你可以直接同意当前方案完结,或修改方案交对方确认。
</p>
<p v-else class="action-hint">
{{
checkoutRoundLabel || '请核对消耗与扣款'
}}。确认无误后同意完结;也可修改方案交对方确认(最多 6
@@ -127,11 +127,20 @@ const qrGenerating = cashier.qrGenerating
const checkingPayment = cashier.checkingPayment
const paymentPayURL = cashier.payURL
const activePayWayLabel = computedPayWayLabel(activePayment)
const handoffFocused = ref(false)
const isOwnerCheckoutPending = computed(() => {
if (!order.value || !isOwner.value) return false
return (
order.value.status === 'pending_checkout_confirm' ||
(order.value.status === 'abnormal' &&
(order.value.handoff_status === 'owner_checkout_confirm_timeout' ||
order.value.handoff_status === 'owner_return_confirm_timeout' ||
order.value.handoff_status === 'pending_owner_checkout'))
)
})
const hasSidebarActions = computed(() => {
if (!order.value) return false
return (
(isOwner.value && order.value.status === 'pending_checkout_confirm') ||
isOwnerCheckoutPending.value ||
(isRenter.value && order.value.status === 'pending_checkout_accept')
)
})
@@ -139,7 +148,7 @@ const showCheckoutCounterForm = computed(
() =>
!!order.value &&
canCounterCheckout.value &&
((isOwner.value && order.value.status === 'pending_checkout_confirm') ||
(isOwnerCheckoutPending.value ||
(isRenter.value && order.value.status === 'pending_checkout_accept'))
)
const disputeSupportTitle = computed(() => {
@@ -325,14 +334,20 @@ watch([() => route.query.focus, order, loading], () => {
<div
v-if="
isOwner &&
order.status === 'pending_handoff' &&
order.handoff_status === 'pending_owner'
(order.status === 'pending_handoff' || order.status === 'abnormal') &&
(order.handoff_status === 'pending_owner' || order.handoff_status === 'owner_timeout')
"
class="form-section handoff-action-section"
>
<div class="section-header compact">
<h2>当前待办:提交交接说明</h2>
<span>填写后租客即可确认收号</span>
<span
v-if="order.handoff_status === 'owner_timeout'"
style="color: #e6a23c; font-weight: 500"
>
当前交接已超时,请尽快补提交交接说明避免订单被关闭
</span>
<span v-else>填写后租客即可确认收号</span>
</div>
<div class="handoff-action-card">
<el-input
@@ -502,12 +517,14 @@ watch([() => route.query.focus, order, loading], () => {
v-if="
order &&
order.checkout &&
[
'pending_checkout_confirm',
'pending_checkout_accept',
'checkout_disputing',
'completed',
].includes(order.status)
(
[
'pending_checkout_confirm',
'pending_checkout_accept',
'checkout_disputing',
'completed',
].includes(order.status) || order.status === 'abnormal'
)
"
:order="order"
:is-owner="isOwner"
@@ -618,9 +635,16 @@ watch([() => route.query.focus, order, loading], () => {
<!-- 右侧悬浮操作区 -->
<div v-if="order && hasSidebarActions" class="action-sidebar">
<!-- 确认结账 -->
<div v-if="isOwner && order.status === 'pending_checkout_confirm'" class="sidebar-card">
<div v-if="isOwnerCheckoutPending" class="sidebar-card">
<h3 class="sidebar-title">确认结账</h3>
<p v-if="checkoutRoundLabel" class="sidebar-hint">{{ checkoutRoundLabel }}</p>
<p
v-if="order.handoff_status === 'owner_checkout_confirm_timeout'"
class="sidebar-hint"
style="color: #e6a23c; font-weight: 500"
>
结账确认已超时,你可以直接同意当前方案完结,或修改方案交对方确认。
</p>
<p v-else-if="checkoutRoundLabel" class="sidebar-hint">{{ checkoutRoundLabel }}</p>
<p v-if="checkoutShortfallCent > 0" class="sidebar-hint" style="color: #dc2626">
押金不足,无法同意完结
</p>