feat: 流量记录查询、套餐人工冲正与退款资产后处理
Some checks failed
构建并部署前端到测试环境 / deploy (push) Failing after 7m27s

- 新增采集成功/失败记录、卡日流量、套餐日流量详单、冲正流水、退款后处理尝试记录 6 个查询页
- 资产详情新增采集记录、冲正记录与人工冲正,同步后展示本次流量入账结果
- 退款列表与详情展示资产后处理状态,支持按状态筛选、人工重试与查看尝试记录
- 新增前端权限码常量(需在 tb_permission 补数据)
This commit is contained in:
邹进
2026-11-07 13:19:26 +09:00
parent 49a4d32eab
commit 984db9889c
35 changed files with 2693 additions and 31 deletions

View File

@@ -41,6 +41,21 @@
"
>停复机记录</ElButton
>
<ElButton
v-if="
cardInfo?.asset_type === 'card' &&
canViewTrafficCollections &&
hasAuth(TRAFFIC_RECORD_PERMISSIONS.assetCollections.card)
"
type="primary"
link
@click="
emit('showTrafficCollections', {
identifier: cardInfo.iccid || cardInfo.identifier
})
"
>采集记录</ElButton
>
<ElButton v-if="auditTarget" type="primary" link @click="openAssetAudit">
{{ isSubjectActivityView ? '活动记录' : '审计记录' }}
</ElButton>
@@ -540,6 +555,16 @@
"
>停复机记录</ElButton
>
<ElButton
v-if="
bindingCard.iccid &&
canViewTrafficCollections &&
hasAuth(TRAFFIC_RECORD_PERMISSIONS.assetCollections.device)
"
type="primary"
@click="emit('showTrafficCollections', { identifier: bindingCard.iccid })"
>采集记录</ElButton
>
<ElButton
v-if="bindingCard.network_status === 0 && hasAuth('iot_info:start')"
type="success"
@@ -752,6 +777,8 @@
import { useAuth } from '@/composables/useAuth'
import { JULY_PERMISSIONS } from '@/config/constants'
import { useUserStore } from '@/store/modules/user'
import { TRAFFIC_RECORD_PERMISSIONS } from '@/config/constants/trafficRecords'
import { isEnterpriseAccount } from '@/utils/business/trafficRecords'
import { formatDateTime } from '@/utils/business/format'
import SilenceRecordsDialog from '@/components/business/package-silence/SilenceRecordsDialog.vue'
const firstPurchaseVisible = ref(false)
@@ -903,6 +930,10 @@
}
)
const userStore = useUserStore()
// 资产采集记录接口企业账号无权调用
const canViewTrafficCollections = computed(
() => !isEnterpriseAccount(Number(userStore.info.user_type))
)
const isSubjectActivityView = computed(() => [3, 4].includes(Number(userStore.info.user_type)))
const auditTarget = computed(() => {
const userType = Number(userStore.info.user_type)
@@ -1003,6 +1034,7 @@
// Emits
interface Emits {
(e: 'showStopResumeRecords', payload: { cardId: number; iccid: string }): void
(e: 'showTrafficCollections', payload: { identifier: string }): void
(e: 'showPollingState', payload: { cardId: number; iccid: string }): void
(e: 'update:pollingEnabled', value: boolean): void
(e: 'enableCard'): void

View File

@@ -285,7 +285,7 @@
{{ formatDateTime(scope.row.created_at) }}
</template>
</ElTableColumn>
<ElTableColumn label="操作" width="240" fixed="right">
<ElTableColumn label="操作" width="300" fixed="right">
<template #default="scope">
<div class="package-actions">
<ElButton
@@ -316,6 +316,22 @@
>
退款详情
</ElButton>
<ElButton
v-if="canViewTrafficAdjustments"
type="primary"
link
@click="handleShowAdjustments(scope.row)"
>
冲正记录
</ElButton>
<ElButton
v-if="canAdjustTraffic"
type="primary"
link
@click="handleShowAdjust(scope.row)"
>
人工冲正
</ElButton>
<ElButton
v-if="canUpdateUsedData"
type="primary"
@@ -359,6 +375,28 @@
@success="handleRefundSuccess"
/>
<ElDialog
v-model="adjustmentsVisible"
:title="`冲正记录:${adjustTarget?.package_name || ''}`"
width="min(1200px, 96vw)"
destroy-on-close
>
<PackageTrafficAdjustments
v-if="adjustmentsVisible && props.assetIdentifier && adjustTargetId"
:identifier="props.assetIdentifier"
:package-usage-id="adjustTargetId"
/>
</ElDialog>
<TrafficAdjustDialog
v-model="adjustVisible"
:identifier="props.assetIdentifier || ''"
:package-usage-id="adjustTargetId"
:package-name="adjustTarget?.package_name"
:current-usage-mb="Number(adjustTarget?.real_used_mb || 0)"
@success="emit('refresh')"
/>
<ElDialog
v-model="usedDataDialogVisible"
title="修改已用量"
@@ -471,6 +509,10 @@
import { canEditRestrictedAsset, canAccessOrderCategory } from '@/utils/business/packageSilence'
import { storeToRefs } from 'pinia'
import CreateRefundDialog from '@/components/business/CreateRefundDialog.vue'
import PackageTrafficAdjustments from '@/components/business/traffic-records/PackageTrafficAdjustments.vue'
import TrafficAdjustDialog from '@/components/business/traffic-records/TrafficAdjustDialog.vue'
import { TRAFFIC_RECORD_PERMISSIONS } from '@/config/constants/trafficRecords'
import { isEnterpriseAccount } from '@/utils/business/trafficRecords'
const { hasAuth } = useAuth()
const userStore = useUserStore()
@@ -498,6 +540,35 @@
canUseAdjustmentInCurrentEnv('package:update_expires_at')
)
// 冲正记录与人工冲正:企业账号无权调用(后端按账号类型拒绝),其余按按钮权限
const notEnterprise = computed(() => !isEnterpriseAccount(Number(userInfo.value.user_type)))
const canViewTrafficAdjustments = computed(
() => notEnterprise.value && hasAuth(TRAFFIC_RECORD_PERMISSIONS.packageAdjustments)
)
const canAdjustTraffic = computed(
() => notEnterprise.value && hasAuth(TRAFFIC_RECORD_PERMISSIONS.packageAdjust)
)
const adjustmentsVisible = ref(false)
const adjustVisible = ref(false)
const adjustTarget = ref<AssetPackageUsageRecord | null>(null)
const adjustTargetId = computed(() =>
adjustTarget.value ? getPackageUsageId(adjustTarget.value) : undefined
)
const handleShowAdjustments = (row: AssetPackageUsageRecord) => {
if (!canViewTrafficAdjustments.value) return
adjustTarget.value = row
adjustmentsVisible.value = true
}
const handleShowAdjust = (row: AssetPackageUsageRecord) => {
if (!canAdjustTraffic.value) return
if (getPackageUsageId(row) === undefined) {
ElMessage.error('缺少套餐使用记录ID')
return
}
adjustTarget.value = row
adjustVisible.value = true
}
// 退款申请对话框
const createRefundDialogVisible = ref(false)
const currentRefundOrderId = ref<number | undefined>(undefined)

View File

@@ -4,6 +4,7 @@
*/
import { getCurrentScope, onScopeDispose, ref, watch } from 'vue'
import { describeTrafficRefresh } from '@/utils/business/trafficRecords'
import { ElMessage } from 'element-plus'
import { AssetService } from '@/api/modules'
import { useUserStore } from '@/store/modules/user'
@@ -558,9 +559,14 @@ export function useAssetInfo() {
if (!isCurrent() || cardInfo.value.asset_type !== assetType) return false
try {
// 主动同步网关的接口仅允许由右上角“同步”按钮触发,搜索和普通数据重载不能调用。
await AssetService.refreshAsset(identifier)
const refreshResponse = await AssetService.refreshAsset(identifier)
if (!isCurrent()) return false
ElMessage.success('刷新成功')
const trafficText = describeTrafficRefresh(refreshResponse?.data?.traffic_refresh)
if (trafficText) {
ElMessage({ type: 'success', message: `刷新成功;${trafficText}`, duration: 6000 })
} else {
ElMessage.success('刷新成功')
}
// 绑定/解绑和实名时间由详情接口确认,不能只刷新实时状态而保留过期绑定关系。
return Boolean(await fetchAssetDetail(identifier, { preservePackageList: true }))

View File

@@ -41,6 +41,7 @@
@show-realname-policy="showRealnamePolicyDialog"
@show-speed-limit="speedLimitDialogVisible = true"
@show-stop-resume-records="showStopResumeRecords"
@show-traffic-collections="showTrafficCollections"
@show-polling-state="showPollingState"
@show-update-realname-status="showUpdateRealnameStatusDialog"
@enable-binding-card="handleEnableBindingCard"
@@ -125,6 +126,19 @@
:permission="stopResumePermission"
/>
</ElDialog>
<ElDialog
v-model="trafficCollectionsVisible"
:title="`采集记录:${trafficCollectionsIdentifier}`"
width="min(1400px, 96vw)"
destroy-on-close
>
<TrafficCollectionRecords
v-if="trafficCollectionsVisible && trafficCollectionsIdentifier"
:key="trafficCollectionsIdentifier"
mode="asset"
:identifier="trafficCollectionsIdentifier"
/>
</ElDialog>
<SwitchCardDialog
v-model="switchCardDialogVisible"
:device-info="cardInfo?.virtual_no || ''"
@@ -208,6 +222,7 @@
import { useAuth } from '@/composables/useAuth'
import { GATEWAY_PERMISSIONS } from '@/config/constants/gateway'
import StopResumeRecords from '@/components/business/gateway/StopResumeRecords.vue'
import TrafficCollectionRecords from '@/components/business/traffic-records/TrafficCollectionRecords.vue'
import PollingStateDialog from '@/components/business/polling/PollingStateDialog.vue'
import { SCHEDULER_PERMISSIONS } from '@/config/constants/pollingScheduler'
import { canEditRestrictedAsset, canAccessOrderCategory } from '@/utils/business/packageSilence'
@@ -344,6 +359,14 @@
? GATEWAY_PERMISSIONS.cardHistory
: GATEWAY_PERMISSIONS.deviceCardHistory
)
const trafficCollectionsVisible = ref(false)
const trafficCollectionsIdentifier = ref('')
function showTrafficCollections(target: { identifier: string }) {
const identifier = target.identifier?.trim()
if (!identifier) return
trafficCollectionsIdentifier.value = identifier
trafficCollectionsVisible.value = true
}
function showStopResumeRecords(target: { cardId: number; iccid: string }) {
if (
!hasAuth(stopResumePermission.value) ||

View File

@@ -0,0 +1,8 @@
<template>
<ArtTableFullScreen><CardDailyUsages /></ArtTableFullScreen>
</template>
<script setup lang="ts">
import CardDailyUsages from '@/components/business/traffic-records/CardDailyUsages.vue'
defineOptions({ name: 'CardDailyUsagesPage' })
</script>

View File

@@ -0,0 +1,8 @@
<template>
<ArtTableFullScreen><PackageTrafficAdjustments /></ArtTableFullScreen>
</template>
<script setup lang="ts">
import PackageTrafficAdjustments from '@/components/business/traffic-records/PackageTrafficAdjustments.vue'
defineOptions({ name: 'PackageTrafficAdjustmentsPage' })
</script>

View File

@@ -0,0 +1,8 @@
<template>
<ArtTableFullScreen><PackageUsageDailyRecords /></ArtTableFullScreen>
</template>
<script setup lang="ts">
import PackageUsageDailyRecords from '@/components/business/traffic-records/PackageUsageDailyRecords.vue'
defineOptions({ name: 'PackageUsageDailyRecordsPage' })
</script>

View File

@@ -0,0 +1,8 @@
<template>
<ArtTableFullScreen><TrafficCollectionRecords mode="failure" /></ArtTableFullScreen>
</template>
<script setup lang="ts">
import TrafficCollectionRecords from '@/components/business/traffic-records/TrafficCollectionRecords.vue'
defineOptions({ name: 'TrafficCollectionFailuresPage' })
</script>

View File

@@ -0,0 +1,8 @@
<template>
<ArtTableFullScreen><TrafficCollectionRecords mode="success" /></ArtTableFullScreen>
</template>
<script setup lang="ts">
import TrafficCollectionRecords from '@/components/business/traffic-records/TrafficCollectionRecords.vue'
defineOptions({ name: 'TrafficCollectionRecordsPage' })
</script>

View File

@@ -0,0 +1,8 @@
<template>
<ArtTableFullScreen><RefundPostProcessAttempts /></ArtTableFullScreen>
</template>
<script setup lang="ts">
import RefundPostProcessAttempts from '@/components/business/traffic-records/RefundPostProcessAttempts.vue'
defineOptions({ name: 'RefundPostProcessAttemptsPage' })
</script>

View File

@@ -29,6 +29,17 @@
>
恢复审批
</ElButton>
<ElButton
v-if="refund && canRetryAssetPost"
type="warning"
:loading="retryAssetPostLoading"
@click="handleRetryAssetPost"
>
人工重试后处理
</ElButton>
<ElButton v-if="refund && canViewPostAttempts" @click="postAttemptsVisible = true">
后处理尝试记录
</ElButton>
<template v-if="refund && canManualApproveRefund(refund)">
<ElButton
v-if="hasAuth('refund:approve')"
@@ -64,6 +75,15 @@
</div>
</ElCard>
<ElDialog
v-model="postAttemptsVisible"
title="退款资产后处理尝试记录"
width="min(1300px, 96vw)"
destroy-on-close
>
<RefundPostProcessAttempts v-if="postAttemptsVisible && refund" :refund-id="refund.id" />
</ElDialog>
<PaymentVoucherDialog :file-keys="refundVoucherFileKeys" @close="refundVoucherFileKeys = []" />
<!-- 退款审批操作对话框 -->
@@ -214,6 +234,14 @@
import { useAuth } from '@/composables/useAuth'
import { useUserStore } from '@/store/modules/user'
import { AUGUST_PERMISSIONS } from '@/config/constants/augustIteration'
import {
REFUND_ASSET_POST_MAX_ATTEMPTS,
REFUND_ASSET_POST_STATUS,
REFUND_ASSET_POST_STATUS_LABELS,
REFUND_ASSET_POST_STATUS_TAGS,
TRAFFIC_RECORD_PERMISSIONS
} from '@/config/constants/trafficRecords'
import RefundPostProcessAttempts from '@/components/business/traffic-records/RefundPostProcessAttempts.vue'
defineOptions({ name: 'RefundDetail' })
@@ -225,6 +253,53 @@
const loading = ref(false)
const recoverApprovalLoading = ref(false)
const retryAssetPostLoading = ref(false)
const postAttemptsVisible = ref(false)
const isPlatformUser = computed(() => [1, 2].includes(Number(userStore.info.user_type)))
const canViewPostAttempts = computed(
() => isPlatformUser.value && hasAuth(TRAFFIC_RECORD_PERMISSIONS.refundPostAttempts.page)
)
// 人工重试:仅"需人工处理" + 平台账号 + 按钮权限
const canRetryAssetPost = computed(
() =>
!!refund.value &&
refund.value.asset_post_status === REFUND_ASSET_POST_STATUS.manualRequired &&
!refund.value.asset_reset &&
isPlatformUser.value &&
hasAuth(TRAFFIC_RECORD_PERMISSIONS.refundAssetPostRetry)
)
const handleRetryAssetPost = async () => {
const current = refund.value
if (!current || retryAssetPostLoading.value || !canRetryAssetPost.value) return
try {
await ElMessageBox.confirm(
`重试会重新执行退款单 ${current.refund_no} 的资产后处理(可能包括停机),确认继续?`,
'人工重试资产后处理',
{ confirmButtonText: '确认重试', cancelButtonText: '取消', type: 'warning' }
)
} catch {
return
}
retryAssetPostLoading.value = true
try {
const res = await RefundService.retryAssetPostProcessing(current.id)
if (res.code === 0 && res.data) {
refund.value = res.data
ElMessage.success('资产后处理重试成功')
return
}
ElMessage.error(res.msg || '资产后处理重试失败')
await fetchRefundDetail(current.id)
} catch (error) {
// HTTP 错误已由请求层提示后端信息;重新加载以展示最新尝试次数与错误
if (!(error as { response?: unknown })?.response) {
ElMessage.error(getErrorMessage(error, '资产后处理重试失败'))
}
await fetchRefundDetail(current.id)
} finally {
retryAssetPostLoading.value = false
}
}
const refund = ref<Refund | null>(null)
const refundVoucherFileKeys = ref<string[]>([])
const approvalDialogVisible = ref(false)
@@ -564,6 +639,34 @@
label: '资产重置',
formatter: (_, data) => (data.asset_reset ? '是' : '否')
},
{
label: '资产后处理状态',
formatter: (_, data) => {
const status = data.asset_post_status
if (status === undefined || status === null) return '-'
return h(
ElTag,
{ type: REFUND_ASSET_POST_STATUS_TAGS[status] || 'info', size: 'small' },
() => REFUND_ASSET_POST_STATUS_LABELS[status] || String(status)
)
}
},
{
label: '后处理尝试次数',
formatter: (_, data) =>
data.asset_post_attempts === undefined || data.asset_post_attempts === null
? '-'
: `${data.asset_post_attempts} / ${REFUND_ASSET_POST_MAX_ATTEMPTS}(自动重试上限)`
},
{
label: '后处理最后错误',
formatter: (_, data) => data.asset_post_last_error || '-'
},
{
label: '下次自动重试',
formatter: (_, data) =>
data.asset_post_next_at ? formatDateTime(data.asset_post_next_at) : '-'
},
{
label: '佣金扣除',
formatter: (_, data) => (data.commission_deducted ? '是' : '否')

View File

@@ -196,6 +196,13 @@
import { RefundService, ShopService, OrderService } from '@/api/modules'
import { ElMessage, ElMessageBox, ElTag, ElButton } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import {
REFUND_ASSET_POST_STATUS,
REFUND_ASSET_POST_STATUS_LABELS,
REFUND_ASSET_POST_STATUS_OPTIONS,
REFUND_ASSET_POST_STATUS_TAGS,
TRAFFIC_RECORD_PERMISSIONS
} from '@/config/constants/trafficRecords'
import {
RefundStatus,
RefundMethod,
@@ -280,7 +287,8 @@
status: undefined,
order_id: undefined,
shop_id: undefined,
asset_identifier: ''
asset_identifier: '',
asset_post_status: undefined
}
// 搜索表单
@@ -349,6 +357,16 @@
config: {
clearable: true
}
},
{
label: '资产后处理',
prop: 'asset_post_status',
type: 'select',
placeholder: '请选择资产后处理状态',
options: REFUND_ASSET_POST_STATUS_OPTIONS,
config: {
clearable: true
}
}
]
@@ -372,6 +390,7 @@
{ label: '退款方式', prop: 'method' },
{ label: '冻结实收金额', prop: 'frozen_actual_received_amount' },
{ label: '渠道退款状态', prop: 'channel_refund_status' },
{ label: '资产后处理', prop: 'asset_post_status' },
{ label: '渠道退款流水号', prop: 'channel_refund_no' },
{ label: '渠道退款金额', prop: 'channel_refund_amount' },
{ label: '失败分类', prop: 'failure_reason' },
@@ -558,6 +577,20 @@
width: 130,
formatter: (row: Refund) => row.channel_refund_status_name || '-'
},
{
prop: 'asset_post_status',
label: '资产后处理',
width: 120,
formatter: (row: Refund) => {
const status = row.asset_post_status
if (status === undefined || status === null) return '-'
return h(
ElTag,
{ type: REFUND_ASSET_POST_STATUS_TAGS[status] || 'info', size: 'small' },
() => REFUND_ASSET_POST_STATUS_LABELS[status] || String(status)
)
}
},
{
prop: 'channel_refund_no',
label: '渠道退款流水号',
@@ -796,7 +829,11 @@
status: searchForm.status,
order_id: searchForm.order_id,
shop_id: searchForm.shop_id,
asset_identifier: assetIdentifier || undefined
asset_identifier: assetIdentifier || undefined,
asset_post_status:
searchForm.asset_post_status === undefined || searchForm.asset_post_status === null
? undefined
: searchForm.asset_post_status
}
const res = await RefundService.getRefunds(params)
if (res.code === 0) {
@@ -1052,6 +1089,44 @@
})
}
// 退款资产后处理人工重试:仅"需人工处理" + 平台账号 + 按钮权限
const retryAssetPostLoading = ref(false)
const canRetryAssetPost = (row: Refund) =>
row.asset_post_status === REFUND_ASSET_POST_STATUS.manualRequired &&
!row.asset_reset &&
[1, 2].includes(userStore.getUserInfo.user_type || 0) &&
hasAuth(TRAFFIC_RECORD_PERMISSIONS.refundAssetPostRetry)
const handleRetryAssetPost = async (row: Refund) => {
if (retryAssetPostLoading.value || !canRetryAssetPost(row)) return
try {
await ElMessageBox.confirm(
`重试会重新执行退款单 ${row.refund_no} 的资产后处理(可能包括停机),确认继续?`,
'人工重试资产后处理',
{ confirmButtonText: '确认重试', cancelButtonText: '取消', type: 'warning' }
)
} catch {
return
}
retryAssetPostLoading.value = true
try {
const res = await RefundService.retryAssetPostProcessing(row.id)
if (res.code === 0) {
ElMessage.success('资产后处理重试成功')
} else {
ElMessage.error(res.msg || '资产后处理重试失败')
}
} catch (error) {
// HTTP 错误已由请求层提示后端信息(如"资产后处理仍未完成:…")
if (!(error as { response?: unknown })?.response) {
ElMessage.error(getErrorMessage(error, '资产后处理重试失败'))
}
} finally {
retryAssetPostLoading.value = false
await getTableData()
}
}
// 获取操作按钮
const getActions = (row: Refund) => {
const actions: any[] = []
@@ -1149,6 +1224,14 @@
})
}
if (canRetryAssetPost(row)) {
actions.push({
label: '人工重试',
handler: () => handleRetryAssetPost(row),
type: 'warning'
})
}
if (canResubmit(row) && hasAuth('refund:resubmit')) {
actions.push({
label: '重新申请',