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

import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

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

@Data
@ApiModel
public class EnginOrderListBean {

    private static final long serialVersionUID=1L;
    @ApiModelProperty(value = "engin_order_id")
    private String enginOrderId;

    @ApiModelProperty(value = "企业id")
    private String adminCompanyId;

    @ApiModelProperty(value = "客户id")
    private String customerId;

    @ApiModelProperty(value = "客户编码")
    private String customerNumber;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @ApiModelProperty(value = "业务员")
    private String serviceId;

    @ApiModelProperty(value = "业务员名称")
    private String serviceName;

    @ApiModelProperty(value = "销售类型id")
    private String saleTypeId;

    @ApiModelProperty(value = "销售类型编码")
    private String saleTypeCode;

    @ApiModelProperty(value = "销售类型名称")
    private String saleTypeName;

    @ApiModelProperty(value = "工程机系统帐号")
    private String enginUserName;

    @ApiModelProperty(value = "工程类型 TRADE=商用 HOME=家用")
    private String enginOrderType;

    @ApiModelProperty(value = "工程订单编号")
    private String enginOrderNo;

    @ApiModelProperty(value = "订单日期")
    private Date orderDate;

    @ApiModelProperty(value = "工程登录单号")
    private String refEnginRecordNo;

    @ApiModelProperty(value = "项目类别")
    private String refProjectCategory;

    @ApiModelProperty(value = "项目名称")
    private String refProjectName;

    @ApiModelProperty(value = "项目类型")
    private String refProjectType;

    @ApiModelProperty(value = "项目说明")
    private String refProjectNote;

    @ApiModelProperty(value = "使用单位")
    private String refUseUnit;

    @ApiModelProperty(value = "安装地址")
    private String refInstallAddress;

    @ApiModelProperty(value = "工程编号")
    private String refProjectNo;

    @ApiModelProperty(value = "跨区厂编号")
    private String refFactoryNo;

    @ApiModelProperty(value = "工程登录类型")
    private String refPromiseStatus;

    @ApiModelProperty(value = "行业类别")
    private String refTradeCategory;

    @ApiModelProperty(value = "权限分类")
    private String refPowerCategory;

    @ApiModelProperty(value = "机型类别")
    private String refMachineType;

    @ApiModelProperty(value = "购买单位名称")
    private String refBuyUnitName;

    @ApiModelProperty(value = "保证函")
    private String refPromiseProvide;

    @ApiModelProperty(value = "区域")
    private String refRegionWork;

    @ApiModelProperty(value = "引用次数")
    private Integer refCount;

    @ApiModelProperty(value = "联系人")
    private String refLinkman;

    @ApiModelProperty(value = "联系电话")
    private String refPhone;

    @ApiModelProperty(value = "固定电话")
    private String refTel;

    @ApiModelProperty(value = "第几申报")
    private String refDeclareNo;

    @ApiModelProperty(value = "文件编号")
    private String fileNo;

    @ApiModelProperty(value = "扣押金 false=扣 true=不扣")
    private Boolean takeDeposit;

    @ApiModelProperty(value = "直调状态 false=未完结 true=已完结")
    private Boolean directTransferStatus;

    @ApiModelProperty(value = "格力回复")
    private String geLiNote;

    @ApiModelProperty(value = "格力内部备注")
    private String geLiInerNote;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "审核说明")
    private String examineNote;

    @ApiModelProperty(value = "单据状态 SAVE=保存 WAIT=待审核 OK=通过 FAIL=不通过 CLOSE=关闭")
    private String examineStatus;

    @ApiModelProperty(value = "创建人")
    private String createBy;

    @ApiModelProperty(value = "创建人名称")
    private String createName;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "更新人")
    private String updateBy;

    @ApiModelProperty(value = "更新人名称")
    private String updateName;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @ApiModelProperty(value = "提交人")
    private String submitBy;

    @ApiModelProperty(value = "提交人名称")
    private String submitName;

    @ApiModelProperty(value = "提交时间")
    private Date submitTime;

    @ApiModelProperty(value = "审核人")
    private String confirmBy;

    @ApiModelProperty(value = "审核人名称")
    private String confirmName;

    @ApiModelProperty(value = "审核时间")
    private Date confirmTime;

    @ApiModelProperty(value = "弃审人")
    private String abandonBy;

    @ApiModelProperty(value = "弃审人名称")
    private String abandonName;

    @ApiModelProperty(value = "弃审时间")
    private Date abandonTime;

    @ApiModelProperty(value = "关闭人")
    private String closeBy;

    @ApiModelProperty(value = "关闭人名称")
    private String closeName;

    @ApiModelProperty(value = "关闭时间")
    private Date closeTime;

    @ApiModelProperty(value = "直调完结人")
    private String endDirectBy;

    @ApiModelProperty(value = "直调完结人名称")
    private String endDirectName;

    @ApiModelProperty(value = "直调完结时间")
    private Date endDirectTime;

    @ApiModelProperty(value = "是否删除 0=正常 1=删除")
    @TableLogic
    private Boolean del;

    @ApiModelProperty(value = "金蝶同步状态 NOT=未同步 SALES=销售订单 OUTSTOCK=销售出库单 TRANSFER=直接调拨单 ")
    private String kingDeeSync;

    @ApiModelProperty(value = "金蝶单据id")
    private String kingDeeId;

    @ApiModelProperty(value = "明细id")
    private String id;

    @ApiModelProperty(value = "工程订单id")
    private String parentId;

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

    @ApiModelProperty(value = "明细销售类型id")
    private String itemSaleTypeId;

    @ApiModelProperty(value = "明细销售类型编码")
    private String itemSaleTypeCode;

    @ApiModelProperty(value = "明细销售类型名称")
    private String itemSaleTypeName;

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

    @ApiModelProperty(value = "明细业务员名称")
    private String itemServiceName;

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

    @ApiModelProperty(value = "金蝶物料编码")
    private String materialNumber;

    @ApiModelProperty(value = "厂产品编码")
    private String materialOldNumber;

    @ApiModelProperty(value = "金蝶物料名称")
    private String materialName;

    @ApiModelProperty(value = "规格型号")
    private String specification;

    @ApiModelProperty(value = "基本单位编码")
    private String unit;

    @ApiModelProperty(value = "工程单单价")
    private BigDecimal enginPrice;

    @ApiModelProperty(value = "工程单金额")
    private BigDecimal enginTotality;

    @ApiModelProperty(value = "工程单记录数量")
    private Integer enginNum;

    @ApiModelProperty(value = "数量")
    private Integer qty;

    @ApiModelProperty(value = "单价")
    private BigDecimal price;

    @ApiModelProperty(value = "折扣金额")
    private BigDecimal discAmount;

    @ApiModelProperty(value = "订单金额")
    private BigDecimal totalAmount;

    @ApiModelProperty(value = "返利钱包的返利比例")
    private BigDecimal rebateRate;

    @ApiModelProperty(value = "返利金额")
    private BigDecimal rebateAmount;

    @ApiModelProperty(value = "押金比例")
    private BigDecimal depositRate;

    @ApiModelProperty(value = "经销商现金钱包id")
    private String customerWalletId;

    @ApiModelProperty(value = "经销商现金钱包名称")
    private String customerWalletName;

    @ApiModelProperty(value = "经销商返利钱包id")
    private String customerWalletId2;

    @ApiModelProperty(value = "经销商返利钱包名称")
    private String customerWalletName2;

    @ApiModelProperty(value = "是否直调 false=否 true=是")
    private Boolean isDirectTransfer;

    @ApiModelProperty(value = "直调数量")
    private Integer directTransferQty;

    @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;

    @ApiModelProperty(value = "实付金额(订单金额-返利金额-折扣金额-不够扣的返利金额)")
    private BigDecimal payAmount;

    @ApiModelProperty(value = "实际扣除的返利金额")
    private BigDecimal payRebateAmount;

    @ApiModelProperty(value = "实际支付的现金金额")
    private BigDecimal payCashAmount;

    @ApiModelProperty(value = "实际支付的信用金额")
    private BigDecimal payCreditAmount;

    @ApiModelProperty(value = "总押金金额")
    private BigDecimal totalDepositAmount;

    @ApiModelProperty(value = "原数量")
    private Integer oldQty;

    @ApiModelProperty(value = "原实付金额")
    private BigDecimal oldPayAmount;

    @ApiModelProperty(value = "原实付返利金额")
    private BigDecimal oldRebateAmount;

    @ApiModelProperty(value = "税率例如: 0.13")
    private BigDecimal tax;

    @ApiModelProperty(value = "可退数量")
    private Integer refundableQty;

    @ApiModelProperty(value = "已退数量")
    private Integer retiredQty;

    @ApiModelProperty(value = "明细备注")
    private String itemRemark;

    @ApiModelProperty(value = "退货数量")
    private Integer refundProductQty;

    @ApiModelProperty(value = "退货金额")
    private BigDecimal refundProductAmount;

    @ApiModelProperty(value = "发货数量")
    private Integer applySendQty;

    @ApiModelProperty("实装机型名称")
    private String realMaterialName;
    @ApiModelProperty("实装机型编码")
    private String realMaterialNumber;
    @ApiModelProperty("实装机型旧编码")
    private String realMaterialOldNumber;

    @ApiModelProperty("实装机型规格")
    private String realSpecification;

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

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

    @ApiModelProperty("物料分组")
    private String materialGroupName;

    @ApiModelProperty("存货类别")
    private String k3CategoryName;

    @ApiModelProperty("明细id")
    private String itemId;


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

}
