166 lines
7.9 KiB
SQL
166 lines
7.9 KiB
SQL
create table user_market_genealogy
|
|
(
|
|
id int8 not null primary key, -- user_id
|
|
level int4 default 1, --当前层数
|
|
pid int8,
|
|
root_id int8, --遍历当前树
|
|
group_id int8, --树内最近团队长的id
|
|
genealogy_list int8[], -- 往上所有父级
|
|
user_child_number int, --用户下线总人数
|
|
user_direct_number int, --用户直推总人数
|
|
user_direct_list int8[], --直推列表
|
|
remark text,
|
|
create_user int8,
|
|
create_dept int8,
|
|
create_time timestamp(6),
|
|
update_user int8,
|
|
update_time timestamp(6),
|
|
status int4 default 1, -- 1: active -- 2: revoked (注销) -- 3: frozen (冻结)
|
|
is_deleted int4 default 0
|
|
);
|
|
CREATE INDEX idx_ug_pid ON user_market_genealogy (pid) WHERE status = 1;
|
|
CREATE INDEX idx_ug_root ON user_market_genealogy (root_id) WHERE status = 1;
|
|
CREATE INDEX idx_ug_root_level ON user_market_genealogy (root_id, level) WHERE status = 1;
|
|
CREATE INDEX idx_ug_path ON user_market_genealogy USING gin (genealogy_list);
|
|
CREATE INDEX idx_ug_direct ON user_market_genealogy USING gin (user_direct_list);
|
|
|
|
comment on table user_market_genealogy is '用户族谱表';
|
|
comment on column user_market_genealogy.id is '主键';
|
|
comment on column user_market_genealogy.pid is '上级id';
|
|
comment on column user_market_genealogy.level is '层级';
|
|
comment on column user_market_genealogy.root_id is '根节点id';
|
|
comment on column user_market_genealogy.group_id is '团队长id';
|
|
comment on column user_market_genealogy.genealogy_list is '族谱列表';
|
|
comment on column user_market_genealogy.user_child_number is '用户下线总人数';
|
|
comment on column user_market_genealogy.user_direct_number is '用户直推总人数';
|
|
comment on column user_market_genealogy.user_direct_list is '直推列表';
|
|
comment on column user_market_genealogy.create_user is '创建人';
|
|
comment on column user_market_genealogy.create_dept is '创建部门';
|
|
comment on column user_market_genealogy.create_time is '创建时间';
|
|
comment on column user_market_genealogy.update_user is '修改人';
|
|
comment on column user_market_genealogy.update_time is '修改时间';
|
|
comment on column user_market_genealogy.status is '状态 -- 1: active -- 2: revoked (注销) -- 3: frozen (冻结)';
|
|
comment on column user_market_genealogy.is_deleted is '是否已删除';
|
|
alter table user_market_genealogy
|
|
owner to yicha1lu;
|
|
|
|
|
|
|
|
create table user_market_tree
|
|
(
|
|
id int8 not null primary key, --user_id
|
|
level int4 default 1,
|
|
pid int8,
|
|
create_user int8,
|
|
create_dept int8,
|
|
create_time timestamp(6),
|
|
update_user int8,
|
|
update_time timestamp(6),
|
|
status int4 default 1, -- 1: active -- 2: revoked (注销) -- 3: frozen (冻结)
|
|
is_deleted int4 default 0
|
|
);
|
|
CREATE INDEX idx_user_tree_pid ON user_market_tree (pid) WHERE status = 1;
|
|
CREATE INDEX idx_user_tree_level ON user_market_tree (level) WHERE status = 1;
|
|
|
|
comment on table user_market_tree is '用户树结构表';
|
|
comment on column user_market_tree.id is '主键';
|
|
comment on column user_market_tree.pid is '上级id';
|
|
comment on column user_market_tree.level is '层级';
|
|
|
|
comment on column user_market_tree.create_user is '创建人';
|
|
comment on column user_market_tree.create_dept is '创建部门';
|
|
comment on column user_market_tree.create_time is '创建时间';
|
|
comment on column user_market_tree.update_user is '修改人';
|
|
comment on column user_market_tree.update_time is '修改时间';
|
|
comment on column user_market_tree.status is '状态';
|
|
comment on column user_market_tree.is_deleted is '是否已删除';
|
|
alter table user_market_tree
|
|
owner to yicha1lu;
|
|
|
|
|
|
|
|
create table user_market_info
|
|
(
|
|
id int8 not null primary key, --user_id
|
|
pid int8,
|
|
synchronized int4 default 0, --是否同步
|
|
vendor int4 default 0, -- 是否成为服务商 0-否 1-是
|
|
e_signed int4 default 0, -- 是否已经签署电子合同 0-否 1-是
|
|
e_signed_url text, -- 电子合同地址
|
|
verified int4 default 0, -- 是否实名用户 0-否 1-是
|
|
verified_date timestamp(6), -- 实名时间
|
|
real_name varchar(128), -- 实名姓名
|
|
id_card varchar(128), -- 实名身份证
|
|
create_user int8,
|
|
create_dept int8,
|
|
create_time timestamp(6),
|
|
update_user int8,
|
|
update_time timestamp(6),
|
|
status int4 default 1, -- 1: active -- 2: revoked (注销) -- 3: frozen (冻结)
|
|
is_deleted int4 default 0
|
|
);
|
|
|
|
CREATE INDEX idx_user_market_pid ON user_market_info (pid) WHERE status = 1;
|
|
|
|
|
|
comment on table user_market_info is '用户拓展信息表';
|
|
|
|
comment on column user_market_info.id is '主键';
|
|
comment on column user_market_info.pid is '邀请人';
|
|
comment on column user_market_info.synchronized is '是否同步族谱 0-否 1-是';
|
|
comment on column user_market_info.vendor is '是否成为服务商 0-否 1-是';
|
|
comment on column user_market_info.e_signed is '是否签署法大大协议 0-否 1-是';
|
|
comment on column user_market_info.e_signed_url is '电子合同地址';
|
|
comment on column user_market_info.verified is '是否实名用户 0-否 1-是';
|
|
comment on column user_market_info.verified_date is '实名时间';
|
|
comment on column user_market_info.real_name is '实名姓名';
|
|
comment on column user_market_info.id_card is '实名身份证';
|
|
comment on column user_market_info.create_user is '创建人';
|
|
comment on column user_market_info.create_dept is '创建部门';
|
|
comment on column user_market_info.create_time is '创建时间';
|
|
comment on column user_market_info.update_user is '修改人';
|
|
comment on column user_market_info.update_time is '修改时间';
|
|
comment on column user_market_info.status is '状态';
|
|
comment on column user_market_info.is_deleted is '是否已删除';
|
|
alter table user_market_info owner to yicha1lu;
|
|
|
|
|
|
|
|
create table user_market_level_info
|
|
(
|
|
id int8 not null primary key, --user_id
|
|
current_vip_id int4, --用户当前等级
|
|
current_vip_name varchar(12), --用户当前等级
|
|
pid int8,
|
|
p_vip int4 default 1,
|
|
version int4 default 1,
|
|
create_user int8,
|
|
create_dept int8,
|
|
create_time timestamp(6),
|
|
update_user int8,
|
|
update_time timestamp(6),
|
|
status int4 default 1, -- 1: active -- 2: revoked (注销) -- 3: frozen (冻结)
|
|
is_deleted int4 default 0
|
|
);
|
|
|
|
CREATE INDEX idx_user_level_pid ON user_market_level_info (pid) WHERE status = 1;
|
|
|
|
comment on table user_market_level_info is '用户等级信息表';
|
|
|
|
comment on column user_market_level_info.id is '主键';
|
|
comment on column user_market_level_info.current_vip_id is '用户当前升级id';
|
|
comment on column user_market_level_info.current_vip_name is '用户当前升级名称';
|
|
comment on column user_market_level_info.pid is '父级id';
|
|
comment on column user_market_level_info.p_vip is '父级升级升级';
|
|
comment on column user_market_level_info.version is '版本号';
|
|
comment on column user_market_level_info.create_user is '创建人';
|
|
comment on column user_market_level_info.create_dept is '创建部门';
|
|
comment on column user_market_level_info.create_time is '创建时间';
|
|
comment on column user_market_level_info.update_user is '修改人';
|
|
comment on column user_market_level_info.update_time is '修改时间';
|
|
comment on column user_market_level_info.status is '状态';
|
|
comment on column user_market_level_info.is_deleted is '是否已删除';
|
|
alter table user_market_level_info
|
|
owner to yicha1lu;
|
|
|