package cn.iocoder.yudao.module.order.dal.dataobject.order;

import cn.iocoder.yudao.module.order.dal.dataobject.orderCargoControl.OrderCargoControlDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignee.OrderConsigneeDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderConsignor.OrderConsignorDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderDeparture.OrderDepartureDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderItem.OrderItemDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.math.BigDecimal;
import java.util.*;

import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;

/**
 * 订单 DO
 *
 * @author 系统管理员
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("ecw_order")
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class OrderDO extends BaseDO {

    /**
     * 主键ID
     */
    @TableId
    private Long orderId;
    /**
     * 订单编号
     */
    private String orderNo;
    /**
     * 快递单号
     */
    private String number;
    /**
     * 提单编号
     */
    private String tidanNo;
    /**
     * 父编号
     */
    private String parentNumber;

    /**
     * 父订单id
     */
    private Long parentOrderId;
    /**
     * 初始母订单id
     */
    @ApiModelProperty(value = "初始母订单id")
    private Long initialParentOrderId;

    @ApiModelProperty(value = "初始母订单编号")
    private String initialParentOrderNo;


    /**
     * 旧编号
     */
    private String oldNumbers;
    /**
     * 订单编号变更记录
     */
    private String noChargeRecord;
    /**
     * 货柜自编号
     */
    private String containerNumber;
    /**
     * 运输方式id
     */
    private Integer transportId;
    /**
     * 线路ID
     */
    private Long lineId;
    /**
     * 渠道ID
     */
    private Long channelId;
    /**
     * 订单类型(可多选)：1 集运服务 2 海外仓
     */
    private String type;

    /**
     * 订单类型：1 普货 2 重货 3 泡货
     */
    private Integer orderType;
    /**
     * 泡货类型 1 默认值 2 半泡(当订单为泡货时才使用此字段)
     */
    private Integer pickleType;

    /**
     * 泡重比例，默认100%
     */
    private BigDecimal bubbleWeightRatio = BigDecimal.ONE;
    /**
     * 下单会员id
     */
    private Long userId;
    /**
     * 客户经理ID
     */
    @ApiModelProperty(value = "客户经理ID")
    private Long salesmanId;
    /**
     * 部门ID
     */
    @ApiModelProperty(value = "客户经理所属部门ID")
    private Long deptId;
    /**
     * 唛头
     */
    private String marks;
    /**
     * 产品备案属性：1有牌,2无牌,3中性,4混牌
     */
    private Integer productRecord;
    /**
     * 是否控货
     */
    private Boolean isCargoControl = Boolean.FALSE;
    /**
     * 0 控货中；1 已放完货；2 部分控货
     */
    private Integer cargoControlStatus;
    /**
     * 报关类别：我司全代：1，自单代报：2，混合报关：3
     */
    private Integer customsType;
    /**
     * 上传文件
     */
    private String upFile;
    /**
     * 付款类型
     */
    private Integer payType;

    /**
     * 订单状态详情见字典：order_status
     */
    private Integer status;

    /**
     * 订单异常状态(字典 order_abnormal_state)
     */
    private Integer abnormalState;

    /**
     * 订单入仓状态(字典 order_warehouse_in_status)
     */
    private Integer inWarehouseState;

    /**
     * 订单出货状态(字典 order_shipment_state)
     */
    private Integer shipmentState;

    /**
     * 上次订单主状态值
     */
    private Integer oldStatus;

    /**
     * 上次订单入仓状态值
     */
    private Integer oldInWarehouseState;

    /**
     * 上次订单出货状态值
     */
    private Integer oldShipmentState;


    @ApiModelProperty(value = "审核类型(字典 order_approval_type) 0 为正常")
    private Integer auditType;

    @ApiModelProperty(value = "审核结果")
    private String auditResult;

    /**
     * 是否被删掉 1 删掉；0正常
     */
    private Boolean isDel;

    @ApiModelProperty(value = "代收金额")
    private BigDecimal collectionProxy;

    @ApiModelProperty(value = "代收货币ID")
    private Integer collectionProxyCurrency;
    /**
     * 是否代收货款收款 0为否 1为是
     */
    private Boolean isCollection;
    /**
     * 重货体积
     */
    private BigDecimal wVolume;
    /**
     * 泡货重量
     */
    private BigDecimal vWeight;

    /**
     * 原应收重货体积
     */
    private BigDecimal orgWVolume;
    /**
     * 原应收泡货重量
     */
    private BigDecimal orgVWeight;


    @ApiModelProperty(value = "最小计量重量")
    private BigDecimal minMeteringWeight = BigDecimal.ZERO;

    @ApiModelProperty(value = "最小计量体积")
    private BigDecimal minMeteringVolume = BigDecimal.ZERO;

    @ApiModelProperty(value = "最小计量个数")
    private BigDecimal minMeteringQuantity = BigDecimal.ZERO;
    /**
     * 重货标准基数
     */
    private BigDecimal weightUnit;
    /**
     * 泡货标准基数
     */
    private BigDecimal volumeUnit;

    @ApiModelProperty(value = "原重货标准基数")
    private BigDecimal orgWeightUnit;

    @ApiModelProperty(value = "原泡货标准基数")
    private BigDecimal orgVolumeUnit;

    @ApiModelProperty(value = "计算使用的重货标准基数")
    private BigDecimal useWeightUnit;

    @ApiModelProperty(value = "计算使用的泡货标准基数")
    private BigDecimal useVolumeUnit;
    /**
     * 入仓类型
     */
    private Integer warehouseType;
    /**
     * 是否发送过入仓短信 已发送：1，未发送：0
     */
    private Boolean sendsms;
    /**
     * 单证资料
     */
    private String documentsFile;
    /**
     * 备注
     */
    private String remarks;

    /**
     * 调仓始发仓
     */
    private Long adjustToStartWarehouseId;
    /**
     * 调仓目的仓
     */
    private Long adjustToDestWarehouseId;

    /**
     * 目的地调仓始发仓
     */
    private Long destAdjustToStartWarehouseId;
    /**
     * 目的地调仓目的仓
     */
    private Long destAdjustToDestWarehouseId;

    @ApiModelProperty(value = "入仓数量", required = true)
    private Integer sumQuantity;
    /**
     * 入仓件数
     */
    private Integer sumNum;
    /**
     * 自定义入仓体积
     */
    private BigDecimal customSumVolume;
    /**
     * 入仓体积
     */
    private BigDecimal sumVolume;
    /**
     * 自定义入仓重量
     */
    private BigDecimal customSumWeight;
    /**
     * 入仓重量
     */
    private BigDecimal sumWeight;
    /**
     * 重货比
     */
    private BigDecimal weightRatio;
    /**
     * 发货人的客户id
     */
    private Long customerId;


    /**
     * 完成入仓的入仓体积
     */
    private BigDecimal sumVolumeFinishedWarehouseIn;
    /**
     * 完成入仓的入仓重量
     */
    private BigDecimal sumWeightFinishedWarehouseIn;

    /**
     * 完成入仓的箱/件数
     */
    private Integer sumCartonsNumFinishedWarehouseIn;

    /**
     * 完成入仓的所有箱内总货物数量
     */
    private Integer sumQuantityAllFinishedWarehouseIn;

    /**
     * 上次打包的入仓体积
     */
    @ApiModelProperty(value = "上次打包的入仓体积")
    private BigDecimal sumVolumePrevPacked;
    /**
     * 上次打包的入仓重量
     */
    @ApiModelProperty(value = "上次打包的入仓重量")
    private BigDecimal sumWeightPrevPacked;

    /**
     * 上次打包的箱/件数
     */
    @ApiModelProperty(value = "上次打包的箱数")
    private Integer sumCartonsNumPrevPacked;

    /**
     * 上次打包的所有箱内总货物数量
     */
    @ApiModelProperty(value = "上次打包的所有箱内总货物数量")
    private Integer sumQuantityAllPrevPacked;


    @ApiModelProperty(value = "航空公司id")
    private Long airlineCompany;

    @ApiModelProperty(value = "船公司id")
    private Long shippingCompany;

    @ApiModelProperty(value = "清关证书：0 否 1 是")
    private Boolean customsClearCert;

    @ApiModelProperty(value = "清关证书备注")
    private String customsClearCertRemarks;

    @ApiModelProperty(value = "出单方式：1 电放 2 正本")
    private Integer issuingMethod;

    @ApiModelProperty(value = "是否拆包：0 否 1 是")
    private Boolean isUnpack;

    @ApiModelProperty(value = "是否单票立刻转运：0 否 1 是")
    private Boolean isSingleTicketTransport;
    /**
     * 费用清单
     */
    private String cost;

    @ApiModelProperty(value = "付款人： 1 发货人 2 收货人 3 自定义")
    private Integer drawee;

    @ApiModelProperty(value = "自定义付款人信息")
    private String customDrawee;


    @ApiModelProperty(value = "送货时间")
    private Date deliveryDate;

    /**
     * 入仓时间
     */
    private Date rucangTime;
    /**
     * 到港时间
     */
    private Date daogangTime;
    /**
     * 清关时间
     */
    private Date qingguanTime;
    /**
     * 已预装时间
     */
    private Date preLoadTime;
    /**
     * 已装柜时间
     */
    private Date loadTime;
    /**
     * 已卸柜时间
     */
    private Date unloadTime;
    /**
     * 提货时间
     */
    private Date takeTime;
    /**
     * 拆单时间
     */
    private Date splitTime;

    /**
     * 是否已发送入仓短信
     */
    private Boolean hasSendRucangSms = false;
    /**
     * 是否已发送入仓通知
     */
    private Boolean hasSendWarehouseInNotice = false;
    /**
     * 是否退场入仓订单
     */
    private Boolean hasExitAndEntry = false;

    @ApiModelProperty(value = "包装类型ids")
    private String packageType;

    @ApiModelProperty(value = "包装备注")
    private String packageRemarks;

    @ApiModelProperty(value = "是否双清：1 客户自清 2 我司双清")
    private Integer doubleClear;

    @ApiModelProperty(value = "装箱单url")
    private String packingListUrl;

    @ApiModelProperty(value = "是否外部仓")
    private Boolean isExternalWarehouse = Boolean.FALSE;

    @ApiModelProperty(value = "外部仓信息")
    private String externalWarehouseJson;

    /**
     * 关联订单状态
     */
    @ApiModelProperty(value = "关联订单状态")
    private String guanLianOrderStatus;

    @ApiModelProperty(value = "不阻塞流程的异常说明(支持多个异常说明)")
    private String exceptionReason;

    @ApiModelProperty(value = "是否有异常(此处为不阻塞流程的异常)")
    private Boolean isException = Boolean.FALSE;

    @ApiModelProperty(value = "是否生成了佣金应付")
    private Boolean commissionPayable;

    @ApiModelProperty(value = "目的港清关：1 我司 2 客户")
    private Integer portDestCustomsClear;

    @ApiModelProperty(value = "发货方式：1 多票 2 单票")
    private Integer deliveryWay;

    @ApiModelProperty(value = "空运可出货状态： 0 默认值 1 待出 2 可出 3 备货中 4 已备货")
    private Integer airShipment;

    @ApiModelProperty(value = "特价泡重")
    private BigDecimal specialVWeight;

    @ApiModelProperty(value = "是否处理了渠道特性异常")
    private Boolean handlerChannelAttrException;


    @ApiModelProperty(value = "打包前入仓重量")
    private BigDecimal weightBeforePack;


    @ApiModelProperty(value = "打包后入仓重量")
    private BigDecimal weightAfterPack;

    @ApiModelProperty(value = "备货重量阀值")
    private BigDecimal stockOverWeightLimit;

    @ApiModelProperty(value = "首次完成备货时间")
    private Date firstStockedTime;

    @ApiModelProperty(value = "拆单子订单是作为独立订单计算(拆单业务只要涉及到空运即将所有拆单后的子订单作为独立订单来计算)")
    private Boolean splitSeparateOrder = false;

    @ApiModelProperty(value = "是否显示提单金额")
    private Boolean displayBillLadingPrice = true;

    @ApiModelProperty(value = "是否有收货人，1-是，0-否")
    private Boolean hasConsignee = true;
//
//    @ApiModelProperty(value = "拆单子订单是否变更运输方式")
//    private Boolean splitChangeTransport = false;

    @TableField(exist = false)
    @ApiModelProperty(value = "订单商品项列表")
    @NotNull(message = "订单商品项列表不能为空")
    @NotEmpty(message = "订单商品项列表不能为空")
    private List<OrderItemDO> orderItemDOList;

    @TableField(exist = false)
    @ApiModelProperty(value = "始发地信息")
    @NotNull(message = "始发地信息不能为空")
    private OrderDepartureDO orderDepartureDO;

    @TableField(exist = false)
    @ApiModelProperty(value = "目的地信息")
    @NotNull(message = "目的地信息不能为空")
    private OrderObjectiveDO orderObjectiveDO;

    @TableField(exist = false)
    @ApiModelProperty(value = "发货人信息")
    @NotNull(message = "发货人信息不能为空")
    private OrderConsignorDO orderConsignorDO;

    @TableField(exist = false)
    @ApiModelProperty(value = "收货人信息")
    @NotNull(message = "收货人信息不能为空")
    private OrderConsigneeDO orderConsigneeDO;

    @TableField(exist = false)
    @ApiModelProperty(value = "控货人信息")
    private OrderCargoControlDO orderCargoControlDO;

    @TableField(exist = false)
    @ApiModelProperty(value = "始发地ID")
    private Long departureId;

    @TableField(exist = false)
    @ApiModelProperty(value = "始发地")
    private String departureName;

    @TableField(exist = false)
    @ApiModelProperty(value = "目的地ID")
    private Long objectiveId;

    @TableField(exist = false)
    @ApiModelProperty(value = "目的地")
    private String objectiveName;

    @TableField(exist = false)
    @ApiModelProperty(value = "入仓状态变更前缀(例如：理货移除、预装移除、撤销拆单、装柜移除)")
    private String prefixStatusZh = "";
    @TableField(exist = false)
    @ApiModelProperty(value = "入仓状态变更前缀(例如：理货移除、预装移除、撤销拆单、装柜移除)")
    private String prefixStatusEn = "";

    @TableField(exist = false)
    @ApiModelProperty(value = "是否主拆单")
    private Boolean isMaster;

    @TableField(exist = false)
    @ApiModelProperty(value = "是否主拆单")
    private Boolean isBoxSplitOrder = false;

    @TableField(exist = false)
    @ApiModelProperty(value = "是否主拆单")
    private Boolean partRefundSplit = false;

    @TableField(exist = false)
    @ApiModelProperty(value = "订单状态文字")
    private String orderStatusMsg;

    @TableField(exist = false)
    @ApiModelProperty(value = "自动处理不可出渠道异常")
    private Boolean isAutomaticHandleNoCanShipmentChannelException = false;

    /**
     * 每次入仓动态更新当前的入仓总数量
     */
    @TableField(exist = false)
    private Integer lastTimeTotalNum;

//    @TableField(exist = false)
//    @ApiModelProperty(value = "是否重置订单编号")
//    private Boolean resetOrderNo;


    /*
     lanbm 2024-05-13 add
     */
    @ApiModelProperty(value = "客户业绩类型：1 新客户业绩 0老客户业绩")
    private Integer yejiType;

    /*
     业绩产生时间 lanbm 2024-05-13 add
     */
    private Date yejiCreateDate;

    /*
     海运根据体积计算出的V值，空运根据重量计算出的V值
     lanbm 2024-05-13 add
     */
    private BigDecimal calVValue;


}
