package com.cpop.jambox.business.bo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author DB
 * @version 1.0.0
 * @since 2024-01-08 9:23
 */
@Data
@ApiModel(value = "先学后付次付")
public class LearnNowPayLaterOncePayDto {

    /**
     * 支付分计划名称
     */
    @NotBlank(message = "支付分计划名称不能为空")
    @ApiModelProperty(value = "支付分计划名称", required = true)
    private String planName;

    /**
     * 支付分计划有效期(单位天)
     */
    @NotNull(message = "支付分计划有效期不能为空")
    @ApiModelProperty(value = "支付分计划有效期(单位天)", required = true)
    private Integer planDuration;

    /**
     * 支付分计划扣费次数
     */
    @NotNull(message = "支付分计划扣费次数不能为空")
    @ApiModelProperty(value = "支付分计划扣费次数", required = true)
    private Integer deductionQuantity;

    /**
     * 支付分计划原总金额(单位分)
     */
    @NotNull(message = "支付分计划原总金额不能为空")
    @ApiModelProperty(value = "支付分计划原总金额(单位分)", required = true)
    private Integer totalOriginalPrice;

    public void setTotalOriginalPrice(String totalOriginalPrice) {
        double price = Double.parseDouble(totalOriginalPrice) * 100;
        this.totalOriginalPrice = (int) price;
    }

    /**
     * 支付分计划实际扣费总金额(单位分)
     */
    @NotNull(message = "支付分计划实际扣费总金额不能为空")
    @ApiModelProperty(value = "支付分计划实际扣费总金额(单位分)", required = true)
    private Integer totalActualPrice;

    public void setTotalActualPrice(String totalActualPrice) {
        double price = Double.parseDouble(totalActualPrice) * 100;
        this.totalActualPrice = (int) price;
    }


    /**
     * 支付分计划明细列表
     */
    @NotEmpty(message = "支付分计划明细列表不能为空")
    @ApiModelProperty(value = "支付分计划明细列表", required = true)
    private List<PlanDetail> planDetailList;

    @Data
    public static class PlanDetail {
        /**
         * 计划明细原支付金额(单位分)
         */
        @NotNull(message = "计划明细原支付金额不能为空")
        @ApiModelProperty(value = "计划明细原支付金额(单位分)",required = true)
        private Integer originalPrice;

        public void setOriginalPrice(String originalPrice) {
            double price = Double.parseDouble(originalPrice) * 100;
            this.originalPrice = (int) price;
        }

        /**
         * 计划明细优惠说明
         */
        @NotBlank(message = "计划明细优惠说明不能为空")
        @ApiModelProperty(value = "计划明细优惠说明",required = true)
        private String planDiscountDescription;

        /**
         * 计划明细实际支付金额(单位分)
         */
        @NotNull(message = "计划明细实际支付金额不能为空")
        @ApiModelProperty(value = "计划明细实际支付金额(单位分)",required = true)
        private Integer actualPrice;

        public void setActualPrice(String actualPrice) {
            double price = Double.parseDouble(actualPrice) * 100;
            this.actualPrice = (int) price;
        }

        /**
         * 计划明细名称
         */
        @NotBlank(message = "计划明细名称不能为空")
        @ApiModelProperty(value = "计划明细名称",required = true)
        private String planDetailName;
    }
}
