-- ----------------------------
--  Title:客户表
--  Author:lcc
--  Table:lc_receiver_customers
-- ---------------------------
drop table if exists lc_receiver_customers;
create table lc_receiver_customers (
  id          int(10) unsigned    not null auto_increment comment '自增id',
  rid         int(10) unsigned    not null default '0'    comment '线索池id',
  name        varchar(32)         not null                comment '客户姓名',
  mobile      varchar(11)         not null                comment '客户手机号码',
  biz_id      int(10)             not null default '0'    comment '门店id',
  brand_id    int(10)             not null default '0'    comment '车型品牌id',
  s_id        int(10)             not null default '0'    comment '车系id',
  v_id        int(10)             not null default '0'    comment '车型号',
  if_driver   tinyint(4)          not null default '0'    comment '是否试驾(0否 1是)',
  is_top      tinyint(4)          not null default '0'    comment '是否置顶(0否 1是)',
  admin_id    int(10)             not null default '0'    comment '销售id',
  level       enum('h','a','b','c','d') not null default 'd' comment '用户等级',
  cf_title    varchar(50)         not null default ''     comment '来源title',
  t_num       tinyint(3)          not null default '0'    comment '试驾次数',
  a_num       tinyint(3)          not null default '0'    comment '到店次数',
  p_time      timestamp           not null default '0000-00-00 00:00:00' comment '分配时间',
  cont_time   timestamp           not null default '0000-00-00 00:00:00' comment '最后联系时间',
  buy_time    tinyint(3)          not null default '0'    comment '预计购买时间',
  info_json   json                         default null   comment '用户其它数据',
  car_json    json                         default null   comment '车信息',
  jsondata    json                         default null   comment '其他信息',
  status      tinyint(1)          not null default '0'    comment '状态：-1删除 0未见客户 1到店客户 2订单客户 3战败客户',
  c_time      int(10) unsigned    not null default '0'    comment '创建时间',
  u_time      timestamp           not null default current_timestamp on update current_timestamp,
  primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='客户表';
alter table lc_receiver_customers add cf_clues varchar(50) not null default '' comment '线索来源' after cf_title;

ALTER TABLE `lc_receiver_customers` ADD `order_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '下单时间' AFTER `dt_time`;

-- ----------------------------
--  Title:客户操作日志表
--  Author:lcc
--  Table:lc_receiver_customer_oplogs
-- ---------------------------
drop table if exists lc_receiver_customer_oplogs;
create table lc_receiver_customer_oplogs (
  id          int(10) unsigned    not null auto_increment comment '自增id',
  customer_id int(10) unsigned    not null                comment '客户id',
  uid         int(10) unsigned    not null                comment '操作用户id',
  uname       varchar(32)         not null default ''     comment '用户名',
  type        tinyint(1)          not null default '0'    comment '类型 0 普通 1短信 2电话',
  log         varchar(256)        not null default ''     comment '操作内容',
  cf_platform varchar(10)         not null default ''     comment '来源平台',
  c_time      int(10) unsigned    not null default '0'    comment '创建时间',
  u_time      timestamp           not null default current_timestamp on update current_timestamp,
  primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='客户操作日志表';
alter table lc_receiver_customer_oplogs add imgs json default null comment '图片' after log;

