f
This commit is contained in:
@@ -140,6 +140,7 @@ type (
|
||||
AccessToken string `json:"accessToken"`
|
||||
AccessExpire int64 `json:"accessExpire"`
|
||||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
IsAgent bool `json:"is_agent,optional"` // 该手机号已是代理时为 true,前端可据此自动进入代理中心
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -105,13 +105,14 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
|
||||
userID = user.Id
|
||||
}
|
||||
|
||||
// 3. 检查是否已是代理
|
||||
// 3. 检查是否已是代理(H5 已注册过代理时,小程序绑定手机后视为自动登录,此处直接返回成功)
|
||||
existingAgent, err := l.svcCtx.AgentModel.FindOneByUserId(transCtx, userID)
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
|
||||
}
|
||||
if existingAgent != nil {
|
||||
return errors.Wrapf(xerr.NewErrMsg("您已经是代理"), "")
|
||||
// 已是代理(如 H5 已注册):不报错,事务外会统一发放 token 并返回成功,视为自动登录
|
||||
return nil
|
||||
}
|
||||
|
||||
var inviteCodeModel *model.AgentInviteCode
|
||||
|
||||
@@ -96,7 +96,7 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成Token失败: %v", err)
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
return &types.BindMobileResp{AccessToken: token, AccessExpire: now + l.svcCtx.Config.JwtAuth.AccessExpire, RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter}, nil
|
||||
return l.bindMobileResp(token, now, finalUserID), nil
|
||||
}
|
||||
|
||||
// 手机号已存在:进入账号合并或快捷登录流程
|
||||
@@ -123,7 +123,7 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成Token失败: %v", err)
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
return &types.BindMobileResp{AccessToken: token, AccessExpire: now + l.svcCtx.Config.JwtAuth.AccessExpire, RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter}, nil
|
||||
return l.bindMobileResp(token, now, finalUserID), nil
|
||||
}
|
||||
|
||||
// 微信唯一性约束(按类型):
|
||||
@@ -238,5 +238,19 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成Token失败: %v", err)
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
return &types.BindMobileResp{AccessToken: token, AccessExpire: now + l.svcCtx.Config.JwtAuth.AccessExpire, RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter}, nil
|
||||
return l.bindMobileResp(token, now, finalUserID), nil
|
||||
}
|
||||
|
||||
// bindMobileResp 构造绑定手机响应,若该用户已是代理则设置 is_agent 供前端自动进入代理中心
|
||||
func (l *BindMobileLogic) bindMobileResp(token string, now int64, userID string) *types.BindMobileResp {
|
||||
resp := &types.BindMobileResp{
|
||||
AccessToken: token,
|
||||
AccessExpire: now + l.svcCtx.Config.JwtAuth.AccessExpire,
|
||||
RefreshAfter: now + l.svcCtx.Config.JwtAuth.RefreshAfter,
|
||||
}
|
||||
agent, err := l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||
if err == nil && agent != nil {
|
||||
resp.IsAgent = true
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
@@ -1291,6 +1291,7 @@ type BindMobileResp struct {
|
||||
AccessToken string `json:"accessToken"`
|
||||
AccessExpire int64 `json:"accessExpire"`
|
||||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
IsAgent bool `json:"is_agent,optional"` // 该手机号已是代理时为 true,前端可据此自动进入代理中心
|
||||
}
|
||||
|
||||
type CheckFeatureWhitelistStatusReq struct {
|
||||
|
||||
Reference in New Issue
Block a user