Files
one-pipe-system/src/utils/business/paymentConfig.ts
luo 93f67967c5
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m8s
fix: formate code and test money
2026-08-18 10:54:01 +08:00

65 lines
1.7 KiB
TypeScript

import type { PaymentProviderType, PaymentSettings } from '@/types/api'
const PAYMENT_PROVIDER_LABELS: Record<PaymentProviderType, string> = {
wechat: '微信直连',
wechat_v2: '微信直连V2',
fuiou: '富友支付'
}
export const getPaymentProviderText = (type: PaymentProviderType): string => {
return PAYMENT_PROVIDER_LABELS[type] || type
}
export const getPaymentMerchantId = (
config: Pick<PaymentSettings, 'provider_type' | 'wx_mch_id' | 'fy_mchnt_cd'>
): string => {
if (config.provider_type === 'wechat' || config.provider_type === 'wechat_v2') {
return config.wx_mch_id || '-'
}
if (config.provider_type === 'fuiou') {
return config.fy_mchnt_cd || '-'
}
return '-'
}
export const getPaymentNotifyUrl = (
config: Pick<
PaymentSettings,
'provider_type' | 'wx_notify_url' | 'fy_notify_url' | 'ali_notify_url'
>
): string => {
if (config.provider_type === 'wechat' || config.provider_type === 'wechat_v2') {
return config.wx_notify_url || '-'
}
if (config.provider_type === 'fuiou') {
return config.fy_notify_url || '-'
}
return config.ali_notify_url || '-'
}
export const getPaymentConfigStatus = (value: string | undefined | null): string => {
if (!value) return '未配置'
if (value === 'configured' || value === '[已配置]' || value === '已配置') {
return '已配置'
}
if (value === '[未配置]' || value === '未配置') {
return '未配置'
}
return value
}
export const isMaskedPaymentConfigValue = (value: string | undefined | null): boolean => {
if (!value) return false
return (
value === '***' || value.includes('已配置') || value.includes('未配置') || /\*{2,}/.test(value)
)
}