Files
yichayilu_boot/doc/sql/pending/user_point.sql

245 lines
10 KiB
SQL

--- 福利积分 benefit_point
DROP TABLE IF EXISTS benefit_point;
create table benefit_point
(
id int8 not null primary key,
amount decimal(14, 2) default 0,
version int4 default 1,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 default 1,
is_deleted int4 default 0
);
comment on table benefit_point is '用户福利值表';
comment on column benefit_point.id is '主键(用户id)';
comment on column benefit_point.amount is '金额';
comment on column benefit_point.version is '版本号';
comment on column benefit_point.create_user is '创建人';
comment on column benefit_point.create_dept is '创建部门';
comment on column benefit_point.create_time is '创建时间';
comment on column benefit_point.update_user is '修改人';
comment on column benefit_point.update_time is '修改时间';
comment on column benefit_point.status is '状态';
comment on column benefit_point.is_deleted is '是否已删除';
alter table benefit_point
owner to yicha1lu;
DROP TABLE IF EXISTS benefit_point_log;
create table benefit_point_log
(
id int8 not null primary key,
user_id int8,
amount decimal(14, 2) default 0,
last_amount decimal(14, 2) default 0, -- 上一笔金额
fee decimal(14, 2) default 0,
source_type int4, -- 来源类型 0-福利包产出 1-福利包兑换 2-用户直推 3-otc交易
source_id int8,
source_detail text,
type int4 default 1,
is_complete int4 default 0, -- 0-未完成 1-已完成
statistical_date timestamp(6),
remark text,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 default 1,
is_deleted int4 default 0
);
create index idx_umbl_uid
on benefit_point_log (is_complete, user_id, type, statistical_date, create_time DESC);
comment on table benefit_point_log is '用户福利值流水表';
comment on column benefit_point_log.id is '主键';
comment on column benefit_point_log.user_id is '用户id';
comment on column benefit_point_log.amount is '金额';
comment on column benefit_point_log.last_amount is '上一笔金额';
comment on column benefit_point_log.fee is '手续费';
comment on column benefit_point_log.source_type is '来源类型 0-福利包产出 1-福利包兑换 2-用户直推 3-otc交易';
comment on column benefit_point_log.source_id is '来源id';
comment on column benefit_point_log.source_detail is '来源详情';
comment on column benefit_point_log.type is '消费类型 1-收入 2-支出';
comment on column benefit_point_log.is_complete is '是否完成 0-未完成 1-已完成';
comment on column benefit_point_log.statistical_date is '统计时间';
comment on column benefit_point_log.remark is '备注';
comment on column benefit_point_log.create_user is '创建人';
comment on column benefit_point_log.create_dept is '创建部门';
comment on column benefit_point_log.create_time is '创建时间';
comment on column benefit_point_log.update_user is '修改人';
comment on column benefit_point_log.update_time is '修改时间';
comment on column benefit_point_log.status is '状态';
comment on column benefit_point_log.is_deleted is '是否已删除';
alter table benefit_point_log
owner to yicha1lu;
--- 现金券 cash_coupon
DROP TABLE IF EXISTS cash_coupon;
create table cash_coupon
(
id int8 not null primary key,
amount decimal(14, 2) default 0,
version int4 default 1,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 default 1,
is_deleted int4 default 0
);
comment on table cash_coupon is '用户现金券表';
comment on column cash_coupon.id is '主键(用户id)';
comment on column cash_coupon.amount is '面额';
comment on column cash_coupon.version is '版本号';
comment on column cash_coupon.create_user is '创建人';
comment on column cash_coupon.create_dept is '创建部门';
comment on column cash_coupon.create_time is '创建时间';
comment on column cash_coupon.update_user is '修改人';
comment on column cash_coupon.update_time is '修改时间';
comment on column cash_coupon.status is '状态';
comment on column cash_coupon.is_deleted is '是否已删除';
alter table cash_coupon
owner to yicha1lu;
DROP TABLE IF EXISTS cash_coupon_log;
create table cash_coupon_log
(
id int8 not null primary key,
user_id int8,
amount decimal(14, 2) default 0,
last_amount decimal(14, 2) default 0, -- 上一笔金额
source_type int4, -- 来源类型 0-商城抽奖 1-福利包兑换
source_id int8,
source_detail text,
type int4 default 1,
is_complete int4 default 0, -- 0-未完成 1-已完成
statistical_date timestamp(6),
remark text,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 default 1,
is_deleted int4 default 0
);
create index idx_umcl_uid
on cash_coupon_log (is_complete, user_id, type, statistical_date, create_time DESC);
comment on table cash_coupon_log is '用户现金券流水表';
comment on column cash_coupon_log.id is '主键';
comment on column cash_coupon_log.user_id is '用户id';
comment on column cash_coupon_log.amount is '金额';
comment on column cash_coupon_log.last_amount is '上一笔金额';
comment on column cash_coupon_log.source_type is '来源类型 0-商城抽奖 1-福利包兑换';
comment on column cash_coupon_log.source_id is '来源id';
comment on column cash_coupon_log.source_detail is '来源详情';
comment on column cash_coupon_log.type is '消费类型 1-收入 2-支出';
comment on column cash_coupon_log.statistical_date is '统计时间';
comment on column cash_coupon_log.is_complete is '是否完成 0-未完成 1-已完成';
comment on column cash_coupon_log.remark is '备注';
comment on column cash_coupon_log.create_user is '创建人';
comment on column cash_coupon_log.create_dept is '创建部门';
comment on column cash_coupon_log.create_time is '创建时间';
comment on column cash_coupon_log.update_user is '修改人';
comment on column cash_coupon_log.update_time is '修改时间';
comment on column cash_coupon_log.status is '状态';
comment on column cash_coupon_log.is_deleted is '是否已删除';
alter table cash_coupon_log
owner to yicha1lu;
--- 用户积分 user_point
DROP TABLE IF EXISTS user_point;
create table user_point
(
id int8 not null primary key,
amount decimal(14, 2) default 0,
version int4 default 1,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 default 1,
is_deleted int4 default 0
);
comment on table user_point is '用户商城积分表';
comment on column user_point.id is '主键(用户id)';
comment on column user_point.amount is '面额';
comment on column user_point.version is '版本号';
comment on column user_point.create_user is '创建人';
comment on column user_point.create_dept is '创建部门';
comment on column user_point.create_time is '创建时间';
comment on column user_point.update_user is '修改人';
comment on column user_point.update_time is '修改时间';
comment on column user_point.is_deleted is '是否已删除';
alter table user_point
owner to yicha1lu;
DROP TABLE IF EXISTS user_point_log;
create table user_point_log
(
id int8 not null primary key,
user_id int8,
amount decimal(14, 2) default 0,
last_amount decimal(14, 2) default 0, -- 上一笔金额
source_type int4, -- 来源类型 0-商城订单 1-商城抽奖
source_id int8,
source_detail text,
type int4 default 1,
is_complete int4 default 0, -- 0-未完成 1-已完成
statistical_date timestamp(6),
remark text,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 default 1,
is_deleted int4 default 0
);
create index idx_uapl_uid
on user_point_log (is_complete, user_id, type, statistical_date, create_time DESC);
comment on table user_point_log is '用户商城积分流水表';
comment on column user_point_log.id is '主键';
comment on column user_point_log.user_id is '用户id';
comment on column user_point_log.amount is '金额';
comment on column user_point_log.last_amount is '上一笔金额';
comment on column user_point_log.source_type is '0-商城订单 1-商城抽奖';
comment on column user_point_log.source_id is '来源id';
comment on column user_point_log.source_detail is '来源详情';
comment on column user_point_log.type is '消费类型 1-收入 2-支出';
comment on column user_point_log.statistical_date is '统计时间';
comment on column user_point_log.is_complete is '是否完成 0-未完成 1-已完成';
comment on column user_point_log.remark is '备注';
comment on column user_point_log.create_user is '创建人';
comment on column user_point_log.create_dept is '创建部门';
comment on column user_point_log.create_time is '创建时间';
comment on column user_point_log.update_user is '修改人';
comment on column user_point_log.update_time is '修改时间';
comment on column user_point_log.status is '状态';
comment on column user_point_log.is_deleted is '是否已删除';
alter table user_point_log
owner to yicha1lu;