package com.ycwl.basic.pay.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class PayResponse {
    private boolean valid;
    private String orderNo;
    @JsonIgnore
    private Object originalResponse;
    private Integer orderPrice;
    private Integer payPrice;
    private PAY_STATE state;
    private String payTime;
    @JsonIgnore
    private String customResponse;

    public boolean isPay() {
        return state == PAY_STATE.SUCCESS;
    }

    public boolean isCancel() {
        return state == PAY_STATE.CANCEL;
    }

    public boolean isRefund() {
        return state == PAY_STATE.REFUND;
    }

    public void setPayPriceInYuan(BigDecimal money) {
        payPrice = money.multiply(BigDecimal.valueOf(100)).intValue();
    }

    public void setOrderPriceInYuan(BigDecimal money) {
         orderPrice = money.multiply(BigDecimal.valueOf(100)).intValue();
    }

    public enum PAY_STATE {
        SUCCESS,
        NOT_PAY,
        CANCEL,
        REFUND,
        FAIL,
        UNKNOWN;
    }
}
