-- ----------------------------
--  Title:商家表
--  Author:lcc
--  Table:lc_biz
-- ---------------------------
drop table if exists lc_biz;
create table lc_biz (
  id          int(10) unsigned     not null auto_increment                comment '自增id',
  biz_name    varchar(32)          not null                               comment '商家名称',
  headimg     varchar(128)         not null default ''                    comment '商家头像',
  cover       varchar(128)         not null default ''                    comment '商家封面',
  brand_id    int(10) unsigned     not null default '0'                   comment '品牌id',
  province_id int(10) unsigned     not null default '0'                   comment '省id',
  city_id     int(10) unsigned     not null default '0'                   comment '城市id',
  county_id   int(10) unsigned     not null default '0'                   comment '区id',
  area_id     int(10) unsigned     not null default '0'                   comment '商圈/路段id',
  firstchar   varchar(16)          not null default ''                    comment '大写拼音首字母',
  lat         double(15,12)        not null default '0.000000000000'      comment '经度',
  lng         double(15,12)        not null default '0.000000000000'      comment '纬度',
  address     varchar(255)         not null default ''                    comment '具体地址',
  floor       tinyint(1)           not null default '0'                   comment '楼层',
  status      tinyint(1)           not null default '0'                   comment '-1删除,0下架，1正常',
  c_time      int(11)              not null default '0'                   comment '创建时间',
  u_time      timestamp            not null default current_timestamp on update current_timestamp comment '更新时间',
  primary key (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商家表';
alter table lc_biz add column type        tinyint(1) not null default 0 comment '类型：1-合伙店，2-加盟店，3-代理店' after floor;
alter table lc_biz add column company_id  int        not null default 0 comment '公司ID' after type;

-- ----------------------------
--  Title:品牌表
--  Author:lcc
--  Table:lc_biz_brand
-- ---------------------------
drop table if exists lc_biz_brand;
create table lc_biz_brand (
  id         int(10) unsigned      not null auto_increment                comment '自增id',
  brand_name varchar(32)           not null                               comment '品牌名称',
  brand_logo varchar(128)          not null default ''                    comment '品牌logo',
  status     tinyint(1)            not null default '1'                   comment '状态 -1删除 0:禁用 1:启用',
  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_biz_brand add column type        tinyint(1) not null default 0 comment '类型：1-直营店，2-二网，3-合作店' after brand_logo;
alter table lc_biz_brand add column company_id  int        not null default 0 comment '公司ID' after type;
alter table lc_biz_brand drop column type;
alter table lc_biz_brand drop column company_id;

-- ----------------------------
--  Title:商家标签关系
--  Author:lcc
--  Table:lc_biz_tagdata
-- ---------------------------
drop table if exists lc_biz_tagdata;
create table lc_biz_tagdata (
  biz_id int(10) unsigned         not null                      comment '商家id',
  tag_id int(10) unsigned         not null                      comment '标签id',
  type   tinyint(1)               not null default '1'          comment '1亮点标签 2附加标签',
  primary key (biz_id,tag_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商家标签关系';
