fix: order
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m33s

This commit is contained in:
sexygoat
2026-04-30 10:39:51 +08:00
parent 1a4eb00440
commit 044c07fae6
10 changed files with 437 additions and 158 deletions

View File

@@ -112,6 +112,8 @@
filterable
clearable
style="width: 100%"
@focus="handleOwnerShopFocus"
@visible-change="handleOwnerShopVisibleChange"
@change="handleShopChange"
/>
</ElFormItem>
@@ -530,10 +532,6 @@
onMounted(() => {
getTableData()
// 只有非代理账号才需要加载店铺列表
if (!isAgentAccount.value) {
loadShopList()
}
})
onActivated(() => {
@@ -542,6 +540,8 @@
// 加载店铺列表 - 改用级联查询
const loadShopList = async () => {
if (shopLoading.value) return
shopLoading.value = true
try {
const res = await ShopService.getShopsCascade({ parent_id: undefined })
@@ -559,6 +559,16 @@
}
}
const handleOwnerShopFocus = async () => {
if (isAgentAccount.value) return
await loadShopList()
}
const handleOwnerShopVisibleChange = async (visible: boolean) => {
if (!visible) return
await handleOwnerShopFocus()
}
// 处理店铺选择变化
const handleShopChange = (value: any) => {
if (Array.isArray(value) && value.length > 0) {

View File

@@ -178,7 +178,6 @@
<ElDivider content-position="left">已授权设备</ElDivider>
<ElTable :data="operationResult.authorized_devices" border max-height="200">
<ElTableColumn prop="virtual_no" label="设备号" width="180" />
<ElTableColumn prop="device_id" label="设备ID" width="100" />
<ElTableColumn label="绑定卡数">
<template #default="{ row }">
{{ row.card_count || 0 }}

View File

@@ -60,14 +60,20 @@
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { ref, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElCard, ElButton, ElIcon, ElMessage, ElTable, ElTableColumn, ElTag } from 'element-plus'
import { ElCard, ElButton, ElIcon, ElMessage, ElTable, ElTableColumn } from 'element-plus'
import { ArrowLeft, Loading } from '@element-plus/icons-vue'
import DetailPage from '@/components/common/DetailPage.vue'
import type { DetailSection } from '@/components/common/DetailPage.vue'
import { OrderService } from '@/api/modules'
import type { Order } from '@/types/api'
import type {
Order,
OrderCommissionResult,
OrderCommissionStatus,
OrderOperatorType,
OrderPaymentMethod
} from '@/types/api'
import { formatDateTime } from '@/utils/business/format'
defineOptions({ name: 'OrderDetail' })
@@ -94,25 +100,61 @@
}
// 获取支付方式文本
const getPaymentMethodText = (method: string): string => {
const methodMap: Record<string, string> = {
const getPaymentMethodText = (method: OrderPaymentMethod): string => {
const methodMap: Record<OrderPaymentMethod, string> = {
wallet: '钱包支付',
wechat: '微信支付',
alipay: '支付宝支付'
alipay: '支付宝支付',
offline: '线下支付'
}
return methodMap[method] || method
}
// 获取佣金状态文本
const getCommissionStatusText = (status: number): string => {
const statusMap: Record<number, string> = {
0: '不适用',
1: '待结算',
2: '已结算'
// 获取操作者类型文本
const getOperatorTypeText = (type?: OrderOperatorType): string => {
if (!type) return '-'
const typeMap: Record<OrderOperatorType, string> = {
platform: '平台',
agent: '代理',
enterprise: '企业',
personal_customer: '个人客户'
}
return typeMap[type] || type
}
// 获取佣金流程状态文本
const getCommissionStatusText = (
status?: OrderCommissionStatus,
statusName?: string
): string => {
if (statusName) return statusName
if (status === undefined) return '-'
const statusMap: Record<OrderCommissionStatus, string> = {
1: '待计算',
2: '已完成',
3: '待人工处理'
}
return statusMap[status] || '-'
}
// 获取佣金业务结果文本
const getCommissionResultText = (
result?: OrderCommissionResult,
resultName?: string
): string => {
if (resultName) return resultName
if (result === undefined) return '-'
const resultMap: Record<OrderCommissionResult, string> = {
0: '未知',
1: '有佣金',
2: '无佣金',
3: '链路异常'
}
return resultMap[result] || '-'
}
// 获取订单角色文本
const getPurchaseRoleText = (role: string): string => {
const roleMap: Record<string, string> = {
@@ -173,6 +215,11 @@
prop: 'purchase_remark',
formatter: (value) => value || '-'
},
{
label: '支付时间',
prop: 'paid_at',
formatter: (value) => (value ? formatDateTime(value) : '-')
},
{
label: '是否上级代购',
formatter: (_, data) => (data.is_purchased_by_parent ? '是' : '否')
@@ -182,16 +229,6 @@
prop: 'asset_identifier',
formatter: (value) => value || '-'
},
{
label: '操作者类型',
prop: 'operator_type',
formatter: (value) => value || '-'
},
{
label: '操作者名称',
prop: 'operator_name',
formatter: (value) => value || '-'
},
{
label: '是否超时',
formatter: (_, data) => {
@@ -204,14 +241,6 @@
prop: 'expires_at',
formatter: (value) => (value ? formatDateTime(value) : '-')
},
{
label: '佣金状态',
formatter: (_, data) => getCommissionStatusText(data.commission_status)
},
{
label: '佣金配置版本',
prop: 'commission_config_version'
},
{
label: '创建时间',
prop: 'created_at',
@@ -223,6 +252,50 @@
formatter: (value) => formatDateTime(value)
}
]
},
{
title: '操作者信息',
fields: [
{
label: '操作者类型',
prop: 'operator_type',
formatter: (value) => getOperatorTypeText(value)
},
{
label: '操作者名称',
prop: 'operator_name',
formatter: (value) => value || '-'
}
]
},
{
title: '业务归属信息',
fields: [
{
label: '销售店铺名称',
prop: 'seller_shop_name',
formatter: (value) => value || '-'
}
]
},
{
title: '佣金信息',
fields: [
{
label: '流程状态',
formatter: (_, data) =>
getCommissionStatusText(data.commission_status, data.commission_status_name)
},
{
label: '业务结果',
formatter: (_, data) =>
getCommissionResultText(data.commission_result, data.commission_result_name)
},
{
label: '佣金配置版本',
prop: 'commission_config_version'
}
]
}
]

View File

@@ -36,7 +36,7 @@
:total="pagination.total"
:marginTop="10"
:actions="getActions"
:actionsWidth="120"
:actionsWidth="180"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
>
@@ -227,90 +227,6 @@
</template>
</ElDialog>
<!-- 订单详情对话框 -->
<ElDialog v-model="detailDialogVisible" :title="'订单详情'" width="800px">
<div v-if="currentOrder" class="order-detail">
<ElDescriptions :column="2" border>
<ElDescriptionsItem :label="'订单编号'">
{{ currentOrder.order_no }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'订单类型'">
{{ getOrderTypeText(currentOrder.order_type) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'支付状态'">
<ElTag :type="getPaymentStatusType(currentOrder.payment_status)">
{{ currentOrder.payment_status_text }}
</ElTag>
</ElDescriptionsItem>
<ElDescriptionsItem :label="'订单金额'">
{{ formatCurrency(currentOrder.total_amount) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'支付方式'">
{{ getPaymentMethodText(currentOrder.payment_method) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'买家类型'">
{{ getBuyerTypeText(currentOrder.buyer_type) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'买家手机号'">
{{ currentOrder.buyer_phone || '-' }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'买家昵称'">
{{ currentOrder.buyer_nickname || '-' }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'佣金状态'">
{{ getCommissionStatusText(currentOrder.commission_status) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'支付时间'">
{{ currentOrder.paid_at ? formatDateTime(currentOrder.paid_at) : '-' }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'创建时间'">
{{ formatDateTime(currentOrder.created_at) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="'更新时间'">
{{ formatDateTime(currentOrder.updated_at) }}
</ElDescriptionsItem>
</ElDescriptions>
<!-- 订单项列表 -->
<div
v-if="currentOrder.items && currentOrder.items.length > 0"
style="margin-top: 20px"
>
<h4>{{ '订单项' }}</h4>
<ElTable :data="currentOrder.items" border style="margin-top: 10px">
<ElTableColumn prop="package_name" :label="'套餐名称'" min-width="150" />
<ElTableColumn prop="package_type" :label="'套餐类型'" width="120">
<template #default="{ row }">
{{
row.package_type === 'formal'
? '正式套餐'
: row.package_type === 'addon'
? '加油包'
: '-'
}}
</template>
</ElTableColumn>
<ElTableColumn prop="quantity" :label="'数量'" width="100" />
<ElTableColumn prop="unit_price" :label="'单价'" width="120">
<template #default="{ row }">
{{ formatCurrency(row.unit_price) }}
</template>
</ElTableColumn>
<ElTableColumn prop="amount" :label="'金额'" width="120">
<template #default="{ row }">
{{ formatCurrency(row.amount) }}
</template>
</ElTableColumn>
</ElTable>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<ElButton @click="detailDialogVisible = false">{{ '关闭' }}</ElButton>
</div>
</template>
</ElDialog>
<!-- 支付凭证预览 -->
<PaymentVoucherDialog
:file-key="paymentVoucherFileKey"
@@ -344,6 +260,7 @@
BuyerType,
OrderPaymentMethod,
OrderCommissionStatus,
OrderCommissionResult,
StandaloneIotCard,
Device,
PackageResponse
@@ -358,6 +275,10 @@
defineOptions({ name: 'OrderList' })
type OrderSearchFormState = Omit<OrderQueryParams, 'is_expired'> & {
is_expired?: number
}
const router = useRouter()
const { hasAuth } = useAuth()
const userStore = useUserStore()
@@ -367,13 +288,11 @@
const voucherUploading = ref(false)
const tableRef = ref()
const createDialogVisible = ref(false)
const detailDialogVisible = ref(false)
const currentOrder = ref<Order | null>(null)
const paymentVoucherFileKey = ref('')
let activeVoucherUploadId = 0
// 搜索表单初始值
const initialSearchState: OrderQueryParams = {
const initialSearchState: OrderSearchFormState = {
order_no: '',
buyer_phone: '',
payment_status: undefined,
@@ -388,7 +307,7 @@
}
// 搜索表单
const searchForm = reactive<OrderQueryParams>({ ...initialSearchState })
const searchForm = reactive<OrderSearchFormState>({ ...initialSearchState })
// 店铺列表(用于代理商搜索)
const shopOptions = ref<any[]>([])
@@ -508,8 +427,8 @@
type: 'select',
placeholder: '请选择',
options: [
{ label: '已过期', value: true },
{ label: '未过期', value: false }
{ label: '已过期', value: 1 },
{ label: '未过期', value: 0 }
],
config: {
clearable: true
@@ -576,8 +495,10 @@
{ label: '购买备注', prop: 'purchase_remark' },
{ label: '下单时间', prop: 'created_at' },
{ label: '操作者', prop: 'operator_name' },
{ label: '销售店铺', prop: 'seller_shop_name' },
{ label: '支付状态', prop: 'payment_status' },
{ label: '佣金状态', prop: 'commission_status_name' },
{ label: '佣金流程状态', prop: 'commission_status_name' },
{ label: '佣金业务结果', prop: 'commission_result_name' },
{ label: '订单金额', prop: 'total_amount' },
{ label: '实付金额', prop: 'actual_paid_amount' },
{ label: '支付方式', prop: 'payment_method' },
@@ -876,22 +797,70 @@
return methodMap[method] || method
}
// 获取佣金状态文本
const getCommissionStatusText = (status: OrderCommissionStatus): string => {
// 获取佣金流程状态文本
const getCommissionStatusText = (status?: OrderCommissionStatus, statusName?: string): string => {
if (statusName) return statusName
if (status === undefined) return '-'
const statusMap: Record<OrderCommissionStatus, string> = {
0: '不适用',
1: '待结算',
2: '已结算'
1: '待计算',
2: '已完成',
3: '待人工处理'
}
return statusMap[status] || '-'
}
// 获取佣金业务结果文本
const getCommissionResultText = (result?: OrderCommissionResult, resultName?: string): string => {
if (resultName) return resultName
if (result === undefined) return '-'
const resultMap: Record<OrderCommissionResult, string> = {
0: '未知',
1: '有佣金',
2: '无佣金',
3: '链路异常'
}
return resultMap[result] || '-'
}
const getCommissionStatusType = (
status?: OrderCommissionStatus
): 'success' | 'info' | 'warning' | 'danger' => {
switch (status) {
case 1:
return 'warning'
case 2:
return 'success'
case 3:
return 'danger'
default:
return 'info'
}
}
const getCommissionResultType = (
result?: OrderCommissionResult
): 'success' | 'info' | 'warning' | 'danger' => {
switch (result) {
case 1:
return 'success'
case 2:
return 'info'
case 3:
return 'danger'
default:
return 'warning'
}
}
// 动态列配置
const { columnChecks, columns } = useCheckedColumns(() => [
{
prop: 'order_no',
label: '订单编号',
minWidth: 220,
showOverflowTooltip: true,
formatter: (row: Order) => {
return h(
'span',
@@ -992,14 +961,33 @@
{
prop: 'operator_name',
label: '操作者',
width: 120,
width: 140,
formatter: (row: Order) => row.operator_name || '-'
},
{
prop: 'seller_shop_name',
label: '销售店铺',
width: 160,
showOverflowTooltip: true,
formatter: (row: Order) => row.seller_shop_name || '-'
},
{
prop: 'commission_status_name',
label: '佣金状态',
width: 120,
formatter: (row: Order) => row.commission_status_name || '-'
label: '佣金流程状态',
width: 140,
formatter: (row: Order) =>
h(ElTag, { type: getCommissionStatusType(row.commission_status), size: 'small' }, () =>
getCommissionStatusText(row.commission_status, row.commission_status_name)
)
},
{
prop: 'commission_result_name',
label: '佣金业务结果',
width: 140,
formatter: (row: Order) =>
h(ElTag, { type: getCommissionResultType(row.commission_result), size: 'small' }, () =>
getCommissionResultText(row.commission_result, row.commission_result_name)
)
},
{
prop: 'total_amount',
@@ -1070,7 +1058,8 @@
order_type: searchForm.order_type,
purchase_role: searchForm.purchase_role,
identifier: searchForm.identifier || undefined,
is_expired: searchForm.is_expired,
is_expired:
searchForm.is_expired === undefined ? undefined : Boolean(searchForm.is_expired),
seller_shop_id: searchForm.seller_shop_id,
start_time: searchForm.start_time || undefined,
end_time: searchForm.end_time || undefined
@@ -1229,12 +1218,6 @@
return
}
// 检查是否是赠送套餐
const selectedPackage = packageOptions.value.find(
(pkg) => pkg.id === createForm.package_id
)
const isGiftPackage = selectedPackage?.is_gift || false
// 线下支付时,支付凭证为必填
if (createForm.payment_method === 'offline' && !createForm.payment_voucher_key) {
ElMessage.error('线下支付必须上传支付凭证')
@@ -1253,7 +1236,8 @@
data.payment_voucher_key = createForm.payment_voucher_key
}
await OrderService.createOrder(data)
const res = await OrderService.createOrder(data)
if (res.code !== 0) return
// 根据支付方式显示不同的成功消息
if (createForm.payment_method === 'wallet') {
@@ -1362,12 +1346,6 @@
height: 100%;
}
.order-detail {
:deep(.el-descriptions__label) {
width: 140px;
}
}
:deep(.el-table__row.table-row-with-context-menu) {
cursor: pointer;
}

View File

@@ -338,7 +338,7 @@
</div>
</div>
<div class="form-tip"
>设置每个套餐的成本价单位不能低于不能高于价的50%溢价</div
>设置每个套餐的成本价单位不能低于成本不能高于建议售价的50%溢价</div
>
</ElFormItem>
</template>