All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m18s
主要变更: - 重构分配模型:从加价模式(pricing_mode/pricing_value)改为返佣模式(base_commission + tier_commission) - 删除独立的 my_package 接口,统一到 /api/admin/packages(通过数据权限自动过滤) - 新增批量分配和批量调价功能,支持事务和性能优化 - 新增配置版本管理,订单创建时锁定返佣配置 - 新增成本价历史记录,支持审计和纠纷处理 - 新增统计缓存系统(Redis + 异步任务),优化梯度返佣计算性能 - 删除冗余的梯度佣金独立 CRUD 接口(合并到分配配置中) - 归档 3 个已完成的 OpenSpec changes 并同步 8 个新 capabilities 到 main specs 技术细节: - 数据库迁移:000026_refactor_shop_package_allocation - 新增 Store:AllocationConfigStore, PriceHistoryStore, CommissionStatsStore - 新增 Service:BatchAllocationService, BatchPricingService, CommissionStatsService - 新增异步任务:统计更新、定时同步、周期归档 - 测试覆盖:批量操作集成测试、梯度佣金 CRUD 清理验证 影响: - API 变更:删除 4 个梯度 CRUD 接口(POST/GET/PUT/DELETE /:id/tiers) - API 新增:批量分配、批量调价接口 - 数据模型:重构 shop_series_allocation 表结构 - 性能优化:批量操作使用 CreateInBatches,统计使用 Redis 缓存 相关文档: - openspec/changes/archive/2026-01-28-refactor-shop-package-allocation/ - openspec/specs/agent-available-packages/ - openspec/specs/allocation-config-versioning/ - 等 8 个新 capability specs
149 lines
5.0 KiB
Go
149 lines
5.0 KiB
Go
package constants
|
||
|
||
import "fmt"
|
||
|
||
// ========================================
|
||
// 认证相关 Redis Key
|
||
// ========================================
|
||
|
||
// RedisAuthTokenKey 生成访问令牌的 Redis 键
|
||
// 用途:存储用户 access token 信息
|
||
// 过期时间:24 小时(可配置)
|
||
func RedisAuthTokenKey(token string) string {
|
||
return fmt.Sprintf("auth:token:%s", token)
|
||
}
|
||
|
||
// RedisRefreshTokenKey 生成刷新令牌的 Redis 键
|
||
// 用途:存储用户 refresh token 信息
|
||
// 过期时间:7 天(可配置)
|
||
func RedisRefreshTokenKey(token string) string {
|
||
return fmt.Sprintf("auth:refresh:%s", token)
|
||
}
|
||
|
||
// RedisUserTokensKey 生成用户令牌列表的 Redis 键
|
||
// 用途:维护用户的所有有效 token 列表(Set 结构)
|
||
// 过期时间:7 天(可配置)
|
||
func RedisUserTokensKey(userID uint) string {
|
||
return fmt.Sprintf("auth:user:%d:tokens", userID)
|
||
}
|
||
|
||
// RedisRateLimitKey 生成限流的 Redis 键
|
||
func RedisRateLimitKey(ip string) string {
|
||
return fmt.Sprintf("ratelimit:%s", ip)
|
||
}
|
||
|
||
// RedisTaskLockKey 生成任务锁的 Redis 键
|
||
// 用途:幂等性控制,防止重复执行
|
||
// 过期时间:24 小时
|
||
func RedisTaskLockKey(requestID string) string {
|
||
return fmt.Sprintf("task:lock:%s", requestID)
|
||
}
|
||
|
||
// RedisTaskStatusKey 生成任务状态的 Redis 键
|
||
// 用途:存储任务执行状态
|
||
// 过期时间:7 天
|
||
func RedisTaskStatusKey(taskID string) string {
|
||
return fmt.Sprintf("task:status:%s", taskID)
|
||
}
|
||
|
||
// RedisShopSubordinatesKey 生成店铺下级 ID 列表的 Redis 键
|
||
// 用途:缓存递归查询的下级店铺 ID 列表
|
||
// 过期时间:30 分钟
|
||
func RedisShopSubordinatesKey(shopID uint) string {
|
||
return fmt.Sprintf("shop:subordinates:%d", shopID)
|
||
}
|
||
|
||
// RedisVerificationCodeKey 生成验证码的 Redis 键
|
||
// 用途:存储手机验证码
|
||
// 过期时间:5 分钟
|
||
func RedisVerificationCodeKey(phone string) string {
|
||
return fmt.Sprintf("verification:code:%s", phone)
|
||
}
|
||
|
||
// RedisVerificationCodeLimitKey 生成验证码发送频率限制的 Redis 键
|
||
// 用途:限制验证码发送频率
|
||
// 过期时间:60 秒
|
||
func RedisVerificationCodeLimitKey(phone string) string {
|
||
return fmt.Sprintf("verification:limit:%s", phone)
|
||
}
|
||
|
||
// ========================================
|
||
// 钱包相关 Redis Key
|
||
// ========================================
|
||
|
||
// RedisWalletLockKey 生成钱包操作锁的 Redis 键
|
||
// 用途:钱包余额变更时的分布式锁,防止并发冲突
|
||
// 过期时间:10 秒
|
||
func RedisWalletLockKey(walletID uint) string {
|
||
return fmt.Sprintf("wallet:lock:%d", walletID)
|
||
}
|
||
|
||
// RedisWalletBalanceKey 生成钱包余额缓存的 Redis 键
|
||
// 用途:缓存钱包余额,减少数据库查询
|
||
// 过期时间:5 分钟
|
||
func RedisWalletBalanceKey(walletID uint) string {
|
||
return fmt.Sprintf("wallet:balance:%d", walletID)
|
||
}
|
||
|
||
// RedisRechargeOrderKey 生成充值订单缓存的 Redis 键
|
||
// 用途:充值订单状态查询缓存
|
||
// 过期时间:1 小时
|
||
func RedisRechargeOrderKey(rechargeNo string) string {
|
||
return fmt.Sprintf("recharge:order:%s", rechargeNo)
|
||
}
|
||
|
||
// RedisWalletTransactionKey 生成钱包交易幂等性的 Redis 键
|
||
// 用途:防止重复交易
|
||
// 过期时间:24 小时
|
||
func RedisWalletTransactionKey(requestID string) string {
|
||
return fmt.Sprintf("wallet:transaction:%s", requestID)
|
||
}
|
||
|
||
// ========================================
|
||
// 标签相关 Redis Key
|
||
// ========================================
|
||
|
||
// RedisTagCacheKey 生成标签缓存的 Redis 键
|
||
// 用途:缓存热门标签列表
|
||
// 过期时间:1 小时
|
||
func RedisTagCacheKey() string {
|
||
return "tag:cache:list"
|
||
}
|
||
|
||
// RedisResourceTagsKey 生成资源标签关联缓存的 Redis 键
|
||
// 用途:缓存资源的标签列表
|
||
// 过期时间:30 分钟
|
||
func RedisResourceTagsKey(resourceType string, resourceID uint) string {
|
||
return fmt.Sprintf("resource:tags:%s:%d", resourceType, resourceID)
|
||
}
|
||
|
||
// ========================================
|
||
// 权限相关 Redis Key
|
||
// ========================================
|
||
|
||
// RedisUserPermissionsKey 生成用户权限列表缓存的 Redis 键
|
||
// 用途:缓存用户的所有权限列表(包含 permCode 和 platform 信息)
|
||
// 格式:JSON 数组 [{"perm_code":"user:list","platform":"web"},...]
|
||
// 过期时间:30 分钟
|
||
func RedisUserPermissionsKey(userID uint) string {
|
||
return fmt.Sprintf("permission:user:%d:list", userID)
|
||
}
|
||
|
||
// ========================================
|
||
// 佣金统计相关 Redis Key
|
||
// ========================================
|
||
|
||
// RedisCommissionStatsKey 生成佣金统计缓存的 Redis 键
|
||
// 用途:缓存梯度返佣统计数据(Hash 结构: total_count, total_amount)
|
||
// 过期时间:周期结束后 7 天
|
||
func RedisCommissionStatsKey(allocationID uint, period string) string {
|
||
return fmt.Sprintf("commission:stats:%d:%s", allocationID, period)
|
||
}
|
||
|
||
// RedisCommissionStatsLockKey 生成佣金统计同步锁的 Redis 键
|
||
// 用途:定时同步任务的分布式锁,防止并发同步
|
||
// 过期时间:5 分钟
|
||
func RedisCommissionStatsLockKey() string {
|
||
return "commission:stats:sync:lock"
|
||
}
|