优化交易创建流程,客户管理新增折扣与来源字段及功能

This commit is contained in:
2026-03-27 16:16:55 +08:00
parent 75ad12efb3
commit 7e8d824ba6
26 changed files with 523 additions and 140 deletions

View File

@@ -258,10 +258,12 @@ drop table if exists "user" cascade;
create table "user" (
id int generated by default as identity primary key,
admin_id int,
discount_id int,
phone text not null unique,
username text,
email text,
password text,
source int default 0,
name text,
avatar text,
status int not null default 1,
@@ -279,6 +281,7 @@ create table "user" (
deleted_at timestamptz
);
create index idx_user_admin_id on "user" (admin_id) where deleted_at is null;
create index idx_user_discount_id on "user" (discount_id) where deleted_at is null;
create unique index udx_user_phone on "user" (phone) where deleted_at is null;
create unique index udx_user_username on "user" (username) where deleted_at is null;
create unique index udx_user_email on "user" (email) where deleted_at is null;
@@ -288,9 +291,11 @@ create index idx_user_created_at on "user" (created_at) where deleted_at is null
comment on table "user" is '用户表';
comment on column "user".id is '用户ID';
comment on column "user".admin_id is '管理员ID';
comment on column "user".discount_id is '折扣ID';
comment on column "user".password is '用户密码';
comment on column "user".username is '用户名';
comment on column "user".phone is '手机号码';
comment on column "user".source is '用户来源0-官网注册1-管理员添加2-代理商注册3-代理商添加';
comment on column "user".name is '真实姓名';
comment on column "user".avatar is '头像URL';
comment on column "user".status is '用户状态0-禁用1-正常';
@@ -1053,6 +1058,8 @@ comment on column coupon.deleted_at is '删除时间';
-- user表外键
alter table "user"
add constraint fk_user_admin_id foreign key (admin_id) references admin (id) on delete set null;
alter table "user"
add constraint fk_user_discount_id foreign key (discount_id) references product_discount (id) on delete set null;
-- session表外键
alter table session