package com.bohuikeji.delivery.backstage.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.bohuikeji.frame.module.admin.annotation.TableKeyField;
import com.bohuikeji.frame.module.admin.annotation.TableQueryField;
import com.bohuikeji.frame.module.admin.base.EntityBase;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import com.bohuikeji.frame.module.admin.annotation.TableShowField;
import com.bohuikeji.frame.module.admin.annotation.TableNewField;
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.enums.ColumnTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 客户信息表
 * </p>
 *
 * @author 10552
 * @since 2019-08-22
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="TCustomer对象", description="客户信息表")
@TableName("t_customer")
public class TCustomer extends EntityBase<TCustomer> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value="客户id(新增时请留空或null)")
    @TableId(value = "customer_id", type = IdType.AUTO)
    @TableShowField(value = "ID",id = true)
    @TableField("customer_id")
    @TableQueryField(show = false)
    @TableNewField(show = false)
    private Integer customerId;

    @ApiModelProperty(value = "客户用户名（客户的注册时的手机号+编号）")
    @TableField("customer_name")
    @TableQueryField(show = false)
    @TableShowField(value = "用户名")
    @TableNewField
    private String customerName;

    @ApiModelProperty(value = "客户手机号")
    @TableField("customer_phone")
    @TableShowField(value = "客户手机号")
    @TableNewField(limit = RegEx.INTEGER,edit = false,required = false)
    @TableQueryField(show = false)
    private String customerPhone;

    @ApiModelProperty(value = "客户密码")
    @TableField("customer_pwd")
    private String customerPwd;

    @ApiModelProperty(value = "客户类型")
    @TableField("customer_type")
    @TableQueryField()
    @TableShowField(value = "客户类型")
    @TableNewField(required = false,options = {"普通客户","商家用户"})
    private String customerType="普通客户";

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

    @ApiModelProperty(value = "营业执照")
    @TableField("license_photo")
    @TableShowField(value = "营业执照",type = ColumnTypeEnum.IMAGE)
    @TableNewField(block = FileBlock.class,required = false,show = false)
    private String licensePhoto;

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

    @ApiModelProperty(value = "累计金额")
    @TableField("cum_money")
    @TableShowField("累计金额(￥)")
    @TableNewField(edit = false)
    private String cumMoney="0.00";

    @ApiModelProperty(value = "下单次数")
    @TableField("order_frequency")
    @TableShowField("下单次数")
    @TableNewField(edit = false)
    private Integer orderFrequency=0;

    @ApiModelProperty(value = "客户信用积分")
    @TableField("credit_score")
    @TableShowField("客户信用积分")
    @TableNewField(edit = false)
    private Integer creditScore=0;

    @ApiModelProperty(value = "更新时间")
    @TableField("update_time")
    @TableShowField(value = "更新时间",show = false)
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "客户状态")
    @TableField("customer_status")
    @TableQueryField
    @TableShowField(value = "客户状态")
    private String customerStatus;

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

    @ApiModelProperty(value = "用户唯一标识微信开发者id，微信小程序")
    @TableField("open_id")
    private String openId;

    @ApiModelProperty(value = "客户App绑定微信的openId")
    @TableField("cust_app_open_id")
    private String custAppOpenId;

    @ApiModelProperty(value = "微信会话密钥")
    @TableField("session_key")
    private String sessionKey;

    @ApiModelProperty("签约商户")
    @TableField("big_id")
    @TableShowField("签约商户")
    @TableQueryField(like = false)
    @TableNewField(block = SelectBlock.class,required = false)
    @TableKeyField(table = "t_customer_big",keyShowFields = {"big_name"},where = "big_status = '已签约'",key = TCustomer.class)
    private Integer bigId;

    @ApiModelProperty(value = "登陆标识")
    @TableField("registrat_meth")
    @TableQueryField
    @TableShowField(value = "登陆标识")
    private String registratMeth;

    @ApiModelProperty(value = "消息开关")
    @TableField("message_switch")
    @TableShowField(value = "消息开关")
    @TableNewField(options = {"开启","关闭"})
    private String messageSwitch="开启";

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

    @ApiModelProperty(value = "个推用户个人标识")
    @TableField("cid")
    @TableQueryField(show = false)
    @TableShowField(value = "个推用户个人标识",show = false)
    @TableNewField(edit = false,required = false,show = false)
    private String cid;

    @ApiModelProperty(value = "是否推送")
    @TableField("push_or_not")
    @TableQueryField(show = false)
    @TableShowField(value = "是否推送",show = false)
    @TableNewField(edit = false,required = false,show = false)
    private Boolean pushOrNot;

    @ApiModelProperty(value = "是否选择用户类型")
    @TableField("is_type")
    @TableQueryField(show = false)
    @TableShowField(value = "是否选择用户类型",show = false)
    @TableNewField(edit = false,required = false,show = false)
    private Boolean isType;

    @ApiModelProperty(value = "加盟商id")
    @TableField(exist = false) //不为数据库字段
    private Integer franId;

    /*@ApiModelProperty(value = "注册来源（App、小程序）")
    @TableField("registrat_meth")
    private String registratMeth;*/

}
