package com.yiqi.order.domain;

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

import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yiqi.app.domain.AppUserAddress;
import com.yiqi.common.annotation.Excel;
import com.yiqi.common.utils.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yiqi.common.core.domain.BaseEntity;
import lombok.Data;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

/**
 * 订单配送对象 order_delivery
 *
 * @author ruoyi
 * @date 2024-09-07
 */
@ApiModel("订单配送")
@TableName("order_delivery")
@Data
public class OrderDelivery extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @ApiModelProperty("主键ID")
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 配送单号
     */
    @Excel(name = "配送单号")
    @ApiModelProperty("配送单号")
    private String deliverySn;

    /**
     * 商品订单号
     */
    @Excel(name = "商品订单号")
    @ApiModelProperty("商品订单号")
    private String orderSn;

    /**
     * 门店ID
     */
    @Excel(name = "门店ID")
    @ApiModelProperty("门店ID")

    private Long storeId;

    /**
     * 微信门店id
     */
    @Excel(name = "微信门店id")
    @ApiModelProperty("微信门店id")
    private String wxStoreId;

    /**
     * 衣服订单类型（0=收衣，1=取衣）
     */
    @Excel(name = "衣服订单类型", readConverterExp = "0==收衣，1=取衣")
    @ApiModelProperty("衣服订单类型（0=收衣，1=取衣）")
    private String clothOrderType;

    /**
     * 运力ID
     */
    @Excel(name = "运力ID")
    @ApiModelProperty("运力ID")
    private String serviceTransId;

    /**
     * 客户ID
     */
    @Excel(name = "客户ID")
    @ApiModelProperty("客户ID")

    private Long appUserId;

    /**
     * 自配送配送员
     */
    @Excel(name = "配送员")
    @ApiModelProperty("配送员")
    private Long deliveryManId;

    /**
     * 经纬度
     */
    @Excel(name = "经纬度")
    @ApiModelProperty("经纬度")
    private String userLng;

    /**
     * 经纬度
     */
    @Excel(name = "经纬度")
    @ApiModelProperty("经纬度")
    private String userLat;

    /**
     * 地址
     */
    @Excel(name = "地址")
    @ApiModelProperty("地址")
    private String userAddress;

    /**
     * 用户手机号
     */
    @Excel(name = "用户手机号")
    @ApiModelProperty("用户手机号")
    private String userPhone;

    /**
     * 用户姓名
     */
    @Excel(name = "用户姓名")
    @ApiModelProperty("用户姓名")
    private String userName;

    /**
     * 配送距离(整数单位：米)
     */
    @Excel(name = "配送距离(整数单位：米)")
    @ApiModelProperty("配送距离(整数单位：米)")
    private String distance;

    /**
     * 实际运费(单位：元)，运费减去优惠券费用
     */
    @Excel(name = "实际运费(单位：元)，运费减去优惠券费用")
    @ApiModelProperty("实际运费(单位：元)，运费减去优惠券费用")
    private BigDecimal fee;

    /**
     * 取货码
     */
    @Excel(name = "取货码")
    @ApiModelProperty("取货码")
    private String fetchCode;

    /**
     * 收货码
     */
    @Excel(name = "收货码")
    @ApiModelProperty("收货码")
    private String recvCode;

    /**
     * 运力订单号
     */
    @Excel(name = "运力订单号")
    @ApiModelProperty("运力订单号")

    private String transOrderId;

    /**
     * 配送状态，枚举值 {@link com.yiqi.common.enums.OrderDeliveryStatusEnum}
     */
    @Excel(name = "配送状态，枚举值")
    @ApiModelProperty("配送状态，枚举值")
    private String deliveryStatus;

    /**
     * 状态描述
     */
    @Excel(name = "状态描述")
    @ApiModelProperty("状态描述")
    private String deliveryStatusMsg;

    /**
     * 配送员接单时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "配送员接单时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("配送员接单时间")
    private Date acceptTime;

    /**
     * 配送员取货时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "配送员取货时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("配送员取货时间")
    private Date fetchTime;

    /**
     * 配送员完成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "配送员完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("配送员完成时间")
    private Date finishTime;

    /**
     * 取消时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Excel(name = "取消时间", width = 30, dateFormat = "yyyy-MM-dd")
    @ApiModelProperty("取消时间")
    private Date cancelTime;

    /**
     * 配送员姓名
     */
    @Excel(name = "配送员姓名")
    @ApiModelProperty("配送员姓名")
    private String transporterName;

    /**
     * 配送员电话
     */
    @Excel(name = "配送员电话")
    @ApiModelProperty("配送员电话")
    private String transporterPhone;

    /**
     * 配送方式 {@link com.yiqi.common.enums.ClothOrderDeliveryWay}
     */
    @Excel(name = "配送方式")
    @ApiModelProperty("配送方式 ")
    private String deliveryWay;

    public OrderDelivery() {
    }

    public OrderDelivery(AppUserAddress appUserAddress) {
        this.appUserId = appUserAddress.getAppUserId();
        this.userAddress = appUserAddress.getAddress() + appUserAddress.getAddressDetail();
        this.userLat = String.valueOf(appUserAddress.getLongitude());
        this.userLng = String.valueOf(appUserAddress.getLatitude());
        this.userPhone = appUserAddress.getContactPhone();
        this.userName = appUserAddress.getContactName();
        setCreateTime(DateUtils.getNowDate());
    }

    public OrderDelivery(OrderDelivery orderDelivery) {
        this.appUserId = orderDelivery.getAppUserId();
        this.userAddress = orderDelivery.getUserAddress();
        this.userLat = orderDelivery.getUserLat();
        this.userLng = orderDelivery.getUserLng();
        this.userPhone = orderDelivery.getUserPhone();
        this.userName = orderDelivery.getUserName();
        this.storeId = orderDelivery.getStoreId();
        setCreateTime(DateUtils.getNowDate());
    }

}
