package com.ghy.payment.domain;

import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity;
import com.ghy.common.enums.FinancialDetailType;
import com.ghy.common.enums.PayStatus;
import com.ghy.common.enums.PayTypeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author clunt
 * 财务细单(可能是师傅分佣后的细单关联，也可能是分佣账单，平台提成账单等类型)
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class FinancialDetail extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @Excel(name = "序号", cellType = Excel.ColumnType.NUMERIC)
    private Long id;

    @Excel(name = "商户ID", cellType = Excel.ColumnType.NUMERIC)
    private Long deptId;

    @Excel(name = "编码", cellType = Excel.ColumnType.STRING)
    private String code;

    @Excel(name = "主财务单ID", cellType = Excel.ColumnType.NUMERIC)
    private Long financialMasterId;

    @Excel(name = "主财务单编码", cellType = Excel.ColumnType.STRING)
    private String financialMasterCode;

    @Excel(name = "子订单ID", cellType = Excel.ColumnType.NUMERIC)
    private Long orderDetailId;

    @Excel(name = "子订单编码", cellType = Excel.ColumnType.STRING)
    private String orderDetailCode;

    @Excel(name = "子单总金额", cellType = Excel.ColumnType.STRING)
    private BigDecimal totalMoney;

    @Excel(name = "优惠金额", cellType = Excel.ColumnType.STRING)
    private BigDecimal discountMoney;

    @Excel(name = "实付金额", cellType = Excel.ColumnType.STRING)
    private BigDecimal payMoney;

    /**
     * {@link FinancialDetailType}
     */
    @Excel(name = "财务子单类型", cellType = Excel.ColumnType.NUMERIC)
    private Integer financialDetailType;

    /**
     * 收款人ID
     * 当财务子单类型是师傅转派时 收款人ID是师傅或徒弟的workerId
     * 当财务子单类型是多级分销时 收款人ID是分销者的customerId
     * 当财务子单类型是4时 无需填写收款人ID
     * 当财务子单类型是3,5时 金额属于平台 无需填写收款人ID
     */
    @Excel(name = "收款人ID", cellType = Excel.ColumnType.NUMERIC)
    private Long payeeId;

    /**
     * Adapay撤销支付或退款ID
     */
    @Excel(name = "Adapay撤销支付或退款ID", cellType = Excel.ColumnType.STRING)
    private String reverseId;

    /**
     * @see PayTypeEnum
     */
    @Excel(name = "支付方式", cellType = Excel.ColumnType.NUMERIC)
    private Integer payType;

    /**
     * @see PayStatus
     */
    @Excel(name = "支付状态", cellType = Excel.ColumnType.NUMERIC)
    private Integer payStatus;

    @Excel(name = "付款时间", cellType = Excel.ColumnType.STRING)
    private Date payTime;

    private String beginTime;

    private String endTime;

    private List<Integer> financialDetailTypes;

    private String billingState;

    public FinancialDetail() {
    }

    public FinancialDetail(Long financialMasterId) {
        this.financialMasterId = financialMasterId;
    }

    public FinancialDetail(Long deptId, String code, Long financialMasterId, String financialMasterCode,
                           BigDecimal payMoney, Integer financialDetailType, Long payeeId) {
        this.deptId = deptId;
        this.code = code;
        this.financialMasterId = financialMasterId;
        this.financialMasterCode = financialMasterCode;
        this.payMoney = payMoney;
        this.financialDetailType = financialDetailType;
        this.payeeId = payeeId;
    }

    public FinancialDetail(Long deptId, String code, Long financialMasterId, String financialMasterCode,
                           Long orderDetailId, String orderDetailCode, BigDecimal payMoney, Integer financialDetailType,
                           Long payeeId, Integer payType, Integer payStatus, Date payTime) {
        this.deptId = deptId;
        this.code = code;
        this.financialMasterId = financialMasterId;
        this.financialMasterCode = financialMasterCode;
        this.orderDetailId = orderDetailId;
        this.orderDetailCode = orderDetailCode;
        this.payMoney = payMoney;
        this.financialDetailType = financialDetailType;
        this.payeeId = payeeId;
        this.payType = payType;
        this.payStatus = payStatus;
        this.payTime = payTime;
    }
}
