fix: analusis sync register
CI / changes (push) Successful in 1m29s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 1s
CI / aiserver (push) Successful in 0s
CI / analysis (push) Successful in 35s
CI / bff (push) Successful in 0s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 1s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 1s
CI / message (push) Successful in 0s
CI / order (push) Successful in 1s
CI / payment (push) Successful in 0s
CI / percutaneous (push) Successful in 0s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 0s
CI / store (push) Successful in 0s
CI / support (push) Successful in 1s
CI / task (push) Successful in 0s
CI / water (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
CI / ws (push) Successful in 1s
CI / changes (push) Successful in 1m29s
CI / ad (push) Successful in 0s
CI / admin (push) Successful in 1s
CI / aiserver (push) Successful in 0s
CI / analysis (push) Successful in 35s
CI / bff (push) Successful in 0s
CI / chore (push) Successful in 0s
CI / equipment (push) Successful in 1s
CI / express (push) Successful in 0s
CI / factory (push) Successful in 1s
CI / message (push) Successful in 0s
CI / order (push) Successful in 1s
CI / payment (push) Successful in 0s
CI / percutaneous (push) Successful in 0s
CI / product (push) Successful in 0s
CI / record (push) Successful in 0s
CI / sale (push) Successful in 0s
CI / store (push) Successful in 0s
CI / support (push) Successful in 1s
CI / task (push) Successful in 0s
CI / water (push) Successful in 0s
CI / user (push) Successful in 0s
CI / wecom (push) Successful in 0s
CI / ws (push) Successful in 1s
This commit is contained in:
@@ -2,10 +2,14 @@ package analysisuserlogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"lone-services/pkg/modelbase"
|
||||
"lone-services/pkg/utils"
|
||||
analysis "lone-services/rpc/analysis/pb"
|
||||
userpb "lone-services/rpc/user/pb"
|
||||
"lone-services/services/analysis/internal/logic/common"
|
||||
"lone-services/services/analysis/internal/model"
|
||||
"lone-services/services/analysis/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
@@ -26,7 +30,7 @@ func NewUserStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserSt
|
||||
}
|
||||
|
||||
func (l *UserStatusLogic) UserStatus(in *analysis.UserStatusReq) (*analysis.Response, error) {
|
||||
bizId, _, fail := common.RequireAnalysisUserId(l.ctx)
|
||||
bizId, loginUser, fail := common.RequireAnalysisUserId(l.ctx)
|
||||
if fail != nil {
|
||||
return fail, nil
|
||||
}
|
||||
@@ -40,8 +44,10 @@ func (l *UserStatusLogic) UserStatus(in *analysis.UserStatusReq) (*analysis.Resp
|
||||
return common.FailResponse(utils.ErrorNotFund), nil
|
||||
}
|
||||
|
||||
isRegistered := l.syncRegisteredFromUser(bizId, loginUser.ID, row.IsRegistered)
|
||||
|
||||
status := utils.NumberOne
|
||||
if row.IsRegistered == uint8(utils.StatusOk) {
|
||||
if isRegistered == uint8(utils.StatusOk) {
|
||||
status = utils.NumberTwo
|
||||
}
|
||||
if row.IsFaceVerified == uint8(utils.StatusOk) {
|
||||
@@ -53,3 +59,42 @@ func (l *UserStatusLogic) UserStatus(in *analysis.UserStatusReq) (*analysis.Resp
|
||||
|
||||
return common.OkResponse(map[string]int{"status": status}), nil
|
||||
}
|
||||
|
||||
func (l *UserStatusLogic) syncRegisteredFromUser(bizId, userId int64, isRegistered uint8) uint8 {
|
||||
if isRegistered == uint8(utils.StatusOk) {
|
||||
return isRegistered
|
||||
}
|
||||
if isRegistered != uint8(utils.StatusFail) {
|
||||
return isRegistered
|
||||
}
|
||||
if userId < utils.NumberOne || l.svcCtx.UserSvcName == utils.StringEmpty {
|
||||
return isRegistered
|
||||
}
|
||||
|
||||
cli, err := svc.GetRpcClient(l.svcCtx.UserSvcName)
|
||||
if err != nil {
|
||||
l.Errorf("user status get user rpc: %v", err)
|
||||
return isRegistered
|
||||
}
|
||||
info, err := userpb.NewUserClient(cli.Conn()).InternalGetUserInfo(l.ctx, &userpb.InternalGetUserInfoReq{
|
||||
UserId: userId,
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorf("user status get user info: %v", err)
|
||||
return isRegistered
|
||||
}
|
||||
if info == nil || info.Mobile == utils.StringEmpty {
|
||||
return isRegistered
|
||||
}
|
||||
|
||||
_, err = model.UserModel{}.Init().Edit(modelbase.Params{
|
||||
Eq: map[string]string{"id": strconv.FormatInt(bizId, utils.NumberTen)},
|
||||
}, map[string]interface{}{
|
||||
"is_registered": uint8(utils.NumberOne),
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorf("user status set registered: %v", err)
|
||||
return isRegistered
|
||||
}
|
||||
return uint8(utils.StatusOk)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user