Files
junhong_cmp_fiber/internal/model/dto/polling_cleanup_dto.go
huang 18daeae65a
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m17s
feat: 钱包系统分离 - 代理钱包与卡钱包完全隔离
## 变更概述
将统一钱包系统拆分为代理钱包和卡钱包两个独立系统,实现数据表和代码层面的完全隔离。

## 数据库变更
- 新增 6 张表:tb_agent_wallet、tb_agent_wallet_transaction、tb_agent_recharge_record、tb_card_wallet、tb_card_wallet_transaction、tb_card_recharge_record
- 删除 3 张旧表:tb_wallet、tb_wallet_transaction、tb_recharge_record
- 代理钱包:按 (shop_id, wallet_type) 唯一标识,支持主钱包和分佣钱包
- 卡钱包:按 (resource_type, resource_id) 唯一标识,支持物联网卡和设备

## 代码变更
- Model 层:新增 AgentWallet、AgentWalletTransaction、AgentRechargeRecord、CardWallet、CardWalletTransaction、CardRechargeRecord 模型
- Store 层:新增 6 个独立 Store,支持事务、乐观锁、Redis 缓存
- Service 层:重构 commission_calculation、commission_withdrawal、order、recharge 等 8 个服务
- Bootstrap 层:更新 Store 和 Service 依赖注入
- 常量层:按钱包类型重新组织常量和 Redis Key 生成函数

## 技术特性
- 乐观锁:使用 version 字段防止并发冲突
- 多租户:支持 shop_id_tag 和 enterprise_id_tag 过滤
- 事务管理:所有余额变动使用事务保证 ACID
- 缓存策略:Cache-Aside 模式,余额变动后删除缓存

## 业务影响
- 代理钱包和卡钱包业务完全隔离,互不影响
- 为独立监控、优化、扩展打下基础
- 提升代理钱包的稳定性和独立性

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-25 09:51:00 +08:00

104 lines
5.4 KiB
Go
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.
package dto
import "time"
// CreateDataCleanupConfigReq 创建数据清理配置请求
type CreateDataCleanupConfigReq struct {
TargetTable string `json:"table_name" validate:"required,max=100" description:"表名"`
RetentionDays int `json:"retention_days" validate:"required,min=7" description:"保留天数最少7天"`
BatchSize int `json:"batch_size" validate:"omitempty,min=1000,max=100000" description:"每批删除条数默认10000"`
Description string `json:"description" validate:"omitempty,max=500" description:"配置说明"`
}
// UpdateDataCleanupConfigReq 更新数据清理配置请求Body 部分)
type UpdateDataCleanupConfigReq struct {
RetentionDays *int `json:"retention_days" validate:"omitempty,min=7" description:"保留天数"`
BatchSize *int `json:"batch_size" validate:"omitempty,min=1000,max=100000" description:"每批删除条数"`
Enabled *int `json:"enabled" validate:"omitempty,oneof=0 1" description:"是否启用0-禁用1-启用"`
Description *string `json:"description" validate:"omitempty,max=500" description:"配置说明"`
}
// UpdateDataCleanupConfigParams 更新数据清理配置参数(包含路径参数和 Body
type UpdateDataCleanupConfigParams struct {
IDReq
UpdateDataCleanupConfigReq
}
// DataCleanupConfigResp 数据清理配置响应
type DataCleanupConfigResp struct {
ID uint `json:"id" description:"配置ID"`
TargetTable string `json:"table_name" description:"表名"`
RetentionDays int `json:"retention_days" description:"保留天数"`
BatchSize int `json:"batch_size" description:"每批删除条数"`
Enabled int `json:"enabled" description:"是否启用0-禁用1-启用"`
Description string `json:"description" description:"配置说明"`
CreatedAt time.Time `json:"created_at" description:"创建时间"`
UpdatedAt time.Time `json:"updated_at" description:"更新时间"`
UpdatedBy *uint `json:"updated_by,omitempty" description:"更新人ID"`
}
// DataCleanupConfigListResp 数据清理配置列表响应
type DataCleanupConfigListResp struct {
Items []*DataCleanupConfigResp `json:"items" description:"配置列表"`
}
// DataCleanupLogResp 数据清理日志响应
type DataCleanupLogResp struct {
ID uint `json:"id" description:"日志ID"`
TargetTable string `json:"table_name" description:"表名"`
CleanupType string `json:"cleanup_type" description:"清理类型scheduled/manual"`
RetentionDays int `json:"retention_days" description:"保留天数"`
DeletedCount int64 `json:"deleted_count" description:"删除记录数"`
DurationMs int64 `json:"duration_ms" description:"执行耗时(毫秒)"`
Status string `json:"status" description:"状态success/failed/running"`
ErrorMessage string `json:"error_message,omitempty" description:"错误信息"`
StartedAt time.Time `json:"started_at" description:"开始时间"`
CompletedAt *time.Time `json:"completed_at,omitempty" description:"完成时间"`
TriggeredBy *uint `json:"triggered_by,omitempty" description:"触发人ID"`
}
// DataCleanupLogListResp 数据清理日志列表响应
type DataCleanupLogListResp struct {
Items []*DataCleanupLogResp `json:"items" description:"日志列表"`
Total int64 `json:"total" description:"总数"`
Page int `json:"page" description:"当前页"`
PageSize int `json:"page_size" description:"每页数量"`
TotalPages int `json:"total_pages" description:"总页数"`
}
// ListDataCleanupLogReq 查询数据清理日志请求
type ListDataCleanupLogReq struct {
TableName string `json:"table_name" query:"table_name" description:"表名筛选"`
Page int `json:"page" query:"page" validate:"omitempty,min=1" description:"页码"`
PageSize int `json:"page_size" query:"page_size" validate:"omitempty,min=1,max=100" description:"每页数量"`
}
// DataCleanupPreviewResp 数据清理预览响应
type DataCleanupPreviewResp struct {
Items []*DataCleanupPreviewItem `json:"items" description:"预览列表"`
}
// DataCleanupPreviewItem 数据清理预览项
type DataCleanupPreviewItem struct {
TableName string `json:"table_name" description:"表名"`
RetentionDays int `json:"retention_days" description:"保留天数"`
RecordCount int64 `json:"record_count" description:"待清理记录数"`
Description string `json:"description" description:"配置说明"`
}
// DataCleanupProgressResp 数据清理进度响应
type DataCleanupProgressResp struct {
IsRunning bool `json:"is_running" description:"是否正在运行"`
CurrentTable string `json:"current_table,omitempty" description:"当前清理的表"`
TotalTables int `json:"total_tables" description:"总表数"`
ProcessedTables int `json:"processed_tables" description:"已处理表数"`
TotalDeleted int64 `json:"total_deleted" description:"已删除记录数"`
StartedAt *time.Time `json:"started_at,omitempty" description:"开始时间"`
LastLog *DataCleanupLogResp `json:"last_log,omitempty" description:"最近一条清理日志"`
}
// TriggerDataCleanupReq 手动触发数据清理请求
type TriggerDataCleanupReq struct {
TableName string `json:"table_name" validate:"omitempty,max=100" description:"表名,为空则清理所有"`
}