RcbStateUtils.java
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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; // 未知支付方式
};
}
}