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.constant.RegEx;
import com.bohuikeji.frame.module.admin.entity.web.block.FileBlock;
import com.bohuikeji.frame.module.admin.entity.web.block.SelectBlock;
import com.bohuikeji.frame.module.admin.entity.web.block.TextBlock;
import com.bohuikeji.frame.module.admin.enums.ColumnTypeEnum;
import com.bohuikeji.frame.module.admin.utils.NumberUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 大客户信息表
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="TCustomerBig对象", description="大客户信息表")
public class TCustomerBig extends EntityBase<TCustomerBig> {

    @ApiModelProperty(value="自增id(新增时请留空或null)")
    @TableId(value = "big_id", type = IdType.AUTO)
    @TableShowField(value = "ID",id = true)
    @TableNewField(show = false,required = false)
    private Integer bigId;

    @ApiModelProperty(value = "客户信息")
    @TableField("customer_id")
    @TableShowField(value = "客户信息")
    @TableKeyField(table = "t_customer",keyShowFields = "customer_name",keyLikeFields = "customer_name",key = TCustomer.class)
    @TableNewField(block = SelectBlock.class,edit = false)
    private Integer customerId;

    @ApiModelProperty(value = "后台用户id")
    @TableField("user_id")
    @TableShowField(value = "绑定后台账号",show = false)
    @TableKeyField(table = "sys_user",keyShowFields = "user_phone",keyLikeFields = "user_phone",where = "fran_id in(##FRAN_IDS##)")
    @TableNewField(block = SelectBlock.class,required = false,edit = false,show = false)
    private Integer userId;

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

    @ApiModelProperty(value = "商户名称")
    @TableField("big_name")
    @TableShowField("商户名称")
    @TableNewField
    @TableQueryField(show = false)
    private String bigName;

    @ApiModelProperty(value = "商户号")
    @TableField("big_num")
    @TableShowField(value = "商户号")
    @TableNewField(edit = false)
    @TableQueryField(show = false)
    private String bigNum=NumberUtils.getRandom(6);

    @ApiModelProperty(value = "手机号码")
    @TableField("big_phone")
    @TableShowField("手机号码")
    @TableNewField()
    @TableQueryField()
    private String bigPhone;

    @ApiModelProperty(value = "服务行业")
    @TableField("big_server")
    @TableShowField("服务行业")
    @TableQueryField(like = false)
    @TableNewField(options = {"食品鲜花","搬运跑腿","贸易零售","电子商务","生鲜冷链","信邮票据","其他"})
    private String bigServer;

    @ApiModelProperty(value = "每单价格")
    @TableField("big_price")
    @TableShowField(value = "每单价格",show = false)
    @TableNewField(limit = RegEx.INTEGER,show = false,edit = false,required = false)
    private String bigPrice;

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

    @TableShowField("计费模板")
    @TableField("template_id")
    @TableQueryField(like = false)
    @TableNewField(block = SelectBlock.class,required = false)
    @TableKeyField(table = "t_customer_template",where = "fran_id in(##FRAN_IDS##) group by template_code,id",keyShowFields = {"template_name","template_code"})
    private String templateId;

    @ApiModelProperty(value = "绑定骑手")
    @TableField("courier_id")
    @TableShowField(value = "绑定骑手")
    @TableKeyField(table = "t_courier",keyShowFields = {"courier_name"},keyLikeFields = {"courier_name"},where = "courier_auth='认证成功'  and fran_id in(##FRAN_IDS##)")
    @TableNewField(block = SelectBlock.class,edit = false,add = false,required = false,show = false)
    private Integer courierId;

    @ApiModelProperty(value = "签约起始日期")
    @TableField("big_sign_start_date")
    @TableShowField(value = "签约起始日期",show = false)
    @TableNewField(edit = false,add = false,required = false,show = false)
    private LocalDate bigSignStartDate;

    @ApiModelProperty(value = "签约结束日期")
    @TableField("big_sidn_end_date")
    @TableShowField(value = "签约结束日期",show = false)
    @TableNewField(edit = false,add = false,required = false,show = false)
    private LocalDate bigSidnEndDate;

    @ApiModelProperty(value = "营业执照")
    @TableField("big_license")
    @TableShowField(value = "营业执照",type = ColumnTypeEnum.FILE)
    @TableNewField(block = FileBlock.class,required = false)
    private String bigLicense;

    @ApiModelProperty(value = "门店照片")
    @TableField("store_photo")
    @TableShowField(value = "门店照片",type = ColumnTypeEnum.FILE)
    @TableNewField(block = FileBlock.class,required = false)
    private String storePhoto;

    @ApiModelProperty(value = "门头照")
    @TableField("door_photo")
    @TableShowField(value = "门头照",type = ColumnTypeEnum.IMAGE)
    @TableNewField(block = FileBlock.class,edit = false,add = false,required = false)
    private String doorPhoto;

    @ApiModelProperty(value = "身份证反正面")
    @TableField("id_photo")
    @TableShowField(value = "身份证反正面",type = ColumnTypeEnum.IMAGE)
    @TableNewField(block = FileBlock.class,required = false)
    private String idPhoto;

    @ApiModelProperty(value = "合同附件")
    @TableField("big_contract")
    @TableShowField(value = "合同附件",type = ColumnTypeEnum.FILE)
    @TableNewField(block = FileBlock.class,required = false)
    private String bigContract;

    @ApiModelProperty(value = "经营范围")
    @TableField("big_range")
    @TableShowField("经营范围")
    @TableQueryField(show = false)
    @TableNewField(block = TextBlock.class,required = false)
    private String bigRange;

    @ApiModelProperty(value = "备注")
    @TableField("big_rmk")
    @TableShowField("备注")
    @TableQueryField(show = false)
    @TableNewField(block = TextBlock.class,required = false)
    private String bigRmk;

    @ApiModelProperty(value = "商户地址")
    @TableField("big_address")
    @TableShowField("商户地址")
    @TableQueryField(show = false)
    @TableNewField(block = TextBlock.class)
    private String bigAddress;

    @ApiModelProperty(value = "经纬度")
    @TableField(exist = false) //不为数据库字段
    private String location;

    /**
     * 状态
     * 已签约、签约到期、已欠费
     */
    @ApiModelProperty(value = "状态")
    @TableField("big_status")
    @TableShowField("状态")
    @TableQueryField(like = false)
    @TableNewField(options = {"审核中","待绑定","已签约","已过期","已结束"},add = false,edit = false)
    private String bigStatus="已签约";

}
