sql脚本-重新整理sql

This commit is contained in:
2026-01-26 14:54:51 +08:00
parent 2478bae74f
commit 2b912d48ab
4 changed files with 1076 additions and 497 deletions

View File

@@ -0,0 +1,550 @@
-- 佣金账户表
create table user_commission_account
(
id bigint not null primary key,
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
amount decimal(14,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 user_commission_account_index
on user_commission_account (is_deleted, user_id);
comment on table user_commission_account is '用户佣金账户表';
comment on column user_commission_account.id is '主键';
comment on column user_commission_account.account_name is '账户名称';
comment on column user_commission_account.account_number is '账户编号';
comment on column user_commission_account.account_code is '账户代码';
comment on column user_commission_account.amount is '账户总余额';
comment on column user_commission_account.version is '版本号';
comment on column user_commission_account.create_user is '创建人';
comment on column user_commission_account.create_dept is '创建部门';
comment on column user_commission_account.create_time is '创建时间';
comment on column user_commission_account.update_user is '修改人';
comment on column user_commission_account.update_time is '修改时间';
comment on column user_commission_account.status is '状态';
comment on column user_commission_account.is_deleted is '是否已删除';
alter table user_commission_account
owner to postgres;
-- 25%商品成本佣金流水表
create table user_commission_goods_cost_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
user_id bigint,
user_phone bigint,
user_name varchar(128),
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
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 ucc_log_date_index
on user_commission_goods_cost_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_goods_cost_log is '25%商品成本佣金流水表';
comment on column user_commission_goods_cost_log.id is '主键';
comment on column user_commission_goods_cost_log.account_id is '账户id';
comment on column user_commission_goods_cost_log.account_name is '账户名称';
comment on column user_commission_goods_cost_log.account_number is '账户编号';
comment on column user_commission_goods_cost_log.account_code is '账户代码';
comment on column user_commission_goods_cost_log.user_id is '用户id';
comment on column user_commission_goods_cost_log.user_phone is '用户手机号';
comment on column user_commission_goods_cost_log.user_name is '用户名称';
comment on column user_commission_goods_cost_log.amount is '变动金额';
comment on column user_commission_goods_cost_log.source_id is '来源id';
comment on column user_commission_goods_cost_log.source_detail is '来源详情';
comment on column user_commission_goods_cost_log.order_id is '订单id';
comment on column user_commission_goods_cost_log.order_detail is '订单详情';
comment on column user_commission_goods_cost_log.type is '类型 1-收入 2-支出';
comment on column user_commission_goods_cost_log.statistical_date is '统计时间';
comment on column user_commission_goods_cost_log.channel is '渠道';
comment on column user_commission_goods_cost_log.channel_detail is '渠道详情';
comment on column user_commission_goods_cost_log.remark is '备注';
comment on column user_commission_goods_cost_log.create_user is '创建人';
comment on column user_commission_goods_cost_log.create_dept is '创建部门';
comment on column user_commission_goods_cost_log.create_time is '创建时间';
comment on column user_commission_goods_cost_log.update_user is '修改人';
comment on column user_commission_goods_cost_log.update_time is '修改时间';
comment on column user_commission_goods_cost_log.status is '状态';
comment on column user_commission_goods_cost_log.is_deleted is '是否已删除';
alter table user_commission_goods_cost_log
owner to postgres;
-- 30%购买人获取用户积分佣金流水表
create table user_commission_user_point_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
user_id bigint,
user_phone bigint,
user_name varchar(128),
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
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 ucup_log_date_index
on user_commission_user_point_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_user_point_log is '30%购买人获取用户积分佣金流水表';
comment on column user_commission_user_point_log.id is '主键';
comment on column user_commission_user_point_log.account_id is '账户id';
comment on column user_commission_user_point_log.account_name is '账户名称';
comment on column user_commission_user_point_log.account_number is '账户编号';
comment on column user_commission_user_point_log.account_code is '账户代码';
comment on column user_commission_user_point_log.user_id is '用户id';
comment on column user_commission_user_point_log.user_phone is '用户手机号';
comment on column user_commission_user_point_log.user_name is '用户名称';
comment on column user_commission_user_point_log.amount is '变动金额';
comment on column user_commission_user_point_log.source_id is '来源id';
comment on column user_commission_user_point_log.source_detail is '来源详情';
comment on column user_commission_user_point_log.order_id is '订单id';
comment on column user_commission_user_point_log.order_detail is '订单详情';
comment on column user_commission_user_point_log.type is '类型 1-收入 2-支出';
comment on column user_commission_user_point_log.statistical_date is '统计时间';
comment on column user_commission_user_point_log.channel is '渠道';
comment on column user_commission_user_point_log.channel_detail is '渠道详情';
comment on column user_commission_user_point_log.remark is '备注';
comment on column user_commission_user_point_log.create_user is '创建人';
comment on column user_commission_user_point_log.create_dept is '创建部门';
comment on column user_commission_user_point_log.create_time is '创建时间';
comment on column user_commission_user_point_log.update_user is '修改人';
comment on column user_commission_user_point_log.update_time is '修改时间';
comment on column user_commission_user_point_log.status is '状态';
comment on column user_commission_user_point_log.is_deleted is '是否已删除';
alter table user_commission_user_point_log
owner to postgres;
-- 10%直推人佣金流水表
create table user_commission_direct_push_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
user_id bigint,
user_phone bigint,
user_name varchar(128),
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
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 ucdp_log_date_index
on user_commission_direct_push_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_direct_push_log is '10%直推人佣金流水表';
comment on column user_commission_direct_push_log.id is '主键';
comment on column user_commission_direct_push_log.account_id is '账户id';
comment on column user_commission_direct_push_log.account_name is '账户名称';
comment on column user_commission_direct_push_log.account_number is '账户编号';
comment on column user_commission_direct_push_log.account_code is '账户代码';
comment on column user_commission_direct_push_log.user_id is '用户id';
comment on column user_commission_direct_push_log.user_phone is '用户手机号';
comment on column user_commission_direct_push_log.user_name is '用户名称';
comment on column user_commission_direct_push_log.amount is '变动金额';
comment on column user_commission_direct_push_log.source_id is '来源id';
comment on column user_commission_direct_push_log.source_detail is '来源详情';
comment on column user_commission_direct_push_log.order_id is '订单id';
comment on column user_commission_direct_push_log.order_detail is '订单详情';
comment on column user_commission_direct_push_log.type is '类型 1-收入 2-支出';
comment on column user_commission_direct_push_log.statistical_date is '统计时间';
comment on column user_commission_direct_push_log.channel is '渠道';
comment on column user_commission_direct_push_log.channel_detail is '渠道详情';
comment on column user_commission_direct_push_log.remark is '备注';
comment on column user_commission_direct_push_log.create_user is '创建人';
comment on column user_commission_direct_push_log.create_dept is '创建部门';
comment on column user_commission_direct_push_log.create_time is '创建时间';
comment on column user_commission_direct_push_log.update_user is '修改人';
comment on column user_commission_direct_push_log.update_time is '修改时间';
comment on column user_commission_direct_push_log.status is '状态';
comment on column user_commission_direct_push_log.is_deleted is '是否已删除';
alter table user_commission_direct_push_log
owner to postgres;
-- 5%运营佣金流水表
create table user_commission_operation_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
user_id bigint,
user_phone bigint,
user_name varchar(128),
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
statistical_date timestamp(6), -- 统计时间
channel varchar(64), -- 渠道
channel_detail text, -- 渠道详情
remark text, -- 备注
random_deduction decimal(14,4) default 0, -- 随机立减金额
random_deduction_desc 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 ucop_log_date_index
on user_commission_operation_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_operation_log is '5%运营佣金流水表';
comment on column user_commission_operation_log.id is '主键';
comment on column user_commission_operation_log.account_id is '账户id';
comment on column user_commission_operation_log.account_name is '账户名称';
comment on column user_commission_operation_log.account_number is '账户编号';
comment on column user_commission_operation_log.account_code is '账户代码';
comment on column user_commission_operation_log.order_detail is '订单详情';
comment on column user_commission_operation_log.user_id is '用户id';
comment on column user_commission_operation_log.user_phone is '用户手机号';
comment on column user_commission_operation_log.user_name is '用户名称';
comment on column user_commission_operation_log.amount is '变动金额';
comment on column user_commission_operation_log.source_id is '来源id';
comment on column user_commission_operation_log.source_detail is '来源详情';
comment on column user_commission_operation_log.order_id is '订单id';
comment on column user_commission_operation_log.type is '类型 1-收入 2-支出';
comment on column user_commission_operation_log.statistical_date is '统计时间';
comment on column user_commission_operation_log.channel is '渠道';
comment on column user_commission_operation_log.channel_detail is '渠道详情';
comment on column user_commission_operation_log.remark is '备注';
comment on column user_commission_operation_log.random_deduction is '随机立减金额';
comment on column user_commission_operation_log.random_deduction_desc is '随机立减说明';
comment on column user_commission_operation_log.create_user is '创建人';
comment on column user_commission_operation_log.create_dept is '创建部门';
comment on column user_commission_operation_log.create_time is '创建时间';
comment on column user_commission_operation_log.update_user is '修改人';
comment on column user_commission_operation_log.update_time is '修改时间';
comment on column user_commission_operation_log.status is '状态';
comment on column user_commission_operation_log.is_deleted is '是否已删除';
alter table user_commission_operation_log
owner to postgres;
-- 5%广告补贴佣金流水表
create table user_commission_advertising_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
statistical_date timestamp(6), -- 统计时间
channel varchar(64), -- 渠道
channel_detail text, -- 渠道详情
remark text, -- 备注
daily_statistics_date timestamp(6), -- 每日统计日期
statistics_cycle varchar(32), -- 统计周期
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 uca_log_date_index
on user_commission_advertising_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_advertising_log is '5%广告补贴佣金流水表';
comment on column user_commission_advertising_log.id is '主键';
comment on column user_commission_advertising_log.account_id is '账户id';
comment on column user_commission_advertising_log.account_name is '账户名称';
comment on column user_commission_advertising_log.account_number is '账户编号';
comment on column user_commission_advertising_log.account_code is '账户代码';
comment on column user_commission_advertising_log.amount is '变动金额';
comment on column user_commission_advertising_log.source_id is '来源id';
comment on column user_commission_advertising_log.source_detail is '来源详情';
comment on column user_commission_advertising_log.order_id is '订单id';
comment on column user_commission_advertising_log.order_detail is '订单详情';
comment on column user_commission_advertising_log.type is '类型 1-收入 2-支出';
comment on column user_commission_advertising_log.statistical_date is '统计时间';
comment on column user_commission_advertising_log.channel is '渠道';
comment on column user_commission_advertising_log.channel_detail is '渠道详情';
comment on column user_commission_advertising_log.remark is '备注';
comment on column user_commission_advertising_log.daily_statistics_date is '每日统计日期';
comment on column user_commission_advertising_log.statistics_cycle is '统计周期';
comment on column user_commission_advertising_log.create_user is '创建人';
comment on column user_commission_advertising_log.create_dept is '创建部门';
comment on column user_commission_advertising_log.create_time is '创建时间';
comment on column user_commission_advertising_log.update_user is '修改人';
comment on column user_commission_advertising_log.update_time is '修改时间';
comment on column user_commission_advertising_log.status is '状态';
comment on column user_commission_advertising_log.is_deleted is '是否已删除';
alter table user_commission_advertising_log
owner to postgres;
-- 5%服务商佣金流水表
create table user_commission_service_provider_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
user_id bigint,
user_phone bigint,
user_name varchar(128),
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
statistical_date timestamp(6), -- 统计时间
channel varchar(64), -- 渠道
channel_detail text, -- 渠道详情
remark text, -- 备注
service_type varchar(64), -- 服务类型
service_provider_id bigint, -- 服务商ID
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 ucsp_log_date_index
on user_commission_service_provider_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_service_provider_log is '5%服务商佣金流水表';
comment on column user_commission_service_provider_log.id is '主键';
comment on column user_commission_service_provider_log.account_id is '账户id';
comment on column user_commission_service_provider_log.account_name is '账户名称';
comment on column user_commission_service_provider_log.account_number is '账户编号';
comment on column user_commission_service_provider_log.account_code is '账户代码';
comment on column user_commission_service_provider_log.order_detail is '订单详情';
comment on column user_commission_service_provider_log.amount is '变动金额';
comment on column user_commission_service_provider_log.source_id is '来源id';
comment on column user_commission_service_provider_log.source_detail is '来源详情';
comment on column user_commission_service_provider_log.order_id is '订单id';
comment on column user_commission_service_provider_log.type is '类型 1-收入 2-支出';
comment on column user_commission_service_provider_log.statistical_date is '统计时间';
comment on column user_commission_service_provider_log.channel is '渠道';
comment on column user_commission_service_provider_log.channel_detail is '渠道详情';
comment on column user_commission_service_provider_log.remark is '备注';
comment on column user_commission_service_provider_log.service_type is '服务类型';
comment on column user_commission_service_provider_log.service_provider_id is '服务商ID';
comment on column user_commission_service_provider_log.create_user is '创建人';
comment on column user_commission_service_provider_log.create_dept is '创建部门';
comment on column user_commission_service_provider_log.create_time is '创建时间';
comment on column user_commission_service_provider_log.update_user is '修改人';
comment on column user_commission_service_provider_log.update_time is '修改时间';
comment on column user_commission_service_provider_log.status is '状态';
comment on column user_commission_service_provider_log.is_deleted is '是否已删除';
alter table user_commission_service_provider_log
owner to postgres;
-- 15%极差代理佣金流水表
create table user_commission_agency_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
user_id bigint,
user_phone bigint,
user_name varchar(128),
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
statistical_date timestamp(6), -- 统计时间
channel varchar(64), -- 渠道
channel_detail text, -- 渠道详情
remark text, -- 备注
agency_level varchar(32), -- 代理级别
agency_parent_id bigint, -- 上级代理ID
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 ucal_log_date_index
on user_commission_agency_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_agency_log is '15%极差代理佣金流水表';
comment on column user_commission_agency_log.id is '主键';
comment on column user_commission_agency_log.account_id is '账户id';
comment on column user_commission_agency_log.account_name is '账户名称';
comment on column user_commission_agency_log.account_number is '账户编号';
comment on column user_commission_agency_log.account_code is '账户代码';
comment on column user_commission_agency_log.user_id is '用户id';
comment on column user_commission_agency_log.user_phone is '用户手机号';
comment on column user_commission_agency_log.user_name is '用户名称';
comment on column user_commission_agency_log.order_detail is '订单详情';
comment on column user_commission_agency_log.amount is '变动金额';
comment on column user_commission_agency_log.source_id is '来源id';
comment on column user_commission_agency_log.source_detail is '来源详情';
comment on column user_commission_agency_log.order_id is '订单id';
comment on column user_commission_agency_log.type is '类型 1-收入 2-支出';
comment on column user_commission_agency_log.statistical_date is '统计时间';
comment on column user_commission_agency_log.channel is '渠道';
comment on column user_commission_agency_log.channel_detail is '渠道详情';
comment on column user_commission_agency_log.remark is '备注';
comment on column user_commission_agency_log.agency_level is '代理级别';
comment on column user_commission_agency_log.agency_parent_id is '上级代理ID';
comment on column user_commission_agency_log.create_user is '创建人';
comment on column user_commission_agency_log.create_dept is '创建部门';
comment on column user_commission_agency_log.create_time is '创建时间';
comment on column user_commission_agency_log.update_user is '修改人';
comment on column user_commission_agency_log.update_time is '修改时间';
comment on column user_commission_agency_log.status is '状态';
comment on column user_commission_agency_log.is_deleted is '是否已删除';
alter table user_commission_agency_log
owner to postgres;
-- 5%联创佣金流水表
create table user_commission_co_creator_log
(
id bigint not null primary key,
account_id bigint, -- 账户id
account_name varchar(128), -- 账户名称
account_number varchar(64), -- 账户编号
account_code varchar(64), -- 账户代码
user_id bigint,
user_phone bigint,
user_name varchar(128),
amount decimal(14,4) default 0, -- 变动金额
source_id bigint, -- 来源id
source_detail text, -- 来源详情
order_id bigint, -- 订单id
order_detail text, -- 订单详情
type int default 1, -- 类型 1-收入 2-支出
statistical_date timestamp(6), -- 统计时间
channel varchar(64), -- 渠道
channel_detail text, -- 渠道详情
remark text, -- 备注
co_creator_type varchar(64), -- 联创类型
co_creator_rank varchar(32), -- 联创等级
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 uccc_log_date_index
on user_commission_co_creator_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_co_creator_log is '5%联创佣金流水表';
comment on column user_commission_co_creator_log.id is '主键';
comment on column user_commission_co_creator_log.account_id is '账户id';
comment on column user_commission_co_creator_log.account_name is '账户名称';
comment on column user_commission_co_creator_log.account_number is '账户编号';
comment on column user_commission_co_creator_log.account_code is '账户代码';
comment on column user_commission_co_creator_log.order_detail is '订单详情';
comment on column user_commission_co_creator_log.amount is '变动金额';
comment on column user_commission_co_creator_log.source_id is '来源id';
comment on column user_commission_co_creator_log.source_detail is '来源详情';
comment on column user_commission_co_creator_log.order_id is '订单id';
comment on column user_commission_co_creator_log.type is '类型 1-收入 2-支出';
comment on column user_commission_co_creator_log.statistical_date is '统计时间';
comment on column user_commission_co_creator_log.channel is '渠道';
comment on column user_commission_co_creator_log.channel_detail is '渠道详情';
comment on column user_commission_co_creator_log.remark is '备注';
comment on column user_commission_co_creator_log.co_creator_type is '联创类型';
comment on column user_commission_co_creator_log.co_creator_rank is '联创等级';
comment on column user_commission_co_creator_log.create_user is '创建人';
comment on column user_commission_co_creator_log.create_dept is '创建部门';
comment on column user_commission_co_creator_log.create_time is '创建时间';
comment on column user_commission_co_creator_log.update_user is '修改人';
comment on column user_commission_co_creator_log.update_time is '修改时间';
comment on column user_commission_co_creator_log.status is '状态';
comment on column user_commission_co_creator_log.is_deleted is '是否已删除';
alter table user_commission_co_creator_log
owner to postgres;

View File

@@ -1,79 +1,16 @@
create table user_base
(
id bigint not null primary key,
pid bigint,
name varchar(128),
phone bigint,
password varchar(128),
avatar varchar(255) ,
identity int default 1,
start_time timestamp(6),
end_time timestamp(6),
member_id bigint ,
login_ip varchar(18) ,
login_time timestamp(6) ,
remark text ,
payment_password varchar(128) ,
is_auth int default 0,
auth_time timestamp ,
auth_name varchar(128) ,
id_card varchar(128) ,
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,
constraint user_index_phone
unique (is_deleted, phone)
);
comment on table user_base is '用户信息表';
comment on column user_base.id is '主键';
comment on column user_base.pid is '上级id';
comment on column user_base.name is '用户名';
comment on column user_base.phone is '手机号';
comment on column user_base.password is '密码';
comment on column user_base.avatar is '头像';
comment on column user_base.identity is '用户身份 1-普通用户 2-会员';
comment on column user_base.start_time is '会员开始时间';
comment on column user_base.end_time is '会员结束时间';
comment on column user_base.member_id is '会员id';
comment on column user_base.login_ip is '最近一次登录ip';
comment on column user_base.login_time is '最近一次登录时间';
comment on column user_base.payment_password is '支付密码';
comment on column user_base.is_auth is '是否实名认证 0-否 1-是';
comment on column user_base.auth_time is '实名认证时间';
comment on column user_base.auth_name is '实名认证姓名';
comment on column user_base.id_card is '实名认证身份证号';
comment on column user_base.remark is '备注';
comment on column user_base.create_user is '创建人';
comment on column user_base.create_dept is '创建部门';
comment on column user_base.create_time is '创建时间';
comment on column user_base.update_user is '修改人';
comment on column user_base.update_time is '修改时间';
comment on column user_base.status is '状态';
comment on column user_base.is_deleted is '是否已删除';
create index id_card_index
on user_base (is_deleted, id_card);
create index user_index_pid
on user_base (is_deleted, pid);
alter table user_base
owner to postgres;
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,
genealogy_list 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),
@@ -85,6 +22,8 @@ create table user_genealogy
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);
@@ -92,11 +31,15 @@ create index user_genealogy_phone_index
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.phone is '手机号';
comment on column user_genealogy.name is '用户名';
comment on column user_genealogy.root_id is '根id';
comment on column user_genealogy.group_id is '组id';
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 '创建时间';
@@ -108,12 +51,102 @@ 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,
@@ -132,6 +165,9 @@ 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 '每日福利积分加速';
@@ -156,6 +192,8 @@ create table user_level_log
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,
@@ -180,6 +218,9 @@ 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 '每日福利积分加速';
@@ -195,3 +236,399 @@ 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;

View File

@@ -1,337 +0,0 @@
CREATE TABLE package_info (
id BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(128) NULL,
buy_amount decimal(14,4) default 0, -- 购买积分
buy_qty INTEGER default 0, -- 最大购买数量
day_total decimal(16,4) default 0, -- 产出总天数
amount_total decimal(14,4) default 0, -- 总产出
bonus decimal(16,4) default 0, -- 激活比率
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_amount 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.bonus 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),
buy_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, -- 产出天数
bonus 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.statistical_date 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.buy_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.bonus 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_pack_statistics
(
id bigint not null primary key,
user_id bigint,
phone bigint,
user_name varchar(128),
one_pack int,
two_pack int,
three_pack int,
four_pack int,
version int 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 ups_index
on user_pack_statistics (is_deleted, user_id);
COMMENT ON TABLE user_pack_statistics IS '用户积分包统计表';
COMMENT ON COLUMN user_pack_statistics.id IS '主键';
COMMENT ON COLUMN user_pack_statistics.user_id IS '用户ID';
COMMENT ON COLUMN user_pack_statistics.phone IS '用户手机号';
COMMENT ON COLUMN user_pack_statistics.user_name IS '用户名称';
COMMENT ON COLUMN user_pack_statistics.one_pack IS '一级积分包数量';
COMMENT ON COLUMN user_pack_statistics.two_pack IS '二级积分包数量';
COMMENT ON COLUMN user_pack_statistics.three_pack IS '三级积分包数量';
COMMENT ON COLUMN user_pack_statistics.four_pack IS '四级积分包数量';
COMMENT ON COLUMN user_pack_statistics.version IS '版本号';
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_pack_statistics
owner to postgres;
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;

View File

@@ -1,71 +0,0 @@
create table user_tree
(
id bigint not null primary key,
name varchar(128),
phone bigint,
pid bigint,
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.phone is '手机号';
comment on column user_tree.name is '用户名';
comment on column user_tree.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_child
(
id bigint not null primary key,
name varchar(128),
phone bigint,
child_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_child_list_gin_idx
ON user_child USING gin (child_list);
create index user_child_phone_index
on user_child (is_deleted, phone);
comment on table user_child is '用户直推表';
comment on column user_child.id is '主键';
comment on column user_child.phone is '手机号';
comment on column user_child.name is '用户名';
comment on column user_child.child_list is '直推列表';
comment on column user_child.create_user is '创建人';
comment on column user_child.create_dept is '创建部门';
comment on column user_child.create_time is '创建时间';
comment on column user_child.update_user is '修改人';
comment on column user_child.update_time is '修改时间';
comment on column user_child.status is '状态';
comment on column user_child.is_deleted is '是否已删除';
alter table user_child
owner to postgres;