修改bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m6s

This commit is contained in:
sexygoat
2026-04-09 16:56:30 +08:00
parent 6a46aeea15
commit 472099bf96
9 changed files with 432 additions and 170 deletions

View File

@@ -235,6 +235,78 @@
</template>
</ArtTable>
</ElTabPane>
<!-- 预充值钱包流水 Tab -->
<ElTabPane label="预充值钱包流水" name="mainWallet">
<ArtTable
ref="mainWalletTableRef"
row-key="id"
:loading="mainWalletLoading"
:data="mainWalletRecords"
:currentPage="mainWalletPagination.page"
:pageSize="mainWalletPagination.pageSize"
:total="mainWalletPagination.total"
:marginTop="10"
:height="500"
@size-change="handleMainWalletSizeChange"
@current-change="handleMainWalletCurrentChange"
>
<template #default>
<ElTableColumn label="交易类型" prop="transaction_type" width="120">
<template #default="scope">
<ElTag
:type="
scope.row.transaction_type === 'recharge'
? 'success'
: scope.row.transaction_type === 'deduct'
? 'warning'
: 'info'
"
>
{{
scope.row.transaction_type === 'recharge'
? '充值入账'
: scope.row.transaction_type === 'deduct'
? '套餐扣款'
: scope.row.transaction_type === 'refund'
? '退款'
: scope.row.transaction_type
}}
</ElTag>
</template>
</ElTableColumn>
<ElTableColumn label="交易金额" prop="amount" width="120">
<template #default="scope">
<span
:style="{
fontWeight: 500,
color:
scope.row.amount > 0 ? 'var(--el-color-success)' : 'var(--el-color-danger)'
}"
>
{{ scope.row.amount > 0 ? '+' : '' }}{{ formatMoney(scope.row.amount) }}
</span>
</template>
</ElTableColumn>
<ElTableColumn label="交易前余额" prop="balance_before" width="130">
<template #default="scope">
{{ formatMoney(scope.row.balance_before) }}
</template>
</ElTableColumn>
<ElTableColumn label="交易后余额" prop="balance_after" width="130">
<template #default="scope">
{{ formatMoney(scope.row.balance_after) }}
</template>
</ElTableColumn>
<ElTableColumn label="备注" prop="remark" min-width="200" show-overflow-tooltip />
<ElTableColumn label="交易时间" prop="created_at" width="180">
<template #default="scope">
{{ formatDateTime(scope.row.created_at) }}
</template>
</ElTableColumn>
</template>
</ArtTable>
</ElTabPane>
</ElTabs>
</ElDrawer>
@@ -303,10 +375,11 @@
import { ElMessage, ElMessageBox, ElTag } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import type {
ShopCommissionSummaryItem,
ShopFundSummaryItem,
ShopCommissionRecordItem,
WithdrawalRequestItem,
CommissionResolveAction
CommissionResolveAction,
MainWalletTransactionItem
} from '@/types/api/commission'
import { useCheckedColumns } from '@/composables/useCheckedColumns'
import { useAuth } from '@/composables/useAuth'
@@ -328,7 +401,7 @@
// 主表格状态
const loading = ref(false)
const tableRef = ref()
const summaryList = ref<ShopCommissionSummaryItem[]>([])
const summaryList = ref<ShopFundSummaryItem[]>([])
// 搜索表单
const searchForm = reactive({
@@ -345,8 +418,8 @@
// 详情抽屉状态
const detailDrawerVisible = ref(false)
const activeTab = ref<'commission' | 'withdrawal'>('commission')
const currentShop = ref<ShopCommissionSummaryItem | null>(null)
const activeTab = ref<'commission' | 'withdrawal' | 'mainWallet'>('commission')
const currentShop = ref<ShopFundSummaryItem | null>(null)
// 佣金明细状态
const commissionLoading = ref(false)
@@ -396,12 +469,23 @@
remark: [{ max: 500, message: '备注最多500字符', trigger: 'blur' }]
}))
// 预充值钱包流水状态
const mainWalletLoading = ref(false)
const mainWalletTableRef = ref()
const mainWalletRecords = ref<MainWalletTransactionItem[]>([])
const mainWalletPagination = reactive({
page: 1,
pageSize: 20,
total: 0
})
// 列配置
const columnOptions = [
{ label: '店铺编码', prop: 'shop_code' },
{ label: '店铺名称', prop: 'shop_name' },
{ label: '用户名', prop: 'username' },
{ label: '手机号', prop: 'phone' },
{ label: '预充值余额', prop: 'main_balance' },
{ label: '总佣金', prop: 'total_commission' },
{ label: '可提现', prop: 'available_commission' },
{ label: '冻结中', prop: 'frozen_commission' },
@@ -411,7 +495,7 @@
]
// 处理名称点击
const handleNameClick = (row: ShopCommissionSummaryItem) => {
const handleNameClick = (row: ShopFundSummaryItem) => {
if (hasAuth('agent_commission:detail')) {
showDetail(row)
} else {
@@ -431,7 +515,7 @@
label: '店铺名称',
minWidth: 180,
showOverflowTooltip: true,
formatter: (row: ShopCommissionSummaryItem) => {
formatter: (row: ShopFundSummaryItem) => {
return h(
'span',
{
@@ -455,17 +539,29 @@
label: '手机号',
width: 130
},
{
prop: 'main_balance',
label: '预充值余额',
width: 130,
formatter: (row: ShopFundSummaryItem) => {
return h(
'span',
{ style: 'color: var(--el-color-primary); font-weight: 500' },
formatMoney(row.main_balance)
)
}
},
{
prop: 'total_commission',
label: '总佣金',
width: 120,
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.total_commission)
formatter: (row: ShopFundSummaryItem) => formatMoney(row.total_commission)
},
{
prop: 'available_commission',
label: '可提现',
width: 120,
formatter: (row: ShopCommissionSummaryItem) => {
formatter: (row: ShopFundSummaryItem) => {
return h(
'span',
{ style: 'color: var(--el-color-success); font-weight: 500' },
@@ -477,13 +573,13 @@
prop: 'frozen_commission',
label: '冻结中',
width: 120,
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.frozen_commission)
formatter: (row: ShopFundSummaryItem) => formatMoney(row.frozen_commission)
},
{
prop: 'withdrawing_commission',
label: '提现中',
width: 120,
formatter: (row: ShopCommissionSummaryItem) => {
formatter: (row: ShopFundSummaryItem) => {
return h(
'span',
{ style: 'color: var(--el-color-warning)' },
@@ -495,13 +591,13 @@
prop: 'withdrawn_commission',
label: '已提现',
width: 120,
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.withdrawn_commission)
formatter: (row: ShopFundSummaryItem) => formatMoney(row.withdrawn_commission)
},
{
prop: 'unwithdraw_commission',
label: '未提现',
width: 120,
formatter: (row: ShopCommissionSummaryItem) => formatMoney(row.unwithdraw_commission)
formatter: (row: ShopFundSummaryItem) => formatMoney(row.unwithdraw_commission)
}
])
@@ -519,7 +615,7 @@
shop_name: searchForm.shop_name || undefined,
shop_code: searchForm.shop_code || undefined
}
const res = await CommissionService.getShopCommissionSummary(params)
const res = await CommissionService.getShopFundSummary(params)
if (res.code === 0) {
summaryList.value = res.data.items || []
pagination.total = res.data.total || 0
@@ -563,7 +659,7 @@
}
// 显示详情抽屉
const showDetail = (row: ShopCommissionSummaryItem) => {
const showDetail = (row: ShopFundSummaryItem) => {
currentShop.value = row
detailDrawerVisible.value = true
activeTab.value = 'commission'
@@ -571,13 +667,14 @@
// 重置分页
commissionPagination.page = 1
withdrawalPagination.page = 1
mainWalletPagination.page = 1
// 加载佣金明细
loadCommissionRecords()
}
// 获取操作按钮
const getActions = (row: ShopCommissionSummaryItem) => {
const getActions = (row: ShopFundSummaryItem) => {
const actions: any[] = []
if (hasAuth('agent_commission:detail')) {
@@ -597,6 +694,8 @@
loadCommissionRecords()
} else if (newTab === 'withdrawal') {
loadWithdrawalRecords()
} else if (newTab === 'mainWallet') {
loadMainWalletRecords()
}
})
@@ -691,6 +790,43 @@
loadWithdrawalRecords()
}
// 加载预充值钱包流水
const loadMainWalletRecords = async () => {
if (!currentShop.value) return
mainWalletLoading.value = true
try {
const params = {
page: mainWalletPagination.page,
pageSize: mainWalletPagination.pageSize
}
const res = await CommissionService.getMainWalletTransactions(
currentShop.value.shop_id,
params
)
if (res.code === 0) {
mainWalletRecords.value = res.data.items || []
mainWalletPagination.total = res.data.total || 0
}
} catch (error) {
console.error(error)
ElMessage.error('获取预充值钱包流水失败')
} finally {
mainWalletLoading.value = false
}
}
// 预充值钱包流水分页
const handleMainWalletSizeChange = (newPageSize: number) => {
mainWalletPagination.pageSize = newPageSize
loadMainWalletRecords()
}
const handleMainWalletCurrentChange = (newCurrentPage: number) => {
mainWalletPagination.page = newCurrentPage
loadMainWalletRecords()
}
// 处理佣金修正
const handleResolveCommission = (
row: ShopCommissionRecordItem,

View File

@@ -218,11 +218,19 @@
import type { SearchFormItem } from '@/types'
import { useCheckedColumns } from '@/composables/useCheckedColumns'
import { useAuth } from '@/composables/useAuth'
import { useUserStore } from '@/store/modules/user'
import { formatDateTime, formatMoney } from '@/utils/business/format'
defineOptions({ name: 'MyCommission' })
const { hasAuth } = useAuth()
const userStore = useUserStore()
// 获取当前用户的 shop_id
const currentShopId = computed(() => userStore.userInfo?.shop_id)
// 如果没有 shop_id显示提示
const hasShopId = computed(() => !!currentShopId.value)
// 标签页
const activeTab = ref('commission')
@@ -378,6 +386,11 @@
// 获取佣金明细
const getCommissionList = async () => {
if (!currentShopId.value) {
ElMessage.warning('未找到店铺信息')
return
}
commissionLoading.value = true
try {
const params = {
@@ -388,7 +401,7 @@
start_time: commissionSearchForm.start_time || undefined,
end_time: commissionSearchForm.end_time || undefined
} as CommissionRecordQueryParams
const res = await CommissionService.getMyCommissionRecords(params)
const res = await CommissionService.getShopCommissionRecords(currentShopId.value, params)
if (res.code === 0) {
commissionList.value = res.data.items || []
commissionPagination.total = res.data.total || 0
@@ -566,6 +579,11 @@
// 获取提现记录
const getWithdrawalList = async () => {
if (!currentShopId.value) {
ElMessage.warning('未找到店铺信息')
return
}
withdrawalLoading.value = true
try {
const params = {
@@ -575,7 +593,7 @@
start_time: withdrawalSearchForm.start_time || undefined,
end_time: withdrawalSearchForm.end_time || undefined
} as WithdrawalRequestQueryParams
const res = await CommissionService.getMyWithdrawalRequests(params)
const res = await CommissionService.getShopWithdrawalRequests(currentShopId.value, params)
if (res.code === 0) {
withdrawalList.value = res.data.items || []
withdrawalPagination.total = res.data.total || 0
@@ -695,6 +713,10 @@
// 提交提现申请
const handleSubmitWithdrawal = async () => {
if (!withdrawalFormRef.value) return
if (!currentShopId.value) {
ElMessage.warning('未找到店铺信息')
return
}
await withdrawalFormRef.value.validate(async (valid) => {
if (valid) {
@@ -713,7 +735,7 @@
params.bank_name = withdrawalForm.bank_name
}
await CommissionService.submitWithdrawalRequest(params)
await CommissionService.submitShopWithdrawalRequest(currentShopId.value, params)
ElMessage.success('提现申请提交成功')
withdrawalDialogVisible.value = false
@@ -735,10 +757,28 @@
// 加载佣金概览
const loadSummary = async () => {
if (!currentShopId.value) {
return
}
try {
const res = await CommissionService.getMyCommissionSummary()
if (res.code === 0) {
summary.value = res.data
// 调用 fund-summary 接口,通过 shop_id 过滤获取自己的数据
const res = await CommissionService.getShopFundSummary({
page: 1,
pageSize: 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)
if (myShopData) {
summary.value = {
total_commission: myShopData.total_commission,
available_commission: myShopData.available_commission,
frozen_commission: myShopData.frozen_commission,
withdrawing_commission: myShopData.withdrawing_commission,
withdrawn_commission: myShopData.withdrawn_commission
}
}
}
} catch (error) {
console.error(error)
@@ -755,6 +795,10 @@
})
onMounted(() => {
if (!hasShopId.value) {
ElMessage.warning('当前账号未关联店铺,无法查看佣金信息')
return
}
loadSummary()
getCommissionList()
})