package com.goafanti.common.utils;

import com.goafanti.common.model.TOrderNew;
import com.goafanti.order.enums.LiquidationState;

import java.math.BigDecimal;

public class OrderUtils {


    public static int getLiquidationStatus(TOrderNew t){
        if (t.getSettlementAmount().compareTo(t.getFirstAmount())<0)return LiquidationState.WAIT_PAY_FIRST_BALANCE.getCode();
        else if (t.getSettlementAmount().compareTo(t.getFirstAmount())>-1
          &&t.getSettlementAmount().compareTo(t.getTotalAmount())<0)return LiquidationState.WAIT_PAY_LAST_BALANCE.getCode();
        else{
            return LiquidationState.ALREADY_PAY.getCode();
        }
    }

    public static int getLiquidationStatus(BigDecimal total,BigDecimal first,BigDecimal settlement){
        TOrderNew t=new TOrderNew();
        t.setTotalAmount(total);
        t.setFirstAmount(first);
        t.setSettlementAmount(settlement);
        return getLiquidationStatus(t);
    }


}
