fix: some
This commit is contained in:
89
src/config/constants/refund.ts
Normal file
89
src/config/constants/refund.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* 退款管理展示与规则常量
|
||||
*/
|
||||
|
||||
import {
|
||||
RefundStatus,
|
||||
RefundMethod,
|
||||
ChannelRefundStatus,
|
||||
RefundFailureReason
|
||||
} from '@/types/api/refund'
|
||||
|
||||
/** 退款状态名称映射 */
|
||||
export const RefundStatusNameMap: Record<RefundStatus, string> = {
|
||||
[RefundStatus.PENDING]: '待审批',
|
||||
[RefundStatus.APPROVED]: '已通过',
|
||||
[RefundStatus.REJECTED]: '已拒绝',
|
||||
[RefundStatus.RETURNED]: '已退回',
|
||||
[RefundStatus.REFUNDING]: '原路退款处理中',
|
||||
[RefundStatus.REFUND_FAILED]: '原路退款失败'
|
||||
}
|
||||
|
||||
/** 退款状态标签类型映射 */
|
||||
export const RefundStatusTypeMap: Record<
|
||||
RefundStatus,
|
||||
'warning' | 'success' | 'danger' | 'info'
|
||||
> = {
|
||||
[RefundStatus.PENDING]: 'warning',
|
||||
[RefundStatus.APPROVED]: 'success',
|
||||
[RefundStatus.REJECTED]: 'danger',
|
||||
[RefundStatus.RETURNED]: 'info',
|
||||
[RefundStatus.REFUNDING]: 'warning',
|
||||
[RefundStatus.REFUND_FAILED]: 'danger'
|
||||
}
|
||||
|
||||
/** 退款方式名称映射 */
|
||||
export const RefundMethodNameMap: Record<RefundMethod, string> = {
|
||||
[RefundMethod.ORIGINAL_ROUTE]: '原路退回',
|
||||
[RefundMethod.CUSTOMER_ACCOUNT]: '客户收款信息',
|
||||
[RefundMethod.ASSET_WALLET]: '资产钱包',
|
||||
[RefundMethod.AGENT_WALLET]: '代理钱包'
|
||||
}
|
||||
|
||||
/** 渠道退款状态名称映射 */
|
||||
export const ChannelRefundStatusNameMap: Record<ChannelRefundStatus, string> = {
|
||||
[ChannelRefundStatus.NOT_STARTED]: '未发起或不适用',
|
||||
[ChannelRefundStatus.PROCESSING]: '处理中',
|
||||
[ChannelRefundStatus.SUCCEEDED]: '已成功',
|
||||
[ChannelRefundStatus.FAILED]: '已失败'
|
||||
}
|
||||
|
||||
/** 失败分类名称映射 */
|
||||
export const RefundFailureReasonNameMap: Record<RefundFailureReason, string> = {
|
||||
[RefundFailureReason.CHANNEL_REJECTED]: '渠道明确拒绝',
|
||||
[RefundFailureReason.CREDENTIAL_INVALID]: '渠道凭证失效',
|
||||
[RefundFailureReason.INSUFFICIENT_BALANCE]: '渠道余额不足',
|
||||
[RefundFailureReason.TIMEOUT_UNKNOWN]: '超时或结果未知',
|
||||
[RefundFailureReason.APPROVAL_REJECTED]: '企微驳回或关闭',
|
||||
[RefundFailureReason.REVOKED_AFTER_APPROVED]: '企微通过后撤销',
|
||||
[RefundFailureReason.PAYMENT_FACT_INVALID]: '本地原支付事实不可用'
|
||||
}
|
||||
|
||||
/** 退款方式选项(表单用) */
|
||||
export const RefundMethodOptions = [
|
||||
{ label: '原路退回', value: RefundMethod.ORIGINAL_ROUTE },
|
||||
{ label: '客户收款信息', value: RefundMethod.CUSTOMER_ACCOUNT },
|
||||
{ label: '资产钱包', value: RefundMethod.ASSET_WALLET },
|
||||
{ label: '代理钱包', value: RefundMethod.AGENT_WALLET }
|
||||
]
|
||||
|
||||
/**
|
||||
* 是否可重提:3 已拒绝 / 4 已退回 / 6 原路退款失败(anomaly_flag=1 时禁止)
|
||||
*/
|
||||
export const canResubmitRefund = (item: {
|
||||
status?: RefundStatus
|
||||
anomaly_flag?: number
|
||||
}): boolean => {
|
||||
if (!item.status) return false
|
||||
if (item.status === RefundStatus.REJECTED || item.status === RefundStatus.RETURNED) return true
|
||||
if (item.status === RefundStatus.REFUND_FAILED) return item.anomaly_flag !== 1
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 审批操作是否可用:仅待审批且未关联企微审批实例(存量无实例)的申请
|
||||
*/
|
||||
export const canManualApproveRefund = (item: {
|
||||
status?: RefundStatus
|
||||
approval_instance_id?: number | null
|
||||
}): boolean => item.status === RefundStatus.PENDING && !item.approval_instance_id
|
||||
Reference in New Issue
Block a user