规范: 新增枚举与状态字段规范并修复代理充值状态描述错误
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled

- 新增 docs/enum-status-standards.md:完整的枚举/状态规范,涵盖 int vs string 选择、起始值约定、description 格式统一、constants 唯一真相来源、Response DTO 必须提供 status_name
- 更新 dto-standards SKILL.md:加入枚举规范要点,AI 写 DTO 时自动触发
- 更新 AGENTS.md:常量管理章节和 Code Review 检查清单各加入枚举检查项
- 修复 agent_recharge_dto.go:description 从错误的 3 个状态改为正确的 5 个状态(原 3:已取消 实为 3:已完成)
- 修复 agent_recharge service:toResponse 补充 StatusName 中文字段,防止前端映射出错
This commit is contained in:
2026-04-11 11:25:58 +08:00
parent c807b99a91
commit e9ff14df0e
5 changed files with 449 additions and 58 deletions

View File

@@ -469,6 +469,23 @@ func (s *Service) generateRechargeNo() string {
return fmt.Sprintf("%s%s%06d", constants.AgentRechargeOrderPrefix, timestamp, randomNum)
}
func agentRechargeStatusName(status int) string {
switch status {
case constants.RechargeStatusPending:
return "待支付"
case constants.RechargeStatusPaid:
return "已支付"
case constants.RechargeStatusCompleted:
return "已完成"
case constants.RechargeStatusClosed:
return "已关闭"
case constants.RechargeStatusRefunded:
return "已退款"
default:
return "未知"
}
}
// toResponse 将模型转换为响应 DTO
func toResponse(record *model.AgentRechargeRecord, shopName string) *dto.AgentRechargeResponse {
resp := &dto.AgentRechargeResponse{
@@ -480,6 +497,7 @@ func toResponse(record *model.AgentRechargeRecord, shopName string) *dto.AgentRe
Amount: record.Amount,
PaymentMethod: record.PaymentMethod,
Status: record.Status,
StatusName: agentRechargeStatusName(record.Status),
CreatedAt: record.CreatedAt.Format("2006-01-02 15:04:05"),
UpdatedAt: record.UpdatedAt.Format("2006-01-02 15:04:05"),
}