package com.cpop.pay.framewok.core.request.ecpp;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author DB
 * @version 1.0.0
 * @since 2024-01-30 15:31
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class EcppServiceEntryRequest extends EcppVerifyRequest {

    /**
     * 速达商户Id
     */
    private String merchantId = "100";

    /**
     * 渠道编号
     */
    private String channelCode = "01";

    /**
     * 服务名称
     */
    private String serviceName;

    /**
     * 服务开始日期
     */
    private String serviceStartDate;

    public void setServiceStartDate(LocalDate serviceStartDate) {
        this.serviceStartDate = serviceStartDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
    }

    /**
     * 服务结束日期
     */
    private String serviceEndDate;

    public void setServiceEndDate(LocalDate serviceEndDate) {
        this.serviceEndDate = serviceEndDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
    }

    /**
     * 服务数量
     */
    private String serviceQuantity;

    public void setServiceQuantity(Integer serviceQuantity) {
        this.serviceQuantity = serviceQuantity.toString();
    }

    /**
     * 服务金额
     */
    private String serviceAmount;

    public void setServiceAmount(BigDecimal serviceAmount) {
        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
        this.serviceAmount = decimalFormat.format(serviceAmount);
    }

    /**
     * 服务等级 01、匿名预付；02、弱实名预付；03、强实名预付
     */
    private String serviceGrade = "01";

    /**
     * 核销模式 01、按次数；02、按金额
     */
    private String writeOffMode = "02";

    /**
     * 适用门店描述
     */
    private String applyDesc = "适用门店描述";
    /**
     * 卡片归还规则描述
     */
    private String returnDesc = "卡片归还规则描述";

    /**
     * 到期清算基数 01、按总额；02、按余额；
     */
    private String expLiquidateCardinal;

    public void setExpLiquidateCardinal(Integer expLiquidateCardinal) {
        this.expLiquidateCardinal = "0" + expLiquidateCardinal;
    }

    /**
     * 到期清算模式 01、按比例；02、按金额；
     */
    private String expLiquidateMode;

    public void setExpLiquidateMode(Integer expLiquidateMode) {
        this.expLiquidateMode = "0" + expLiquidateMode;
    }

    /**
     * 到期清算比例 合约到期，资金处置所属合作方的份额比例值，输入10.00 代表 10.00%；到期清算模式按比例时必填
     */
    private String expLiquidateRate;

    public void setExpLiquidateRate(BigDecimal expLiquidateRate) {
        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
        this.expLiquidateRate = decimalFormat.format(expLiquidateRate);
    }

    /**
     * 到期清算金额 合约到期，资金处置所属合作方的金额值；到期清算模式按金额时必填，
     */
    private String expLiquidateAmount;

    public void setExpLiquidateAmount(BigDecimal expLiquidateAmount) {
        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
        this.expLiquidateAmount = decimalFormat.format(expLiquidateAmount);
    }

    /**
     * 违约清算基数 01、按总额；02、按余额；
     */
    private String defaultLiquidateCardinal;

    public void setDefaultLiquidateCardinal(Integer defaultLiquidateCardinal) {
        this.defaultLiquidateCardinal = "0" + defaultLiquidateCardinal;
    }

    /**
     * 违约清算模式 01、按比例；02、按金额；
     */
    private String defaultLiquidateMode;

    public void setDefaultLiquidateMode(Integer defaultLiquidateMode) {
        this.defaultLiquidateMode = "0" + defaultLiquidateMode;
    }

    /**
     * 违约清算比例 客户主动违约，资金处置所属合作方的份额比例值，输入 10.00 代表 10.00%；到期清算模式按比例时必填，
     */
    private String defaultLiquidateRate;

    public void setDefaultLiquidateRate(BigDecimal defaultLiquidateRate) {
        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
        this.defaultLiquidateRate = decimalFormat.format(defaultLiquidateRate);
    }

    /**
     * 违约清算金额 客户主动违约，资金处置所属合作方的金额值；到期清算模式按金额时必填，
     */
    private String defaultLiquidateAmount;

    public void setDefaultLiquidateAmount(BigDecimal defaultLiquidateAmount) {
        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
        this.defaultLiquidateAmount = decimalFormat.format(defaultLiquidateAmount);
    }

    /**
     * 服务图片
     */
    private EcppServiceImageRequest serviceImage;
}
