RcbStateUtils.java 1.35 KB
package com.diligrp.cashier.pipeline.util;

import com.diligrp.cashier.pipeline.type.OutPaymentType;
import com.diligrp.cashier.pipeline.type.PaymentState;

public final class RcbStateUtils {
    public static PaymentState paymentState(String orderStatus) {
        return switch (orderStatus) {
            case "3", "6" -> PaymentState.SUCCESS; // 3-交易成功; 6-交易成功但有退款
            case "1", "2" -> PaymentState.PROCESSING;
            default -> PaymentState.FAILED;
        };
    }

    public static PaymentState refundState(String orderStatus) {
        return switch (orderStatus) {
            case "01" -> PaymentState.SUCCESS;
            case "02" -> PaymentState.FAILED;
            default -> PaymentState.PROCESSING;
        };
    }

    public static String refundInfo(PaymentState refundState) {
        return switch (refundState) {
            case SUCCESS -> "退款成功";
            case FAILED -> "退款失败";
            default -> "退款处理中";
        };
    }

    public static OutPaymentType outPayType(String tradeChannel) {
        return switch (tradeChannel) {
            case "01" -> OutPaymentType.WXPAY; // 微信
            case "02" -> OutPaymentType.ALIPAY; // 支付宝
            case "04" -> OutPaymentType.UPAY; // 银联
            default -> OutPaymentType.NOP; // 未知支付方式
        };
    }
}