package com.yiqi.order.domain.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yiqi.common.enums.HqInfoEnums;
import com.yiqi.system.domain.ManageFactory;
import com.yiqi.system.domain.SysStore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;

@ApiModel("商品订单快递组织参数")
@Data
public class DeliveryOrgInfoDTO {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("公司名称")
    private String name;

    @ApiModelProperty("座机号")
    private String Tel;

    @ApiModelProperty("省")
    private String province;

    @ApiModelProperty("城市")
    private String city;

    @ApiModelProperty("区域")
    private String area;

    @ApiModelProperty("地址")
    private String address;

    @ApiModelProperty("门牌号")
    private String addressDetail;

    @ApiModelProperty("联系人姓名")
    private String contactName;

    @ApiModelProperty("联系人手机号")
    private String contactPhone;

    public static DeliveryOrgInfoDTO buildDeliveryOrgInfoDTOByStore(SysStore sysStore){
        DeliveryOrgInfoDTO deliveryOrgInfoDTO = new DeliveryOrgInfoDTO();
        deliveryOrgInfoDTO.setName(sysStore.getName());
        deliveryOrgInfoDTO.setTel(sysStore.getContactWorkTel());
        deliveryOrgInfoDTO.setContactName(sysStore.getContactName());
        deliveryOrgInfoDTO.setContactPhone(sysStore.getContactPhone());
        deliveryOrgInfoDTO.setProvince(sysStore.getProvinceName());
        deliveryOrgInfoDTO.setCity(sysStore.getCityName());
        deliveryOrgInfoDTO.setArea(sysStore.getAreaName());
        deliveryOrgInfoDTO.setAddress(sysStore.getAddress());
        deliveryOrgInfoDTO.setAddressDetail(sysStore.getAddressDetail());
        return deliveryOrgInfoDTO;
    }

    public static DeliveryOrgInfoDTO buildDeliveryOrgInfoDTOByFactory(ManageFactory factory){
        DeliveryOrgInfoDTO deliveryOrgInfoDTO = new DeliveryOrgInfoDTO();
        deliveryOrgInfoDTO.setName(factory.getFactoryName());
        deliveryOrgInfoDTO.setContactName(factory.getApplyName());
        deliveryOrgInfoDTO.setContactPhone(factory.getApplyPhone());
        deliveryOrgInfoDTO.setProvince(factory.getProvince());
        deliveryOrgInfoDTO.setCity(factory.getCity());
        deliveryOrgInfoDTO.setArea(factory.getArea());
        deliveryOrgInfoDTO.setAddress(factory.getAddress());
        deliveryOrgInfoDTO.setAddressDetail(factory.getDetailAddress());
        return deliveryOrgInfoDTO;
    }

    public static DeliveryOrgInfoDTO buildDeliveryOrgInfoDTOByHq(){
        DeliveryOrgInfoDTO deliveryOrgInfoDTO = new DeliveryOrgInfoDTO();
        deliveryOrgInfoDTO.setName(HqInfoEnums.company.getInfo());
        deliveryOrgInfoDTO.setTel(HqInfoEnums.Tel.getInfo());
        deliveryOrgInfoDTO.setContactName(HqInfoEnums.contactName.getInfo());
        deliveryOrgInfoDTO.setContactPhone(HqInfoEnums.contactPhone.getInfo());
        deliveryOrgInfoDTO.setProvince(HqInfoEnums.province.getInfo());
        deliveryOrgInfoDTO.setCity(HqInfoEnums.city.getInfo());
        deliveryOrgInfoDTO.setArea(HqInfoEnums.area.getInfo());
        deliveryOrgInfoDTO.setAddress(HqInfoEnums.address.getInfo());
        return deliveryOrgInfoDTO;
    }
}
