f
This commit is contained in:
@@ -36,6 +36,24 @@ func NewRegisterByInviteCodeLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
func isInPhoneRange(mobile string) bool {
|
||||
// 检查手机号长度
|
||||
if len(mobile) != 11 {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查是否为纯数字
|
||||
num, err := strconv.ParseInt(mobile, 10, 64)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查是否在指定区间内
|
||||
minPhone := int64(16000000000)
|
||||
maxPhone := int64(16000000100)
|
||||
|
||||
return num >= minPhone && num <= maxPhone
|
||||
}
|
||||
|
||||
func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByInviteCodeReq) (resp *types.RegisterByInviteCodeResp, err error) {
|
||||
l.Infof("[RegisterByInviteCode] 开始处理代理注册请求, mobile: %s, referrer: %s", req.Mobile, req.Referrer)
|
||||
@@ -49,6 +67,9 @@ func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByIn
|
||||
|
||||
// 校验验证码(开发环境下跳过;验证码 168888、143838 为测试用万能码,可跳过校验)
|
||||
if req.Code != "143838" {
|
||||
if !isInPhoneRange(req.Mobile) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请输入有效的测试手机号"), "")
|
||||
}
|
||||
redisKey := fmt.Sprintf("%s:%s", "agentApply", encryptedMobile)
|
||||
cacheCode, err := l.svcCtx.Redis.Get(redisKey)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user