重构优化套餐数据结构,修复提取计数问题

This commit is contained in:
2025-12-10 20:07:33 +08:00
parent c8c86081d9
commit 05fba68b3e
11 changed files with 310 additions and 250 deletions

View File

@@ -713,14 +713,13 @@ drop table if exists resource_short cascade;
create table resource_short (
id int generated by default as identity primary key,
resource_id int not null,
type int not null,
live int not null,
expire timestamptz,
quota int,
type int not null,
quota int not null,
expire_at timestamptz,
used int not null default 0,
daily_limit int not null default 0,
daily_used int not null default 0,
daily_last timestamptz
daily int not null default 0,
last_at timestamptz
);
create index idx_resource_short_resource_id on resource_short (resource_id);
@@ -728,28 +727,26 @@ create index idx_resource_short_resource_id on resource_short (resource_id);
comment on table resource_short is '短效动态套餐表';
comment on column resource_short.id is 'ID';
comment on column resource_short.resource_id is '套餐ID';
comment on column resource_short.type is '套餐类型1-包时2-包量';
comment on column resource_short.live is '可用时长(秒)';
comment on column resource_short.quota is '配额数';
comment on column resource_short.used is '已用数量';
comment on column resource_short.expire is '过期时间';
comment on column resource_short.daily_limit is '每日限制';
comment on column resource_short.daily_used is '今日已用数';
comment on column resource_short.daily_last is '今日最后使用时间';
comment on column resource_short.type is '套餐类型1-包时2-包';
comment on column resource_short.quota is '每日配额(包时)或总配额(包量)';
comment on column resource_short.expire_at is '套餐过期时间,包时模式可用';
comment on column resource_short.used is '总用量';
comment on column resource_short.daily is '当日用';
comment on column resource_short.last_at is '最后使用时间';
-- resource_long
drop table if exists resource_long cascade;
create table resource_long (
id int generated by default as identity primary key,
resource_id int not null,
type int not null,
live int not null,
expire timestamptz,
quota int,
type int not null,
quota int not null,
expire_at timestamptz,
used int not null default 0,
daily_limit int not null default 0,
daily_used int not null default 0,
daily_last timestamptz
daily int not null default 0,
last_at timestamptz
);
create index idx_resource_long_resource_id on resource_long (resource_id);
@@ -757,14 +754,13 @@ create index idx_resource_long_resource_id on resource_long (resource_id);
comment on table resource_long is '长效动态套餐表';
comment on column resource_long.id is 'ID';
comment on column resource_long.resource_id is '套餐ID';
comment on column resource_long.live is '可用时长(小时)';
comment on column resource_long.type is '套餐类型1-包时2-包量';
comment on column resource_long.live is '可用时长(天)';
comment on column resource_long.quota is '配额数量';
comment on column resource_long.used is '已用数';
comment on column resource_long.expire is '过期时间';
comment on column resource_long.daily_limit is '每日限制';
comment on column resource_long.daily_used is '今日已用数量';
comment on column resource_long.daily_last is '今日最后使用时间';
comment on column resource_long.quota is '每日配额(包时)或总配额(包量)';
comment on column resource_long.expire_at is '套餐过期时间,包时模式可用';
comment on column resource_long.used is '总用';
comment on column resource_long.daily is '当日用量';
comment on column resource_long.last_at is '最后使用时间';
-- endregion