This commit is contained in:
@@ -199,22 +199,15 @@
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type {
|
||||
MyCommissionSummary,
|
||||
MyCommissionRecordItem,
|
||||
ShopCommissionRecordItem,
|
||||
WithdrawalRequestItem,
|
||||
CommissionRecordQueryParams,
|
||||
WithdrawalRequestQueryParams,
|
||||
SubmitWithdrawalParams,
|
||||
CommissionType,
|
||||
CommissionStatus,
|
||||
WithdrawalStatus
|
||||
} from '@/types/api/commission'
|
||||
import { WithdrawalMethod } from '@/types/api/commission'
|
||||
import {
|
||||
CommissionStatusMap,
|
||||
CommissionTypeMap,
|
||||
WithdrawalStatusMap,
|
||||
WithdrawalMethodMap
|
||||
} from '@/config/constants/commission'
|
||||
import { WithdrawalStatusMap, WithdrawalMethodMap } from '@/config/constants/commission'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
@@ -227,7 +220,7 @@
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 获取当前用户的 shop_id
|
||||
const currentShopId = computed(() => userStore.userInfo?.shop_id)
|
||||
const currentShopId = computed(() => userStore.info?.shop_id)
|
||||
|
||||
// 如果没有 shop_id,显示提示
|
||||
const hasShopId = computed(() => !!currentShopId.value)
|
||||
@@ -237,6 +230,7 @@
|
||||
|
||||
// 佣金概览
|
||||
const summary = ref<MyCommissionSummary>({
|
||||
main_balance: 0,
|
||||
total_commission: 0,
|
||||
available_commission: 0,
|
||||
frozen_commission: 0,
|
||||
@@ -251,10 +245,13 @@
|
||||
|
||||
// 搜索表单初始值
|
||||
const initialCommissionSearchState = {
|
||||
commission_type: undefined as CommissionType | undefined,
|
||||
status: undefined as CommissionStatus | undefined,
|
||||
commission_source: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
end_time: '',
|
||||
iccid: '',
|
||||
virtual_no: '',
|
||||
order_no: ''
|
||||
}
|
||||
|
||||
// 搜索表单
|
||||
@@ -263,16 +260,16 @@
|
||||
// 搜索表单配置
|
||||
const commissionSearchItems = computed<SearchFormItem[]>(() => [
|
||||
{
|
||||
label: '佣金类型',
|
||||
prop: 'commission_type',
|
||||
label: '佣金来源',
|
||||
prop: 'commission_source',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: '一次性佣金', value: 'one_time' },
|
||||
{ label: '长期佣金', value: 'long_term' }
|
||||
{ label: '成本差价', value: 'cost_diff' },
|
||||
{ label: '一次性佣金', value: 'one_time' }
|
||||
],
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请选择佣金类型'
|
||||
placeholder: '请选择佣金来源'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -290,6 +287,33 @@
|
||||
placeholder: '请选择状态'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'ICCID',
|
||||
prop: 'iccid',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入ICCID'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '虚拟号',
|
||||
prop: 'virtual_no',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入虚拟号'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '订单号',
|
||||
prop: 'order_no',
|
||||
type: 'input',
|
||||
config: {
|
||||
clearable: true,
|
||||
placeholder: '请输入订单号'
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '时间范围',
|
||||
prop: 'dateRange',
|
||||
@@ -322,64 +346,95 @@
|
||||
|
||||
// 列配置
|
||||
const commissionColumnOptions = [
|
||||
{ label: 'ID', prop: 'id' },
|
||||
{ label: '佣金金额', prop: 'amount' },
|
||||
{ label: '佣金类型', prop: 'commission_type' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
{ label: '订单ID', prop: 'order_id' },
|
||||
{ label: '佣金来源', prop: 'commission_source' },
|
||||
{ label: '状态', prop: 'status_name' },
|
||||
{ label: 'ICCID', prop: 'iccid' },
|
||||
{ label: '虚拟号', prop: 'virtual_no' },
|
||||
{ label: '订单号', prop: 'order_no' },
|
||||
{ label: '卖家店铺', prop: 'seller_shop_name' },
|
||||
{ label: '入账后余额', prop: 'balance_after' },
|
||||
{ label: '创建时间', prop: 'created_at' }
|
||||
]
|
||||
|
||||
const commissionList = ref<MyCommissionRecordItem[]>([])
|
||||
const commissionList = ref<ShopCommissionRecordItem[]>([])
|
||||
|
||||
// 佣金来源映射
|
||||
const CommissionSourceMap = {
|
||||
cost_diff: { label: '成本差价', type: 'primary' as const },
|
||||
one_time: { label: '一次性佣金', type: 'success' as const }
|
||||
}
|
||||
|
||||
// 状态映射
|
||||
const CommissionRecordStatusMap = {
|
||||
1: { label: '已冻结', type: 'info' as const },
|
||||
2: { label: '解冻中', type: 'warning' as const },
|
||||
3: { label: '已发放', type: 'success' as const },
|
||||
4: { label: '已失效', type: 'danger' as const }
|
||||
}
|
||||
|
||||
// 动态列配置
|
||||
const { columnChecks: commissionColumnChecks, columns: commissionColumns } = useCheckedColumns(
|
||||
() => [
|
||||
{
|
||||
prop: 'id',
|
||||
label: 'ID',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
prop: 'amount',
|
||||
label: '佣金金额',
|
||||
width: 140,
|
||||
formatter: (row: MyCommissionRecordItem) => formatMoney(row.amount)
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionRecordItem) => formatMoney(row.amount)
|
||||
},
|
||||
{
|
||||
prop: 'commission_type',
|
||||
label: '佣金类型',
|
||||
prop: 'commission_source',
|
||||
label: '佣金来源',
|
||||
width: 120,
|
||||
formatter: (row: MyCommissionRecordItem) => {
|
||||
const config = CommissionTypeMap[row.commission_type as keyof typeof CommissionTypeMap]
|
||||
formatter: (row: ShopCommissionRecordItem) => {
|
||||
const config =
|
||||
CommissionSourceMap[row.commission_source as keyof typeof CommissionSourceMap]
|
||||
if (!config) return String(row.commission_source ?? '-')
|
||||
return h(ElTag, { type: config.type }, () => config.label)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
prop: 'status_name',
|
||||
label: '状态',
|
||||
width: 100,
|
||||
formatter: (row: MyCommissionRecordItem) => {
|
||||
const config = CommissionStatusMap[row.status as keyof typeof CommissionStatusMap]
|
||||
return h(ElTag, { type: config.type }, () => config.label)
|
||||
formatter: (row: ShopCommissionRecordItem) => {
|
||||
return String(row.status_name ?? '-')
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'order_id',
|
||||
label: '订单ID',
|
||||
width: 100,
|
||||
formatter: (row: MyCommissionRecordItem) => row.order_id || '-'
|
||||
prop: 'iccid',
|
||||
label: 'ICCID',
|
||||
formatter: (row: ShopCommissionRecordItem) => row.iccid || '-'
|
||||
},
|
||||
{
|
||||
prop: 'shop_id',
|
||||
label: '店铺ID',
|
||||
width: 100
|
||||
prop: 'virtual_no',
|
||||
label: '虚拟号',
|
||||
width: 130,
|
||||
formatter: (row: ShopCommissionRecordItem) => row.virtual_no || '-'
|
||||
},
|
||||
{
|
||||
prop: 'order_no',
|
||||
label: '订单号',
|
||||
width: 160,
|
||||
formatter: (row: ShopCommissionRecordItem) => row.order_no || '-'
|
||||
},
|
||||
{
|
||||
prop: 'seller_shop_name',
|
||||
label: '卖家店铺',
|
||||
width: 150,
|
||||
formatter: (row: ShopCommissionRecordItem) => row.seller_shop_name || '-'
|
||||
},
|
||||
{
|
||||
prop: 'balance_after',
|
||||
label: '入账后余额',
|
||||
width: 120,
|
||||
formatter: (row: ShopCommissionRecordItem) => formatMoney(row.balance_after)
|
||||
},
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '创建时间',
|
||||
width: 180,
|
||||
formatter: (row: MyCommissionRecordItem) => formatDateTime(row.created_at)
|
||||
formatter: (row: ShopCommissionRecordItem) => formatDateTime(row.created_at)
|
||||
}
|
||||
]
|
||||
)
|
||||
@@ -393,14 +448,17 @@
|
||||
|
||||
commissionLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
pageSize: commissionPagination.pageSize,
|
||||
current: commissionPagination.page,
|
||||
commission_type: commissionSearchForm.commission_type,
|
||||
const params: CommissionRecordQueryParams = {
|
||||
page_size: commissionPagination.pageSize,
|
||||
page: commissionPagination.page,
|
||||
commission_source: commissionSearchForm.commission_source,
|
||||
status: commissionSearchForm.status,
|
||||
start_time: commissionSearchForm.start_time || undefined,
|
||||
end_time: commissionSearchForm.end_time || undefined
|
||||
} as CommissionRecordQueryParams
|
||||
end_time: commissionSearchForm.end_time || undefined,
|
||||
iccid: commissionSearchForm.iccid || undefined,
|
||||
virtual_no: commissionSearchForm.virtual_no || undefined,
|
||||
order_no: commissionSearchForm.order_no || undefined
|
||||
}
|
||||
const res = await CommissionService.getShopCommissionRecords(currentShopId.value, params)
|
||||
if (res.code === 0) {
|
||||
commissionList.value = res.data.items || []
|
||||
@@ -512,8 +570,10 @@
|
||||
{ label: '手续费', prop: 'fee' },
|
||||
{ label: '实际到账', prop: 'actual_amount' },
|
||||
{ label: '提现方式', prop: 'withdrawal_method' },
|
||||
{ label: '状态', prop: 'status' },
|
||||
{ label: '申请时间', prop: 'created_at' }
|
||||
{ label: '状态', prop: 'status_name' },
|
||||
{ label: '拒绝原因', prop: 'reject_reason' },
|
||||
{ label: '申请时间', prop: 'created_at' },
|
||||
{ label: '到账时间', prop: 'paid_at' }
|
||||
]
|
||||
|
||||
const withdrawalList = ref<WithdrawalRequestItem[]>([])
|
||||
@@ -560,19 +620,33 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'status',
|
||||
prop: 'status_name',
|
||||
label: '状态',
|
||||
width: 100,
|
||||
formatter: (row: WithdrawalRequestItem) => {
|
||||
const config = WithdrawalStatusMap[row.status as keyof typeof WithdrawalStatusMap]
|
||||
return h(ElTag, { type: config.type }, () => config.label)
|
||||
const tagType = config?.type || 'info'
|
||||
const label = row.status_name || config?.label || String(row.status)
|
||||
return h(ElTag, { type: tagType }, () => label)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'reject_reason',
|
||||
label: '拒绝原因',
|
||||
minWidth: 120,
|
||||
formatter: (row: WithdrawalRequestItem) => row.reject_reason || '-'
|
||||
},
|
||||
{
|
||||
prop: 'created_at',
|
||||
label: '申请时间',
|
||||
width: 180,
|
||||
formatter: (row: WithdrawalRequestItem) => formatDateTime(row.created_at)
|
||||
},
|
||||
{
|
||||
prop: 'paid_at',
|
||||
label: '到账时间',
|
||||
width: 180,
|
||||
formatter: (row: WithdrawalRequestItem) => (row.paid_at ? formatDateTime(row.paid_at) : '-')
|
||||
}
|
||||
]
|
||||
)
|
||||
@@ -586,13 +660,13 @@
|
||||
|
||||
withdrawalLoading.value = true
|
||||
try {
|
||||
const params = {
|
||||
pageSize: withdrawalPagination.pageSize,
|
||||
current: withdrawalPagination.page,
|
||||
const params: WithdrawalRequestQueryParams = {
|
||||
page_size: withdrawalPagination.pageSize,
|
||||
page: withdrawalPagination.page,
|
||||
status: withdrawalSearchForm.status,
|
||||
start_time: withdrawalSearchForm.start_time || undefined,
|
||||
end_time: withdrawalSearchForm.end_time || undefined
|
||||
} as WithdrawalRequestQueryParams
|
||||
}
|
||||
const res = await CommissionService.getShopWithdrawalRequests(currentShopId.value, params)
|
||||
if (res.code === 0) {
|
||||
withdrawalList.value = res.data.items || []
|
||||
@@ -655,7 +729,7 @@
|
||||
amount: [
|
||||
{ required: true, message: '请输入提现金额', trigger: 'blur' },
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
validator: (_rule, value, callback) => {
|
||||
if (value < 100) {
|
||||
callback(new Error('提现金额不能小于100分(1元)'))
|
||||
} else if (value > summary.value.available_commission) {
|
||||
@@ -678,7 +752,7 @@
|
||||
],
|
||||
bank_name: [
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
validator: (_rule, value, callback) => {
|
||||
if (withdrawalForm.withdrawal_method === WithdrawalMethod.BANK && !value) {
|
||||
callback(new Error('请选择银行名称'))
|
||||
} else {
|
||||
@@ -740,9 +814,9 @@
|
||||
withdrawalDialogVisible.value = false
|
||||
|
||||
// 刷新数据
|
||||
loadSummary()
|
||||
await loadSummary()
|
||||
if (activeTab.value === 'withdrawal') {
|
||||
getWithdrawalList()
|
||||
await getWithdrawalList()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -765,13 +839,14 @@
|
||||
// 调用 fund-summary 接口,通过 shop_id 过滤获取自己的数据
|
||||
const res = await CommissionService.getShopFundSummary({
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
page_size: 1
|
||||
})
|
||||
if (res.code === 0 && res.data.items && res.data.items.length > 0) {
|
||||
// 从结果中找到当前用户的店铺数据
|
||||
const myShopData = res.data.items.find(item => item.shop_id === currentShopId.value)
|
||||
const myShopData = res.data.items.find((item) => item.shop_id === currentShopId.value)
|
||||
if (myShopData) {
|
||||
summary.value = {
|
||||
main_balance: myShopData.main_balance || 0,
|
||||
total_commission: myShopData.total_commission,
|
||||
available_commission: myShopData.available_commission,
|
||||
frozen_commission: myShopData.frozen_commission,
|
||||
@@ -803,9 +878,3 @@
|
||||
getCommissionList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.my-commission-page {
|
||||
// 样式已移动到分析页的佣金概览组件
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user