package com.trade.service.trade.exportrebate.domain;

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

import cn.hutool.core.util.StrUtil;
import com.trade.common.core.domain.BaseEntity;
import com.trade.common.utils.DateUtils;
import com.trade.service.DictConstants;
import com.trade.service.thirdparty.xiaotu.dto.PurchaseDetailsResponse;

/**
 * 出口退税-进货明细表表实体类
 *
 * @author hlb
 * @since 2024-10-24 20:48:57
 */
public class TaxRebatePurchaseDetails extends BaseEntity<TaxRebatePurchaseDetails> {

    /**
     * 出口退税-出口明细表id
     */
    private Long rebateExportDetailsId;
    /**
     * 客户id
     */
    private Long customerUserId;
    /**
     * 代理公司统一社会信用代码/注册号
     */
    private String agencyCertNo;
    /**
     * 申报年月（yyyyMM）
     */
    private String declarationMonthYear;
    /**
     * 申报批次
     */
    private String declarationBatch;
    /**
     * 申报序号
     */
    private String declarationSerialNo;
    /**
     * 关联号
     */
    private String correlationNo;
    /**
     * 凭证种类
     */
    private String voucherType;
    /**
     * 凭证种类名称
     */
    private String voucherTypeName;
    /**
     * 进货凭证号
     */
    private String purchaseVoucherNo;
    /**
     * 开票日期
     */
    private Date invoiceDate;
    /**
     * 供货方纳税人识别号
     */
    private String vendorTaxNo;
    /**
     * 商品HS编码
     */
    private String hsCode;
    /**
     * 出口商品代码
     */
    private String exportCommodityCode;
    /**
     * 商品名称
     */
    private String exportCommodityName;
    /**
     * 计量单位
     */
    private String measurementUnit;
    /**
     * 数量
     */
    private BigDecimal exportQuantity;
    /**
     * 计税金额
     */
    private BigDecimal taxBaseAmount;
    /**
     * 征税率（百分制，即已乘100）
     */
    private BigDecimal addedTaxRate;
    /**
     * 退税率（百分制，即已乘100）
     */
    private BigDecimal exportTaxRebateRate;
    /**
     * 可退税额
     */
    private BigDecimal taxRefundableAmount;
    /**
     * 审核标志
     */
    private String auditStatus;
    /**
     * 退税额（根据出口明细退税额，按比例计算得）(暂时取的可退税额)
     */
    private BigDecimal taxRefundAmount;
    /**
     * 备注
     */
    private String mark;
    /**
     * 不予办理标志
     */
    private String notProcessFlag;
    /**
     * 不予退税标志
     */
    private String notTaxRefund;
    /**
     * 暂不办理标志
     */
    private String deferredProcessFlag;
    /**
     * 不予办理年月
     */
    private String notProcessMonthYear;
    /**
     * 不予退税年月
     */
    private String notRefundMonthYear;
    /**
     * 暂不办理年月
     */
    private String suspensionMonthYear;
    /**
     * 最终解除暂不办理准予年月
     */
    private String liftingSuspensionApprovalDate;
    /**
     * 单证不齐标志
     */
    private String missingDocsFlag;
    /**
     * 退税状态，枚举rebate_process_status
     */
    private String status;

    public Long getRebateExportDetailsId() {
        return rebateExportDetailsId;
    }

    public void setRebateExportDetailsId(Long rebateExportDetailsId) {
        this.rebateExportDetailsId = rebateExportDetailsId;
    }

    public Long getCustomerUserId() {
        return customerUserId;
    }

    public void setCustomerUserId(Long customerUserId) {
        this.customerUserId = customerUserId;
    }

    public String getAgencyCertNo() {
        return agencyCertNo;
    }

    public void setAgencyCertNo(String agencyCertNo) {
        this.agencyCertNo = agencyCertNo;
    }

    public String getDeclarationMonthYear() {
        return declarationMonthYear;
    }

    public void setDeclarationMonthYear(String declarationMonthYear) {
        this.declarationMonthYear = declarationMonthYear;
    }

    public String getDeclarationBatch() {
        return declarationBatch;
    }

    public void setDeclarationBatch(String declarationBatch) {
        this.declarationBatch = declarationBatch;
    }

    public String getDeclarationSerialNo() {
        return declarationSerialNo;
    }

    public void setDeclarationSerialNo(String declarationSerialNo) {
        this.declarationSerialNo = declarationSerialNo;
    }

    public String getCorrelationNo() {
        return correlationNo;
    }

    public void setCorrelationNo(String correlationNo) {
        this.correlationNo = correlationNo;
    }

    public String getVoucherType() {
        return voucherType;
    }

    public void setVoucherType(String voucherType) {
        this.voucherType = voucherType;
    }

    public String getVoucherTypeName() {
        return voucherTypeName;
    }

    public void setVoucherTypeName(String voucherTypeName) {
        this.voucherTypeName = voucherTypeName;
    }

    public String getPurchaseVoucherNo() {
        return purchaseVoucherNo;
    }

    public void setPurchaseVoucherNo(String purchaseVoucherNo) {
        this.purchaseVoucherNo = purchaseVoucherNo;
    }

    public Date getInvoiceDate() {
        return invoiceDate;
    }

    public void setInvoiceDate(Date invoiceDate) {
        this.invoiceDate = invoiceDate;
    }

    public String getVendorTaxNo() {
        return vendorTaxNo;
    }

    public void setVendorTaxNo(String vendorTaxNo) {
        this.vendorTaxNo = vendorTaxNo;
    }

    public String getHsCode() {
        return hsCode;
    }

    public void setHsCode(String hsCode) {
        this.hsCode = hsCode;
    }

    public String getExportCommodityCode() {
        return exportCommodityCode;
    }

    public void setExportCommodityCode(String exportCommodityCode) {
        this.exportCommodityCode = exportCommodityCode;
    }

    public String getExportCommodityName() {
        return exportCommodityName;
    }

    public void setExportCommodityName(String exportCommodityName) {
        this.exportCommodityName = exportCommodityName;
    }

    public String getMeasurementUnit() {
        return measurementUnit;
    }

    public void setMeasurementUnit(String measurementUnit) {
        this.measurementUnit = measurementUnit;
    }

    public BigDecimal getExportQuantity() {
        return exportQuantity;
    }

    public void setExportQuantity(BigDecimal exportQuantity) {
        this.exportQuantity = exportQuantity;
    }

    public BigDecimal getTaxBaseAmount() {
        return taxBaseAmount;
    }

    public void setTaxBaseAmount(BigDecimal taxBaseAmount) {
        this.taxBaseAmount = taxBaseAmount;
    }

    public BigDecimal getAddedTaxRate() {
        return addedTaxRate;
    }

    public void setAddedTaxRate(BigDecimal addedTaxRate) {
        this.addedTaxRate = addedTaxRate;
    }

    public BigDecimal getExportTaxRebateRate() {
        return exportTaxRebateRate;
    }

    public void setExportTaxRebateRate(BigDecimal exportTaxRebateRate) {
        this.exportTaxRebateRate = exportTaxRebateRate;
    }

    public BigDecimal getTaxRefundableAmount() {
        return taxRefundableAmount;
    }

    public void setTaxRefundableAmount(BigDecimal taxRefundableAmount) {
        this.taxRefundableAmount = taxRefundableAmount;
    }

    public String getAuditStatus() {
        return auditStatus;
    }

    public void setAuditStatus(String auditStatus) {
        this.auditStatus = auditStatus;
    }

    public BigDecimal getTaxRefundAmount() {
        return taxRefundAmount;
    }

    public void setTaxRefundAmount(BigDecimal taxRefundAmount) {
        this.taxRefundAmount = taxRefundAmount;
    }

    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    public String getNotProcessFlag() {
        return notProcessFlag;
    }

    public void setNotProcessFlag(String notProcessFlag) {
        this.notProcessFlag = notProcessFlag;
    }

    public String getNotTaxRefund() {
        return notTaxRefund;
    }

    public void setNotTaxRefund(String notTaxRefund) {
        this.notTaxRefund = notTaxRefund;
    }

    public String getDeferredProcessFlag() {
        return deferredProcessFlag;
    }

    public void setDeferredProcessFlag(String deferredProcessFlag) {
        this.deferredProcessFlag = deferredProcessFlag;
    }

    public String getNotProcessMonthYear() {
        return notProcessMonthYear;
    }

    public void setNotProcessMonthYear(String notProcessMonthYear) {
        this.notProcessMonthYear = notProcessMonthYear;
    }

    public String getNotRefundMonthYear() {
        return notRefundMonthYear;
    }

    public void setNotRefundMonthYear(String notRefundMonthYear) {
        this.notRefundMonthYear = notRefundMonthYear;
    }

    public String getSuspensionMonthYear() {
        return suspensionMonthYear;
    }

    public void setSuspensionMonthYear(String suspensionMonthYear) {
        this.suspensionMonthYear = suspensionMonthYear;
    }

    public String getLiftingSuspensionApprovalDate() {
        return liftingSuspensionApprovalDate;
    }

    public void setLiftingSuspensionApprovalDate(String liftingSuspensionApprovalDate) {
        this.liftingSuspensionApprovalDate = liftingSuspensionApprovalDate;
    }

    public String getMissingDocsFlag() {
        return missingDocsFlag;
    }

    public void setMissingDocsFlag(String missingDocsFlag) {
        this.missingDocsFlag = missingDocsFlag;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public TaxRebatePurchaseDetails(){
    }

    public TaxRebatePurchaseDetails(PurchaseDetailsResponse response, TaxRebateExportDetails taxRebateExportDetails){
        this.rebateExportDetailsId = taxRebateExportDetails.getId();
        this.customerUserId = taxRebateExportDetails.getCustomerUserId();
        this.agencyCertNo = taxRebateExportDetails.getAgencyCertNo();
        this.declarationMonthYear = response.getSsq();
        this.declarationBatch = response.getSbpc();
        this.declarationSerialNo = response.getSbxh();
        this.correlationNo = response.getGlh();
        this.voucherType = response.getCktmspzlxDm();
        this.voucherTypeName = response.getCktmspzlxmc();
        this.purchaseVoucherNo = response.getJhpzh();
        this.invoiceDate = response.getKprq() == null ? null : new Date(response.getKprq());
        this.vendorTaxNo = response.getGhfnsrsbh1();
        this.hsCode = taxRebateExportDetails.getHsCode();
        this.exportCommodityCode = response.getCkspDm();
        this.exportCommodityName = response.getSbhgspmc();
        this.measurementUnit = response.getHgjldwmc();
        this.exportQuantity = response.getSl();
        this.taxBaseAmount = response.getJsje();
        this.addedTaxRate = response.getZssl();
        this.exportTaxRebateRate = response.getTsl();
        this.taxRefundableAmount = response.getTse();
        this.auditStatus = response.getShbz();
        this.taxRefundAmount = response.getTse();
        this.mark = response.getBz();
        this.notProcessFlag = response.getByblbz();
        this.notTaxRefund = response.getBytsbz();
        this.deferredProcessFlag = response.getZbblbz();
        this.notProcessMonthYear = response.getByblny();
        this.notRefundMonthYear = response.getBytsny();
        this.suspensionMonthYear = response.getZbblny();
        this.liftingSuspensionApprovalDate = response.getZzjczbblzyny();
        this.missingDocsFlag = response.getDzbqbz();
        // 审核标志（shbz）为Y，且不予办理标志（byblbz）为N（或空），且不予退税标志（bytsbz）为N（或空），且暂不办理标志（zbblbz）为N（或空），则表示已退税
        this.status = DictConstants.SYS_YES.equals(response.getShbz())
                && (StrUtil.isBlank(response.getByblbz()) || DictConstants.SYS_NO.equals(response.getByblbz()))
                && (StrUtil.isBlank(response.getBytsbz()) || DictConstants.SYS_NO.equals(response.getBytsbz()))
                && (StrUtil.isBlank(response.getZbblbz()) || DictConstants.SYS_NO.equals(response.getZbblbz()))
                        ? DictConstants.REBATE_PROCESS_STATUS_DONE
                        : DictConstants.REBATE_PROCESS_STATUS_NOT_REBATE;
    }
}
