This commit is contained in:
64
src/utils/business/paymentConfig.ts
Normal file
64
src/utils/business/paymentConfig.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import type { PaymentProviderType, WechatConfig } 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<WechatConfig, '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<WechatConfig, '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)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user