feat(admin): full integration of order, product, and finance modules with real RPC data streams
This commit is contained in:
33
docs/sql/10_schema/finance/ml_user_bill_v1.sql
Normal file
33
docs/sql/10_schema/finance/ml_user_bill_v1.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- =====================================================================================
|
||||
-- Schema: 用户资金流水表
|
||||
-- 位置:docs/sql/10_schema/finance/
|
||||
-- 对象类型:Schema (DDL)
|
||||
-- 版本:v1
|
||||
-- 说明:记录用户余额、积分、佣金的所有增减流水(原子日志)
|
||||
-- =====================================================================================
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.ml_user_bill (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
uid UUID NOT NULL REFERENCES public.ak_users(id),
|
||||
|
||||
link_id TEXT NULL, -- 关联业务ID(订单号、提现ID、充值ID等)
|
||||
pm SMALLINT NOT NULL DEFAULT 1, -- 0:支出, 1:收入
|
||||
|
||||
title TEXT NOT NULL, -- 流水标题(如:商品购买、充值、提现)
|
||||
category TEXT NOT NULL, -- 业务大类(如:balance-余额, integral-积分, brokerage-佣金)
|
||||
type TEXT NOT NULL, -- 业务子类型(如:recharge, extract, pay, refund, system_add, system_sub)
|
||||
|
||||
number DECIMAL(12,2) NOT NULL DEFAULT 0, -- 变动金额
|
||||
balance DECIMAL(12,2) NOT NULL DEFAULT 0, -- 变动后的余额快照
|
||||
|
||||
mark TEXT NULL, -- 备注
|
||||
status SMALLINT NOT NULL DEFAULT 1, -- 状态(1:有效, 0:无效/冲正)
|
||||
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
-- 常用查询索引
|
||||
CREATE INDEX IF NOT EXISTS ml_user_bill_uid_idx ON public.ml_user_bill (uid);
|
||||
CREATE INDEX IF NOT EXISTS ml_user_bill_category_type_idx ON public.ml_user_bill (category, type);
|
||||
CREATE INDEX IF NOT EXISTS ml_user_bill_created_at_idx ON public.ml_user_bill (created_at DESC);
|
||||
Reference in New Issue
Block a user