支付功能动态化扩展

This commit is contained in:
2026-03-18 13:07:06 +08:00
parent 99853b8514
commit 9d996acf5f
16 changed files with 1402 additions and 195 deletions

View File

@@ -720,6 +720,58 @@ comment on column product.created_at is '创建时间';
comment on column product.updated_at is '更新时间';
comment on column product.deleted_at is '删除时间';
-- product_sku
drop table if exists product_sku cascade;
create table product_sku (
id int generated by default as identity primary key,
product_id int not null,
code text not null,
name text not null,
price decimal not null,
discount float not null,
created_at timestamptz default current_timestamp,
updated_at timestamptz default current_timestamp,
deleted_at timestamptz
);
create index idx_product_sku_product_id on product_sku (product_id) where deleted_at is null;
create index idx_product_sku_code on product_sku (code) where deleted_at is null;
-- product_sku表字段注释
comment on table product_sku is '产品SKU表';
comment on column product_sku.id is 'SKU ID';
comment on column product_sku.product_id is '产品ID';
comment on column product_sku.code is 'SKU 代码:格式为 key=value,key=value,...其中key:value 是 SKU 的属性,多个属性用逗号分隔';
comment on column product_sku.name is 'SKU 可读名称';
comment on column product_sku.price is '定价';
comment on column product_sku.discount is '折扣0 - 1 的小数,表示 xx 折';
comment on column product_sku.created_at is '创建时间';
comment on column product_sku.updated_at is '更新时间';
comment on column product_sku.deleted_at is '删除时间';
-- product_sku_user
drop table if exists product_sku_user cascade;
create table product_sku_user (
id int generated by default as identity primary key,
user_id int not null,
product_sku_id int not null,
price decimal,
discount float,
created_at timestamptz default current_timestamp,
updated_at timestamptz default current_timestamp
);
create index idx_product_sku_user_user_id on product_sku_user (user_id);
create index idx_product_sku_user_product_sku_id on product_sku_user (product_sku_id);
-- product_sku_user表字段注释
comment on table product_sku_user is '用户产品SKU表';
comment on column product_sku_user.id is 'ID';
comment on column product_sku_user.user_id is '用户ID';
comment on column product_sku_user.product_sku_id is '产品SKU ID';
comment on column product_sku_user.price is '定价';
comment on column product_sku_user.discount is '折扣0 - 1 的小数,表示 xx 折';
comment on column product_sku_user.created_at is '创建时间';
comment on column product_sku_user.updated_at is '更新时间';
-- resource
drop table if exists resource cascade;
create table resource (
@@ -1058,4 +1110,14 @@ alter table bill
alter table coupon
add constraint fk_coupon_user_id foreign key (user_id) references "user" (id) on delete cascade;
-- product_sku表外键
alter table product_sku
add constraint fk_product_sku_product_id foreign key (product_id) references product (id) on delete cascade;
-- product_sku_user表外键
alter table product_sku_user
add constraint fk_product_sku_user_user_id foreign key (user_id) references "user" (id) on delete cascade;
alter table product_sku_user
add constraint fk_product_sku_user_product_sku_id foreign key (product_sku_id) references product_sku (id) on delete cascade;
-- endregion