From aa41a5ed5e1b9c1e2edcbfe048b8c1e952676ecb Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 16 Mar 2026 23:28:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=AE=A1=E7=90=86=E7=9B=B8=E5=85=B3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=BF=81=E7=A7=BB=EF=BC=88000078-000081?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 000078: 创建 tb_wechat_config 表(支持微信直连和富友双渠道,含软删除) - 000079: tb_order 新增 payment_config_id 字段(nullable,记录下单时使用的配置) - 000080: tb_asset_recharge_record 新增 payment_config_id 字段 - 000081: tb_agent_recharge_record 新增 payment_config_id 字段 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- ...000078_create_wechat_config_table.down.sql | 1 + .../000078_create_wechat_config_table.up.sql | 53 +++++++++++++++++++ ...79_add_payment_config_id_to_order.down.sql | 2 + ...0079_add_payment_config_id_to_order.up.sql | 4 ++ ...yment_config_id_to_asset_recharge.down.sql | 2 + ...payment_config_id_to_asset_recharge.up.sql | 4 ++ ...yment_config_id_to_agent_recharge.down.sql | 3 ++ ...payment_config_id_to_agent_recharge.up.sql | 4 ++ 8 files changed, 73 insertions(+) create mode 100644 migrations/000078_create_wechat_config_table.down.sql create mode 100644 migrations/000078_create_wechat_config_table.up.sql create mode 100644 migrations/000079_add_payment_config_id_to_order.down.sql create mode 100644 migrations/000079_add_payment_config_id_to_order.up.sql create mode 100644 migrations/000080_add_payment_config_id_to_asset_recharge.down.sql create mode 100644 migrations/000080_add_payment_config_id_to_asset_recharge.up.sql create mode 100644 migrations/000081_add_payment_config_id_to_agent_recharge.down.sql create mode 100644 migrations/000081_add_payment_config_id_to_agent_recharge.up.sql diff --git a/migrations/000078_create_wechat_config_table.down.sql b/migrations/000078_create_wechat_config_table.down.sql new file mode 100644 index 0000000..ebfef0b --- /dev/null +++ b/migrations/000078_create_wechat_config_table.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS tb_wechat_config; diff --git a/migrations/000078_create_wechat_config_table.up.sql b/migrations/000078_create_wechat_config_table.up.sql new file mode 100644 index 0000000..8b03111 --- /dev/null +++ b/migrations/000078_create_wechat_config_table.up.sql @@ -0,0 +1,53 @@ +-- 创建微信参数配置表 +CREATE TABLE tb_wechat_config ( + id BIGSERIAL PRIMARY KEY, + name VARCHAR(100) NOT NULL, + description TEXT, + provider_type VARCHAR(20) NOT NULL, + is_active BOOLEAN NOT NULL DEFAULT FALSE, + + -- OAuth 公众号 + oa_app_id VARCHAR(100) NOT NULL DEFAULT '', + oa_app_secret VARCHAR(200) NOT NULL DEFAULT '', + oa_token VARCHAR(200) DEFAULT '', + oa_aes_key VARCHAR(200) DEFAULT '', + oa_oauth_redirect_url VARCHAR(500) DEFAULT '', + + -- OAuth 小程序 + miniapp_app_id VARCHAR(100) DEFAULT '', + miniapp_app_secret VARCHAR(200) DEFAULT '', + + -- 支付-微信直连 + wx_mch_id VARCHAR(100) DEFAULT '', + wx_api_v3_key VARCHAR(200) DEFAULT '', + wx_api_v2_key VARCHAR(200) DEFAULT '', + wx_cert_content TEXT DEFAULT '', + wx_key_content TEXT DEFAULT '', + wx_serial_no VARCHAR(200) DEFAULT '', + wx_notify_url VARCHAR(500) DEFAULT '', + + -- 支付-富友 + fy_ins_cd VARCHAR(50) DEFAULT '', + fy_mchnt_cd VARCHAR(50) DEFAULT '', + fy_term_id VARCHAR(50) DEFAULT '', + fy_private_key TEXT DEFAULT '', + fy_public_key TEXT DEFAULT '', + fy_api_url VARCHAR(500) DEFAULT '', + fy_notify_url VARCHAR(500) DEFAULT '', + + -- 审计字段 + creator BIGINT NOT NULL DEFAULT 0, + updater BIGINT NOT NULL DEFAULT 0, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), + deleted_at TIMESTAMPTZ +); + +CREATE INDEX idx_wechat_config_is_active ON tb_wechat_config(is_active) WHERE deleted_at IS NULL; +CREATE INDEX idx_wechat_config_provider_type ON tb_wechat_config(provider_type) WHERE deleted_at IS NULL; +CREATE INDEX idx_wechat_config_deleted_at ON tb_wechat_config(deleted_at); + +COMMENT ON TABLE tb_wechat_config IS '微信参数配置表'; +COMMENT ON COLUMN tb_wechat_config.name IS '配置名称'; +COMMENT ON COLUMN tb_wechat_config.provider_type IS '支付渠道类型: wechat-微信直连, fuiou-富友'; +COMMENT ON COLUMN tb_wechat_config.is_active IS '是否激活(全局唯一)'; diff --git a/migrations/000079_add_payment_config_id_to_order.down.sql b/migrations/000079_add_payment_config_id_to_order.down.sql new file mode 100644 index 0000000..2a5e42f --- /dev/null +++ b/migrations/000079_add_payment_config_id_to_order.down.sql @@ -0,0 +1,2 @@ +DROP INDEX IF EXISTS idx_order_payment_config_id; +ALTER TABLE tb_order DROP COLUMN IF EXISTS payment_config_id; diff --git a/migrations/000079_add_payment_config_id_to_order.up.sql b/migrations/000079_add_payment_config_id_to_order.up.sql new file mode 100644 index 0000000..f4baec7 --- /dev/null +++ b/migrations/000079_add_payment_config_id_to_order.up.sql @@ -0,0 +1,4 @@ +-- tb_order 新增 payment_config_id 列 +ALTER TABLE tb_order ADD COLUMN payment_config_id BIGINT; +COMMENT ON COLUMN tb_order.payment_config_id IS '支付配置ID(关联tb_wechat_config.id)'; +CREATE INDEX idx_order_payment_config_id ON tb_order(payment_config_id) WHERE payment_config_id IS NOT NULL; diff --git a/migrations/000080_add_payment_config_id_to_asset_recharge.down.sql b/migrations/000080_add_payment_config_id_to_asset_recharge.down.sql new file mode 100644 index 0000000..8fd02f4 --- /dev/null +++ b/migrations/000080_add_payment_config_id_to_asset_recharge.down.sql @@ -0,0 +1,2 @@ +DROP INDEX IF EXISTS idx_asset_recharge_payment_config_id; +ALTER TABLE tb_asset_recharge_record DROP COLUMN IF EXISTS payment_config_id; diff --git a/migrations/000080_add_payment_config_id_to_asset_recharge.up.sql b/migrations/000080_add_payment_config_id_to_asset_recharge.up.sql new file mode 100644 index 0000000..9084ec2 --- /dev/null +++ b/migrations/000080_add_payment_config_id_to_asset_recharge.up.sql @@ -0,0 +1,4 @@ +-- tb_asset_recharge_record 新增 payment_config_id 列 +ALTER TABLE tb_asset_recharge_record ADD COLUMN payment_config_id BIGINT; +COMMENT ON COLUMN tb_asset_recharge_record.payment_config_id IS '支付配置ID(关联tb_wechat_config.id)'; +CREATE INDEX idx_asset_recharge_payment_config_id ON tb_asset_recharge_record(payment_config_id) WHERE payment_config_id IS NOT NULL; diff --git a/migrations/000081_add_payment_config_id_to_agent_recharge.down.sql b/migrations/000081_add_payment_config_id_to_agent_recharge.down.sql new file mode 100644 index 0000000..c793b67 --- /dev/null +++ b/migrations/000081_add_payment_config_id_to_agent_recharge.down.sql @@ -0,0 +1,3 @@ +-- 回滚:删除代理充值记录的支付配置ID字段 +DROP INDEX IF EXISTS idx_agent_recharge_payment_config_id; +ALTER TABLE tb_agent_recharge_record DROP COLUMN IF EXISTS payment_config_id; diff --git a/migrations/000081_add_payment_config_id_to_agent_recharge.up.sql b/migrations/000081_add_payment_config_id_to_agent_recharge.up.sql new file mode 100644 index 0000000..1991876 --- /dev/null +++ b/migrations/000081_add_payment_config_id_to_agent_recharge.up.sql @@ -0,0 +1,4 @@ +-- 为代理充值记录添加支付配置ID字段 +ALTER TABLE tb_agent_recharge_record ADD COLUMN payment_config_id BIGINT; +COMMENT ON COLUMN tb_agent_recharge_record.payment_config_id IS '支付配置ID(关联tb_wechat_config.id)'; +CREATE INDEX idx_agent_recharge_payment_config_id ON tb_agent_recharge_record(payment_config_id) WHERE payment_config_id IS NOT NULL;