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

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class BusinessRecordExportVO {

    @ExcelIgnore
    private Long coachId;

    @ExcelProperty(value = "业务经理姓名", index = 0)
    private String businessName;

    @ExcelProperty(value = "报名时间", index = 1)
    private String createTimeStr;

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

    @ExcelProperty(value = "手机号", index = 3)
    private String phone;

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

    @ExcelProperty(value = "学员年龄", index = 5)
    private String age;

    @ExcelProperty(value = "学员性别", index = 6)
    private String sexStr;

    @ExcelIgnore
    private String sex;

    @ExcelProperty(value = "来源", index = 7)
    private String channel;

    @ExcelProperty(value = "是否面签", index = 8)
    private String isSignStr;

    @ExcelIgnore
    private Integer isSign;
    @ExcelIgnore
    private String ifEnd;

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

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

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

    @ExcelProperty(value = "所选教练", index = 12)
    private String coachUserName;

    @ExcelProperty(value = "支付金额", index = 13)
    private BigDecimal reserveMoney;

    @ExcelProperty(value = "尾款金额", index = 14)
    private BigDecimal restMoney;

    @ExcelIgnore
    private String paymentStatus;

    @ExcelProperty(value = "订单状态", index = 15)
    private String paymentStatusStr;

    @ExcelProperty(value = "支付方式", index = 16)
    private String payTypeStr;

    @ExcelIgnore
    private String payType;

    @ExcelProperty(value = "业务经理手机号", index = 17)
    private String businessPhone;

    @ExcelProperty(value = "补贴金额", index = 18)
    private BigDecimal subsidy;


    @ExcelIgnore
    private String scheme;

    @ExcelIgnore
    private String courseId;

    @ExcelIgnore
    private String startTimeStr;
    @ExcelIgnore
    private String endTimeStr;

    // 分页参数
    @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 getSexStr() {
        if ("0".equals(sex)) return "男";
        if ("1".equals(sex)) return "女";
        return "未知";
    }

    public String getPayTypeStr() {
        if ("1".equals(payType)) return "定金";
        if ("2".equals(payType)) return "全款";
        return "未知";
    }

    public void setCreateTime(Date createTime) {
        if (createTime != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            this.createTimeStr = sdf.format(createTime);
        }
    }

    public void setSignTime(Date signTime) {
        if (signTime != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            this.signTimeStr = sdf.format(signTime);
        }
    }

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

    public String getPaymentStatusStr() {
        switch (paymentStatus) {
            case "0": return "待支付";
            case "1": return "已取消";
            case "2": return "已支付";
            case "3": return "待面签";
            case "4": return "已面签";
            case "5": return "已完成";
            case "6": return "申请退款";
            case "7": return "退款中";
            case "8": return "退款成功";
            default: return "暂无数据";
        }
    }
}
