package cn.pluss.platform.dto.jft;

import cn.pluss.platform.exception.MsgException;
import cn.pluss.platform.util.StringUtil;
import lombok.Data;

import java.math.BigDecimal;

/**
 * TODO
 *
 * @author crystal
 * @date 2022/7/1 23:25
 */
@Data
public class JftReceiptOrderDTO {

    private String startDate;

    private String endDate;

    /**
     * 支付状态 01：未支付 02：已支付
     */
    private String status;

    private Long userId;

    private String merchantCode;

    private String subject;

    private String city;

    private String province;

    private String mercOrderNo;

    private String notifyUrl;

    private BigDecimal orderAmt;

    private String payType;

    private String remark;

    private String merchantName;

    public void checkOrderParams() {
//        MsgException.checkBlank(this.getMerchantCode(),"商户编号不能为空！");
        MsgException.checkBlank(this.getSubject(),"订单标题不能为空！");
        MsgException.checkBlank(this.getCity(),"下单用户所属城市不能为空！");
        MsgException.checkBlank(this.getMercOrderNo(),"商户单号不能为空！");
        MsgException.check(this.getMercOrderNo().length() < 10 || this.getMercOrderNo().length() > 50 ,"订单号过长，订单号长度应介于10-50位之间");
        MsgException.checkBlank(this.getNotifyUrl(),"异步通知地址不能为空！");
        MsgException.checkNull(this.getOrderAmt(),"订单金额不能为空");
        MsgException.check(!StringUtil.isNumber(this.getOrderAmt().toString()),"订单金额格式有误，金额保留两位小数，单位元");
        MsgException.checkBlank(this.getPayType(),"支付方式不能为空");
    }
}
