package cn.iocoder.yudao.module.course.vo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

@Data
public class CourseOrderExportVO {

    /*@ExcelProperty(value = " ", index = 0)
    @ColumnWidth(8)
    private Integer serialNumber;*/

    @ExcelIgnore
    private Long studentId;

    @ExcelProperty(value = "学员姓名", index = 0)
    private String studentName;

    @ExcelProperty(value = "学员身份证号", index = 1)
    private String studentIdCard;

    @ExcelProperty(value = "学员手机号", index = 2)
    private String studentPhone;

    /*@ExcelProperty(value = "学员报名时间", index = 4)
    @DateTimeFormat("yyyy-MM-dd")*/
    @ExcelIgnore
    private Date signUpTime;

    @ExcelProperty(value = "学员报名时间", index = 3)
    private String signUpTimeStr;

    public void setSignUpTime(Date signUpTime) {
        this.signUpTime = signUpTime;
        if (signUpTime != null) {
            this.signUpTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(signUpTime);
        }
    }

    @ExcelIgnore
    private Long courseId;

    @ExcelProperty(value = "课程名称", index = 4)
    private String courseName;

    @ExcelProperty(value = "课程类型", index = 5)
    private String courseType;

    @ExcelProperty(value = "课程金额", index = 6)
    private BigDecimal reserveMoney;

    @ExcelProperty(value = "优惠金额", index = 7)
    private BigDecimal discount;

    @ExcelIgnore
    private String discountIndex;

    @ExcelProperty(value = "实付金额", index = 8)
    private BigDecimal actualPayment;

    /*@ExcelProperty(value = "缴费时间", index = 8)
    @DateTimeFormat("yyyy-MM-dd")*/
    @ExcelIgnore
    private Date payFeesTime;
    @ExcelProperty(value = "缴费时间", index = 9)
    private String payFeesTimeStr;

    public void setPayFeesTime(Date payFeesTime) {
        this.payFeesTime = payFeesTime;
        if (payFeesTime != null) {
            this.payFeesTimeStr = new SimpleDateFormat("yyyy-MM-dd").format(payFeesTime);
        }
    }

    @ExcelIgnore
    private String source;

    @ExcelProperty(value = "渠道", index = 10)
    private String sourceStr;

    @ExcelProperty(value = "订单备注", index = 11)
    private String orderRemark;

//    @ExcelProperty(value = "是否已面签", index = 13)
    @ExcelIgnore
    private Integer isSign;

    @ExcelProperty(value = "是否已面签", index = 12)
    private String isSignDisplay;

    @ExcelIgnore
    private LocalDateTime signTime;

    @ExcelProperty(value = "面签时间", index = 13)
    private String signTimeStr;

    public void setSignTime(LocalDateTime signTime) {
        this.signTime = signTime;
        if (signTime != null) {
            this.signTimeStr = signTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        }
    }
    @ExcelIgnore
    private Long coachId;

    @ExcelProperty(value = "科目二教练", index = 14)
    private String subject2CoachName;

    @ExcelProperty(value = "科目二提成(预提)", index = 15)
    private String subject2Deduct;

    @ExcelProperty(value = "科目三教练", index = 16)
    private String subject3CoachName;

    @ExcelProperty(value = "科目三提成(预提)", index = 17)
    private String subject3Deduct;

    @ExcelProperty(value = "出纳是否确认收款", index = 18)
    private String cashierConfirmDisplay;

    @ExcelProperty(value = "收款账号", index = 19)
    private String paymentAccount;
    @ExcelIgnore
    private String cashierConfirm;

    /*@ExcelProperty(value = "出纳确认时间", index = 17)*/
    @ExcelIgnore
    private Date cashierConfirmTime;

    @ExcelProperty(value = "出纳确认时间", index = 20)
    private String cashierConfirmTimeStr;

    public void setCashierConfirmTime(Date cashierConfirmTime) {
        this.cashierConfirmTime = cashierConfirmTime;
        if (cashierConfirmTime != null) {
            this.cashierConfirmTimeStr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cashierConfirmTime);
        }
    }

    @ExcelProperty(value = "出纳备注", index = 21)
    private String cashierConfirmRemark;

    /**
     * 订单状态 0：待支付 1：已取消 :2：已支付(已报名) 3：待面签 4：已面签 5：已完成  6：申请退款 7：退款中 8：退款成功
     */
    @ExcelIgnore
    private String paymentStatus;

    /**
     * 支付类型 1：定金 2：全款
     */
    @ExcelIgnore
    private String payType;

    @ExcelIgnore
    private Integer subject;

    @ExcelIgnore
    private String signUpStartTimeStr;
    @ExcelIgnore
    private String signUpEndTimeStr;

    @ExcelIgnore
    private String payFeesStartTimeStr;
    @ExcelIgnore
    private String payFeesEndTimeStr;

    @ExcelIgnore
    private String cashierConfirmStartTimeStr;
    @ExcelIgnore
    private String cashierConfirmEndTimeStr;

    // 分页参数
    @ExcelIgnore
    private Integer pageNo = 1;
    @ExcelIgnore
    private Integer pageSize = 10;

    // 导出类型：all(全部)、current(当前页)、range(自定义范围)
    @ExcelIgnore
    private String exportType;

    // 自定义范围参数
    @ExcelIgnore
    private Integer startPage;
    @ExcelIgnore
    private Integer endPage;



    public String getIsSignDisplay() {
        return isSign != null && isSign == 1 ? "是" : "否";
    }

    public String getCashierConfirmDisplay() {
        if (cashierConfirm == null) {
            return "待确认";
        }
        switch (cashierConfirm) {
            case "0":
                return "未到账";
            case "1":
                return "已到账";
            default:
                return "未知状态";
        }
    }

    public void setSource(String source) {
        this.source = source;

        if (source == null) {
            this.sourceStr = "";
            return;
        }

        switch (source) {
            case "01":
                this.sourceStr = "驾校统招";
                break;
            case "02":
                this.sourceStr = "教练自招";
                break;
            case "03":
                this.sourceStr = "自来客户";
                break;
            case "04":
                this.sourceStr = "业务经理统招";
                break;
            default:
                this.sourceStr = "未知渠道";
                break;
        }
    }

}
