From 5ca417928565099146daaf7f6f62021c083cec5a Mon Sep 17 00:00:00 2001 From: Chang lue Tsen Date: Sat, 27 Sep 2025 10:13:41 -0400 Subject: [PATCH] feat(user): add OnlyFirstPurchase field to user creation logic --- internal/logic/auth/oauth/oAuthLoginGetTokenLogic.go | 2 +- internal/logic/auth/telephoneUserRegisterLogic.go | 3 ++- internal/logic/auth/userRegisterLogic.go | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/logic/auth/oauth/oAuthLoginGetTokenLogic.go b/internal/logic/auth/oauth/oAuthLoginGetTokenLogic.go index e84bc30..4e12d2f 100644 --- a/internal/logic/auth/oauth/oAuthLoginGetTokenLogic.go +++ b/internal/logic/auth/oauth/oAuthLoginGetTokenLogic.go @@ -357,7 +357,7 @@ func (l *OAuthLoginGetTokenLogic) register(email, avatar, method, openid, reques logger.Field("avatar", avatar), ) - userInfo = &user.User{Avatar: avatar} + userInfo = &user.User{Avatar: avatar, OnlyFirstPurchase: &l.svcCtx.Config.Invite.OnlyFirstPurchase} if err := db.Create(userInfo).Error; err != nil { l.Errorw("failed to create user record", logger.Field("request_id", requestID), diff --git a/internal/logic/auth/telephoneUserRegisterLogic.go b/internal/logic/auth/telephoneUserRegisterLogic.go index e29f3fa..6db07ee 100644 --- a/internal/logic/auth/telephoneUserRegisterLogic.go +++ b/internal/logic/auth/telephoneUserRegisterLogic.go @@ -106,7 +106,8 @@ func (l *TelephoneUserRegisterLogic) TelephoneUserRegister(req *types.TelephoneR // Generate password pwd := tool.EncodePassWord(req.Password) userInfo := &user.User{ - Password: pwd, + Password: pwd, + OnlyFirstPurchase: &l.svcCtx.Config.Invite.OnlyFirstPurchase, AuthMethods: []user.AuthMethods{ { AuthType: "mobile", diff --git a/internal/logic/auth/userRegisterLogic.go b/internal/logic/auth/userRegisterLogic.go index 221cee6..e4e01e4 100644 --- a/internal/logic/auth/userRegisterLogic.go +++ b/internal/logic/auth/userRegisterLogic.go @@ -89,7 +89,8 @@ func (l *UserRegisterLogic) UserRegister(req *types.UserRegisterRequest) (resp * // Generate password pwd := tool.EncodePassWord(req.Password) userInfo := &user.User{ - Password: pwd, + Password: pwd, + OnlyFirstPurchase: &l.svcCtx.Config.Invite.OnlyFirstPurchase, } if referer != nil { userInfo.RefererId = referer.Id