小妖用户绑定微信

This commit is contained in:
2025-07-10 10:17:20 +08:00
parent c1943e9b7e
commit 4b3dcac324

View File

@ -141,11 +141,16 @@ func (s *sUser) Login(ctx context.Context, in *model.UserLoginIn) (out *model.Us
return nil, ecode.Fail.Sub("参数错误:用户不存在")
}
// User exists, bind in.OpenId and update last login store ID
// User exists, check WxOpenId
if err := dao.Users.Ctx(ctx).Where(do.Users{XyUserId: xyUserId}).Scan(&user); err != nil {
return nil, ecode.Fail.Sub("查找用户失败")
}
userId = user.Id
if user.WxOpenId != "" && user.WxOpenId != in.OpenId {
return nil, ecode.Fail.Sub("当前微信已绑定其他微信号")
}
// Bind in.OpenId and update last login store ID
if _, err := dao.Users.Ctx(ctx).Where(do.Users{Id: userId}).Update(do.Users{
WxOpenId: in.OpenId,
LastLoginAt: gtime.Now(),