package com.hys.app.model.erp.dos;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hys.app.framework.database.mybatisplus.base.BaseDO;
import com.hys.app.model.erp.enums.OrderTypeEnum;
import com.hys.app.model.erp.enums.SaleOrderSendStatusEnum;
import com.hys.app.model.erp.enums.SaleOrderStatusEnum;
import com.hys.app.model.erp.vo.OrderItemVO;
import com.hys.app.model.erp.vo.OrderSendItemVO;
import com.hys.app.service.kuaidiniao.entity.KdGood;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.*;

/**
 * 订单 DO
 *
 * @author 张崧
 * 2024-01-24 15:58:30
 */
@TableName(value = "erp_order_send", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class OrderSendDO extends BaseDO {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    private Long orderId;

    private Long warehouseId;

    // ================== 基本信息 ==================

    @ApiModelProperty(name = "sn", value = "编号")
    private String sn;

    @ApiModelProperty(name = "status", value = "状态")
    private SaleOrderSendStatusEnum status = SaleOrderSendStatusEnum.TO_BE_SEND;

    @ApiModelProperty(name = "type", value = "订单类型")
    private OrderTypeEnum orderType;

    @ApiModelProperty(name = "subtract_stock", value = "是否允许负库存")
    private Boolean subtractStock;

    @ApiModelProperty(name = "warehouse_out_flag", value = "是否已出库")
    private Boolean warehouseOutFlag = false;

    @ApiModelProperty(name = "warehouse_out_id", value = "出库单id")
    private Long warehouseOutId;

    @ApiModelProperty(name = "ship_time", value = "发货时间")
    private Long shipTime;

    @ApiModelProperty(name = "deleted", value = "是否删除")
    @TableLogic
    private Boolean deleted;

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


    @ApiModelProperty(value = "门店业务类型 1：商家门店  2：个人即时配")
    private Integer storeBusinessType = 2;

    @ApiModelProperty(value = "1、storeCode平台门店编码(商家自定义门店编码，唯一)，个人即时配编码固定传storeCode；2、merchantCode快递鸟门店编码(商家门店编码映射KDN门店编码)个人即时配编码固传merchantCode”;3、平台门店编码和快递鸟门店编码必填一项，且两者只能同时填一项。")
    private String storeCode;

    @ApiModelProperty(value = "(商家门店编码映射KDN门店编码)个人即时配编码固传merchantCode”;3、平台门店编码和快递鸟门店编码必填一项，且两者只能同时填一项。")
    private String merchantCode = "merchantCode";

    @ApiModelProperty(value = "商户名称")
    private String merchantName = "上海瑞赢旷视科技";

    @ApiModelProperty(value = "产品类型编码，默认:B")
    private String productTypeCode = "B";

    @ApiModelProperty(value = "即时配编码,多个即时配编码用逗号分隔。")
    private String intraCode = "SFTC,";

    @ApiModelProperty(value = "预约类型0：立即单、1：预约上门单")
    private Integer appointmentType;

    @ApiModelProperty(value = "预约上门单必填预约上门时间格式：YYYY-MM-DD  hh:mm:ss说明：当前时间+2小时，10分钟间隔向上取整。")
//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private String appointmentTime;

    @ApiModelProperty(value = "交通方式，默认0：未指定。指定交通方式会产生额外的费用。暂不支持")
    private Integer travelWay = 0;

    @ApiModelProperty(value = "下单类型1:帮我送 、2:帮我取；默认1")
    private Integer deliveryType;

    @ApiModelProperty(value = "坐标类型1:百度地图、 2:高德地图 、3:腾讯地图")
    private Integer lbsType = 2;

    @ApiModelProperty(value = "物品类型")
    private String goodsType;

    @ApiModelProperty(value = "物品数量1-99的整数")
    private Integer goodsNum;

    @ApiModelProperty(value = "物品总重量单位kg")
    private Double totalWeight;

    @ApiModelProperty(value = "物品总体积，单位立方厘米")
    private Double totalVolume;

    @ApiModelProperty(value = "物品声明价值，单位：元。去尾法，保留两位小数。所有物品总计声明价值。")
    private Double declaredValue;

    @ApiModelProperty(value = "是否保价  1：是 0：否 暂不支持保价，默认传0")
    private Integer insured = 0;

    @ApiModelProperty(value = "丢破损保障费用，单位：元。去尾法，保留两位小数。根据声明价值计算需要支付的保障用。暂不支持，默认传0")
    private Double insuranceFee = 0.0;

    @ApiModelProperty(value = "下单人姓名")
    private String orderName;

    @ApiModelProperty(value = "下单人手机号(下单人手机号和下单人座机二选一必填)")
    private String orderMobile;

    @ApiModelProperty(value = "下单人座机号(下单人手机号和下单人座机二选一必填)")
    private String orderPhone;


    @ApiModelProperty(value = "商家订单号 全局唯一")
    private String orderCode;


    @ApiModelProperty(name = "receiver_province_name", value = "收货人省")
    private String receiverProvinceName;

    @ApiModelProperty(name = "receiver_city_name", value = "收货人市")
    private String receiverCityName;

    @ApiModelProperty(name = "receiver_area_name", value = "收货人县")
    private String receiverAreaName;

    @ApiModelProperty(name = "receiver_address", value = "收货人地址")
    private String receiverAddress;

    @ApiModelProperty(name = "receiver_name", value = "收货人姓名")
    private String receiverName;

    @ApiModelProperty(name = "receiver_phone", value = "收货人电话")
    private String receiverPhone;

    @ApiModelProperty(name = "receiver_mobile", value = "收货人座机")
    private String receiverMobile;

    @ApiModelProperty(name = "receiver_latitude", value = "收货人纬度")
    private String receiverLatitude;

    @ApiModelProperty(name = "receiver_longitude", value = "收货人经度")
    private String receiverLongitude;

    @ApiModelProperty(name = "sender_province_name", value = "发货人省")
    private String senderProvinceName;

    @ApiModelProperty(name = "sender_city_name", value = "发货人市")
    private String senderCityName;

    @ApiModelProperty(name = "sender_area_name", value = "发货人县")
    private String senderAreaName;

    @ApiModelProperty(name = "sender_address", value = "发货人地址")
    private String senderAddress;

    @ApiModelProperty(name = "sender_name", value = "发货人姓名")
    private String senderName;

    @ApiModelProperty(name = "goods_list", value = "货物信息，最大数量50")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private List<KdGood> goodsList;

    @ApiModelProperty(name = "sender_mobile", value = "发货人座机")
    private String senderMobile;

    @ApiModelProperty(name = "sender_phone", value = "发货人电话")
    private String senderPhone;

    @ApiModelProperty(name = "sender_latitude", value = "发货人纬度")
    private String senderLatitude;

    @ApiModelProperty(name = "sender_longitude", value = "发货人经度")
    private String senderLongitude;

    @ApiModelProperty(name = "kdn_order_code", value = "快递鸟单号")
    private String kdnOrderCode;

    private String sendAddress;

    private String receiveAddress;

    @ApiModelProperty(name = "kdn_order_code", value = "快递鸟下单失败 0")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> createOrderFail = new HashMap<>();

    @ApiModelProperty(name = "kdn_order_code", value = "待接单状态 1")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> createOrderSuccess = new HashMap<>();

    @ApiModelProperty(name = "kdn_order_code", value = "业务员接单状态 2")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> userTakeOrder = new HashMap<>();

    @ApiModelProperty(name = "kdn_order_code", value = "业务员到达状态 3")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> userArrives = new HashMap<>();

    @ApiModelProperty(name = "kdn_order_code", value = "业务员配送中 4")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> userSending = new HashMap<>();

    @ApiModelProperty(name = "kdn_order_code", value = "订单费用 5")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> orderFee = new HashMap<>();

    @ApiModelProperty(name = "kdn_order_code", value = "签收 6")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> signIn = new HashMap<>();

    @ApiModelProperty(name = "kdn_order_code", value = "取消状态  0")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, Object> cancelOrderKdn = new HashMap<>();

    @TableField(exist = false)
    private OrderDO orderVo;

    @TableField(exist = false)
    private List<OrderSendItemVO> orderItemVOS;

    @TableField(exist = false)
    private WarehouseDO warehouseVO;

    @ApiModelProperty(name = "kdn_order_code", value = "自提单号")
    private Integer selfPickupNum;

    @ApiModelProperty("物流轨迹")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private List<Map> logistics = new ArrayList<>();

    @ApiModelProperty("快递类型")
    private String logisticsType;

    @ApiModelProperty("快递单号")
    private String logisticsCode;

    @ApiModelProperty("快递员电话后4位")
    private String logisticsPhone;

}
