完善套餐与账单接口 & 完善支付数据保存,记录实付价格并关联优惠券
This commit is contained in:
@@ -747,7 +747,7 @@ create table product_sku (
|
||||
id int generated by default as identity primary key,
|
||||
product_id int not null,
|
||||
discount_id int,
|
||||
code text not null,
|
||||
code text not null unique,
|
||||
name text not null,
|
||||
price decimal not null,
|
||||
created_at timestamptz default current_timestamp,
|
||||
@@ -756,7 +756,7 @@ create table product_sku (
|
||||
);
|
||||
create index idx_product_sku_product_id on product_sku (product_id) where deleted_at is null;
|
||||
create index idx_product_sku_discount_id on product_sku (discount_id) where deleted_at is null;
|
||||
create index idx_product_sku_code on product_sku (code) where deleted_at is null;
|
||||
create unique index idx_product_sku_code on product_sku (code) where deleted_at is null;
|
||||
|
||||
-- product_sku表字段注释
|
||||
comment on table product_sku is '产品SKU表';
|
||||
@@ -977,10 +977,12 @@ create table bill (
|
||||
trade_id int,
|
||||
resource_id int,
|
||||
refund_id int,
|
||||
coupon_id int,
|
||||
bill_no text not null,
|
||||
info text,
|
||||
type int not null,
|
||||
amount decimal(12, 2) not null default 0,
|
||||
actual decimal(12, 2) not null default 0,
|
||||
created_at timestamptz default current_timestamp,
|
||||
updated_at timestamptz default current_timestamp,
|
||||
deleted_at timestamptz
|
||||
@@ -990,6 +992,7 @@ create index idx_bill_user_id on bill (user_id) where deleted_at is null;
|
||||
create index idx_bill_trade_id on bill (trade_id) where deleted_at is null;
|
||||
create index idx_bill_resource_id on bill (resource_id) where deleted_at is null;
|
||||
create index idx_bill_refund_id on bill (refund_id) where deleted_at is null;
|
||||
create index idx_bill_coupon_id on bill (coupon_id) where deleted_at is null;
|
||||
create index idx_bill_created_at on bill (created_at) where deleted_at is null;
|
||||
|
||||
-- bill表字段注释
|
||||
@@ -1002,7 +1005,8 @@ comment on column bill.refund_id is '退款ID';
|
||||
comment on column bill.bill_no is '易读账单号';
|
||||
comment on column bill.info is '产品可读信息';
|
||||
comment on column bill.type is '账单类型:1-消费,2-退款,3-充值';
|
||||
comment on column bill.amount is '账单金额';
|
||||
comment on column bill.amount is '应付金额';
|
||||
comment on column bill.actual is '实付金额';
|
||||
comment on column bill.created_at is '创建时间';
|
||||
comment on column bill.updated_at is '更新时间';
|
||||
comment on column bill.deleted_at is '删除时间';
|
||||
@@ -1107,14 +1111,20 @@ alter table channel
|
||||
-- resource表外键
|
||||
alter table resource
|
||||
add constraint fk_resource_user_id foreign key (user_id) references "user" (id) on delete cascade;
|
||||
alter table resource
|
||||
add constraint fk_product_code foreign key (code) references product (code) on update cascade on delete restrict;
|
||||
|
||||
-- resource_short表外键
|
||||
alter table resource_short
|
||||
add constraint fk_resource_short_resource_id foreign key (resource_id) references resource (id) on delete cascade;
|
||||
alter table resource_short
|
||||
add constraint fk_resource_short_code foreign key (code) references product_sku (code) on update cascade on delete restrict;
|
||||
|
||||
-- resource_long表外键
|
||||
alter table resource_long
|
||||
add constraint fk_resource_long_resource_id foreign key (resource_id) references resource (id) on delete cascade;
|
||||
alter table resource_long
|
||||
add constraint fk_resource_long_code foreign key (code) references product_sku (code) on update cascade on delete restrict;
|
||||
|
||||
-- trade表外键
|
||||
alter table trade
|
||||
@@ -1135,6 +1145,8 @@ alter table bill
|
||||
add constraint fk_bill_resource_id foreign key (resource_id) references resource (id) on delete set null;
|
||||
alter table bill
|
||||
add constraint fk_bill_refund_id foreign key (refund_id) references refund (id) on delete set null;
|
||||
alter table bill
|
||||
add constraint fk_bill_coupon_id foreign key (coupon_id) references coupon (id) on delete set null;
|
||||
|
||||
-- coupon表外键
|
||||
alter table coupon
|
||||
|
||||
Reference in New Issue
Block a user