yanderong
4 天以前 7617d46abee2950b7336e3379f8c7a564939cb54
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.ruoyi.order.service.impl;
 
import java.math.BigDecimal;
 
final class ChargingPaymentSupport {
    private ChargingPaymentSupport() {
    }
 
    static int resolvePayMethod(BigDecimal balancePayAmount, BigDecimal thirdPayAmount, int fallback) {
        boolean hasBalance = balancePayAmount != null && balancePayAmount.compareTo(BigDecimal.ZERO) > 0;
        boolean hasThirdPay = thirdPayAmount != null && thirdPayAmount.compareTo(BigDecimal.ZERO) > 0;
        if (hasBalance && hasThirdPay) {
            return 2;
        }
        if (hasBalance) {
            return 1;
        }
        if (hasThirdPay) {
            return 3;
        }
        return fallback;
    }
}