package com.yd.csf.service.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yd.csf.service.model.Commission;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@Data
public class CommissionVO implements Serializable {

    /**
     * commission id
     */
    @Schema(description = "commission id (commission：来佣记录、入账记录、实际来佣记录、实际入账记录)")
    private Long id;

    /**
     * 保单来佣业务id
     */
    @Schema(description = "保单来佣业务id")
    private String commissionBizId;

    /**
     * 应收款编号
     */
    @Schema(description = "应收款编号")
    private String receivableNo;

    /**
     * 应收款类型 R=关联保单应收单 U=非关联保单应收单
     */
    @Schema(description = "应收款类型 R=关联保单应收单 U=非关联保单应收单")
    private String commissionBizType;

    /**
     * 入账检核年月 yyyy-MM
     */
    @Schema(description = "入账检核年月 yyyy-MM")
    private String reconciliationYearMonth;

    /**
     * 保单号
     */
    @Schema(description = "保单号")
    private String policyNo;

    /**
     * 保单币种
     */
    @Schema(description = "保单币种")
    private String policyCurrency;

    /**
     * 期交保费
     */
    @Schema(description = "期交保费")
    private BigDecimal premium;

    /**
     * 产品计划名称
     */
    @Schema(description = "产品计划名称")
    private String productName;

    /**
     * 保险公司
     */
    @Schema(description = "保险公司")
    private String insuranceCompany;

    /**
     * 对账公司
     */
    @Schema(description = "对账公司")
    private String reconciliationCompany;

    /**
     * 对账公司编码
     */
    @Schema(description = "对账公司编码")
    private String reconciliationCompanyCode;

    /**
     * 对账公司 id
     */
    @Schema(description = "对账公司 id")
    private String reconciliationCompanyBizId;

    /**
     * 保险公司 id
     */
    @Schema(description = "保险公司 id")
    private String insuranceCompanyBizId;

    /**
     * 产品计划 id
     */
    @Schema(description = "产品计划 id")
    private String productLaunchBizId;

    /**
     * 佣金期数(1=第一年; 2=第二年; 3=第三年; 4=第四年; 5=第五年)
     */
    @Schema(description = "佣金期数(1=第一年; 2=第二年; 3=第三年; 4=第四年; 5=第五年)")
    private Integer commissionPeriod;

    /**
     * 总来佣期数
     */
    @Schema(description = "总来佣期数")
    private Integer totalPeriod;

    /**
     * 来佣名称(1:销售拥金;2:销售奖金;3:销售津贴;4:续期佣金;5:服务津贴;等等)
     */
    @Schema(description = "来佣名称(1:销售拥金;2:销售奖金;3:销售津贴;4:续期佣金;5:服务津贴;等等)")
    private String commissionName;

    /**
     * 来佣类型(1:销售拥金;2:销售奖金;3:销售津贴;4:续期佣金;5:服务津贴;等等)
     */
    @Schema(description = "来佣类型(1:销售拥金;2:销售奖金;3:销售津贴;4:续期佣金;5:服务津贴;等等)")
    private String commissionType;

    /**
     * 当前结算汇率
     */
    @Schema(description = "当前结算汇率")
    private BigDecimal exchangeRate;

    /**
     * 来佣金额
     */
    @Schema(description = "来佣金额")
    private BigDecimal amount;

    /**
     * 来佣币种
     */
    @Schema(description = "来佣币种")
    private String currency;

    /**
     * 来佣日期
     */
    @Schema(description = "来佣日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date commissionDate;

    /**
     * 当前来佣比例
     */
    @Schema(description = "当前来佣比例")
    private BigDecimal currentCommissionRatio;

    /**
     * 比对状态
     */
    @Schema(description = "比对状态 0=未比对 1=比对成功 2=比对失败 3=未匹配到预计入账记录 字典值: csf_commission_status")
    private String commissionStatus;

    /**
     * 预计来佣业务id
     */
    @Schema(description = "预计来佣业务id")
    private String commissionExpectedBizId;

    /**
     * 入账状态
     */
    @Schema(description = "入账状态 字典值: csf_expected_commission_status")
    private String commissionExpectedStatus;

    /**
     * 总金额
     */
    @Schema(description = "总金额")
    private String expectedAmount;

    /**
     * 累计入账比例
     */
    @Schema(description = "累计入账比例")
    private BigDecimal paidRatio;

    /**
     * 待入账比例
     */
    @Schema(description = "待入账比例")
    private BigDecimal pendingRatio;

    /**
     * 通用备注
     */
    @Schema(description = "备注")
    private String remark;

    /**
     * 记录状态 0=有效 1=无效
     */
    @Schema(description = "记录状态 0=有效 1=无效")
    private Integer isDeleted;

    /**
     * 创建人ID
     */
    @Schema(description = "创建人ID")
    private String creatorId;

    /**
     * 更新人ID
     */
    @Schema(description = "更新人ID")
    private String updaterId;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     * 更新时间
     */
    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    private static final long serialVersionUID = 1L;

    /**
     * 对象转封装类
     *
     * @param commission
     * @return
     */
    public static CommissionVO objToVo(Commission commission) {
        if (commission == null) {
            return null;
        }
        CommissionVO commissionVO = new CommissionVO();
        BeanUtils.copyProperties(commission, commissionVO);
        commissionVO.setCommissionStatus(commission.getStatus());
        return commissionVO;
    }
}
