Files
yichayilu_boot/doc/sql/pending/20260429.sql
RayL 45cbb2f063 update:
1. fix
2026-05-01 17:20:07 +08:00

286 lines
18 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

alter table merchant_application drop column alipay_account;
alter table merchant_application drop column wechat_account;
alter table merchant_catalog drop column specs;
drop table if exists merchant_payout_account;
create table merchant_payout_account
(
id int8 not null primary key,
user_id int8 not null default -1,
account_type int4 not null default -1,
holder_name varchar(255) default '' not null,
account_number varchar(255) not null default '',
account_url text not null default '',
remark varchar(255) not null default '',
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4,
is_deleted int4 default 0
);
create index idx_merchant_payout_account_user_id on merchant_payout_account (user_id) where is_deleted = 0;
comment on table merchant_payout_account is '商家收款资料表';
comment on column merchant_payout_account.id is '主键';
comment on column merchant_payout_account.user_id is '用户id';
comment on column merchant_payout_account.account_type is '账号类型 1:支付宝 2:微信';
comment on column merchant_payout_account.holder_name is '账户所有人';
comment on column merchant_payout_account.account_number is '银行卡号';
comment on column merchant_payout_account.account_url is '收款码图片';
comment on column merchant_payout_account.remark is '备注';
comment on column merchant_payout_account.create_user is '创建人';
comment on column merchant_payout_account.create_dept is '创建部门';
comment on column merchant_payout_account.create_time is '创建时间';
comment on column merchant_payout_account.update_user is '修改人';
comment on column merchant_payout_account.update_time is '修改时间';
comment on column merchant_payout_account.status is '状态';
comment on column merchant_payout_account.is_deleted is '是否已删除';
drop table if exists market_daily_summary;
CREATE TABLE market_daily_summary
(
-- 主键(可选,用于 ORM)
id int8 not null primary key,
-- 用户基础信息
user_id int8 not null,
user_account VARCHAR(64) NOT NULL DEFAULT '',
user_name VARCHAR(128) NOT NULL DEFAULT '',
stat_date DATE NOT NULL, -- 统计日期,如 '2026-04-29'
-- === 直推 & 团队 ===
direct_referral_count int4 NOT NULL DEFAULT 0, -- 直推人数(累计)
new_direct_referral_count int4 NOT NULL DEFAULT 0, -- 当日新增直推人数
team_total_count int4 NOT NULL DEFAULT 0, -- 团队人数(累计)
new_team_count int4 NOT NULL DEFAULT 0, -- 当日新增团队人数
-- === 福利值 ===
total_benefits_value decimal(18, 2) NOT NULL DEFAULT 0.00, -- 总福利值
increase_benefits_value decimal(18, 2) NOT NULL DEFAULT 0.00, -- 当日新增福利值
-- === 直推人福利包相关 ===
direct_with_benefit_package_count int4 NOT NULL DEFAULT 0, -- 当日持有福利包的直推人数
direct_new_benefit_packages JSONB NOT NULL DEFAULT '[]', -- 当日直推人新增的福利包明细(数组)
direct_benefit_package_face_total decimal(18, 2) NOT NULL DEFAULT 0.00, -- 直推人福利包面值总和
direct_accelerated_value decimal(18, 2) NOT NULL DEFAULT 0.00, -- 直推人福利包可提供加速的值(排除后台划拨)
benefit_level int2 NOT NULL DEFAULT 0, -- 当日福利积分系统等级
-- === 直推人现金下单相关 ===
cash_order_direct_count int4 NOT NULL DEFAULT 0, -- 当日现金下单的直推人数
cash_order_direct_amount decimal(18, 2) NOT NULL DEFAULT 0.00, -- 当日直推人现金下单金额
cash_dividend_eligible_direct decimal(18, 2) NOT NULL DEFAULT 0.00, -- 直推人可提供的现金分红金额(排除线下支付)
commission_level int2 NOT NULL DEFAULT 0, -- 当日佣金分红系统等级
-- === 自己福利包相关 ===
self_new_benefit_packages JSONB NOT NULL DEFAULT '[]', -- 当日自己新增福利包(明细数组)
self_new_benefit_face_value decimal(18, 2) NOT NULL DEFAULT 0.00, -- 当日自己新增福利包面值
self_accelerated_value decimal(18, 2) NOT NULL DEFAULT 0.00, -- 自己新增福利包可提供加速的值
total_remaining_benefit_face decimal(18, 2) NOT NULL DEFAULT 0.00, -- 福利包总剩余面值
total_accelerated_by_packages decimal(18, 2) NOT NULL DEFAULT 0.00, -- 福利包加速了多少值(累计)
-- === 自己现金消费相关 ===
cash_commission_paid decimal(18, 2) NOT NULL DEFAULT 0.00, -- 现金分红了多少(即佣金)
self_cash_consumption_amount decimal(18, 2) NOT NULL DEFAULT 0.00, -- 当日现金消费金额(排除线下支付)
self_cash_dividend_eligible decimal(18, 2) NOT NULL DEFAULT 0.00, -- 自己可提供分红的金额(排除线下支付)
-- 时间戳
remark varchar(255) not null default '',
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4,
is_deleted int4 default 0,
UNIQUE (user_id, stat_date)
);
-- 核心索引
CREATE INDEX idx_user_daily_summary_stat_date ON market_daily_summary (stat_date);
CREATE INDEX idx_user_daily_summary_user_id ON market_daily_summary (user_id);
CREATE INDEX idx_user_daily_summary_update_time ON market_daily_summary (update_time);
-- 如需查询 JSON 内容,可加 GIN 索引(按需)
CREATE INDEX idx_direct_new_benefit_packages ON market_daily_summary USING GIN (direct_new_benefit_packages);
CREATE INDEX idx_self_new_benefit_packages ON market_daily_summary USING GIN (self_new_benefit_packages);
comment on table market_daily_summary is '用户日汇总表';
COMMENT ON COLUMN market_daily_summary.id IS '主键';
COMMENT ON COLUMN market_daily_summary.user_id IS '用户ID';
COMMENT ON COLUMN market_daily_summary.user_account IS '用户账号';
COMMENT ON COLUMN market_daily_summary.user_name IS '用户姓名';
COMMENT ON COLUMN market_daily_summary.stat_date IS '统计日期,如 ''2026-04-29''';
-- === 直推 & 团队 ===
COMMENT ON COLUMN market_daily_summary.direct_referral_count IS '直推人数(累计)';
COMMENT ON COLUMN market_daily_summary.new_direct_referral_count IS '当日新增直推人数';
COMMENT ON COLUMN market_daily_summary.team_total_count IS '团队人数(累计)';
COMMENT ON COLUMN market_daily_summary.new_team_count IS '当日新增团队人数';
-- === 福利值 ===
COMMENT ON COLUMN market_daily_summary.total_benefits_value IS '总福利值';
COMMENT ON COLUMN market_daily_summary.increase_benefits_value IS '当日新增福利值';
-- === 直推人福利包相关 ===
COMMENT ON COLUMN market_daily_summary.direct_with_benefit_package_count IS '当日持有福利包的直推人数';
COMMENT ON COLUMN market_daily_summary.direct_new_benefit_packages IS '当日直推人新增的福利包明细(数组)';
COMMENT ON COLUMN market_daily_summary.direct_benefit_package_face_total IS '直推人福利包面值总和';
COMMENT ON COLUMN market_daily_summary.direct_accelerated_value IS '直推人福利包可提供加速的值(排除后台划拨)';
COMMENT ON COLUMN market_daily_summary.benefit_level IS '当日福利积分系统等级';
-- === 直推人现金下单相关 ===
COMMENT ON COLUMN market_daily_summary.cash_order_direct_count IS '当日现金下单的直推人数';
COMMENT ON COLUMN market_daily_summary.cash_order_direct_amount IS '当日直推人现金下单金额';
COMMENT ON COLUMN market_daily_summary.cash_dividend_eligible_direct IS '直推人可提供的现金分红金额(排除线下支付)';
COMMENT ON COLUMN market_daily_summary.commission_level IS '当日佣金分红系统等级';
-- === 自己福利包相关 ===
COMMENT ON COLUMN market_daily_summary.self_new_benefit_packages IS '当日自己新增福利包(明细数组)';
COMMENT ON COLUMN market_daily_summary.self_new_benefit_face_value IS '当日自己新增福利包面值';
COMMENT ON COLUMN market_daily_summary.self_accelerated_value IS '自己新增福利包可提供加速的值';
COMMENT ON COLUMN market_daily_summary.total_remaining_benefit_face IS '福利包总剩余面值';
COMMENT ON COLUMN market_daily_summary.total_accelerated_by_packages IS '福利包加速了多少值(累计)';
-- === 自己现金消费相关 ===
COMMENT ON COLUMN market_daily_summary.cash_commission_paid IS '现金分红了多少(即佣金)';
COMMENT ON COLUMN market_daily_summary.self_cash_consumption_amount IS '当日现金消费金额(排除线下支付)';
COMMENT ON COLUMN market_daily_summary.self_cash_dividend_eligible IS '自己可提供分红的金额(排除线下支付)';
-- 时间戳
comment on column market_daily_summary.remark is '备注';
comment on column market_daily_summary.create_user is '创建人';
comment on column market_daily_summary.create_dept is '创建部门';
comment on column market_daily_summary.create_time is '创建时间';
comment on column market_daily_summary.update_user is '修改人';
comment on column market_daily_summary.update_time is '修改时间';
comment on column market_daily_summary.status is '状态';
comment on column market_daily_summary.is_deleted is '是否已删除';
drop table if exists market_merchant_order;
CREATE TABLE market_merchant_order
(
id int8 not null primary key,
user_id int8 not null,
seller_id int8 not null,
product_name varchar(255) not null default '',
product_id int8 not null,
thumb_image_url text not null,
inventory_id int8 not null,
store_name varchar(255) not null,
unit_price decimal(10, 2) default 0.00 not null,
gift_type int4 default 0 NOT NULL,
unit_gift_amount decimal(10, 2) default 0.00 not null,
quantity int2 default 0 not null,
total_amount decimal(10, 2) default 0.00 not null,
total_gift_amount decimal(10, 2) default 0.00 not null,
payout_account_id int8 not null,
account_type int4 not null default -1,
account_number varchar(255) not null default '',
account_url text not null default '',
account_holder_name varchar(255) default '' not null,
consignee_phone varchar(128) NOT NULL,
consignee varchar(128) NOT NULL,
delivery_address text not null,
payment_voucher_url text not null,
express_no VARCHAR(100) NULL,
remark varchar(255) not null default '',
version int4 not null default 0,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4,
is_deleted int4 default 0
);
CREATE INDEX idx_market_merchant_order_user_id ON market_merchant_order (user_id) where is_deleted = 0;
CREATE INDEX idx_market_merchant_order_seller_id ON market_merchant_order (seller_id) where is_deleted = 0;
CREATE INDEX idx_market_merchant_order_product_id ON market_merchant_order (product_id) where is_deleted = 0;
CREATE INDEX idx_market_merchant_order_inventory_id ON market_merchant_order (inventory_id) where is_deleted = 0;
COMMENT ON TABLE market_merchant_order IS '自营商家订单';
COMMENT ON COLUMN market_merchant_order.id IS '主键';
COMMENT ON COLUMN market_merchant_order.user_id IS '下单用户ID';
COMMENT ON COLUMN market_merchant_order.seller_id IS '商家ID';
COMMENT ON COLUMN market_merchant_order.product_name IS '商品名称';
COMMENT ON COLUMN market_merchant_order.product_id IS '商品ID';
COMMENT ON COLUMN market_merchant_order.thumb_image_url IS '商品缩略图URL';
COMMENT ON COLUMN market_merchant_order.inventory_id IS '库存ID(或SKU ID)';
COMMENT ON COLUMN market_merchant_order.store_name IS '店铺名称';
COMMENT ON COLUMN market_merchant_order.unit_price IS '商品单价';
COMMENT ON COLUMN market_merchant_order.gift_type IS '赠品类型(1:福利积分, 2:现金券, 3:佣金)';
COMMENT ON COLUMN market_merchant_order.unit_gift_amount IS '单件商品附带的赠品金额(如红包或福利值)';
COMMENT ON COLUMN market_merchant_order.quantity IS '购买数量';
COMMENT ON COLUMN market_merchant_order.total_amount IS '订单总金额';
COMMENT ON COLUMN market_merchant_order.total_gift_amount IS '赠品总金额';
COMMENT ON COLUMN market_merchant_order.payout_account_id IS '上架收款账户ID';
COMMENT ON COLUMN market_merchant_order.account_type IS '收款账户类型(1:支付宝, 2:微信, 3:银行卡)';
COMMENT ON COLUMN market_merchant_order.account_number IS '收款账号(银行卡号)';
COMMENT ON COLUMN market_merchant_order.account_url IS '收款账户二维码或链接';
COMMENT ON COLUMN market_merchant_order.account_holder_name IS '收款人姓名';
COMMENT ON COLUMN market_merchant_order.consignee_phone IS '收货人手机号';
COMMENT ON COLUMN market_merchant_order.consignee IS '收货人姓名';
COMMENT ON COLUMN market_merchant_order.delivery_address IS '收货地址';
COMMENT ON COLUMN market_merchant_order.payment_voucher_url IS '付款凭证截图URL';
COMMENT ON COLUMN market_merchant_order.express_no IS '快递单号';
COMMENT ON COLUMN market_merchant_order.remark IS '订单备注';
COMMENT ON COLUMN market_merchant_order.create_user IS '创建人用户ID';
COMMENT ON COLUMN market_merchant_order.create_dept IS '创建部门ID';
COMMENT ON COLUMN market_merchant_order.create_time IS '创建时间';
COMMENT ON COLUMN market_merchant_order.update_user IS '更新人用户ID';
COMMENT ON COLUMN market_merchant_order.update_time IS '更新时间';
COMMENT ON COLUMN market_merchant_order.status IS '订单状态(0=待支付 1=已支付(待发货/待使用)2=已取消 3=已发货/已出票(进行中)4=已完成 5=已关闭(超时未支付)6=退款中 7: 已退款)';
COMMENT ON COLUMN market_merchant_order.is_deleted IS '逻辑删除标志(0:未删除, 1:已删除)';
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669598012903425', '1123598815738675201', 'dailySummary', '用户日汇总表', 'menu', '/market/daily-summary',
NULL, 1, 1, 0, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669598012903426', '2049669598012903425', 'dailySummary_add', '新增', 'add', '/market/daily-summary/add',
'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669598012903427', '2049669598012903425', 'dailySummary_edit', '修改', 'edit', '/market/daily-summary/edit',
'form', 2, 2, 2, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669598012903428', '2049669598012903425', 'dailySummary_delete', '删除', 'delete',
'/api/blade-dailysummary/dailySummary/remove', 'delete', 3, 2, 3, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669598012903429', '2049669598012903425', 'dailySummary_view', '查看', 'view', '/market/daily-summary/view',
'file-text', 4, 2, 2, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669574994563074', '1123598815738675201', 'merchantOrder', '自营商家订单', 'menu', '/market/merchant-order',
NULL, 1, 1, 0, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669574994563075', '2049669574994563074', 'merchantOrder_add', '新增', 'add', '/market/merchant-order/add',
'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669574994563076', '2049669574994563074', 'merchantOrder_edit', '修改', 'edit',
'/market/merchant-order/edit', 'form', 2, 2, 2, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669574994563077', '2049669574994563074', 'merchantOrder_delete', '删除', 'delete',
'/api/blade-merchantorder/merchantOrder/remove', 'delete', 3, 2, 3, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2049669574994563078', '2049669574994563074', 'merchantOrder_view', '查看', 'view',
'/market/merchant-order/view', 'file-text', 4, 2, 2, 1, NULL, 0);