This commit is contained in:
Mrx
2026-01-30 11:39:28 +08:00
parent c64b22ab05
commit 76784c3c1b
19 changed files with 717 additions and 46 deletions

View File

@@ -1,7 +1,7 @@
# 设置输出编码为UTF-8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
# 数据库连接信息 - 修改了URL格式
$DB_URL = "tyc:5vg67b3UNHu8@(127.0.0.1:21001)/tyc"
$DB_URL = "tyc:5vg67b3UNHu8@tcp(127.0.0.1:22001)/tyc"
$OUTPUT_DIR = "./model"
$TEMPLATE_DIR = "../template"
@@ -11,7 +11,7 @@ $tables = @(
# "agent_active_stat",
# "agent_audit",
# "agent_closure",
"agent_commission"
# "agent_commission"
# "agent_wallet_transaction"
# "agent_commission_deduction"
# "agent_link",
@@ -54,10 +54,11 @@ $tables = @(
# "admin_promotion_link_stats_total"
# "admin_promotion_link_stats_history"
# "admin_promotion_order"
"query_user_record"
)
# 为每个表生成模型
foreach ($table in $tables) {
goctl model mysql datasource -url="tyc:5vg67b3UNHu8@tcp(127.0.0.1:21001)/tyc" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero
goctl model mysql datasource -url="tyc:5vg67b3UNHu8@tcp(127.0.0.1:22001)/tyc" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero
}

View File

@@ -0,0 +1,42 @@
-- 查询用户记录表
-- 用途:记录用户查询时输入的姓名、身份证、手机号,以及支付订单号等,用于通过查询条件追溯订单信息
-- 执行说明:在目标数据库执行此脚本创建表
--
-- 使用说明(需在业务代码中接入):
-- 1. 用户提交查询时queryservicelogic.CacheData 之后INSERT 记录 name, id_card, mobile已 AES-ECB+Base64 加密), product, query_no, user_id, agent_identifier
-- 2. 用户发起支付并创建 order 时paymentlogic.QueryOrderPayment 中 Insert order 之后UPDATE 本表 SET order_id WHERE query_no=outTradeNo
-- 3. 支付回调成功更新 order 后alipaycallbacklogic/wechatpaycallbacklogicUPDATE 本表 SET platform_order_id WHERE query_no=orderNo
--
-- 敏感字段加密name、id_card、mobile 使用 pkg/lzkit/crypto 的 AES-ECB+Base64 加密后入库,密钥为 config.Encrypt.SecretKeyhex
-- 解密:姓名 crypto.AesEcbDecrypt(rec.Name, key);身份证 crypto.DecryptIDCard(rec.IdCard, key);手机 crypto.DecryptMobile(rec.Mobile, secretKey)。
CREATE TABLE `query_user_record` (
`id` bigint NOT NULL AUTO_INCREMENT,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`delete_time` datetime DEFAULT NULL COMMENT '删除时间',
`del_state` tinyint NOT NULL DEFAULT '0',
`version` bigint NOT NULL DEFAULT '0' COMMENT '版本号',
/* 业务字段 - 用户查询输入name、id_card、mobile 为 AES-ECB+Base64 密文) */
`user_id` bigint NOT NULL DEFAULT '0' COMMENT '用户ID',
`name` varchar(256) NOT NULL DEFAULT '' COMMENT '姓名密文AES-ECB+Base64',
`id_card` varchar(128) NOT NULL DEFAULT '' COMMENT '身份证号密文AES-ECB+Base64',
`mobile` varchar(128) NOT NULL DEFAULT '' COMMENT '手机号密文AES-ECB+Base64',
`product` varchar(50) NOT NULL DEFAULT '' COMMENT '产品类型,如 marriage/homeservice/riskassessment 等',
/* 关联字段 - 查询单号与订单 */
`query_no` varchar(64) NOT NULL DEFAULT '' COMMENT '查询单号(与 order.order_no 一致,如 Q_xxx用户提交查询时生成',
`order_id` bigint NOT NULL DEFAULT '0' COMMENT '订单ID关联 order 表,用户发起支付并创建订单后写入',
`platform_order_id` varchar(64) DEFAULT NULL COMMENT '支付平台订单号(支付宝/微信),支付成功后由回调写入',
`agent_identifier` varchar(255) DEFAULT NULL COMMENT '代理标识,代理渠道时有值',
PRIMARY KEY (`id`),
KEY `idx_user_id` (`user_id`),
KEY `idx_id_card` (`id_card`),
KEY `idx_mobile` (`mobile`),
KEY `idx_query_no` (`query_no`),
KEY `idx_order_id` (`order_id`),
KEY `idx_platform_order_id` (`platform_order_id`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='查询用户记录表:姓名、身份证、手机号、支付订单号等,用于通过查询信息追溯订单';