package com.bohuikeji.delivery.backstage.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.bohuikeji.frame.module.admin.annotation.TableKeyField;
import com.bohuikeji.frame.module.admin.annotation.TableNewField;
import com.bohuikeji.frame.module.admin.annotation.TableQueryField;
import com.bohuikeji.frame.module.admin.annotation.TableShowField;
import com.bohuikeji.frame.module.admin.base.EntityBase;
import com.bohuikeji.frame.module.admin.entity.TFranchiseeInformation;
import com.bohuikeji.frame.module.admin.entity.sys.SysConfig;
import com.bohuikeji.frame.module.admin.entity.sys.SysUser;
import com.bohuikeji.frame.module.admin.entity.web.block.SelectBlock;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * 订单模板对象
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@ApiModel(value="TOrderTemplate", description="订单模板")
public class TOrderTemplate extends EntityBase<TOrderTemplate> {

    @ApiModelProperty(value = "模板id")
    @TableId(value = "template_id", type = IdType.AUTO)
    @TableShowField(value = "ID",id = true)
    @TableNewField(show = false,add = false,required = false)
    private Integer templateId;

    @TableField("template_num")
    @TableShowField("模板号")
    @TableQueryField(show = false)
    @TableNewField(edit = false,add = false)
    private String templateNum;

    @TableField("template_name")
    @TableShowField("模板名称")
    @TableQueryField(show = false)
    @TableNewField
    private String templateName;

    @ApiModelProperty(value = "车辆id(sys_config表id)用于计算价格")
    @TableField("vehicle_config_id")
    @TableShowField(value = "车辆类型",show = false)
    @TableQueryField(like = false)
    @TableKeyField(table = "sys_config",keyShowFields = {"config_name"},where = "config_group in ('car_type_xshc','car_type_pkc','car_type_mbc','car_type_ddc')",key = SysConfig.class)
    @TableNewField(block = SelectBlock.class)
    private Integer vehicleConfigId;

    @ApiModelProperty(value = "车辆类型(名称)")
    @TableField("vehicle_name")
    private String vehicleName;

    @ApiModelProperty(value = "类型id(sys_config)用于计算价格")
    @TableField("cargo_config_id")
    @TableShowField(value = "货物类型",show = false)
    @TableQueryField(like = false)
    @TableKeyField(table = "sys_config",keyShowFields = {"config_name"},where = "config_group = 'cargo_type'",key = SysConfig.class)
    @TableNewField(block = SelectBlock.class)
    private Integer cargoConfigId;

    @ApiModelProperty(value = "货物类型(鲜花,家电等等..)")
    @TableField("cargo_name")
    private String cargoName;

    @ApiModelProperty(value = "价值配置id(sys_config)用于计算价格")
    @TableField("worth_config_id")
    @TableShowField(value = "物品价值(￥)",show = false)
    @TableKeyField(table = "sys_config",keyShowFields = {"config_name"},where = "config_group = 'cargo_value'",key = SysConfig.class)
    @TableNewField(block = SelectBlock.class)
    @TableQueryField(like = false)
    private Integer worthConfigId;

    @ApiModelProperty(value = "物品价值名称")
    @TableField("worth_name")
    private String worthName;

    @ApiModelProperty(value = "运输方式id(sys_config)用于计算金额")
    @TableField("way_config_id")
    @TableShowField(value = "运输方式",show = false)
    @TableKeyField(table = "sys_config",keyShowFields = {"config_name"},where = "config_group = 'service_type'",key = SysConfig.class)
    @TableNewField(block = SelectBlock.class)
    @TableQueryField(like = false)
    private Integer wayConfigId;

    @ApiModelProperty(value = "运输方式名称")
    @TableField("way_name")
    private String wayName;

    @ApiModelProperty(value = "结算方式配置id(sys_config)用于计算金额")
    @TableField("payment_config_id")
    @TableShowField(value = "结算方式",show = false)
    @TableKeyField(table = "sys_config",keyShowFields = {"config_name"},where = "config_group = 'payment_method'",key = SysConfig.class)
    @TableNewField(block = SelectBlock.class)
    @TableQueryField(like = false)
    private Integer paymentConfigId;

    @ApiModelProperty(value = "结算方式(寄付,到付)")
    @TableField("payment_type")
    private String paymentType;


    @ApiModelProperty(value = "加盟商id")
    @TableField("fran_id")
    @TableShowField(value = "所属加盟商")
    @TableKeyField(table = "t_franchisee_information",keyShowFields = "fran_name",where = "fran_id in(##FRAN_IDS##)",key = TFranchiseeInformation.class)
    @TableQueryField(like = false,sort = 0.1)
    @TableNewField(block = SelectBlock.class,edit = false,add = false)
    private Integer franId;

    @ApiModelProperty(value = "所属签约客户")
    @TableField("big_id")
    @TableShowField(value = "所属签约客户")
    @TableKeyField(table = "t_customer_big",keyShowFields = "big_name",keyLikeFields = {"big_name"},where = "fran_id in(##FRAN_IDS##)",key = TCustomerBig.class)
    @TableQueryField(like = false,sort = 0.2)
    @TableNewField(block = SelectBlock.class,required = false)
    private Integer bigId;

    @TableField("create_user")
    @TableShowField("创建用户")
    @TableKeyField(table = "sys_user",keyShowFields = "user_name",keyLikeFields = "user_name",key = SysUser.class)
    @TableNewField(block = SelectBlock.class,add = false,edit = false)
    private Integer createUser;

    @TableField("create_time")
    @TableShowField("创建时间")
    @TableQueryField(sort = 0,like = false)
    @TableNewField(add = false,edit = false)
    private LocalDateTime createTime=LocalDateTime.now();

    public TOrder pushOrder(TOrder order){
        order.setVehicleConfigId(this.vehicleConfigId);
        order.setVehicleName(this.vehicleName);
        order.setCargoConfigId(this.cargoConfigId);
        order.setCargoName(this.cargoName);
        order.setWorthConfigId(this.worthConfigId);
        order.setWorthName(this.worthName);
        order.setWayConfigId(this.wayConfigId);
        order.setWayName(this.wayName);
        order.setPaymentConfigId(this.paymentConfigId);
        order.setPaymentType(this.paymentType);
        return order;
    }
}
