重构 orm 代码生成逻辑,实现 bill 接口,优化请求字段检查与 list total 查询逻辑

This commit is contained in:
2025-04-11 17:36:34 +08:00
parent c1b4f8d605
commit 636bdcdb87
36 changed files with 794 additions and 193 deletions

View File

@@ -587,16 +587,18 @@ comment on column product.deleted_at is '删除时间';
-- resource
drop table if exists resource cascade;
create table resource (
id serial primary key,
user_id int not null references "user" (id)
id serial primary key,
user_id int not null references "user" (id)
on update cascade
on delete cascade,
active bool not null default true,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
resource_no varchar(255) unique,
active bool not null default true,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
);
create index resource_user_id_index on resource (user_id);
create index resource_resource_no_index on resource (resource_no);
create index resource_active_index on resource (active);
create index resource_deleted_at_index on resource (deleted_at);
@@ -604,6 +606,7 @@ create index resource_deleted_at_index on resource (deleted_at);
comment on table resource is '套餐表';
comment on column resource.id is '套餐ID';
comment on column resource.user_id is '用户ID';
comment on column resource.resource_no is '套餐编号';
comment on column resource.active is '套餐状态';
comment on column resource.created_at is '创建时间';
comment on column resource.updated_at is '更新时间';
@@ -763,6 +766,8 @@ create table refund (
on update cascade --
on delete set null,
amount decimal(12, 2) not null default 0,
reason varchar(255),
status int not null default 0,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
@@ -777,6 +782,8 @@ comment on column refund.id is '退款ID';
comment on column refund.trade_id is '订单ID';
comment on column refund.product_id is '产品ID';
comment on column refund.amount is '退款金额';
comment on column refund.reason is '退款原因';
comment on column refund.status is '退款状态0-待处理1-已退款2-已拒绝';
comment on column refund.created_at is '创建时间';
comment on column refund.updated_at is '更新时间';
comment on column refund.deleted_at is '删除时间';
@@ -785,24 +792,25 @@ comment on column refund.deleted_at is '删除时间';
drop table if exists bill cascade;
create table bill (
id serial primary key,
user_id int not null references "user" (id)
user_id int not null references "user" (id)
on update cascade
on delete cascade,
trade_id int references trade (id) --
on update cascade --
on delete set null,
resource_id int references resource (id) --
on update cascade --
on delete set null,
refund_id int references refund (id) --
on update cascade --
on delete set null,
bill_no varchar(255) not null unique,
trade_id int references trade (id) --
on update cascade --
on delete set null,
resource_id int references resource (id) --
on update cascade --
on delete set null,
refund_id int references refund (id) --
on update cascade --
on delete set null,
bill_no varchar(255) not null unique,
info varchar(255),
type int not null,
status int not null,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
type int not null,
status int not null,
amount decimal(12, 2) not null default 0,
created_at timestamp default current_timestamp,
updated_at timestamp default current_timestamp,
deleted_at timestamp
);
create index bill_user_id_index on bill (user_id);
@@ -825,6 +833,7 @@ comment on column bill.bill_no is '易读账单号';
comment on column bill.info is '产品可读信息';
comment on column bill.type is '账单类型0-充值1-消费2-退款';
comment on column bill.status is '账单状态0-未完成1-已完成2-已作废';
comment on column bill.amount is '账单金额';
comment on column bill.created_at is '创建时间';
comment on column bill.updated_at is '更新时间';
comment on column bill.deleted_at is '删除时间';