初始化sql脚本(用户信息, 四种积分, 积分包, 用户签到 , otc , 高德地图)

This commit is contained in:
2026-01-21 18:35:30 +08:00
parent a2e430ce9a
commit 0e524120d2
8 changed files with 51919 additions and 2 deletions

245
doc/sql/otc_postgres.sql Normal file
View File

@@ -0,0 +1,245 @@
CREATE TABLE IF NOT EXISTS registration_order (
id BIGINT NOT NULL PRIMARY KEY,
spu_id BIGINT NULL,
sku_id BIGINT NULL,
title VARCHAR(100) NOT NULL,
transaction_type INTEGER NOT NULL,
thumbnail VARCHAR(500) NOT NULL,
thumbnail_height INTEGER NULL,
detail TEXT NULL,
price DECIMAL(10, 2) NOT NULL,
points DECIMAL(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
remaining INTEGER NOT NULL,
user_id BIGINT NOT NULL,
user_nickname VARCHAR(100) NULL,
in_transaction INTEGER DEFAULT 0 NOT NULL,
is_full_package INTEGER DEFAULT 0 NOT NULL,
delivery_type INTEGER DEFAULT 1 NULL,
region_code VARCHAR(10) NULL,
region_name VARCHAR(100) NULL,
receiver_address VARCHAR(100) NULL,
contact VARCHAR(100) NULL,
contact_number VARCHAR(100) NULL,
is_virtual INTEGER DEFAULT 0 NOT NULL,
is_closed INTEGER DEFAULT 0 NOT NULL,
version BIGINT DEFAULT 0 NOT NULL,
create_user BIGINT NULL,
create_dept BIGINT NULL,
create_time TIMESTAMP NULL,
update_user BIGINT NULL,
update_time TIMESTAMP NULL,
status INTEGER NULL,
is_deleted INTEGER DEFAULT 0 NULL,
is_vendor INTEGER DEFAULT 0 NULL,
is_priority INTEGER DEFAULT 0 NULL
);
COMMENT ON TABLE registration_order IS '挂单表';
COMMENT ON COLUMN registration_order.id IS '挂单ID';
COMMENT ON COLUMN registration_order.spu_id IS 'spuId';
COMMENT ON COLUMN registration_order.sku_id IS 'skuId';
COMMENT ON COLUMN registration_order.title IS '规格名称';
COMMENT ON COLUMN registration_order.transaction_type IS '交易类型 1-买 2-卖';
COMMENT ON COLUMN registration_order.thumbnail IS '商品缩略图';
COMMENT ON COLUMN registration_order.thumbnail_height IS '缩略图高度';
COMMENT ON COLUMN registration_order.detail IS '详情图';
COMMENT ON COLUMN registration_order.price IS '单价';
COMMENT ON COLUMN registration_order.points IS '单个赠送积分';
COMMENT ON COLUMN registration_order.quantity IS '数量';
COMMENT ON COLUMN registration_order.remaining IS '剩余数量';
COMMENT ON COLUMN registration_order.user_id IS '用户id';
COMMENT ON COLUMN registration_order.user_nickname IS '用户昵称';
COMMENT ON COLUMN registration_order.in_transaction IS '是否交易中 1-交易中 0-空闲中';
COMMENT ON COLUMN registration_order.is_full_package IS '是否全量交易 1-是 0-否';
COMMENT ON COLUMN registration_order.delivery_type IS '配送方式 1-物流快递 2-同城配送 3-上门自提';
COMMENT ON COLUMN registration_order.region_code IS '收货地址区域编码';
COMMENT ON COLUMN registration_order.region_name IS '行政区域名称';
COMMENT ON COLUMN registration_order.receiver_address IS '收货地址';
COMMENT ON COLUMN registration_order.contact IS '收货人';
COMMENT ON COLUMN registration_order.contact_number IS '收货人联系方式';
COMMENT ON COLUMN registration_order.is_virtual IS '是否虚拟商品 1-是 0-否';
COMMENT ON COLUMN registration_order.is_closed IS '是否交易完成 1-是 0-否';
COMMENT ON COLUMN registration_order.version IS '乐观锁版本号';
COMMENT ON COLUMN registration_order.create_user IS '创建人';
COMMENT ON COLUMN registration_order.create_dept IS '创建部门';
COMMENT ON COLUMN registration_order.create_time IS '创建时间';
COMMENT ON COLUMN registration_order.update_user IS '修改人';
COMMENT ON COLUMN registration_order.update_time IS '修改时间';
COMMENT ON COLUMN registration_order.status IS '状态';
COMMENT ON COLUMN registration_order.is_deleted IS '是否已删除';
COMMENT ON COLUMN registration_order.is_vendor IS '是否服务商订单';
COMMENT ON COLUMN registration_order.is_priority IS '是否优先';
CREATE TABLE IF NOT EXISTS transaction_order (
id BIGINT NOT NULL PRIMARY KEY,
registration_id BIGINT NOT NULL,
sku_id BIGINT NULL,
title VARCHAR(100) NOT NULL,
transaction_type INTEGER NOT NULL,
thumbnail VARCHAR(500) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
points DECIMAL(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
total_amount DECIMAL(10, 2) NOT NULL,
total_points DECIMAL(10, 2) NOT NULL,
user_id BIGINT NOT NULL,
user_nickname VARCHAR(500) NULL,
payment_voucher VARCHAR(500) NULL,
delivery_voucher VARCHAR(500) NULL,
delivery_type INTEGER DEFAULT 1 NOT NULL,
region_code VARCHAR(10) NULL,
region_name VARCHAR(100) NULL,
receiver_address VARCHAR(100) NULL,
contact VARCHAR(100) NULL,
contact_number VARCHAR(100) NULL,
counterparty_order_id BIGINT DEFAULT 0 NOT NULL,
is_virtual INTEGER DEFAULT 0 NOT NULL,
supplier_order_sn VARCHAR(100) NULL,
expire_time TIMESTAMP NULL,
create_user BIGINT NULL,
create_dept BIGINT NULL,
create_time TIMESTAMP NULL,
update_user BIGINT NULL,
update_time TIMESTAMP NULL,
status INTEGER NULL,
is_deleted INTEGER DEFAULT 0 NULL
);
COMMENT ON TABLE transaction_order IS '交易单表';
COMMENT ON COLUMN transaction_order.id IS '交易单ID';
COMMENT ON COLUMN transaction_order.registration_id IS '挂单Id';
COMMENT ON COLUMN transaction_order.sku_id IS 'skuId';
COMMENT ON COLUMN transaction_order.title IS '规格名称';
COMMENT ON COLUMN transaction_order.transaction_type IS '交易类型 1-买 2-卖';
COMMENT ON COLUMN transaction_order.thumbnail IS '商品缩略图';
COMMENT ON COLUMN transaction_order.price IS '单价';
COMMENT ON COLUMN transaction_order.points IS '单个赠送积分';
COMMENT ON COLUMN transaction_order.quantity IS '数量';
COMMENT ON COLUMN transaction_order.total_amount IS '总金额';
COMMENT ON COLUMN transaction_order.total_points IS '总赠送积分';
COMMENT ON COLUMN transaction_order.user_id IS '用户id';
COMMENT ON COLUMN transaction_order.user_nickname IS '用户昵称';
COMMENT ON COLUMN transaction_order.payment_voucher IS '付款凭证';
COMMENT ON COLUMN transaction_order.delivery_voucher IS '物流凭证';
COMMENT ON COLUMN transaction_order.delivery_type IS '收货方式 1-物流快递 2-同城配送 3-上门自提';
COMMENT ON COLUMN transaction_order.region_code IS '收货地址区域编码';
COMMENT ON COLUMN transaction_order.region_name IS '行政区域名称';
COMMENT ON COLUMN transaction_order.receiver_address IS '收货地址';
COMMENT ON COLUMN transaction_order.contact IS '收货联系人';
COMMENT ON COLUMN transaction_order.contact_number IS '收货人联系方式';
COMMENT ON COLUMN transaction_order.counterparty_order_id IS '对手单单号';
COMMENT ON COLUMN transaction_order.is_virtual IS '是否虚拟商品 1-是 0-否';
COMMENT ON COLUMN transaction_order.supplier_order_sn IS '三方供应商订单号';
COMMENT ON COLUMN transaction_order.expire_time IS '待支付超时时间';
COMMENT ON COLUMN transaction_order.create_user IS '创建人';
COMMENT ON COLUMN transaction_order.create_dept IS '创建部门';
COMMENT ON COLUMN transaction_order.create_time IS '创建时间';
COMMENT ON COLUMN transaction_order.update_user IS '修改人';
COMMENT ON COLUMN transaction_order.update_time IS '修改时间';
COMMENT ON COLUMN transaction_order.status IS '状态 1-待支付 2-已支付 3-待发货 4-已发货 5-已完成';
COMMENT ON COLUMN transaction_order.is_deleted IS '是否已删除';
CREATE TABLE IF NOT EXISTS user_inventory (
id BIGINT NOT NULL PRIMARY KEY,
user_id BIGINT NOT NULL,
sku_id BIGINT NOT NULL,
title VARCHAR(100) NOT NULL,
thumbnail VARCHAR(500) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
is_virtual INTEGER DEFAULT 0 NOT NULL,
attribute JSON NULL,
version BIGINT DEFAULT 0 NOT NULL,
create_user BIGINT NULL,
create_dept BIGINT NULL,
create_time TIMESTAMP NULL,
update_user BIGINT NULL,
update_time TIMESTAMP NULL,
status INTEGER NULL,
is_deleted INTEGER DEFAULT 0 NULL
);
COMMENT ON TABLE user_inventory IS '用户库存';
COMMENT ON COLUMN user_inventory.id IS '库存ID';
COMMENT ON COLUMN user_inventory.user_id IS '用户Id';
COMMENT ON COLUMN user_inventory.sku_id IS 'skuId';
COMMENT ON COLUMN user_inventory.title IS '规格名称';
COMMENT ON COLUMN user_inventory.thumbnail IS '商品缩略图';
COMMENT ON COLUMN user_inventory.price IS '单价';
COMMENT ON COLUMN user_inventory.quantity IS '数量';
COMMENT ON COLUMN user_inventory.is_virtual IS '是否虚拟商品 1-是 0-否';
COMMENT ON COLUMN user_inventory.attribute IS '规格';
COMMENT ON COLUMN user_inventory.version IS '乐观锁版本号';
COMMENT ON COLUMN user_inventory.create_user IS '创建人';
COMMENT ON COLUMN user_inventory.create_dept IS '创建部门';
COMMENT ON COLUMN user_inventory.create_time IS '创建时间';
COMMENT ON COLUMN user_inventory.update_user IS '修改人';
COMMENT ON COLUMN user_inventory.update_time IS '修改时间';
COMMENT ON COLUMN user_inventory.status IS '状态';
COMMENT ON COLUMN user_inventory.is_deleted IS '是否已删除';
CREATE TABLE IF NOT EXISTS calendar_non_working (
id BIGINT NOT NULL PRIMARY KEY,
off_date DATE NOT NULL,
remark VARCHAR(200) NULL,
create_user BIGINT NULL,
create_dept BIGINT NULL,
create_time TIMESTAMP NULL,
update_user BIGINT NULL,
update_time TIMESTAMP NULL,
status INTEGER NULL,
is_deleted INTEGER DEFAULT 0 NULL
);
COMMENT ON TABLE calendar_non_working IS '节假日';
COMMENT ON COLUMN calendar_non_working.id IS '主键';
COMMENT ON COLUMN calendar_non_working.off_date IS '休息日期';
COMMENT ON COLUMN calendar_non_working.remark IS '备忘';
COMMENT ON COLUMN calendar_non_working.create_user IS '创建人';
COMMENT ON COLUMN calendar_non_working.create_dept IS '创建部门';
COMMENT ON COLUMN calendar_non_working.create_time IS '创建时间';
COMMENT ON COLUMN calendar_non_working.update_user IS '修改人';
COMMENT ON COLUMN calendar_non_working.update_time IS '修改时间';
COMMENT ON COLUMN calendar_non_working.status IS '状态';
COMMENT ON COLUMN calendar_non_working.is_deleted IS '是否已删除';
CREATE TABLE IF NOT EXISTS user_otc_info (
id BIGINT NOT NULL PRIMARY KEY,
user_id BIGINT NOT NULL,
alipay_account VARCHAR(200) NULL,
wechat_account VARCHAR(200) NULL,
alipay_qr_code VARCHAR(200) NULL,
wechat_qr_code VARCHAR(200) NULL,
bank_account VARCHAR(200) NULL,
branch_info VARCHAR(200) NULL,
create_user BIGINT NULL,
create_dept BIGINT NULL,
create_time TIMESTAMP NULL,
update_user BIGINT NULL,
update_time TIMESTAMP NULL,
status INTEGER NULL,
is_deleted INTEGER DEFAULT 0 NULL
);
COMMENT ON TABLE user_otc_info IS 'OTC收款信息';
COMMENT ON COLUMN user_otc_info.id IS 'ID';
COMMENT ON COLUMN user_otc_info.user_id IS '用户ID';
COMMENT ON COLUMN user_otc_info.alipay_account IS '支付宝账号';
COMMENT ON COLUMN user_otc_info.wechat_account IS '微信账号';
COMMENT ON COLUMN user_otc_info.alipay_qr_code IS '支付宝收款码';
COMMENT ON COLUMN user_otc_info.wechat_qr_code IS '微信收款码';
COMMENT ON COLUMN user_otc_info.bank_account IS '银行账号';
COMMENT ON COLUMN user_otc_info.branch_info IS '银行信息';
COMMENT ON COLUMN user_otc_info.create_user IS '创建人';
COMMENT ON COLUMN user_otc_info.create_dept IS '创建部门';
COMMENT ON COLUMN user_otc_info.create_time IS '创建时间';
COMMENT ON COLUMN user_otc_info.update_user IS '修改人';
COMMENT ON COLUMN user_otc_info.update_time IS '修改时间';
COMMENT ON COLUMN user_otc_info.status IS '状态';
COMMENT ON COLUMN user_otc_info.is_deleted IS '是否已删除';

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,33 @@
CREATE TABLE IF NOT EXISTS regions_info (
id SERIAL PRIMARY KEY,
name VARCHAR(50) NULL,
level INTEGER NULL,
pid INTEGER DEFAULT 0 NULL,
lon DECIMAL(10, 6) NULL,
lat DECIMAL(10, 6) NULL,
region_code VARCHAR(128) NULL,
full_name VARCHAR(200) NULL,
vendor_region_id BIGINT NULL,
store_city_id BIGINT NULL,
hotel_city_code VARCHAR(128) NULL,
hotel_city_pinyin VARCHAR(128) NULL,
hotel_city_initials VARCHAR(4) NULL,
sight_city_name VARCHAR(32) NULL
);
COMMENT ON TABLE regions_info IS '地区详情表';
COMMENT ON COLUMN regions_info.id IS '主键';
COMMENT ON COLUMN regions_info.name IS '名称';
COMMENT ON COLUMN regions_info.level IS '层级';
COMMENT ON COLUMN regions_info.pid IS '父主键';
COMMENT ON COLUMN regions_info.lon IS '经度';
COMMENT ON COLUMN regions_info.lat IS '纬度';
COMMENT ON COLUMN regions_info.region_code IS '地区编码';
COMMENT ON COLUMN regions_info.full_name IS '全称';
COMMENT ON COLUMN regions_info.vendor_region_id IS '服务商地区表id';
COMMENT ON COLUMN regions_info.store_city_id IS '城市店铺id';
COMMENT ON COLUMN regions_info.hotel_city_code IS '酒店地区编码';
COMMENT ON COLUMN regions_info.hotel_city_pinyin IS '酒店地区拼音';
COMMENT ON COLUMN regions_info.hotel_city_initials IS '酒店地区拼音首字母';
COMMENT ON COLUMN regions_info.sight_city_name IS '景点城市名';

View File

@@ -0,0 +1,39 @@
CREATE TABLE IF NOT EXISTS user_daily_sign (
id BIGINT NOT NULL PRIMARY KEY,
user_id BIGINT NULL,
user_phone bigint,
user_name varchar(128),
statistics_date DATE NULL,
sign_count INTEGER NULL,
type INTEGER DEFAULT 1 NULL,
remarks TEXT NULL,
is_deleted INTEGER DEFAULT 0 NULL,
create_time TIMESTAMP NULL,
create_user BIGINT NULL,
update_time TIMESTAMP NULL,
update_user BIGINT NULL,
status INTEGER NULL,
create_dept BIGINT NULL
);
COMMENT ON TABLE user_daily_sign IS '用户看广告记录表';
COMMENT ON COLUMN user_daily_sign.user_id IS '用户id';
COMMENT ON COLUMN user_daily_sign.user_phone IS '用户手机号';
COMMENT ON COLUMN user_daily_sign.user_name IS '用户名称';
COMMENT ON COLUMN user_daily_sign.statistics_date IS '统计日期';
COMMENT ON COLUMN user_daily_sign.sign_count IS '看广告统计';
COMMENT ON COLUMN user_daily_sign.type IS '广告类型 1-积分分产出';
COMMENT ON COLUMN user_daily_sign.remarks IS '备注';
comment on column user_daily_sign.create_user is '创建人';
comment on column user_daily_sign.create_dept is '创建部门';
comment on column user_daily_sign.create_time is '创建时间';
comment on column user_daily_sign.update_user is '修改人';
comment on column user_daily_sign.update_time is '修改时间';
comment on column user_daily_sign.status is '状态';
comment on column user_daily_sign.is_deleted is '是否已删除';
CREATE INDEX uds_date_index
ON user_daily_sign (is_deleted, type, statistics_date);
CREATE INDEX uds_uid_index
ON user_daily_sign (is_deleted, type, user_id, statistics_date);

View File

@@ -0,0 +1,167 @@
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) ,
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.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 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,
pid bigint,
root_id bigint,
group_id bigint,
genealogy_list 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
);
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.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.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 level_info (
id BIGINT NOT NULL PRIMARY KEY,
name VARCHAR(128) NULL,
child_qty INTEGER NULL,
performance DECIMAL(16, 4) NULL,
bonus_cash 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.bonus_cash 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),
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.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;

View File

@@ -0,0 +1,240 @@
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完成
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);
create index upi_date_index
on user_package_info (is_deleted, statistical_date ,user_id);
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.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_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_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;

View File

@@ -0,0 +1,343 @@
create table user_benefit
(
id bigint not null primary key,
user_id bigint,
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_benefit_index
on user_benefit (is_deleted, user_id);
comment on table user_benefit is '用户福利值表';
comment on column user_benefit.id is '主键';
comment on column user_benefit.user_id is '用户id';
comment on column user_benefit.amount is '金额';
comment on column user_benefit.version is '版本号';
comment on column user_benefit.create_user is '创建人';
comment on column user_benefit.create_dept is '创建部门';
comment on column user_benefit.create_time is '创建时间';
comment on column user_benefit.update_user is '修改人';
comment on column user_benefit.update_time is '修改时间';
comment on column user_benefit.status is '状态';
comment on column user_benefit.is_deleted is '是否已删除';
alter table user_benefit
owner to postgres;
create table user_benefit_log
(
id bigint not null primary key,
user_id bigint,
amount decimal(14,4) default 0,
source_id bigint,
user_pack_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 ub_log_date_index
on user_benefit_log (is_deleted, user_id , statistical_date , type);
comment on table user_benefit_log is '用户福利值流水表';
comment on column user_benefit_log.id is '主键';
comment on column user_benefit_log.user_id is '用户id';
comment on column user_benefit_log.amount is '金额';
comment on column user_benefit_log.source_id is '来源id';
comment on column user_benefit_log.user_pack_id is '用户积分包id';
comment on column user_benefit_log.source_detail is '来源详情';
comment on column user_benefit_log.order_id is '订单id';
comment on column user_benefit_log.type is '消费类型 1-收入 2-支出';
comment on column user_benefit_log.statistical_date is '统计时间';
comment on column user_benefit_log.channel is '消费渠道';
comment on column user_benefit_log.channel_detail is '消费渠道详情';
comment on column user_benefit_log.remark is '备注';
comment on column user_benefit_log.create_user is '创建人';
comment on column user_benefit_log.create_dept is '创建部门';
comment on column user_benefit_log.create_time is '创建时间';
comment on column user_benefit_log.update_user is '修改人';
comment on column user_benefit_log.update_time is '修改时间';
comment on column user_benefit_log.status is '状态';
comment on column user_benefit_log.is_deleted is '是否已删除';
alter table user_benefit_log
owner to postgres;
create table user_commission
(
id bigint not null primary key,
user_id bigint,
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_index
on user_commission (is_deleted, user_id);
comment on table user_commission is '用户佣金表';
comment on column user_commission.id is '主键';
comment on column user_commission.user_id is '用户id';
comment on column user_commission.amount is '佣金金额';
comment on column user_commission.version is '版本号';
comment on column user_commission.create_user is '创建人';
comment on column user_commission.create_dept is '创建部门';
comment on column user_commission.create_time is '创建时间';
comment on column user_commission.update_user is '修改人';
comment on column user_commission.update_time is '修改时间';
comment on column user_commission.status is '状态';
comment on column user_commission.is_deleted is '是否已删除';
alter table user_commission
owner to postgres;
create table user_commission_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_commission_log_index
on user_commission_log (is_deleted, user_id, statistical_date, type);
comment on table user_commission_log is '用户佣金流水表';
comment on column user_commission_log.id is '主键';
comment on column user_commission_log.user_id is '用户id';
comment on column user_commission_log.user_phone is '用户手机号';
comment on column user_commission_log.user_name is '用户名称';
comment on column user_commission_log.amount is '金额';
comment on column user_commission_log.source_id is '来源id';
comment on column user_commission_log.source_detail is '来源详情';
comment on column user_commission_log.order_id is '订单id';
comment on column user_commission_log.type is '消费类型 1-收入 2-支出';
comment on column user_commission_log.statistical_date is '统计时间';
comment on column user_commission_log.channel is '消费渠道';
comment on column user_commission_log.channel_detail is '消费渠道详情';
comment on column user_commission_log.remark is '备注';
comment on column user_commission_log.create_user is '创建人';
comment on column user_commission_log.create_dept is '创建部门';
comment on column user_commission_log.create_time is '创建时间';
comment on column user_commission_log.update_user is '修改人';
comment on column user_commission_log.update_time is '修改时间';
comment on column user_commission_log.status is '状态';
comment on column user_commission_log.is_deleted is '是否已删除';
alter table user_commission_log
owner to postgres;
create table user_cash
(
id bigint not null primary key,
user_id bigint,
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),
is_deleted integer default 0
);
create index user_cash_index
on user_cash (is_deleted, user_id);
comment on table user_cash is '用户现金券表';
comment on column user_cash.id is '主键';
comment on column user_cash.user_id is '用户id';
comment on column user_cash.amount is '面额';
comment on column user_cash.version is '版本号';
comment on column user_cash.create_user is '创建人';
comment on column user_cash.create_dept is '创建部门';
comment on column user_cash.create_time is '创建时间';
comment on column user_cash.update_user is '修改人';
comment on column user_cash.update_time is '修改时间';
comment on column user_cash.is_deleted is '是否已删除';
alter table user_cash
owner to postgres;
create table user_cash_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_cash_log_index
on user_cash_log (is_deleted, user_id, statistical_date , type);
comment on table user_cash_log is '用户现金券流水表';
comment on column user_cash_log.id is '主键';
comment on column user_cash_log.user_id is '用户id';
comment on column user_cash_log.user_phone is '用户手机号';
comment on column user_cash_log.user_name is '用户名称';
comment on column user_cash_log.amount is '金额';
comment on column user_cash_log.source_id is '来源id';
comment on column user_cash_log.source_detail is '来源详情';
comment on column user_cash_log.order_id is '订单id';
comment on column user_cash_log.type is '消费类型 1-收入 2-支出';
comment on column user_cash_log.statistical_date is '统计时间';
comment on column user_cash_log.channel is '消费渠道';
comment on column user_cash_log.channel_detail is '消费渠道详情';
comment on column user_cash_log.remark is '备注';
comment on column user_cash_log.create_user is '创建人';
comment on column user_cash_log.create_dept is '创建部门';
comment on column user_cash_log.create_time is '创建时间';
comment on column user_cash_log.update_user is '修改人';
comment on column user_cash_log.update_time is '修改时间';
comment on column user_cash_log.status is '状态';
comment on column user_cash_log.is_deleted is '是否已删除';
alter table user_cash_log
owner to postgres;
create table user_mall_integral
(
id bigint not null primary key,
user_id bigint,
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),
is_deleted integer default 0
);
create index user_mall_integral_index
on user_mall_integral (is_deleted, user_id);
comment on table user_mall_integral is '用户商城积分表';
comment on column user_mall_integral.id is '主键';
comment on column user_mall_integral.user_id is '用户id';
comment on column user_mall_integral.amount is '面额';
comment on column user_mall_integral.version is '版本号';
comment on column user_mall_integral.create_user is '创建人';
comment on column user_mall_integral.create_dept is '创建部门';
comment on column user_mall_integral.create_time is '创建时间';
comment on column user_mall_integral.update_user is '修改人';
comment on column user_mall_integral.update_time is '修改时间';
comment on column user_mall_integral.is_deleted is '是否已删除';
alter table user_mall_integral
owner to postgres;
create table user_mall_integral_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_mall_integral_log_index
on user_mall_integral_log (is_deleted, user_id, statistical_date , type);
comment on table user_mall_integral_log is '用户商城积分流水表';
comment on column user_mall_integral_log.id is '主键';
comment on column user_mall_integral_log.user_id is '用户id';
comment on column user_mall_integral_log.user_phone is '用户手机号';
comment on column user_mall_integral_log.user_name is '用户名称';
comment on column user_mall_integral_log.amount is '金额';
comment on column user_mall_integral_log.source_id is '来源id';
comment on column user_mall_integral_log.source_detail is '来源详情';
comment on column user_mall_integral_log.order_id is '订单id';
comment on column user_mall_integral_log.type is '消费类型 1-收入 2-支出';
comment on column user_mall_integral_log.statistical_date is '统计时间';
comment on column user_mall_integral_log.channel is '消费渠道';
comment on column user_mall_integral_log.channel_detail is '消费渠道详情';
comment on column user_mall_integral_log.remark is '备注';
comment on column user_mall_integral_log.create_user is '创建人';
comment on column user_mall_integral_log.create_dept is '创建部门';
comment on column user_mall_integral_log.create_time is '创建时间';
comment on column user_mall_integral_log.update_user is '修改人';
comment on column user_mall_integral_log.update_time is '修改时间';
comment on column user_mall_integral_log.status is '状态';
comment on column user_mall_integral_log.is_deleted is '是否已删除';
alter table user_mall_integral_log
owner to postgres;