package com.zfire.mall.manager.bean.engin.v2.order;

import com.zfire.mall.manager.annotation.ZfireField;
import com.zfire.mall.manager.enums.ExamineStatusEnum;
import com.zfire.mall.manager.enums.IsEnum;
import com.zfire.mall.manager.enums.OrderTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

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

@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel
public class TradeEnginOrderVO extends EnginOrderVO {

    @ZfireField(tbName = "a", hide = true)
    @ApiModelProperty(value = "engin_order_id")
    private String enginOrderId;

    @ZfireField(tbName = "a", hide = true)
    @ApiModelProperty(value = "企业id")
    private String adminCompanyId;

    @ZfireField(tbName = "a", hide = true)
    @ApiModelProperty(value = "客户id")
    private String customerId;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "经销商编码")
    private String customerNumber;

    @ZfireField(tbName = "a", sortNum = 6)
    @ApiModelProperty(value = "经销商名称")
    private String customerName;

    @ZfireField(tbName = "a", hide = true)
    @ApiModelProperty(value = "表头业务员编号")
    private String serviceId;

    @ZfireField(tbName = "a", sortNum = 7)
    @ApiModelProperty(value = "表头业务员")
    private String serviceName;

//    @ZfireField(tbName = "a", hide = true)
//    @ApiModelProperty(value = "销售类型id")
//    private String saleTypeId;
//
//    @ZfireField(tbName = "a")
//    @ApiModelProperty(value = "销售类型编码")
//    private String saleTypeCode;
//
//    @ZfireField(tbName = "a")
//    @ApiModelProperty(value = "销售类型名称")
//    private String saleTypeName;
//
//    @ZfireField(tbName = "a")
//    @ApiModelProperty(value = "工程机系统帐号")
//    private String enginUserName;

    @ZfireField(tbName = "a", hide = true)
    @ApiModelProperty(value = "工程类型 TRADE=商用 HOME=家用")
    private OrderTypeEnum enginOrderType;

    @ZfireField(tbName = "a", sortNum = 5)
    @ApiModelProperty(value = "工程订单号")
    private String enginOrderNo;

    @ZfireField(tbName = "a", sortNum = 3)
    @ApiModelProperty(value = "订单日期")
    private Date orderDate;

    @ZfireField(tbName = "a", sortNum = 19)
    @ApiModelProperty(value = "工程信息单号")
    private String refEnginRecordNo;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "项目类别")
    private String refProjectCategory;

    @ZfireField(tbName = "a", sortNum = 8)
    @ApiModelProperty(value = "项目名称")
    private String refProjectName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "项目类型")
    private String refProjectType;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "项目说明")
    private String refProjectNote;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "使用单位")
    private String refUseUnit;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "安装地址")
    private String refInstallAddress;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "工程编号")
    private String refProjectNo;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "跨区厂编号")
    private String refFactoryNo;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "工程登录类型")
    private String refPromiseStatus;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "行业类别")
    private String refTradeCategory;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "权限分类")
    private String refPowerCategory;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "机型类别")
    private String refMachineType;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "购买单位名称")
    private String refBuyUnitName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "保证函")
    private String refPromiseProvide;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "区域")
    private String refRegionWork;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "引用次数")
    private Integer refCount;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "联系人")
    private String refLinkman;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "联系电话")
    private String refPhone;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "固定电话")
    private String refTel;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "第几申报")
    private String refDeclareNo;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "文件编号")
    private String fileNo;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "是否不扣押金")
    private IsEnum takeDeposit;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "是否直调完结")
    private IsEnum directTransferStatus;

    @ZfireField(tbName = "a", hide = true)
    @ApiModelProperty(value = "格力回复")
    private String geLiNote;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "格力内部备注")
    private String geLiInerNote;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "备注")
    private String remark;

    @ZfireField(tbName = "a", sortNum = 25, isQuery = false)
    @ApiModelProperty(value = "审核说明")
    private String examineNote;

    @ZfireField(tbName = "a", sortNum = 1)
    @ApiModelProperty(value = "单据状态")
    private ExamineStatusEnum examineStatus;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "制单人")
    private String createName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "制单日期")
    private Date createTime;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "最后更新人")
    private String updateName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "最后更新日期")
    private Date updateTime;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "提交人")
    private String submitName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "提交日期")
    private Date submitTime;

    @ZfireField(tbName = "a", sortNum = 23, isQuery = false)
    @ApiModelProperty(value = "审核人")
    private String confirmName;

    @ZfireField(tbName = "a", sortNum = 24, isQuery = false)
    @ApiModelProperty(value = "审核日期")
    private Date confirmTime;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "弃审人")
    private String abandonName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "弃审日期")
    private Date abandonTime;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "关闭人")
    private String closeName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "关闭日期")
    private Date closeTime;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "直调完结人")
    private String endDirectName;

    @ZfireField(tbName = "a", isShow = false, isQuery = false)
    @ApiModelProperty(value = "直调完结日期")
    private Date endDirectTime;

    @ZfireField(tbName = "b", hide = true)
    @ApiModelProperty(value = "明细id")
    private String id;

    @ZfireField(tbName = "b", hide = true)
    @ApiModelProperty(value = "工程订单id")
    private String parentId;

//    @ApiModelProperty(value = "引用记录")
//    private Integer useRefCount;

//    @ZfireField(tbName = "b", colName = "sale_type_id")
//    @ApiModelProperty(value = "明细销售类型id")
//    private String itemSaleTypeId;

    @ZfireField(tbName = "b", colName = "sale_type_code", isShow = false, isQuery = false)
    @ApiModelProperty(value = "销售类型编码")
    private String itemSaleTypeCode;

    @ZfireField(tbName = "b", colName = "sale_type_name", isShow = false, isQuery = false)
    @ApiModelProperty(value = "销售类型名称")
    private String itemSaleTypeName;

//    @ApiModelProperty(value = "明细业务员")
//    private String itemServiceId;

    @ZfireField(tbName = "b", colName = "service_name", isShow = false, isQuery = false)
    @ApiModelProperty(value = "业务员名称")
    private String itemServiceName;

//    @ZfireField(tbName = "b")
//    @ApiModelProperty(value = "金蝶物料id")
//    private String materialId;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "物料编码")
    private String materialNumber;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "厂产品代码")
    private String materialOldNumber;

    @ZfireField(tbName = "b", sortNum = 9, isQuery = false)
    @ApiModelProperty(value = "产品名称")
    private String materialName;

    @ZfireField(tbName = "b", sortNum = 11)
    @ApiModelProperty(value = "规格型号")
    private String specification;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "基本单位编码")
    private String unit;

//    @ZfireField(tbName = "b")
//    @ApiModelProperty(value = "信息单单价")
//    private BigDecimal enginPrice;
//
//    @ZfireField(tbName = "b")
//    @ApiModelProperty(value = "信息单金额")
//    private BigDecimal enginTotality;
//
//    @ZfireField(tbName = "b")
//    @ApiModelProperty(value = "信息单数量")
//    private Integer enginNum;

    @ZfireField(tbName = "b", isTotal = true, sortNum = 12, isQuery = false)
    @ApiModelProperty(value = "数量")
    private Integer qty;

    @ZfireField(tbName = "b", sortNum = 13, isQuery = false)
    @ApiModelProperty(value = "单价")
    private BigDecimal price;

    @ZfireField(tbName = "b", isTotal = true, isShow = false, isQuery = false)
    @ApiModelProperty(value = "格力折扣")
    private BigDecimal discAmount;

    @ZfireField(tbName = "b", isTotal = true, sortNum = 14, isQuery = false)
    @ApiModelProperty(value = "订单金额")
    private BigDecimal totalAmount;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "返利钱包的返利比例")
    private BigDecimal rebateRate;

    @ZfireField(tbName = "b", isTotal = true, isShow = false, isQuery = false)
    @ApiModelProperty(value = "返利金额")
    private BigDecimal rebateAmount;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "押金比例")
    private BigDecimal depositRate;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "现金钱包编号")
    private String customerWalletId;

    @ZfireField(tbName = "b", sortNum = 20, isQuery = false)
    @ApiModelProperty(value = "现金钱包")
    private String customerWalletName;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "返利类型编号")
    private String customerWalletId2;

    @ZfireField(tbName = "b", isShow = false, isQuery = false)
    @ApiModelProperty(value = "返利类型")
    private String customerWalletName2;

    @ZfireField(tbName = "b", sortNum = 4)
    @ApiModelProperty(value = "是否直调")
    private IsEnum isDirectTransfer;

    @ZfireField(tbName = "b", isTotal = true, sortNum = 21, isQuery = false)
    @ApiModelProperty(value = "直调数量")
    private Integer directTransferQty;

    @ZfireField(tbName = "b", isTotal = true, isShow = false, isQuery = false)
    @ApiModelProperty(value = "出库数量")
    private Integer hasSendQty;

    //    @ApiModelProperty(value = "单个商品的返利金额(实际扣除的返利金额/qty)")
//    private BigDecimal singleRebateAmount;
//
//    @ApiModelProperty(value = "单个商品的折扣金额(折扣金额/qty)")
//    private BigDecimal singleDiscAmount;
//
//    @ApiModelProperty(value = "单个商品的实际支付金额(实际支付金额/qty)")
//    private BigDecimal singlePayPrice;
//
//    @ApiModelProperty(value = "单个商品的押金金额(单个商品的实际支付金额*押金比例)")
//    private BigDecimal singleDepositAmount;
//
    @ZfireField(sortNum = 16, isQuery = false)
    @ApiModelProperty(value = "实付金额")
    private BigDecimal payAmount;

    @ZfireField(tbName = "b", isTotal = true, sortNum = 15, isQuery = false)
    @ApiModelProperty(value = "实付返利金额")
    private BigDecimal payRebateAmount;
//
//    @ApiModelProperty(value = "实际支付的现金金额")
//    private BigDecimal payCashAmount;
//
//    @ApiModelProperty(value = "实际支付的信用金额")
//    private BigDecimal payCreditAmount;

//    @ZfireField(tbName = "b", isTotal = true)
//    @ApiModelProperty(value = "总押金金额")
//    private BigDecimal totalDepositAmount;

    @ZfireField(tbName = "b", isTotal = true, isShow = false, isQuery = false)
    @ApiModelProperty(value = "原订单数量")
    private Integer oldQty;

//    @ApiModelProperty(value = "原实付金额")
//    private BigDecimal oldPayAmount;
//
//    @ApiModelProperty(value = "原实付返利金额")
//    private BigDecimal oldRebateAmount;
//
//    @ApiModelProperty(value = "税率例如: 0.13")
//    private BigDecimal tax;

    @ZfireField(isQuery = false, isTotal = true, isShow = false)
    @ApiModelProperty(value = "可退订数量")
    private Integer refundableQty;

    @ZfireField(tbName = "b", isTotal = true, sortNum = 18, isQuery = false)
    @ApiModelProperty(value = "已退订数量")
    private Integer retiredQty;

    @ZfireField(tbName = "b", colName = "remark", isShow = false, isQuery = false)
    @ApiModelProperty(value = "表体备注")
    private String itemRemark;

    @ZfireField(tbName = "b", isTotal = true, isShow = false, isQuery = false)
    @ApiModelProperty(value = "退货数量")
    private Integer refundProductQty;

    @ZfireField(tbName = "b", isTotal = true, isShow = false, isQuery = false)
    @ApiModelProperty(value = "退货金额")
    private BigDecimal refundProductAmount;

    @ZfireField(sortNum = 17, isQuery = false)
    @ApiModelProperty(value = "发货数量")
    private Integer applySendQty;
//
//    @ZfireField(tbName = "b")
//    @ApiModelProperty("实装机型名称")
//    private String realMaterialName;
//
//    @ZfireField(tbName = "b")
//    @ApiModelProperty("实装机型编码")
//    private String realMaterialNumber;
//
//    @ZfireField(tbName = "b")
//    @ApiModelProperty("实装机型旧编码")
//    private String realMaterialOldNumber;
//
//    @ZfireField(tbName = "b")
//    @ApiModelProperty("实装机型规格")
//    private String realSpecification;

//    @ApiModelProperty("发货仓库ID")
//    private String correspondId;
//
//    @ApiModelProperty("发货仓库")
//    private String correspondName;

    @ZfireField(tbName = "kdm", sortNum = 10)
    @ApiModelProperty("物料分组")
    private String materialGroupName;

    @ZfireField(tbName = "b", sortNum = 22, isQuery = false)
    @ApiModelProperty("存货类别")
    private String k3CategoryName;

    @ZfireField(tbName = "a", sortNum = 2)
    @ApiModelProperty(value = "仓库名称")
    private String correspondName;

    public Integer getApplySendQty() {
        return Math.max((qty - refundableQty), 0);
    }
}
