Files
hfb_sys/frontend/src/features/admin/views/AdminInvitationsView.vue
T

1022 lines
32 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { Setting, User, Coin, Refresh, Search, Check, DataAnalysis } from '@element-plus/icons-vue'
import {
fetchAdminRebateConfig,
updateAdminRebateConfig,
type InvitationRebateConfig,
} from '@/features/invitation/api/invitation'
import {
fetchAdminRebateSummary,
type AdminRebateSummary,
} from '@/features/admin/api/adminInvitations'
import {
fetchDistributionSites,
type DistributionSite,
} from '@/features/admin/api/adminDistribution'
import { apiClient } from '@/shared/api/client'
import { formatCent } from '@/shared/utils/money'
import { readError } from '@/shared/utils/error'
import { useDistributionSiteStore } from '@/stores/distributionSite'
const siteStore = useDistributionSiteStore()
const isTenantSite = computed(() => siteStore.isTenant)
const currentSiteName = computed(() => siteStore.siteName || '大锤商行')
const activeTab = ref<'config' | 'invitations' | 'rebates' | 'summary'>('config')
// 站点列表
const sites = ref<DistributionSite[]>([])
const selectedSiteId = ref(0)
const loadingConfig = ref(false)
const savingConfig = ref(false)
const configForm = reactive({
firstMonthRate: 60,
secondMonthRate: 30,
subsequentRate: 15,
enabled: true,
})
// 邀请关系列表
const loadingInvitations = ref(false)
const invitationQuery = reactive({
phone: '',
invite_code: '',
distribution_site_id: undefined as number | undefined,
page: 1,
pageSize: 20,
})
const invitations = ref<any[]>([])
const invitationsTotal = ref(0)
// 返利流水列表
const loadingRebates = ref(false)
const rebateQuery = reactive({
order_no: '',
inviter_phone: '',
invitee_phone: '',
distribution_site_id: undefined as number | undefined,
page: 1,
pageSize: 20,
})
const rebates = ref<any[]>([])
const rebatesTotal = ref(0)
// 返利统计
const loadingSummary = ref(false)
const summaryQuery = reactive({
dateRange: null as string[] | null,
source: '',
trade_role: '',
distribution_site_id: undefined as number | undefined,
})
const summary = ref<AdminRebateSummary | null>(null)
onMounted(() => {
// 三个页签的数据一起预加载,避免邀请关系/返利流水标签在首次进入时显示 0。
void Promise.all([
isTenantSite.value ? Promise.resolve() : loadSites(),
loadConfig(),
loadInvitations(),
loadRebates(),
])
})
async function loadSites() {
if (isTenantSite.value) {
sites.value = []
return
}
try {
const list = await fetchDistributionSites()
sites.value = list
} catch {
// 忽略加载分站失败
}
}
async function loadConfig() {
loadingConfig.value = true
try {
const siteID = isTenantSite.value ? 0 : selectedSiteId.value
const cfg: InvitationRebateConfig = await fetchAdminRebateConfig(siteID)
configForm.firstMonthRate = Math.round((cfg.first_month_rate || 0.6) * 100)
configForm.secondMonthRate = Math.round((cfg.second_month_rate || 0.3) * 100)
configForm.subsequentRate = Math.round((cfg.subsequent_rate || 0.15) * 100)
configForm.enabled = cfg.enabled !== false
} catch (err) {
ElMessage.error(readError(err, '获取返利配置失败'))
} finally {
loadingConfig.value = false
}
}
async function handleSaveConfig() {
if (
configForm.firstMonthRate < 0 ||
configForm.firstMonthRate > 100 ||
configForm.secondMonthRate < 0 ||
configForm.secondMonthRate > 100 ||
configForm.subsequentRate < 0 ||
configForm.subsequentRate > 100
) {
ElMessage.warning('分成比例必须在 0% 到 100% 之间')
return
}
savingConfig.value = true
try {
const siteID = isTenantSite.value ? 0 : selectedSiteId.value
await updateAdminRebateConfig(siteID, {
first_month_rate: Number((configForm.firstMonthRate / 100).toFixed(4)),
second_month_rate: Number((configForm.secondMonthRate / 100).toFixed(4)),
subsequent_rate: Number((configForm.subsequentRate / 100).toFixed(4)),
enabled: configForm.enabled,
})
ElMessage.success('返利比例配置已保存')
} catch (err) {
ElMessage.error(readError(err, '保存配置失败'))
} finally {
savingConfig.value = false
}
}
async function loadInvitations() {
loadingInvitations.value = true
try {
const params: Record<string, any> = {
page: invitationQuery.page,
page_size: invitationQuery.pageSize,
}
if (invitationQuery.phone.trim()) params.phone = invitationQuery.phone.trim()
if (invitationQuery.invite_code.trim()) params.invite_code = invitationQuery.invite_code.trim()
if (!isTenantSite.value && invitationQuery.distribution_site_id !== undefined) {
params.distribution_site_id = invitationQuery.distribution_site_id
}
const { data } = await apiClient.get('/admin/invitations', { params })
invitations.value = data.data.items || []
invitationsTotal.value = data.data.total || 0
} catch (err) {
ElMessage.error(readError(err, '获取邀请关系失败'))
} finally {
loadingInvitations.value = false
}
}
async function loadRebates() {
loadingRebates.value = true
try {
const params: Record<string, any> = {
page: rebateQuery.page,
page_size: rebateQuery.pageSize,
}
if (rebateQuery.order_no.trim()) params.order_no = rebateQuery.order_no.trim()
if (rebateQuery.inviter_phone.trim()) params.inviter_phone = rebateQuery.inviter_phone.trim()
if (rebateQuery.invitee_phone.trim()) params.invitee_phone = rebateQuery.invitee_phone.trim()
if (!isTenantSite.value && rebateQuery.distribution_site_id !== undefined) {
params.distribution_site_id = rebateQuery.distribution_site_id
}
const { data } = await apiClient.get('/admin/invitations/rebates', { params })
rebates.value = data.data.items || []
rebatesTotal.value = data.data.total || 0
} catch (err) {
ElMessage.error(readError(err, '获取返利流水失败'))
} finally {
loadingRebates.value = false
}
}
async function loadSummary() {
loadingSummary.value = true
try {
const params: Record<string, any> = {}
if (summaryQuery.dateRange && summaryQuery.dateRange.length === 2) {
params.start_date = summaryQuery.dateRange[0]
params.end_date = summaryQuery.dateRange[1]
}
if (summaryQuery.source) params.source = summaryQuery.source
if (summaryQuery.trade_role) params.trade_role = summaryQuery.trade_role
if (!isTenantSite.value && typeof summaryQuery.distribution_site_id === 'number') {
params.distribution_site_id = summaryQuery.distribution_site_id
}
summary.value = await fetchAdminRebateSummary(params)
} catch (err) {
ElMessage.error(readError(err, '获取返利统计失败'))
} finally {
loadingSummary.value = false
}
}
function resetSummary() {
summaryQuery.dateRange = null
summaryQuery.source = ''
summaryQuery.trade_role = ''
summaryQuery.distribution_site_id = undefined
void loadSummary()
}
function percentOf(part: number, total: number) {
if (!total) return '0%'
return `${Math.round((part / total) * 1000) / 10}%`
}
function handleTabChange(tab: 'config' | 'invitations' | 'rebates' | 'summary') {
activeTab.value = tab
if (tab === 'invitations') {
void loadInvitations()
} else if (tab === 'rebates') {
void loadRebates()
} else if (tab === 'summary') {
void loadSummary()
}
}
function searchInvitations() {
invitationQuery.page = 1
void loadInvitations()
}
function searchRebates() {
rebateQuery.page = 1
void loadRebates()
}
function cycleLabel(cycle: string) {
switch (cycle) {
case 'first_month':
return '首月高额'
case 'second_month':
return '次月奖励'
default:
return '长期分成'
}
}
</script>
<template>
<div class="admin-invitations-page">
<div class="page-header">
<h2>邀请返利与分成管理</h2>
<p class="page-desc">
{{
isTenantSite
? `配置【${currentSiteName}】的返利阶梯比例,监控本站邀请关系与返利流水。`
: '配置主站及各分销站点的返利阶梯比例(首月、次月、往后永久),监控历史分销渠道的邀请关系与返利流水。'
}}
</p>
</div>
<!-- 选项卡导航 -->
<div class="nav-tabs">
<button
class="nav-tab-btn"
:class="{ active: activeTab === 'config' }"
@click="handleTabChange('config')"
>
<el-icon><Setting /></el-icon> 返利比例配置
</button>
<button
class="nav-tab-btn"
:class="{ active: activeTab === 'invitations' }"
@click="handleTabChange('invitations')"
>
<el-icon><User /></el-icon>
{{ isTenantSite ? '本站邀请关系' : '全网邀请关系' }} ({{ invitationsTotal }})
</button>
<button
class="nav-tab-btn"
:class="{ active: activeTab === 'rebates' }"
@click="handleTabChange('rebates')"
>
<el-icon><Coin /></el-icon> 返利结算流水 ({{ rebatesTotal }})
</button>
<button
class="nav-tab-btn"
:class="{ active: activeTab === 'summary' }"
@click="handleTabChange('summary')"
>
<el-icon><DataAnalysis /></el-icon> 返利统计
</button>
</div>
<!-- 配置面板 -->
<div v-if="activeTab === 'config'" class="panel-card">
<div class="panel-header">
<div v-if="!isTenantSite" class="site-selector-row">
<label>选择配置生效目标:</label>
<el-select v-model="selectedSiteId" style="width: 260px" @change="loadConfig">
<el-option :value="0" label="主站(默认基础配置)" />
<el-option
v-for="s in sites"
:key="s.id"
:value="s.id"
:label="`分销站: ${s.site_name} (${s.site_code})`"
/>
</el-select>
<el-button :icon="Refresh" circle @click="loadConfig" />
</div>
<div v-else class="site-selector-row">
<label>当前站点:</label>
<el-tag effect="plain">{{ currentSiteName }}</el-tag>
<span class="tenant-config-hint">仅影响当前站点的邀请返利,不会修改其他站点。</span>
</div>
<div v-if="!isTenantSite && selectedSiteId === 0" class="site-desc-hint">
说明:当前配置为历史主站订单默认分成比例;经营站点拥有各自独立配置。
</div>
<div v-else-if="!isTenantSite" class="site-desc-hint">
说明:当前正在为指定历史分销站维护专属返利比例。
</div>
</div>
<div v-loading="loadingConfig" class="config-form-body">
<el-form label-position="top" style="max-width: 600px">
<el-form-item label="功能开关">
<el-switch
v-model="configForm.enabled"
active-text="启用邀请返利"
inactive-text="暂停该站点返利"
/>
<div class="field-hint">关闭后该站点产生的新订单将不计算并发放邀请返利</div>
</el-form-item>
<el-form-item label="首月分成比例(实名生效 1 ~ 30 天)">
<div class="rate-input-box">
<el-input-number v-model="configForm.firstMonthRate" :min="0" :max="100" :step="5" />
<span class="rate-unit">%</span>
</div>
<div class="field-hint">默认 60%,按平台每笔订单单边毛利计算分成基数</div>
</el-form-item>
<el-form-item label="次月分成比例(实名生效 31 ~ 60 天)">
<div class="rate-input-box">
<el-input-number v-model="configForm.secondMonthRate" :min="0" :max="100" :step="5" />
<span class="rate-unit">%</span>
</div>
<div class="field-hint">默认 30%</div>
</el-form-item>
<el-form-item label="往后长期分成比例(实名生效 60 天后永久)">
<div class="rate-input-box">
<el-input-number v-model="configForm.subsequentRate" :min="0" :max="100" :step="1" />
<span class="rate-unit">%</span>
</div>
<div class="field-hint">默认 15%</div>
</el-form-item>
<el-form-item>
<el-button
type="primary"
:icon="Check"
:loading="savingConfig"
@click="handleSaveConfig"
>
保存比例配置
</el-button>
</el-form-item>
</el-form>
</div>
</div>
<!-- 邀请关系面板 -->
<div v-if="activeTab === 'invitations'" class="panel-card">
<div class="filter-bar">
<el-input
v-model="invitationQuery.phone"
placeholder="邀请人/被邀请人手机号"
clearable
style="width: 210px"
@keyup.enter="searchInvitations"
/>
<el-input
v-model="invitationQuery.invite_code"
placeholder="邀请码(支持模糊搜索)"
clearable
style="width: 180px"
@keyup.enter="searchInvitations"
/>
<el-button type="primary" :icon="Search" @click="searchInvitations">查询</el-button>
<el-button :icon="Refresh" @click="searchInvitations">刷新</el-button>
</div>
<div class="table-hint">
{{
isTenantSite
? '仅展示当前站点的邀请关系与累计邀请人数。'
: '「邀请人累计」统计历史分销渠道内的邀请人数。'
}}
</div>
<el-table
v-loading="loadingInvitations"
:data="invitations"
border
style="width: 100%; margin-top: 16px"
>
<el-table-column prop="id" label="ID" width="70" />
<el-table-column label="邀请人" min-width="150">
<template #default="{ row }">
<div>{{ row.inviter_nickname || '-' }}</div>
<code style="font-size: 12px; color: #64748b">{{ row.inviter_phone }}</code>
</template>
</el-table-column>
<el-table-column label="邀请人累计" align="center">
<el-table-column label="总邀请" width="86" align="center">
<template #default="{ row }">
<span class="invite-stat-total">{{ row.inviter_total_invited ?? 0 }}</span>
</template>
</el-table-column>
<el-table-column label="已实名" width="86" align="center">
<template #default="{ row }">
<span class="invite-stat-active">{{ row.inviter_active_invited ?? 0 }}</span>
</template>
</el-table-column>
<el-table-column label="待实名" width="86" align="center">
<template #default="{ row }">
<span class="invite-stat-pending">{{ row.inviter_pending_invited ?? 0 }}</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column label="被邀请人" min-width="150">
<template #default="{ row }">
<div>{{ row.invitee_nickname || '-' }}</div>
<code style="font-size: 12px; color: #64748b">{{ row.invitee_phone }}</code>
</template>
</el-table-column>
<el-table-column prop="invite_code" label="使用邀请码" width="120">
<template #default="{ row }">
<el-tag size="small">{{ row.invite_code }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="status" label="认证生效状态" width="130">
<template #default="{ row }">
<el-tag :type="row.status === 'active' ? 'success' : 'warning'" size="small">
{{ row.status === 'active' ? '已实名 (生效中)' : '待实名 (未生效)' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="verified_at" label="实名生效时间" min-width="160">
<template #default="{ row }">
{{ row.verified_at ? row.verified_at.slice(0, 19).replace('T', ' ') : '-' }}
</template>
</el-table-column>
<el-table-column prop="created_at" label="绑定时间" min-width="160">
<template #default="{ row }">
{{ row.created_at ? row.created_at.slice(0, 19).replace('T', ' ') : '-' }}
</template>
</el-table-column>
</el-table>
<div class="pagination-box">
<el-pagination
v-model:current-page="invitationQuery.page"
v-model:page-size="invitationQuery.pageSize"
:total="invitationsTotal"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@change="loadInvitations"
/>
</div>
</div>
<!-- 返利流水面板 -->
<div v-if="activeTab === 'rebates'" class="panel-card">
<div class="filter-bar">
<el-input
v-model="rebateQuery.order_no"
placeholder="订单号"
clearable
style="width: 180px"
@keyup.enter="searchRebates"
/>
<el-input
v-model="rebateQuery.inviter_phone"
placeholder="邀请人手机号"
clearable
style="width: 150px"
@keyup.enter="searchRebates"
/>
<el-input
v-model="rebateQuery.invitee_phone"
placeholder="被邀请人手机号"
clearable
style="width: 150px"
@keyup.enter="searchRebates"
/>
<el-button type="primary" :icon="Search" @click="searchRebates">查询</el-button>
<el-button :icon="Refresh" @click="searchRebates">刷新</el-button>
</div>
<el-table
v-loading="loadingRebates"
:data="rebates"
border
style="width: 100%; margin-top: 16px"
>
<el-table-column prop="id" label="ID" width="70" />
<el-table-column label="来源" width="80">
<template #default="{ row }">
<el-tag
size="small"
effect="plain"
:type="row.source === 'pickup' ? 'warning' : 'info'"
>
{{ row.source === 'pickup' ? '提号' : '订单' }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="order_no" label="关联单据号" min-width="160">
<template #default="{ row }">
<code>{{ row.order_no }}</code>
</template>
</el-table-column>
<el-table-column prop="inviter_phone" label="收益人(邀请人)" width="130" />
<el-table-column prop="invitee_phone" label="交易人(被邀请人)" width="130" />
<el-table-column prop="trade_role" label="交易端" width="100">
<template #default="{ row }">
<el-tag :type="row.trade_role === 'buyer' ? 'primary' : 'danger'" size="small">
{{ row.trade_role === 'buyer' ? '买家端' : '卖家端' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="收益基数" width="110">
<template #default="{ row }">
¥{{ formatCent(row.single_side_basis_cent || 0) }}
</template>
</el-table-column>
<el-table-column label="提成比例" width="90">
<template #default="{ row }"> {{ Math.round((row.rate_applied || 0) * 100) }}% </template>
</el-table-column>
<el-table-column prop="cycle_stage" label="周期阶段" width="100">
<template #default="{ row }">
{{ cycleLabel(row.cycle_stage) }}
</template>
</el-table-column>
<el-table-column label="返利金额" width="110">
<template #default="{ row }">
<strong style="color: #dc2626">+¥{{ formatCent(row.rebate_amount_cent || 0) }}</strong>
</template>
</el-table-column>
<el-table-column prop="settled_at" label="入账时间" min-width="160">
<template #default="{ row }">
{{ row.settled_at ? row.settled_at.slice(0, 19).replace('T', ' ') : '-' }}
</template>
</el-table-column>
</el-table>
<div class="pagination-box">
<el-pagination
v-model:current-page="rebateQuery.page"
v-model:page-size="rebateQuery.pageSize"
:total="rebatesTotal"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@change="loadRebates"
/>
</div>
</div>
<!-- 返利统计面板 -->
<div v-if="activeTab === 'summary'" class="panel-card">
<div class="filter-bar">
<el-date-picker
v-model="summaryQuery.dateRange"
type="daterange"
value-format="YYYY-MM-DD"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
unlink-panels
style="width: 260px"
/>
<el-select v-model="summaryQuery.source" placeholder="来源" clearable style="width: 120px">
<el-option label="订单" value="rental_order" />
<el-option label="提号" value="pickup" />
</el-select>
<el-select
v-model="summaryQuery.trade_role"
placeholder="交易端"
clearable
style="width: 120px"
>
<el-option label="买家端" value="buyer" />
<el-option label="卖家端" value="seller" />
</el-select>
<el-select
v-if="!isTenantSite && sites.length"
v-model="summaryQuery.distribution_site_id"
placeholder="全部分站"
clearable
style="width: 160px"
>
<el-option v-for="s in sites" :key="s.id" :value="s.id" :label="s.site_name" />
</el-select>
<el-button type="primary" :icon="Search" @click="loadSummary">查询</el-button>
<el-button :icon="Refresh" @click="resetSummary">重置</el-button>
</div>
<div class="table-hint">
统计口径与「返利结算流水」一致,按入账时间筛选,金额按实际发放返利汇总。
</div>
<div v-loading="loadingSummary" class="summary-body">
<div class="stat-grid">
<div class="stat-card stat-card-primary">
<div class="stat-label">返利总额</div>
<div class="stat-value">¥{{ formatCent(summary?.total_rebate_cent ?? 0) }}</div>
<div class="stat-sub">共 {{ summary?.ledger_count ?? 0 }} 笔结算流水</div>
</div>
<div class="stat-card">
<div class="stat-label">流水笔数</div>
<div class="stat-value">{{ summary?.ledger_count ?? 0 }}</div>
<div class="stat-sub">含订单与提号返利</div>
</div>
<div class="stat-card">
<div class="stat-label">邀请人数</div>
<div class="stat-value">{{ summary?.inviter_count ?? 0 }}</div>
<div class="stat-sub">产生过返利的邀请人</div>
</div>
<div class="stat-card">
<div class="stat-label">被邀请人数</div>
<div class="stat-value">{{ summary?.invitee_count ?? 0 }}</div>
<div class="stat-sub">产生过返利的被邀请人</div>
</div>
<div class="stat-card">
<div class="stat-label">平均单笔返利</div>
<div class="stat-value">¥{{ formatCent(summary?.avg_rebate_cent ?? 0) }}</div>
<div class="stat-sub">返利总额 ÷ 流水笔数</div>
</div>
</div>
<div class="breakdown-grid">
<div class="breakdown-card">
<div class="breakdown-title">按来源拆分</div>
<div class="breakdown-row">
<span class="breakdown-label">订单返利</span>
<span class="breakdown-num">
¥{{ formatCent(summary?.order_rebate_cent ?? 0) }} ·
{{ summary?.order_count ?? 0 }} 笔
</span>
<span class="breakdown-percent">
{{ percentOf(summary?.order_rebate_cent ?? 0, summary?.total_rebate_cent ?? 0) }}
</span>
</div>
<div class="breakdown-row">
<span class="breakdown-label">提号返利</span>
<span class="breakdown-num">
¥{{ formatCent(summary?.pickup_rebate_cent ?? 0) }} ·
{{ summary?.pickup_count ?? 0 }} 笔
</span>
<span class="breakdown-percent">
{{ percentOf(summary?.pickup_rebate_cent ?? 0, summary?.total_rebate_cent ?? 0) }}
</span>
</div>
</div>
<div class="breakdown-card">
<div class="breakdown-title">按交易端拆分</div>
<div class="breakdown-row">
<span class="breakdown-label">买家端</span>
<span class="breakdown-num">
¥{{ formatCent(summary?.buyer_rebate_cent ?? 0) }} ·
{{ summary?.buyer_count ?? 0 }} 笔
</span>
<span class="breakdown-percent">
{{ percentOf(summary?.buyer_rebate_cent ?? 0, summary?.total_rebate_cent ?? 0) }}
</span>
</div>
<div class="breakdown-row">
<span class="breakdown-label">卖家端</span>
<span class="breakdown-num">
¥{{ formatCent(summary?.seller_rebate_cent ?? 0) }} ·
{{ summary?.seller_count ?? 0 }} 笔
</span>
<span class="breakdown-percent">
{{ percentOf(summary?.seller_rebate_cent ?? 0, summary?.total_rebate_cent ?? 0) }}
</span>
</div>
</div>
<div class="breakdown-card">
<div class="breakdown-title">按周期阶段拆分</div>
<div class="breakdown-row">
<span class="breakdown-label">首月高额</span>
<span class="breakdown-num">¥{{ formatCent(summary?.first_month_cent ?? 0) }}</span>
<span class="breakdown-percent">
{{ percentOf(summary?.first_month_cent ?? 0, summary?.total_rebate_cent ?? 0) }}
</span>
</div>
<div class="breakdown-row">
<span class="breakdown-label">次月奖励</span>
<span class="breakdown-num">¥{{ formatCent(summary?.second_month_cent ?? 0) }}</span>
<span class="breakdown-percent">
{{ percentOf(summary?.second_month_cent ?? 0, summary?.total_rebate_cent ?? 0) }}
</span>
</div>
<div class="breakdown-row">
<span class="breakdown-label">长期分成</span>
<span class="breakdown-num">¥{{ formatCent(summary?.subsequent_cent ?? 0) }}</span>
<span class="breakdown-percent">
{{ percentOf(summary?.subsequent_cent ?? 0, summary?.total_rebate_cent ?? 0) }}
</span>
</div>
</div>
</div>
<div class="summary-section">
<div class="summary-section-title">每日返利趋势</div>
<el-table
:data="summary?.daily ?? []"
border
size="small"
max-height="340"
empty-text="当前筛选条件下暂无返利数据"
>
<el-table-column prop="date" label="日期" width="130" />
<el-table-column prop="ledger_count" label="流水笔数" width="110" align="right" />
<el-table-column label="返利合计" min-width="130" align="right">
<template #default="{ row }">
<strong style="color: #dc2626"
>+¥{{ formatCent(row.rebate_amount_cent || 0) }}</strong
>
</template>
</el-table-column>
<el-table-column label="订单返利" min-width="120" align="right">
<template #default="{ row }">¥{{ formatCent(row.order_amount_cent || 0) }}</template>
</el-table-column>
<el-table-column label="提号返利" min-width="120" align="right">
<template #default="{ row }">¥{{ formatCent(row.pickup_amount_cent || 0) }}</template>
</el-table-column>
</el-table>
</div>
<div class="summary-section">
<div class="summary-section-title">返利 Top 10 邀请人</div>
<el-table
:data="summary?.top_inviters ?? []"
border
size="small"
empty-text="当前筛选条件下暂无邀请人数据"
>
<el-table-column label="排名" width="70" align="center">
<template #default="{ $index }">{{ $index + 1 }}</template>
</el-table-column>
<el-table-column label="邀请人" min-width="180">
<template #default="{ row }">
<div>{{ row.inviter_nickname || '-' }}</div>
<code style="font-size: 12px; color: #64748b">{{ row.inviter_phone || '-' }}</code>
</template>
</el-table-column>
<el-table-column prop="ledger_count" label="返利笔数" width="110" align="right" />
<el-table-column label="返利金额" min-width="130" align="right">
<template #default="{ row }">
<strong style="color: #dc2626"
>+¥{{ formatCent(row.rebate_amount_cent || 0) }}</strong
>
</template>
</el-table-column>
</el-table>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.admin-invitations-page {
padding: 20px;
}
.page-header h2 {
margin: 0;
font-size: 20px;
font-weight: 700;
color: #1e293b;
}
.page-desc {
margin: 6px 0 18px;
font-size: 13px;
color: #64748b;
}
.nav-tabs {
display: flex;
gap: 10px;
margin-bottom: 16px;
}
.nav-tab-btn {
background: #ffffff;
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 8px 16px;
font-size: 14px;
font-weight: 500;
color: #475569;
cursor: pointer;
display: flex;
align-items: center;
gap: 6px;
transition: all 0.2s;
}
.nav-tab-btn:hover {
background: #f8fafc;
}
.nav-tab-btn.active {
background: #2563eb;
color: #ffffff;
border-color: #2563eb;
}
.panel-card {
background: #ffffff;
border-radius: 12px;
padding: 20px;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
border: 1px solid #f1f5f9;
}
.site-selector-row {
display: flex;
align-items: center;
gap: 12px;
padding-bottom: 14px;
border-bottom: 1px solid #f1f5f9;
margin-bottom: 14px;
}
.tenant-config-hint {
color: #64748b;
font-size: 13px;
}
.site-desc-hint {
font-size: 13px;
color: #475569;
background: #f8fafc;
border-left: 3px solid #3b82f6;
padding: 8px 12px;
border-radius: 4px;
margin-bottom: 18px;
}
.rate-input-box {
display: flex;
align-items: center;
gap: 8px;
}
.rate-unit {
font-weight: 700;
color: #64748b;
}
.field-hint {
font-size: 12px;
color: #94a3b8;
margin-top: 4px;
}
.filter-bar {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.table-hint {
margin-top: 10px;
font-size: 12px;
color: #94a3b8;
}
.invite-stat-total {
font-weight: 700;
color: #1e293b;
}
.invite-stat-active {
font-weight: 700;
color: #16a34a;
}
.invite-stat-pending {
font-weight: 700;
color: #d97706;
}
.summary-body {
margin-top: 16px;
}
.stat-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 12px;
}
.stat-card {
background: #f8fafc;
border: 1px solid #eef2f7;
border-radius: 10px;
padding: 14px 16px;
}
.stat-card-primary {
background: #eff6ff;
border-color: #bfdbfe;
}
.stat-label {
font-size: 12px;
color: #64748b;
}
.stat-value {
margin-top: 6px;
font-size: 22px;
font-weight: 700;
color: #1e293b;
line-height: 1.2;
}
.stat-card-primary .stat-value {
color: #dc2626;
}
.stat-sub {
margin-top: 6px;
font-size: 12px;
color: #94a3b8;
}
.breakdown-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 12px;
margin-top: 16px;
}
.breakdown-card {
border: 1px solid #eef2f7;
border-radius: 10px;
padding: 14px 16px;
}
.breakdown-title {
font-size: 13px;
font-weight: 600;
color: #1e293b;
padding-bottom: 10px;
margin-bottom: 8px;
border-bottom: 1px solid #f1f5f9;
}
.breakdown-row {
display: flex;
align-items: center;
gap: 8px;
padding: 5px 0;
font-size: 13px;
}
.breakdown-label {
width: 70px;
color: #64748b;
}
.breakdown-num {
flex: 1;
text-align: right;
color: #334155;
}
.breakdown-percent {
width: 56px;
text-align: right;
font-weight: 600;
color: #2563eb;
}
.summary-section {
margin-top: 22px;
}
.summary-section-title {
font-size: 14px;
font-weight: 600;
color: #1e293b;
margin-bottom: 10px;
}
.pagination-box {
margin-top: 16px;
display: flex;
justify-content: flex-end;
}
</style>