feat: 实现客户端换货系统(client-exchange-system)
新增完整换货生命周期管理:后台发起 → 客户端填收货信息 → 后台发货 → 确认完成(含可选全量迁移) → 旧资产转新再销售 后台接口(7个): - POST /api/admin/exchanges(发起换货) - GET /api/admin/exchanges(换货列表) - GET /api/admin/exchanges/:id(换货详情) - POST /api/admin/exchanges/:id/ship(发货) - POST /api/admin/exchanges/:id/complete(确认完成+可选迁移) - POST /api/admin/exchanges/:id/cancel(取消) - POST /api/admin/exchanges/:id/renew(旧资产转新) 客户端接口(2个): - GET /api/c/v1/exchange/pending(查询换货通知) - POST /api/c/v1/exchange/:id/shipping-info(填写收货信息) 核心能力: - ExchangeOrder 模型与状态机(1待填写→2待发货→3已发货→4已完成,1/2可取消→5) - 全量迁移事务(11张表:钱包、套餐、标签、客户绑定等) - 旧资产转新(generation+1、状态重置、新钱包、历史隔离) - 旧 CardReplacementRecord 表改名为 legacy,is_replaced 过滤改为查新表 - 数据库迁移:000085 新建 tb_exchange_order,000086 旧表改名
This commit is contained in:
@@ -329,6 +329,24 @@ func RedisOrderCreateLockKey(carrierType string, carrierID uint) string {
|
||||
return fmt.Sprintf("order:create:lock:%s:%d", carrierType, carrierID)
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// 客户端购买相关 Redis Key
|
||||
// ========================================
|
||||
|
||||
// RedisClientPurchaseIdempotencyKey 生成客户端套餐购买幂等性检测的 Redis 键
|
||||
// 用途:防止同一个人客户对同一资产重复提交购买请求(SETNX 快速拒绝)
|
||||
// 过期时间:3 分钟
|
||||
func RedisClientPurchaseIdempotencyKey(businessKey string) string {
|
||||
return fmt.Sprintf("client:purchase:idempotency:%s", businessKey)
|
||||
}
|
||||
|
||||
// RedisClientPurchaseLockKey 生成客户端套餐购买分布式锁的 Redis 键
|
||||
// 用途:防止同一资产的购买请求并发执行
|
||||
// 过期时间:10 秒
|
||||
func RedisClientPurchaseLockKey(assetType string, assetID uint) string {
|
||||
return fmt.Sprintf("client:purchase:lock:%s:%d", assetType, assetID)
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// 设备保护期相关 Redis Key
|
||||
// ========================================
|
||||
|
||||
Reference in New Issue
Block a user