package com.ycwl.basic.pay.entity;

import lombok.Data;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.math.BigInteger;

@Data
@Accessors(chain = true)
public class CreateOrderRequest {
    /**
     * 价格，单位为分
     */
    private Integer price;
    private String goodsName;
    private String orderNo;
    private String description;
    private String userIdentify;
    private String notifyUrl;


    public BigDecimal getPriceInYuan() {
        return new BigDecimal(BigInteger.valueOf(price), 2);
    }
    public CreateOrderRequest setPriceInCents(Integer priceInCents) {
        this.price = priceInCents;
        return this;
    }

    public CreateOrderRequest setPriceInYuan(BigDecimal priceInYuan) {
        this.price = priceInYuan.multiply(new BigDecimal(100)).intValue();
        return this;
    }
}
