fix(代理分销注册): 验证码改为落库成功后消费并细化失败原因
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 12m54s

公开扫码注册原先在审批准备前就消费短信验证码,落库前的任何失败都会烧掉验证码,
客户重试只能得到统一的“分销码不可用”,掩盖了真实失败原因。

- 验证码校验与消费拆分为 CheckCode 与 ConsumeCode,注册记录与审批实例落库成功后才原子消费;
  校验不消费、消费一次性,落库前失败时同一验证码可直接重试
- 分销码无效、所属店铺已停用、上级店铺缺少启用的主账号、验证码错误分别返回各自错误码与提示
- 注册必填字段缺失与请求参数校验失败提示定位到具体字段
- 同步公开接口描述与 agent-distribution-withdrawal 主 Spec 行为契约
This commit is contained in:
2026-09-17 18:01:47 +08:00
parent 398a5e4282
commit e8ab1f471e
7 changed files with 112 additions and 33 deletions

View File

@@ -43,9 +43,20 @@ func ValidateRegistrationInput(input RegistrationInput) (RegistrationInput, erro
input.City = strings.TrimSpace(input.City)
input.District = strings.TrimSpace(input.District)
input.Address = strings.TrimSpace(input.Address)
if input.DistributionCode == "" || input.Phone == "" || input.Username == "" ||
input.ShopName == "" || input.ShopCode == "" {
return RegistrationInput{}, errors.New(errors.CodeInvalidParam, "分销码不可用")
if input.DistributionCode == "" {
return RegistrationInput{}, errors.New(errors.CodeInvalidParam, "分销码不能为空")
}
if input.Phone == "" {
return RegistrationInput{}, errors.New(errors.CodeInvalidParam, "手机号不能为空")
}
if input.Username == "" {
return RegistrationInput{}, errors.New(errors.CodeInvalidParam, "用户名不能为空")
}
if input.ShopName == "" {
return RegistrationInput{}, errors.New(errors.CodeInvalidParam, "店铺名称不能为空")
}
if input.ShopCode == "" {
return RegistrationInput{}, errors.New(errors.CodeInvalidParam, "店铺编号不能为空")
}
if len(input.Phone) != 11 {
return RegistrationInput{}, errors.New(errors.CodeInvalidParam, "手机号格式不正确")