sql脚本-重新整理sql
This commit is contained in:
@@ -1,634 +0,0 @@
|
||||
create table user_genealogy
|
||||
(
|
||||
id bigint not null primary key,
|
||||
name varchar(128),
|
||||
phone bigint,
|
||||
level integer default 1, --当前层数
|
||||
pid bigint,
|
||||
root_id bigint, --遍历当前树
|
||||
group_id bigint, --树内最近团队长的id
|
||||
genealogy_list bigint[] , -- 往上所有父级
|
||||
user_child_number int, --用户下线总人数
|
||||
user_direct_number int, --用户直推总人数
|
||||
user_direct_list bigint[], --直推列表
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
CREATE INDEX user_genealogy_list_gin_idx
|
||||
ON user_genealogy USING gin (genealogy_list);
|
||||
CREATE INDEX user_direct_list_gin_idx
|
||||
ON user_genealogy USING gin (user_direct_list);
|
||||
|
||||
create index user_genealogy_phone_index
|
||||
on user_genealogy (is_deleted, phone);
|
||||
|
||||
comment on table user_genealogy is '用户族谱表';
|
||||
comment on column user_genealogy.id is '主键';
|
||||
comment on column user_genealogy.pid is '上级id';
|
||||
comment on column user_genealogy.name is '用户名';
|
||||
comment on column user_genealogy.phone is '手机号';
|
||||
comment on column user_genealogy.level is '层级';
|
||||
comment on column user_genealogy.root_id is '根节点id';
|
||||
comment on column user_genealogy.group_id is '团队长id';
|
||||
comment on column user_genealogy.genealogy_list is '族谱列表';
|
||||
comment on column user_genealogy.user_child_number is '用户下线总人数';
|
||||
comment on column user_genealogy.user_direct_number is '用户直推总人数';
|
||||
comment on column user_genealogy.user_direct_list is '直推列表';
|
||||
comment on column user_genealogy.create_user is '创建人';
|
||||
comment on column user_genealogy.create_dept is '创建部门';
|
||||
comment on column user_genealogy.create_time is '创建时间';
|
||||
comment on column user_genealogy.update_user is '修改人';
|
||||
comment on column user_genealogy.update_time is '修改时间';
|
||||
comment on column user_genealogy.status is '状态';
|
||||
comment on column user_genealogy.is_deleted is '是否已删除';
|
||||
alter table user_genealogy
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
create table user_tree
|
||||
(
|
||||
id bigint not null primary key,
|
||||
name varchar(128),
|
||||
phone bigint,
|
||||
level integer default 1,
|
||||
pid bigint,
|
||||
p_name varchar(128),
|
||||
p_phone bigint,
|
||||
p_level integer default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
|
||||
create index user_tree_phone_index
|
||||
on user_tree (is_deleted, phone);
|
||||
|
||||
comment on table user_tree is '用户树结构表';
|
||||
comment on column user_tree.id is '主键';
|
||||
comment on column user_tree.pid is '上级id';
|
||||
comment on column user_tree.name is '用户名';
|
||||
comment on column user_tree.phone is '手机号';
|
||||
comment on column user_tree.level is '层级';
|
||||
comment on column user_tree.p_name is '上级用户名';
|
||||
comment on column user_tree.p_phone is '上级用户手机号';
|
||||
comment on column user_tree.p_level is '上级用户层级';
|
||||
comment on column user_tree.create_user is '创建人';
|
||||
comment on column user_tree.create_dept is '创建部门';
|
||||
comment on column user_tree.create_time is '创建时间';
|
||||
comment on column user_tree.update_user is '修改人';
|
||||
comment on column user_tree.update_time is '修改时间';
|
||||
comment on column user_tree.status is '状态';
|
||||
comment on column user_tree.is_deleted is '是否已删除';
|
||||
alter table user_tree
|
||||
owner to postgres;
|
||||
|
||||
create table user_increase_day
|
||||
(
|
||||
id bigint not null primary key,
|
||||
number integer default 1, -- 新增人数
|
||||
direct_number integer default 1, -- 新增人数
|
||||
user_benefit decimal(14,4) default 0, --福利值
|
||||
order_amount decimal(14,4) default 0, --订单金额(整个团队)
|
||||
current_level_id int , --用户当前等级
|
||||
current_level_name varchar(12) , --用户当前等级
|
||||
p_name varchar(128),
|
||||
p_phone bigint,
|
||||
p_level integer default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
create index user_increase_day_phone_index
|
||||
on user_increase_day (is_deleted, phone);
|
||||
comment on table user_increase_day is '用户增加天数表';
|
||||
|
||||
comment on column user_increase_day.id is '主键';
|
||||
comment on column user_increase_day.number is '新增人数';
|
||||
comment on column user_increase_day.direct_number is '新增人数';
|
||||
comment on column user_increase_day.current_level_id is '用户当前等级';
|
||||
comment on column user_increase_day.current_level is '用户当前等级';
|
||||
comment on column user_increase_day.p_name is '上级用户名';
|
||||
comment on column user_increase_day.p_phone is '上级用户手机号';
|
||||
comment on column user_increase_day.p_level is '上级用户层级';
|
||||
comment on column user_increase_day.create_user is '创建人';
|
||||
comment on column user_increase_day.create_dept is '创建部门';
|
||||
comment on column user_increase_day.create_time is '创建时间';
|
||||
comment on column user_increase_day.update_user is '修改人';
|
||||
comment on column user_increase_day.update_time is '修改时间';
|
||||
comment on column user_increase_day.status is '状态';
|
||||
comment on column user_increase_day.is_deleted is '是否已删除';
|
||||
alter table user_increase_day
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE level_info (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(128) NULL,
|
||||
child_qty INTEGER NULL,
|
||||
performance DECIMAL(16, 4) NULL,
|
||||
performance_benefit DECIMAL(16, 4) NULL,
|
||||
next_level_id BIGINT , --晋升等级id
|
||||
is_lowest int , --是否最低等级
|
||||
is_highest int, --是否最高等级
|
||||
bonus_cash_day DECIMAL(16, 4) NULL,
|
||||
bonus_cash_all DECIMAL(16, 4) NULL,
|
||||
bonus_benefit DECIMAL(16, 4) NULL,
|
||||
version BIGINT DEFAULT 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
COMMENT ON TABLE level_info IS '等级信息表';
|
||||
COMMENT ON COLUMN level_info.name IS '等级名称';
|
||||
COMMENT ON COLUMN level_info.child_qty IS '直推人数';
|
||||
COMMENT ON COLUMN level_info.performance IS '现金总业绩';
|
||||
COMMENT ON COLUMN level_info.performance_benefit IS '福利值业绩';
|
||||
COMMENT ON COLUMN level_info.next_level_id IS '晋升等级id';
|
||||
COMMENT ON COLUMN level_info.is_lowest IS '是否最低等级 0-否 1-是';
|
||||
COMMENT ON COLUMN level_info.is_highest IS '是否最高等级 0-否 1-是';
|
||||
COMMENT ON COLUMN level_info.bonus_cash_day IS '每日现金积分加速';
|
||||
COMMENT ON COLUMN level_info.bonus_cash_all IS '全网现金积分加速';
|
||||
COMMENT ON COLUMN level_info.bonus_benefit IS '每日福利积分加速';
|
||||
comment on column level_info.create_user is '创建人';
|
||||
comment on column level_info.create_dept is '创建部门';
|
||||
comment on column level_info.create_time is '创建时间';
|
||||
comment on column level_info.update_user is '修改人';
|
||||
comment on column level_info.update_time is '修改时间';
|
||||
comment on column level_info.status is '状态';
|
||||
comment on column level_info.is_deleted is '是否已删除';
|
||||
|
||||
alter table level_info
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_level_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
statistical_date timestamp(6),
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
level_id bigint,
|
||||
level_name varchar(128),
|
||||
is_lowest int , --是否最低等级
|
||||
is_highest int, --是否最高等级
|
||||
bonus_cash_day DECIMAL(16, 4) NULL,
|
||||
bonus_cash_all DECIMAL(16, 4) NULL,
|
||||
bonus_benefit DECIMAL(16, 4) NULL,
|
||||
bonus_detail text,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index user_level_log_index
|
||||
on user_level_log (is_deleted, statistical_date ,user_id);
|
||||
|
||||
comment on table user_level_log is '用户等级日志表';
|
||||
comment on column user_level_log.id is '主键';
|
||||
comment on column user_level_log.user_id is '用户id';
|
||||
comment on column user_level_log.user_phone is '用户手机号';
|
||||
comment on column user_level_log.user_name is '用户名';
|
||||
comment on column user_level_log.level_id is '等级id';
|
||||
comment on column user_level_log.level_name is '等级名称';
|
||||
comment on column user_level_log.statistical_date is '统计日期';
|
||||
comment on column user_level_log.is_lowest IS '是否最低等级 0-否 1-是';
|
||||
comment on column user_level_log.is_highest IS '是否最高等级 0-否 1-是';
|
||||
comment on column user_level_log.bonus_cash_day is '每日现金积分加速';
|
||||
comment on column user_level_log.bonus_cash_all is '全网现金积分加速';
|
||||
comment on column user_level_log.bonus_benefit is '每日福利积分加速';
|
||||
comment on column user_level_log.bonus_detail is '升级详情';
|
||||
comment on column user_level_log.remark is '备注';
|
||||
comment on column user_level_log.create_user is '创建人';
|
||||
comment on column user_level_log.create_dept is '创建部门';
|
||||
comment on column user_level_log.create_time is '创建时间';
|
||||
comment on column user_level_log.update_user is '修改人';
|
||||
comment on column user_level_log.update_time is '修改时间';
|
||||
comment on column user_level_log.status is '状态';
|
||||
comment on column user_level_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_level_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE package_info (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(128) NULL,
|
||||
buy_qty INTEGER default 0, -- 最大购买数量
|
||||
day_total decimal(16,4) default 0, -- 产出总天数
|
||||
amount_total decimal(14,4) default 0, -- 总产出福利积分
|
||||
give_amount decimal(14,4) default 0, -- 购买赠与福利值
|
||||
bonus decimal(16,4) default 0, -- 激活比率
|
||||
user_benefit decimal(14,4) default 0, --兑换包需要的福利积分
|
||||
user_cash decimal(14,4) default 0, --兑换包需要的现金券
|
||||
is_need_benefit int, --是否需要福利积分
|
||||
is_need_cash int, --是否需要现金券
|
||||
max_exchange_qty integer default 0, -- 全网最大兑换数量
|
||||
exchanged_qty integer default 0, -- 已兑换数量
|
||||
version integer default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
|
||||
);
|
||||
|
||||
COMMENT ON TABLE package_info IS '积分包信息表';
|
||||
COMMENT ON COLUMN package_info.id IS '主键';
|
||||
COMMENT ON COLUMN package_info.name IS '积分包名称';
|
||||
COMMENT ON COLUMN package_info.buy_qty IS '最大购买数量';
|
||||
COMMENT ON COLUMN package_info.day_total IS '产出总天数';
|
||||
COMMENT ON COLUMN package_info.amount_total IS '总产出福利积分';
|
||||
COMMENT ON COLUMN package_info.give_amount IS '购买赠与福利值';
|
||||
COMMENT ON COLUMN package_info.bonus IS '激活比率';
|
||||
COMMENT ON COLUMN package_info.user_benefit IS '兑换包需要的福利积分';
|
||||
COMMENT ON COLUMN package_info.user_cash IS '兑换包需要的现金券';
|
||||
COMMENT ON COLUMN package_info.is_need_benefit IS '是否需要福利积分 0-否 1-是';
|
||||
COMMENT ON COLUMN package_info.is_need_cash IS '是否需要现金券 0-否 1-是';
|
||||
COMMENT ON COLUMN package_info.max_exchange_qty IS '全网最大兑换数量';
|
||||
COMMENT ON COLUMN package_info.exchanged_qty IS '已兑换数量';
|
||||
comment on column package_info.create_user is '创建人';
|
||||
comment on column package_info.create_dept is '创建部门';
|
||||
comment on column package_info.create_time is '创建时间';
|
||||
comment on column package_info.update_user is '修改人';
|
||||
comment on column package_info.update_time is '修改时间';
|
||||
comment on column package_info.status is '状态';
|
||||
comment on column package_info.is_deleted is '是否已删除';
|
||||
|
||||
alter table package_info
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
|
||||
create table user_package_info
|
||||
(
|
||||
id bigint not null primary key,
|
||||
statistical_date timestamp(6),
|
||||
user_id bigint,
|
||||
phone bigint,
|
||||
user_name varchar(128),
|
||||
package_id bigint,
|
||||
package_name varchar(128),
|
||||
user_benefit decimal(14,4) default 0, --兑换包需要的福利积分
|
||||
user_cash decimal(14,4) default 0, --兑换包需要的现金券
|
||||
give_amount decimal(14,4) default 0, -- 购买赠与福利值
|
||||
day_total decimal(16,4) default 0, -- 产出总天数
|
||||
amount_total decimal(14,4) default 0, -- 总产出福利积分
|
||||
amount_day decimal(14,4) default 0, -- 每日产出福利积分 = 总产出 / 总产出
|
||||
amount_out decimal(16,4) default 0, -- 已产出福利积分
|
||||
out_day decimal(16,4) default 0, -- 已产出天数
|
||||
is_complete integer default 0, -- 是否完成 0未完成 1完成
|
||||
expired_date timestamp(6),
|
||||
is_expired integer default 0,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index upi_complete_index
|
||||
on user_package_info (is_deleted, user_id , is_complete , is_expired);
|
||||
|
||||
create index upi_date_index
|
||||
on user_package_info (is_deleted, statistical_date ,user_id);
|
||||
|
||||
create index upi_expired_index
|
||||
on user_package_info (is_deleted, expired_date ,is_expired);
|
||||
|
||||
COMMENT ON TABLE user_package_info IS '用户积分包信息表';
|
||||
COMMENT ON COLUMN user_package_info.id IS '主键';
|
||||
COMMENT ON COLUMN user_package_info.user_id IS '用户id';
|
||||
COMMENT ON COLUMN user_package_info.phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_package_info.user_name IS '用户名';
|
||||
COMMENT ON COLUMN user_package_info.package_id IS '积分包id';
|
||||
COMMENT ON COLUMN user_package_info.package_name IS '积分包名称';
|
||||
COMMENT ON COLUMN user_package_info.user_benefit IS '兑换包需要的福利积分';
|
||||
COMMENT ON COLUMN user_package_info.user_cash IS '兑换包需要的现金券';
|
||||
COMMENT ON COLUMN user_package_info.give_amount IS '购买赠与福利值';
|
||||
COMMENT ON COLUMN user_package_info.day_total IS '产出总天数';
|
||||
COMMENT ON COLUMN user_package_info.amount_total IS '总产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info.amount_day IS '每日产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info.amount_out IS '已产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info.out_day IS '已产出天数';
|
||||
COMMENT ON COLUMN user_package_info.is_complete IS '是否完成 0-未完成 1-完成';
|
||||
COMMENT ON COLUMN user_package_info.expired_date IS '过期时间';
|
||||
COMMENT ON COLUMN user_package_info.is_expired IS '是否过期 0-未过期 1-已过期';
|
||||
COMMENT ON COLUMN user_package_info.remark IS '备注';
|
||||
comment on column user_package_info.create_user is '创建人';
|
||||
comment on column user_package_info.create_dept is '创建部门';
|
||||
comment on column user_package_info.create_time is '创建时间';
|
||||
comment on column user_package_info.update_user is '修改人';
|
||||
comment on column user_package_info.update_time is '修改时间';
|
||||
comment on column user_package_info.status is '状态';
|
||||
comment on column user_package_info.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_package_info
|
||||
owner to postgres;
|
||||
|
||||
create table user_package_info_copy
|
||||
(
|
||||
id bigint not null primary key,
|
||||
statistical_date timestamp(6),
|
||||
user_id bigint,
|
||||
phone bigint,
|
||||
user_name varchar(128),
|
||||
user_package_info bigint, --user_package_info id
|
||||
package_id bigint,
|
||||
package_name varchar(128),
|
||||
user_benefit decimal(14,4) default 0, --兑换包需要的福利积分
|
||||
user_cash decimal(14,4) default 0, --兑换包需要的现金券
|
||||
give_amount decimal(14,4) default 0, -- 购买赠与福利值
|
||||
day_total decimal(16,4) default 0, -- 产出总天数
|
||||
amount_total decimal(14,4) default 0, -- 总产出福利积分
|
||||
amount_day decimal(14,4) default 0, -- 每日产出福利积分 = 总产出 / 总产出
|
||||
amount_out decimal(16,4) default 0, -- 已产出多少福利积分
|
||||
remaining_amount decimal(16,4) default 0, -- 剩余可产出福利积分 (总计 - 已经经历多少天 * 每天产出 - 加速积分)
|
||||
accelerated_amount decimal(16,4) default 0, -- 已加速多少福利积分
|
||||
parent_id bigint, -- 给到谁10%积分,到用户id
|
||||
parent_amount decimal(16,4) default 0, -- 给到谁10%积分,到积分账户(福利积分)
|
||||
out_day decimal(16,4) default 0, -- 产出天数 当前包已经产出天数
|
||||
experience_day decimal(16,4) default 0, -- 当前包已经经历的天数
|
||||
not_sign_list bigint[], -- 未签到日期详情 (数组)
|
||||
is_complete integer default 0, -- 是否完成 0未完成 1完成
|
||||
start_time timestamp(6), -- 当前包生效时间
|
||||
expired_date timestamp(6),
|
||||
is_expired integer default 0,
|
||||
version integer default 1,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
|
||||
);
|
||||
create index upi_copy_complete_index
|
||||
on user_package_info_copy (is_deleted, user_id , is_complete , is_expired);
|
||||
create index upi_copy_date_index
|
||||
on user_package_info_copy (is_deleted, statistical_date ,user_id);
|
||||
create index upi_copy_expired_index
|
||||
on user_package_info_copy (is_deleted, expired_date ,is_expired);
|
||||
|
||||
COMMENT ON TABLE user_package_info_copy IS '用户积分包信息-副本表';
|
||||
COMMENT ON COLUMN user_package_info_copy.id IS '主键';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_id IS '用户id';
|
||||
COMMENT ON COLUMN user_package_info_copy.phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_name IS '用户名';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_package_info IS '用户积分包id';
|
||||
COMMENT ON COLUMN user_package_info_copy.package_id IS '积分包id';
|
||||
COMMENT ON COLUMN user_package_info_copy.package_name IS '积分包名称';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_benefit IS '兑换包需要的福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_cash IS '兑换包需要的现金券';
|
||||
COMMENT ON COLUMN user_package_info_copy.give_amount IS '购买赠与福利值';
|
||||
COMMENT ON COLUMN user_package_info_copy.day_total IS '产出总天数';
|
||||
COMMENT ON COLUMN user_package_info_copy.amount_total IS '总产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.amount_day IS '每日产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.amount_out IS '已产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.remaining_amount IS '剩余可产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.accelerated_amount IS '已加速多少福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.parent_id IS '给到谁10%积分,到用户id';
|
||||
COMMENT ON COLUMN user_package_info_copy.parent_amount IS '给到谁10%积分,到积分账户(福利积分)';
|
||||
COMMENT ON COLUMN user_package_info_copy.out_day IS '产出天数 当前包已经产出天数';
|
||||
COMMENT ON COLUMN user_package_info_copy.experience_day IS '当前包已经经历的天数';
|
||||
COMMENT ON COLUMN user_package_info_copy.not_sign_list IS '未签到日期详情 (数组)';
|
||||
COMMENT ON COLUMN user_package_info_copy.is_complete IS '是否完成 0-未完成 1-完成';
|
||||
COMMENT ON COLUMN user_package_info_copy.start_time IS '当前包生效时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.expired_date IS '过期时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.is_expired IS '是否过期 0-未过期 1-已过期';
|
||||
COMMENT ON COLUMN user_package_info_copy.version IS '版本号';
|
||||
COMMENT ON COLUMN user_package_info_copy.remark IS '备注';
|
||||
COMMENT ON COLUMN user_package_info_copy.create_user IS '创建人';
|
||||
COMMENT ON COLUMN user_package_info_copy.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN user_package_info_copy.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.update_user IS '修改人';
|
||||
COMMENT ON COLUMN user_package_info_copy.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.status IS '状态';
|
||||
COMMENT ON COLUMN user_package_info_copy.is_deleted IS '是否已删除';
|
||||
|
||||
|
||||
|
||||
create table user_performance
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
performance decimal(16,4) default 0,
|
||||
own_performance decimal(16,4) default 0,
|
||||
version int default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
create index up_index
|
||||
on user_performance (is_deleted, user_id);
|
||||
COMMENT ON TABLE user_performance IS '用户现金业绩表';
|
||||
COMMENT ON COLUMN user_performance.id IS '主键';
|
||||
COMMENT ON COLUMN user_performance.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN user_performance.user_phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_performance.user_name IS '用户名称';
|
||||
COMMENT ON COLUMN user_performance.performance IS '总业绩';
|
||||
COMMENT ON COLUMN user_performance.own_performance IS '自身业绩';
|
||||
COMMENT ON COLUMN user_performance.version IS '版本号';
|
||||
comment on column user_performance.create_user is '创建人';
|
||||
comment on column user_performance.create_dept is '创建部门';
|
||||
comment on column user_performance.create_time is '创建时间';
|
||||
comment on column user_performance.update_user is '修改人';
|
||||
comment on column user_performance.update_time is '修改时间';
|
||||
comment on column user_performance.status is '状态';
|
||||
comment on column user_performance.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance
|
||||
owner to postgres;
|
||||
|
||||
create table user_performance_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14,4) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index user_performance_log_index
|
||||
on user_performance_log (is_deleted, user_id, statistical_date , type);
|
||||
|
||||
comment on table user_performance_log is '用户现金业绩日志表';
|
||||
comment on column user_performance_log.id is '主键';
|
||||
comment on column user_performance_log.user_id is '用户ID';
|
||||
comment on column user_performance_log.user_phone is '用户手机号';
|
||||
comment on column user_performance_log.user_name is '用户名称';
|
||||
comment on column user_performance_log.amount is '业绩变动金额';
|
||||
comment on column user_performance_log.source_id is '来源ID';
|
||||
comment on column user_performance_log.source_detail is '来源详情';
|
||||
comment on column user_performance_log.order_id is '订单ID';
|
||||
comment on column user_performance_log.type is '类型 1增加 2减少';
|
||||
comment on column user_performance_log.statistical_date is '统计日期';
|
||||
comment on column user_performance_log.channel is '渠道';
|
||||
comment on column user_performance_log.channel_detail is '渠道详情';
|
||||
|
||||
comment on column user_performance_log.remark is '备注';
|
||||
comment on column user_performance_log.create_user is '创建人';
|
||||
comment on column user_performance_log.create_dept is '创建部门';
|
||||
comment on column user_performance_log.create_time is '创建时间';
|
||||
comment on column user_performance_log.update_user is '修改人';
|
||||
comment on column user_performance_log.update_time is '修改时间';
|
||||
comment on column user_performance_log.status is '状态';
|
||||
comment on column user_performance_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_performance_benefit
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
performance decimal(16,4) default 0,
|
||||
own_performance decimal(16,4) default 0,
|
||||
version int default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
create index upb_index
|
||||
on user_performance_benefit (is_deleted, user_id);
|
||||
COMMENT ON TABLE user_performance_benefit IS '用户福利值业绩表';
|
||||
COMMENT ON COLUMN user_performance_benefit.id IS '主键';
|
||||
COMMENT ON COLUMN user_performance_benefit.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN user_performance_benefit.user_phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_performance_benefit.user_name IS '用户名称';
|
||||
COMMENT ON COLUMN user_performance_benefit.performance IS '总业绩';
|
||||
COMMENT ON COLUMN user_performance_benefit.own_performance IS '自身业绩';
|
||||
COMMENT ON COLUMN user_performance_benefit.version IS '版本号';
|
||||
comment on column user_performance_benefit.create_user is '创建人';
|
||||
comment on column user_performance_benefit.create_dept is '创建部门';
|
||||
comment on column user_performance_benefit.create_time is '创建时间';
|
||||
comment on column user_performance_benefit.update_user is '修改人';
|
||||
comment on column user_performance_benefit.update_time is '修改时间';
|
||||
comment on column user_performance_benefit.status is '状态';
|
||||
comment on column user_performance_benefit.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance_benefit
|
||||
owner to postgres;
|
||||
|
||||
create table user_performance_benefit_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14,4) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index upbl_index
|
||||
on user_performance_benefit_log (is_deleted, user_id, statistical_date , type);
|
||||
|
||||
comment on table user_performance_benefit_log is '用户福利值业绩日志表';
|
||||
comment on column user_performance_benefit_log.id is '主键';
|
||||
comment on column user_performance_benefit_log.user_id is '用户ID';
|
||||
comment on column user_performance_benefit_log.user_phone is '用户手机号';
|
||||
comment on column user_performance_benefit_log.user_name is '用户名称';
|
||||
comment on column user_performance_benefit_log.amount is '业绩变动金额';
|
||||
comment on column user_performance_benefit_log.source_id is '来源ID';
|
||||
comment on column user_performance_benefit_log.source_detail is '来源详情';
|
||||
comment on column user_performance_benefit_log.order_id is '订单ID';
|
||||
comment on column user_performance_benefit_log.type is '类型 1增加 2减少';
|
||||
comment on column user_performance_benefit_log.statistical_date is '统计日期';
|
||||
comment on column user_performance_benefit_log.channel is '渠道';
|
||||
comment on column user_performance_benefit_log.channel_detail is '渠道详情';
|
||||
comment on column user_performance_benefit_log.remark is '备注';
|
||||
comment on column user_performance_benefit_log.create_user is '创建人';
|
||||
comment on column user_performance_benefit_log.create_dept is '创建部门';
|
||||
comment on column user_performance_benefit_log.create_time is '创建时间';
|
||||
comment on column user_performance_benefit_log.update_user is '修改人';
|
||||
comment on column user_performance_benefit_log.update_time is '修改时间';
|
||||
comment on column user_performance_benefit_log.status is '状态';
|
||||
comment on column user_performance_benefit_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance_benefit_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,455 @@
|
||||
create table user_genealogy
|
||||
(
|
||||
id bigint not null primary key,
|
||||
name varchar(128),
|
||||
phone bigint,
|
||||
level integer default 1, --当前层数
|
||||
pid bigint,
|
||||
root_id bigint, --遍历当前树
|
||||
group_id bigint, --树内最近团队长的id
|
||||
genealogy_list bigint[] , -- 往上所有父级
|
||||
user_child_number int, --用户下线总人数
|
||||
user_direct_number int, --用户直推总人数
|
||||
user_direct_list bigint[], --直推列表
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
CREATE INDEX user_genealogy_list_gin_idx
|
||||
ON user_genealogy USING gin (genealogy_list);
|
||||
CREATE INDEX user_direct_list_gin_idx
|
||||
ON user_genealogy USING gin (user_direct_list);
|
||||
|
||||
create index user_genealogy_phone_index
|
||||
on user_genealogy (is_deleted, phone);
|
||||
|
||||
comment on table user_genealogy is '用户族谱表';
|
||||
comment on column user_genealogy.id is '主键';
|
||||
comment on column user_genealogy.pid is '上级id';
|
||||
comment on column user_genealogy.name is '用户名';
|
||||
comment on column user_genealogy.phone is '手机号';
|
||||
comment on column user_genealogy.level is '层级';
|
||||
comment on column user_genealogy.root_id is '根节点id';
|
||||
comment on column user_genealogy.group_id is '团队长id';
|
||||
comment on column user_genealogy.genealogy_list is '族谱列表';
|
||||
comment on column user_genealogy.user_child_number is '用户下线总人数';
|
||||
comment on column user_genealogy.user_direct_number is '用户直推总人数';
|
||||
comment on column user_genealogy.user_direct_list is '直推列表';
|
||||
comment on column user_genealogy.create_user is '创建人';
|
||||
comment on column user_genealogy.create_dept is '创建部门';
|
||||
comment on column user_genealogy.create_time is '创建时间';
|
||||
comment on column user_genealogy.update_user is '修改人';
|
||||
comment on column user_genealogy.update_time is '修改时间';
|
||||
comment on column user_genealogy.status is '状态';
|
||||
comment on column user_genealogy.is_deleted is '是否已删除';
|
||||
alter table user_genealogy
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
create table user_tree
|
||||
(
|
||||
id bigint not null primary key,
|
||||
name varchar(128),
|
||||
phone bigint,
|
||||
level integer default 1,
|
||||
pid bigint,
|
||||
p_name varchar(128),
|
||||
p_phone bigint,
|
||||
p_level integer default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
|
||||
create index user_tree_phone_index
|
||||
on user_tree (is_deleted, phone);
|
||||
|
||||
comment on table user_tree is '用户树结构表';
|
||||
comment on column user_tree.id is '主键';
|
||||
comment on column user_tree.pid is '上级id';
|
||||
comment on column user_tree.name is '用户名';
|
||||
comment on column user_tree.phone is '手机号';
|
||||
comment on column user_tree.level is '层级';
|
||||
comment on column user_tree.p_name is '上级用户名';
|
||||
comment on column user_tree.p_phone is '上级用户手机号';
|
||||
comment on column user_tree.p_level is '上级用户层级';
|
||||
comment on column user_tree.create_user is '创建人';
|
||||
comment on column user_tree.create_dept is '创建部门';
|
||||
comment on column user_tree.create_time is '创建时间';
|
||||
comment on column user_tree.update_user is '修改人';
|
||||
comment on column user_tree.update_time is '修改时间';
|
||||
comment on column user_tree.status is '状态';
|
||||
comment on column user_tree.is_deleted is '是否已删除';
|
||||
alter table user_tree
|
||||
owner to postgres;
|
||||
|
||||
create table user_increase_day
|
||||
(
|
||||
id bigint not null primary key,
|
||||
name varchar(128),
|
||||
phone bigint,
|
||||
number integer default 1, -- 新增人数
|
||||
direct_number integer default 1, -- 新增人数
|
||||
user_benefit decimal(14,4) default 0, --福利值
|
||||
order_amount decimal(14,4) default 0, --订单金额(整个团队)
|
||||
current_level_id int , --用户当前等级
|
||||
current_level_name varchar(12) , --用户当前等级
|
||||
p_name varchar(128),
|
||||
p_phone bigint,
|
||||
p_level integer default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
create index user_increase_day_phone_index
|
||||
on user_increase_day (is_deleted, phone);
|
||||
comment on table user_increase_day is '用户增加天数表';
|
||||
|
||||
comment on column user_increase_day.id is '主键';
|
||||
comment on column user_increase_day.number is '新增人数';
|
||||
comment on column user_increase_day.direct_number is '新增人数';
|
||||
comment on column user_increase_day.current_level_id is '用户当前等级';
|
||||
comment on column user_increase_day.current_level_name is '用户当前等级';
|
||||
comment on column user_increase_day.p_name is '上级用户名';
|
||||
comment on column user_increase_day.p_phone is '上级用户手机号';
|
||||
comment on column user_increase_day.p_level is '上级用户层级';
|
||||
comment on column user_increase_day.create_user is '创建人';
|
||||
comment on column user_increase_day.create_dept is '创建部门';
|
||||
comment on column user_increase_day.create_time is '创建时间';
|
||||
comment on column user_increase_day.update_user is '修改人';
|
||||
comment on column user_increase_day.update_time is '修改时间';
|
||||
comment on column user_increase_day.status is '状态';
|
||||
comment on column user_increase_day.is_deleted is '是否已删除';
|
||||
alter table user_increase_day
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE level_info (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(128) NULL,
|
||||
child_qty INTEGER NULL,
|
||||
performance DECIMAL(16, 4) NULL,
|
||||
performance_benefit DECIMAL(16, 4) NULL,
|
||||
next_level_id BIGINT , --晋升等级id
|
||||
is_lowest int , --是否最低等级
|
||||
is_highest int, --是否最高等级
|
||||
bonus_cash_day DECIMAL(16, 4) NULL,
|
||||
bonus_cash_all DECIMAL(16, 4) NULL,
|
||||
bonus_benefit DECIMAL(16, 4) NULL,
|
||||
version BIGINT DEFAULT 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
COMMENT ON TABLE level_info IS '等级信息表';
|
||||
COMMENT ON COLUMN level_info.name IS '等级名称';
|
||||
COMMENT ON COLUMN level_info.child_qty IS '直推人数';
|
||||
COMMENT ON COLUMN level_info.performance IS '现金总业绩';
|
||||
COMMENT ON COLUMN level_info.performance_benefit IS '福利值业绩';
|
||||
COMMENT ON COLUMN level_info.next_level_id IS '晋升等级id';
|
||||
COMMENT ON COLUMN level_info.is_lowest IS '是否最低等级 0-否 1-是';
|
||||
COMMENT ON COLUMN level_info.is_highest IS '是否最高等级 0-否 1-是';
|
||||
COMMENT ON COLUMN level_info.bonus_cash_day IS '每日现金积分加速';
|
||||
COMMENT ON COLUMN level_info.bonus_cash_all IS '全网现金积分加速';
|
||||
COMMENT ON COLUMN level_info.bonus_benefit IS '每日福利积分加速';
|
||||
comment on column level_info.create_user is '创建人';
|
||||
comment on column level_info.create_dept is '创建部门';
|
||||
comment on column level_info.create_time is '创建时间';
|
||||
comment on column level_info.update_user is '修改人';
|
||||
comment on column level_info.update_time is '修改时间';
|
||||
comment on column level_info.status is '状态';
|
||||
comment on column level_info.is_deleted is '是否已删除';
|
||||
|
||||
alter table level_info
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_level_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
statistical_date timestamp(6),
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
level_id bigint,
|
||||
level_name varchar(128),
|
||||
is_lowest int , --是否最低等级
|
||||
is_highest int, --是否最高等级
|
||||
bonus_cash_day DECIMAL(16, 4) NULL,
|
||||
bonus_cash_all DECIMAL(16, 4) NULL,
|
||||
bonus_benefit DECIMAL(16, 4) NULL,
|
||||
bonus_detail text,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index user_level_log_index
|
||||
on user_level_log (is_deleted, statistical_date ,user_id);
|
||||
|
||||
comment on table user_level_log is '用户等级日志表';
|
||||
comment on column user_level_log.id is '主键';
|
||||
comment on column user_level_log.user_id is '用户id';
|
||||
comment on column user_level_log.user_phone is '用户手机号';
|
||||
comment on column user_level_log.user_name is '用户名';
|
||||
comment on column user_level_log.level_id is '等级id';
|
||||
comment on column user_level_log.level_name is '等级名称';
|
||||
comment on column user_level_log.statistical_date is '统计日期';
|
||||
comment on column user_level_log.is_lowest IS '是否最低等级 0-否 1-是';
|
||||
comment on column user_level_log.is_highest IS '是否最高等级 0-否 1-是';
|
||||
comment on column user_level_log.bonus_cash_day is '每日现金积分加速';
|
||||
comment on column user_level_log.bonus_cash_all is '全网现金积分加速';
|
||||
comment on column user_level_log.bonus_benefit is '每日福利积分加速';
|
||||
comment on column user_level_log.bonus_detail is '升级详情';
|
||||
comment on column user_level_log.remark is '备注';
|
||||
comment on column user_level_log.create_user is '创建人';
|
||||
comment on column user_level_log.create_dept is '创建部门';
|
||||
comment on column user_level_log.create_time is '创建时间';
|
||||
comment on column user_level_log.update_user is '修改人';
|
||||
comment on column user_level_log.update_time is '修改时间';
|
||||
comment on column user_level_log.status is '状态';
|
||||
comment on column user_level_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_level_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
|
||||
CREATE TABLE package_info (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
name VARCHAR(128) NULL,
|
||||
buy_qty INTEGER default 0, -- 最大购买数量
|
||||
day_total decimal(16,4) default 0, -- 产出总天数
|
||||
amount_total decimal(14,4) default 0, -- 总产出福利积分
|
||||
give_amount decimal(14,4) default 0, -- 购买赠与福利值
|
||||
bonus decimal(16,4) default 0, -- 激活比率
|
||||
user_benefit decimal(14,4) default 0, --兑换包需要的福利积分
|
||||
user_cash decimal(14,4) default 0, --兑换包需要的现金券
|
||||
is_need_benefit int, --是否需要福利积分
|
||||
is_need_cash int, --是否需要现金券
|
||||
max_exchange_qty integer default 0, -- 全网最大兑换数量
|
||||
exchanged_qty integer default 0, -- 已兑换数量
|
||||
version integer default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
|
||||
);
|
||||
|
||||
COMMENT ON TABLE package_info IS '积分包信息表';
|
||||
COMMENT ON COLUMN package_info.id IS '主键';
|
||||
COMMENT ON COLUMN package_info.name IS '积分包名称';
|
||||
COMMENT ON COLUMN package_info.buy_qty IS '最大购买数量';
|
||||
COMMENT ON COLUMN package_info.day_total IS '产出总天数';
|
||||
COMMENT ON COLUMN package_info.amount_total IS '总产出福利积分';
|
||||
COMMENT ON COLUMN package_info.give_amount IS '购买赠与福利值';
|
||||
COMMENT ON COLUMN package_info.bonus IS '激活比率';
|
||||
COMMENT ON COLUMN package_info.user_benefit IS '兑换包需要的福利积分';
|
||||
COMMENT ON COLUMN package_info.user_cash IS '兑换包需要的现金券';
|
||||
COMMENT ON COLUMN package_info.is_need_benefit IS '是否需要福利积分 0-否 1-是';
|
||||
COMMENT ON COLUMN package_info.is_need_cash IS '是否需要现金券 0-否 1-是';
|
||||
COMMENT ON COLUMN package_info.max_exchange_qty IS '全网最大兑换数量';
|
||||
COMMENT ON COLUMN package_info.exchanged_qty IS '已兑换数量';
|
||||
comment on column package_info.create_user is '创建人';
|
||||
comment on column package_info.create_dept is '创建部门';
|
||||
comment on column package_info.create_time is '创建时间';
|
||||
comment on column package_info.update_user is '修改人';
|
||||
comment on column package_info.update_time is '修改时间';
|
||||
comment on column package_info.status is '状态';
|
||||
comment on column package_info.is_deleted is '是否已删除';
|
||||
|
||||
alter table package_info
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
|
||||
create table user_package_info
|
||||
(
|
||||
id bigint not null primary key,
|
||||
statistical_date timestamp(6),
|
||||
user_id bigint,
|
||||
phone bigint,
|
||||
user_name varchar(128),
|
||||
package_id bigint,
|
||||
package_name varchar(128),
|
||||
user_benefit decimal(14,4) default 0, --兑换包需要的福利积分
|
||||
user_cash decimal(14,4) default 0, --兑换包需要的现金券
|
||||
give_amount decimal(14,4) default 0, -- 购买赠与福利值
|
||||
day_total decimal(16,4) default 0, -- 产出总天数
|
||||
amount_total decimal(14,4) default 0, -- 总产出福利积分
|
||||
amount_day decimal(14,4) default 0, -- 每日产出福利积分 = 总产出 / 总产出
|
||||
amount_out decimal(16,4) default 0, -- 已产出福利积分
|
||||
out_day decimal(16,4) default 0, -- 已产出天数
|
||||
is_complete integer default 0, -- 是否完成 0未完成 1完成
|
||||
expired_date timestamp(6),
|
||||
is_expired integer default 0,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index upi_complete_index
|
||||
on user_package_info (is_deleted, user_id , is_complete , is_expired);
|
||||
|
||||
create index upi_date_index
|
||||
on user_package_info (is_deleted, statistical_date ,user_id);
|
||||
|
||||
create index upi_expired_index
|
||||
on user_package_info (is_deleted, expired_date ,is_expired);
|
||||
|
||||
COMMENT ON TABLE user_package_info IS '用户积分包信息表';
|
||||
COMMENT ON COLUMN user_package_info.id IS '主键';
|
||||
COMMENT ON COLUMN user_package_info.user_id IS '用户id';
|
||||
COMMENT ON COLUMN user_package_info.phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_package_info.user_name IS '用户名';
|
||||
COMMENT ON COLUMN user_package_info.package_id IS '积分包id';
|
||||
COMMENT ON COLUMN user_package_info.package_name IS '积分包名称';
|
||||
COMMENT ON COLUMN user_package_info.user_benefit IS '兑换包需要的福利积分';
|
||||
COMMENT ON COLUMN user_package_info.user_cash IS '兑换包需要的现金券';
|
||||
COMMENT ON COLUMN user_package_info.give_amount IS '购买赠与福利值';
|
||||
COMMENT ON COLUMN user_package_info.day_total IS '产出总天数';
|
||||
COMMENT ON COLUMN user_package_info.amount_total IS '总产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info.amount_day IS '每日产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info.amount_out IS '已产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info.out_day IS '已产出天数';
|
||||
COMMENT ON COLUMN user_package_info.is_complete IS '是否完成 0-未完成 1-完成';
|
||||
COMMENT ON COLUMN user_package_info.expired_date IS '过期时间';
|
||||
COMMENT ON COLUMN user_package_info.is_expired IS '是否过期 0-未过期 1-已过期';
|
||||
COMMENT ON COLUMN user_package_info.remark IS '备注';
|
||||
comment on column user_package_info.create_user is '创建人';
|
||||
comment on column user_package_info.create_dept is '创建部门';
|
||||
comment on column user_package_info.create_time is '创建时间';
|
||||
comment on column user_package_info.update_user is '修改人';
|
||||
comment on column user_package_info.update_time is '修改时间';
|
||||
comment on column user_package_info.status is '状态';
|
||||
comment on column user_package_info.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_package_info
|
||||
owner to postgres;
|
||||
|
||||
create table user_package_info_copy
|
||||
(
|
||||
id bigint not null primary key,
|
||||
statistical_date timestamp(6),
|
||||
user_id bigint,
|
||||
phone bigint,
|
||||
user_name varchar(128),
|
||||
user_package_info bigint, --user_package_info id
|
||||
package_id bigint,
|
||||
package_name varchar(128),
|
||||
user_benefit decimal(14,4) default 0, --兑换包需要的福利积分
|
||||
user_cash decimal(14,4) default 0, --兑换包需要的现金券
|
||||
give_amount decimal(14,4) default 0, -- 购买赠与福利值
|
||||
day_total decimal(16,4) default 0, -- 产出总天数
|
||||
amount_total decimal(14,4) default 0, -- 总产出福利积分
|
||||
amount_day decimal(14,4) default 0, -- 每日产出福利积分 = 总产出 / 总产出
|
||||
amount_out decimal(16,4) default 0, -- 已产出多少福利积分
|
||||
remaining_amount decimal(16,4) default 0, -- 剩余可产出福利积分 (总计 - 已经经历多少天 * 每天产出 - 加速积分)
|
||||
accelerated_amount decimal(16,4) default 0, -- 已加速多少福利积分
|
||||
parent_id bigint, -- 给到谁10%积分,到用户id
|
||||
parent_amount decimal(16,4) default 0, -- 给到谁10%积分,到积分账户(福利积分)
|
||||
out_day decimal(16,4) default 0, -- 产出天数 当前包已经产出天数
|
||||
experience_day decimal(16,4) default 0, -- 当前包已经经历的天数
|
||||
not_sign_list bigint[], -- 未签到日期详情 (数组)
|
||||
is_complete integer default 0, -- 是否完成 0未完成 1完成
|
||||
start_time timestamp(6), -- 当前包生效时间
|
||||
sign_bitmap bigint default 0, -- 位图将包的签到时间360天二进制转成十进制
|
||||
expired_date timestamp(6),
|
||||
is_expired integer default 0,
|
||||
version integer default 1,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
|
||||
);
|
||||
create index upi_copy_complete_index
|
||||
on user_package_info_copy (is_deleted, user_id , is_complete , is_expired);
|
||||
create index upi_copy_date_index
|
||||
on user_package_info_copy (is_deleted, statistical_date ,user_id);
|
||||
create index upi_copy_expired_index
|
||||
on user_package_info_copy (is_deleted, expired_date ,is_expired);
|
||||
|
||||
COMMENT ON TABLE user_package_info_copy IS '用户积分包信息-副本表';
|
||||
COMMENT ON COLUMN user_package_info_copy.id IS '主键';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_id IS '用户id';
|
||||
COMMENT ON COLUMN user_package_info_copy.phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_name IS '用户名';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_package_info IS '用户积分包id';
|
||||
COMMENT ON COLUMN user_package_info_copy.package_id IS '积分包id';
|
||||
COMMENT ON COLUMN user_package_info_copy.package_name IS '积分包名称';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_benefit IS '兑换包需要的福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.user_cash IS '兑换包需要的现金券';
|
||||
COMMENT ON COLUMN user_package_info_copy.give_amount IS '购买赠与福利值';
|
||||
COMMENT ON COLUMN user_package_info_copy.day_total IS '产出总天数';
|
||||
COMMENT ON COLUMN user_package_info_copy.amount_total IS '总产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.amount_day IS '每日产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.amount_out IS '已产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.remaining_amount IS '剩余可产出福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.accelerated_amount IS '已加速多少福利积分';
|
||||
COMMENT ON COLUMN user_package_info_copy.parent_id IS '给到谁10%积分,到用户id';
|
||||
COMMENT ON COLUMN user_package_info_copy.parent_amount IS '给到谁10%积分,到积分账户(福利积分)';
|
||||
COMMENT ON COLUMN user_package_info_copy.out_day IS '产出天数 当前包已经产出天数';
|
||||
COMMENT ON COLUMN user_package_info_copy.experience_day IS '当前包已经经历的天数';
|
||||
COMMENT ON COLUMN user_package_info_copy.not_sign_list IS '未签到日期详情 (数组)';
|
||||
COMMENT ON COLUMN user_package_info_copy.is_complete IS '是否完成 0-未完成 1-完成';
|
||||
COMMENT ON COLUMN user_package_info_copy.start_time IS '当前包生效时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.sign_bitmap IS '位图将包的签到时间360天二进制转成十进制';
|
||||
COMMENT ON COLUMN user_package_info_copy.expired_date IS '过期时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.is_expired IS '是否过期 0-未过期 1-已过期';
|
||||
COMMENT ON COLUMN user_package_info_copy.version IS '版本号';
|
||||
COMMENT ON COLUMN user_package_info_copy.remark IS '备注';
|
||||
COMMENT ON COLUMN user_package_info_copy.create_user IS '创建人';
|
||||
COMMENT ON COLUMN user_package_info_copy.create_dept IS '创建部门';
|
||||
COMMENT ON COLUMN user_package_info_copy.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.update_user IS '修改人';
|
||||
COMMENT ON COLUMN user_package_info_copy.update_time IS '修改时间';
|
||||
COMMENT ON COLUMN user_package_info_copy.status IS '状态';
|
||||
COMMENT ON COLUMN user_package_info_copy.is_deleted IS '是否已删除';
|
||||
|
||||
|
||||
|
||||
-- 佣金账户表
|
||||
create table user_commission_account
|
||||
(
|
||||
@@ -17,7 +469,7 @@ create table user_commission_account
|
||||
);
|
||||
|
||||
create index user_commission_account_index
|
||||
on user_commission_account (is_deleted, user_id);
|
||||
on user_commission_account (is_deleted, account_code);
|
||||
|
||||
comment on table user_commission_account is '用户佣金账户表';
|
||||
comment on column user_commission_account.id is '主键';
|
||||
@@ -323,7 +775,7 @@ create table user_commission_advertising_log
|
||||
);
|
||||
|
||||
create index uca_log_date_index
|
||||
on user_commission_advertising_log (is_deleted, user_id, statistical_date, type);
|
||||
on user_commission_advertising_log (is_deleted, account_id);
|
||||
|
||||
comment on table user_commission_advertising_log is '5%广告补贴佣金流水表';
|
||||
comment on column user_commission_advertising_log.id is '主键';
|
||||
@@ -548,3 +1000,8 @@ comment on column user_commission_co_creator_log.is_deleted is '是否已删除'
|
||||
|
||||
alter table user_commission_co_creator_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
182
doc/sql/user_performance_postgres.sql
Normal file
182
doc/sql/user_performance_postgres.sql
Normal file
@@ -0,0 +1,182 @@
|
||||
|
||||
create table user_performance
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
performance decimal(16,4) default 0,
|
||||
own_performance decimal(16,4) default 0,
|
||||
version int default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
create index up_index
|
||||
on user_performance (is_deleted, user_id);
|
||||
COMMENT ON TABLE user_performance IS '用户现金业绩表';
|
||||
COMMENT ON COLUMN user_performance.id IS '主键';
|
||||
COMMENT ON COLUMN user_performance.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN user_performance.user_phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_performance.user_name IS '用户名称';
|
||||
COMMENT ON COLUMN user_performance.performance IS '总业绩';
|
||||
COMMENT ON COLUMN user_performance.own_performance IS '自身业绩';
|
||||
COMMENT ON COLUMN user_performance.version IS '版本号';
|
||||
comment on column user_performance.create_user is '创建人';
|
||||
comment on column user_performance.create_dept is '创建部门';
|
||||
comment on column user_performance.create_time is '创建时间';
|
||||
comment on column user_performance.update_user is '修改人';
|
||||
comment on column user_performance.update_time is '修改时间';
|
||||
comment on column user_performance.status is '状态';
|
||||
comment on column user_performance.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance
|
||||
owner to postgres;
|
||||
|
||||
create table user_performance_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14,4) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index user_performance_log_index
|
||||
on user_performance_log (is_deleted, user_id, statistical_date , type);
|
||||
|
||||
comment on table user_performance_log is '用户现金业绩日志表';
|
||||
comment on column user_performance_log.id is '主键';
|
||||
comment on column user_performance_log.user_id is '用户ID';
|
||||
comment on column user_performance_log.user_phone is '用户手机号';
|
||||
comment on column user_performance_log.user_name is '用户名称';
|
||||
comment on column user_performance_log.amount is '业绩变动金额';
|
||||
comment on column user_performance_log.source_id is '来源ID';
|
||||
comment on column user_performance_log.source_detail is '来源详情';
|
||||
comment on column user_performance_log.order_id is '订单ID';
|
||||
comment on column user_performance_log.type is '类型 1增加 2减少';
|
||||
comment on column user_performance_log.statistical_date is '统计日期';
|
||||
comment on column user_performance_log.channel is '渠道';
|
||||
comment on column user_performance_log.channel_detail is '渠道详情';
|
||||
|
||||
comment on column user_performance_log.remark is '备注';
|
||||
comment on column user_performance_log.create_user is '创建人';
|
||||
comment on column user_performance_log.create_dept is '创建部门';
|
||||
comment on column user_performance_log.create_time is '创建时间';
|
||||
comment on column user_performance_log.update_user is '修改人';
|
||||
comment on column user_performance_log.update_time is '修改时间';
|
||||
comment on column user_performance_log.status is '状态';
|
||||
comment on column user_performance_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance_log
|
||||
owner to postgres;
|
||||
|
||||
|
||||
create table user_performance_benefit
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
performance decimal(16,4) default 0,
|
||||
own_performance decimal(16,4) default 0,
|
||||
version int default 1,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
create index upb_index
|
||||
on user_performance_benefit (is_deleted, user_id);
|
||||
COMMENT ON TABLE user_performance_benefit IS '用户福利值业绩表';
|
||||
COMMENT ON COLUMN user_performance_benefit.id IS '主键';
|
||||
COMMENT ON COLUMN user_performance_benefit.user_id IS '用户ID';
|
||||
COMMENT ON COLUMN user_performance_benefit.user_phone IS '用户手机号';
|
||||
COMMENT ON COLUMN user_performance_benefit.user_name IS '用户名称';
|
||||
COMMENT ON COLUMN user_performance_benefit.performance IS '总业绩';
|
||||
COMMENT ON COLUMN user_performance_benefit.own_performance IS '自身业绩';
|
||||
COMMENT ON COLUMN user_performance_benefit.version IS '版本号';
|
||||
comment on column user_performance_benefit.create_user is '创建人';
|
||||
comment on column user_performance_benefit.create_dept is '创建部门';
|
||||
comment on column user_performance_benefit.create_time is '创建时间';
|
||||
comment on column user_performance_benefit.update_user is '修改人';
|
||||
comment on column user_performance_benefit.update_time is '修改时间';
|
||||
comment on column user_performance_benefit.status is '状态';
|
||||
comment on column user_performance_benefit.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance_benefit
|
||||
owner to postgres;
|
||||
|
||||
create table user_performance_benefit_log
|
||||
(
|
||||
id bigint not null primary key,
|
||||
user_id bigint,
|
||||
user_phone bigint,
|
||||
user_name varchar(128),
|
||||
amount decimal(14,4) default 0,
|
||||
source_id bigint,
|
||||
source_detail text,
|
||||
order_id bigint,
|
||||
type int default 1,
|
||||
statistical_date timestamp(6),
|
||||
channel varchar(64),
|
||||
channel_detail text,
|
||||
remark text,
|
||||
create_user bigint,
|
||||
create_dept bigint,
|
||||
create_time timestamp(6),
|
||||
update_user bigint,
|
||||
update_time timestamp(6),
|
||||
status integer default 1,
|
||||
is_deleted integer default 0
|
||||
);
|
||||
|
||||
create index upbl_index
|
||||
on user_performance_benefit_log (is_deleted, user_id, statistical_date , type);
|
||||
|
||||
comment on table user_performance_benefit_log is '用户福利值业绩日志表';
|
||||
comment on column user_performance_benefit_log.id is '主键';
|
||||
comment on column user_performance_benefit_log.user_id is '用户ID';
|
||||
comment on column user_performance_benefit_log.user_phone is '用户手机号';
|
||||
comment on column user_performance_benefit_log.user_name is '用户名称';
|
||||
comment on column user_performance_benefit_log.amount is '业绩变动金额';
|
||||
comment on column user_performance_benefit_log.source_id is '来源ID';
|
||||
comment on column user_performance_benefit_log.source_detail is '来源详情';
|
||||
comment on column user_performance_benefit_log.order_id is '订单ID';
|
||||
comment on column user_performance_benefit_log.type is '类型 1增加 2减少';
|
||||
comment on column user_performance_benefit_log.statistical_date is '统计日期';
|
||||
comment on column user_performance_benefit_log.channel is '渠道';
|
||||
comment on column user_performance_benefit_log.channel_detail is '渠道详情';
|
||||
comment on column user_performance_benefit_log.remark is '备注';
|
||||
comment on column user_performance_benefit_log.create_user is '创建人';
|
||||
comment on column user_performance_benefit_log.create_dept is '创建部门';
|
||||
comment on column user_performance_benefit_log.create_time is '创建时间';
|
||||
comment on column user_performance_benefit_log.update_user is '修改人';
|
||||
comment on column user_performance_benefit_log.update_time is '修改时间';
|
||||
comment on column user_performance_benefit_log.status is '状态';
|
||||
comment on column user_performance_benefit_log.is_deleted is '是否已删除';
|
||||
|
||||
alter table user_performance_benefit_log
|
||||
owner to postgres;
|
||||
Reference in New Issue
Block a user