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.*;
import com.hys.app.service.kuaidiniao.entity.KdGood;
import com.hys.app.service.kuaidiniao.entity.ReceiverSender;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

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

    private static final long serialVersionUID = 1L;

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

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

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

    @ApiModelProperty(name = "status", value = "订单状态")
    private SaleOrderStatusEnum status = SaleOrderStatusEnum.TO_BE_COMMIT;

    @ApiModelProperty(name = "payment_time", value = "支付时间")
    private Long paymentTime;

    @ApiModelProperty(name = "member_id", value = "会员id/企业id")
    private Long memberId;

    @ApiModelProperty(name = "attachment", value = "客户电话")
    private String customerPhone;

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

    @ApiModelProperty(name = "pay_type", value = "支付方式")
    private String payType;

    @ApiModelProperty(name = "order_time", value = "下单时间")
    private Long orderTime;

    @ApiModelProperty(name = "warehouse_id", value = "仓库id")
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private List<Long> warehouseId;

    @ApiModelProperty(name = "return_warehouse_id", value = "仓库id")
    private Long returnWarehouseId;

    @ApiModelProperty(name = "warehouse_name", value = "仓库名称")
    private String warehouseName;

    @ApiModelProperty(name = "dept_id", value = "部门id")
    private Long deptId;

    @ApiModelProperty(name = "dept_name", value = "部门名称")
    private String deptName;

    @ApiModelProperty(name = "marketing_id", value = "销售经理id")
    private Long marketingId;

    @ApiModelProperty(name = "marketing_name", value = "销售经理名称")
    private String marketingName;

    @ApiModelProperty(name = "attachment", value = "附件")
    private String attachment;

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

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

    // ================== 价格相关 ==================

    @ApiModelProperty(name = "total_price", value = "销售金额")
    private Double totalPrice;

    @ApiModelProperty(name = "discount_price", value = "优惠金额")
    private Double discountPrice;

    @ApiModelProperty(name = "tax_price", value = "税额")
    private Double taxPrice;

    @ApiModelProperty(name = "pay_price", value = "应付金额")
    private Double payPrice;

    @ApiModelProperty(name = "real_price", value = "打折后的金额不能为空")
    private Double realPrice;

    @ApiModelProperty(name = "deposit_price", value = "定金金额")
    private Double depositPrice;

    // ================== 配送相关 ==================

    @ApiModelProperty(name = "send_type", value = "配送方式")
    private OrderSendTypeEnum sendType;

    @ApiModelProperty(name = "store_id", value = "自提门店id")
    private Long storeId;

    @ApiModelProperty(name = "store_name", value = "自提门店名称")
    private String storeName;

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

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

    @ApiModelProperty(name = "ship_flag", value = "是否已发货")
    private Boolean shipFlag;

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

    @ApiModelProperty(name = "logistics_company_id", value = "物流公司id")
    private Long logisticsCompanyId;

    @ApiModelProperty(name = "logistics_company_name", value = "物流公司名称")
    private String logisticsCompanyName;

    @ApiModelProperty(name = "logistics_tracking_number", value = "物流单号")
    private String logisticsTrackingNumber;

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

    @ApiModelProperty(name = "province_city_area_address", value = "支付方式")
    private String provinceCityAreaAddress;

    @ApiModelProperty(name = "address", value = "支付方式")
    private String address;

    @ApiModelProperty(name = "province_city_area", value = "支付方式")
    private String provinceCityArea;

    @ApiModelProperty(name = "end_time", value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    @ApiModelProperty(name = "start_time", value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    @ApiModelProperty(name = "start_time", value = "结束时间")
    private String hasSubmit;

    private String sendAddress;

    private String receiveAddress;

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


    @ApiModelProperty(name = "extension", value = "延期次数")
    private Integer  extension;


}
