Files
one-pipe-system/src/config/constants/commission.ts
luo b2a76adc9a
All checks were successful
构建并部署前端到测试环境 / deploy (push) Successful in 55s
fix: some
2026-10-13 11:25:03 +08:00

163 lines
6.6 KiB
TypeScript
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.
/**
* 佣金相关配置
*/
import { CommissionStatus, WithdrawalStatus } from '@/types/api/commission'
// 佣金状态选项
export const COMMISSION_STATUS_OPTIONS = [
{ label: '已冻结', value: CommissionStatus.FROZEN, type: 'info' as const },
{ label: '解冻中', value: CommissionStatus.UNFREEZING, type: 'warning' as const },
{ label: '已发放', value: CommissionStatus.RELEASED, type: 'success' as const },
{ label: '已失效', value: CommissionStatus.INVALID, type: 'danger' as const },
{ label: '回溯', value: CommissionStatus.CLAWBACK, type: 'danger' as const },
{ label: '待人工修正', value: CommissionStatus.PENDING_CORRECTION, type: 'warning' as const }
]
// 提现状态选项
export const WITHDRAWAL_STATUS_OPTIONS = [
{ label: '待审核', value: WithdrawalStatus.PENDING, type: 'warning' as const },
{ label: '已通过', value: WithdrawalStatus.APPROVED, type: 'success' as const },
{ label: '已拒绝', value: WithdrawalStatus.REJECTED, type: 'danger' as const },
{ label: '已到账', value: WithdrawalStatus.COMPLETED, type: 'success' as const },
{
label: '审批提交失败',
value: WithdrawalStatus.APPROVAL_SUBMISSION_FAILED,
type: 'danger' as const
}
]
// 支付方式选项
export const PAYMENT_METHOD_OPTIONS = [
{ label: '银行卡', value: 'bank', icon: 'bank' },
{ label: '支付宝', value: 'alipay', icon: 'alipay' },
{ label: '微信', value: 'wechat', icon: 'wechat' }
]
// ========== 提现状态映射 ==========
// 提现状态映射 (1:待审核, 2:已通过, 3:已拒绝, 4:已到账)
export const WithdrawalStatusMap = {
1: { label: '待审核', type: 'warning' as const, color: '#E6A23C' },
2: { label: '已通过', type: 'success' as const, color: '#67C23A' },
3: { label: '已拒绝', type: 'danger' as const, color: '#F56C6C' },
4: { label: '已到账', type: 'success' as const, color: '#67C23A' },
5: { label: '审批提交失败', type: 'danger' as const, color: '#F56C6C' }
}
export const WITHDRAWAL_QUALIFICATION_APPROVAL_FAILED = 4
export const WITHDRAWAL_QUALIFICATION_STATUS_OPTIONS = [
{ label: '待审批', value: 0 },
{ label: '已通过', value: 1 },
{ label: '已驳回', value: 2 },
{ label: '已作废', value: 3 },
{ label: '审批提交失败', value: WITHDRAWAL_QUALIFICATION_APPROVAL_FAILED }
]
export const canResubmitWithdrawal = (status: number): boolean =>
status === WithdrawalStatus.REJECTED || status === WithdrawalStatus.APPROVAL_SUBMISSION_FAILED
// ========== 佣金状态映射 ==========
// 佣金状态映射 (1:已冻结, 2:解冻中, 3:已发放, 4:已失效, 99:待人工修正)
export const CommissionStatusMap = {
1: { label: '已冻结', type: 'info' as const, color: '#909399' },
2: { label: '解冻中', type: 'warning' as const, color: '#E6A23C' },
3: { label: '已发放', type: 'success' as const, color: '#67C23A' },
4: { label: '已失效', type: 'danger' as const, color: '#F56C6C' },
5: { label: '回溯', type: 'danger' as const, color: '#F56C6C' },
99: { label: '待人工修正', type: 'warning' as const, color: '#E6A23C' }
}
// ========== 提现方式映射 ==========
// 提现方式映射 (alipay:支付宝, wechat:微信, bank:银行卡)
export const WithdrawalMethodMap = {
alipay: { label: '支付宝', icon: 'alipay' },
wechat: { label: '微信', icon: 'wechat' },
bank: { label: '银行卡', icon: 'bank' }
}
// ========== 佣金来源映射 ==========
// 佣金来源映射 (cost_diff:成本差价, one_time:一次性佣金)
export const CommissionSourceMap = {
cost_diff: { label: '成本差价', type: 'primary' as const },
one_time: { label: '一次性佣金', type: 'success' as const }
}
// 佣金类型映射 (one_time:一次性佣金, long_term:长期佣金) - 兼容旧字段
export const CommissionTypeMap = {
one_time: { label: '一次性佣金', type: 'primary' as const },
long_term: { label: '长期佣金', type: 'success' as const }
}
// 获取佣金状态标签
export function getCommissionStatusLabel(status: CommissionStatus): string {
const option = COMMISSION_STATUS_OPTIONS.find((item) => item.value === status)
return option?.label || String(status)
}
// 获取佣金状态类型
export function getCommissionStatusType(status: CommissionStatus) {
const option = COMMISSION_STATUS_OPTIONS.find((item) => item.value === status)
return option?.type || 'info'
}
// 获取提现状态标签
export function getWithdrawalStatusLabel(status: WithdrawalStatus): string {
const option = WITHDRAWAL_STATUS_OPTIONS.find((item) => item.value === status)
return option?.label || String(status)
}
// 获取提现状态类型
export function getWithdrawalStatusType(status: WithdrawalStatus) {
const option = WITHDRAWAL_STATUS_OPTIONS.find((item) => item.value === status)
return option?.type || 'info'
}
// 获取支付方式标签
export function getPaymentMethodLabel(method: string): string {
const option = PAYMENT_METHOD_OPTIONS.find((item) => item.value === method)
return option?.label || method
}
// 获取佣金类型标签
export function getCommissionTypeLabel(type: string): string {
const config = CommissionTypeMap[type as keyof typeof CommissionTypeMap]
return config?.label || String(type)
}
// 获取佣金类型type
export function getCommissionTypeType(type: string) {
const config = CommissionTypeMap[type as keyof typeof CommissionTypeMap]
return config?.type || 'info'
}
// ========== 佣金记录(含回溯明细)映射 ==========
// 记录来源映射 (original:原佣金, clawback:回溯明细)
export const COMMISSION_RECORD_SOURCE_MAP = {
original: { label: '原佣金', type: 'primary' as const },
clawback: { label: '回溯明细', type: 'danger' as const }
}
// 佣金记录状态筛选选项(含回溯,不含待人工修正)
export const COMMISSION_RECORD_STATUS_OPTIONS = [
{ label: '已冻结', value: CommissionStatus.FROZEN },
{ label: '解冻中', value: CommissionStatus.UNFREEZING },
{ label: '已发放', value: CommissionStatus.RELEASED },
{ label: '已失效', value: CommissionStatus.INVALID },
{ label: '回溯', value: CommissionStatus.CLAWBACK }
]
// 是否回溯明细行(source 与 status 双判断,兼容未返回 source 的响应)
export function isCommissionClawbackRecord(record: { source?: string; status?: number }): boolean {
return record.source === 'clawback' || record.status === CommissionStatus.CLAWBACK
}
// 列表行 key:原佣金与回溯明细 ID 空间独立,同一页可能出现相同 id
export function getCommissionRecordRowKey(record: { id: number; source?: string }): string {
return `${record.source || 'original'}:${record.id}`
}