This commit is contained in:
@@ -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()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user