1、增加钱包余额

This commit is contained in:
2024-10-15 23:58:36 +08:00
parent 8609f8566d
commit fdfdbb5ff6
10 changed files with 313 additions and 285 deletions

View File

@@ -32,27 +32,30 @@ func (l *UserInfoLogic) UserInfo(in *user.UserInfoReq) (*user.UserInfoResp, erro
return nil, errors.New("用户不存在")
}
// 查询企业信息
enterprise, err := l.svcCtx.EnterpriseModel.FindOneByUserId(l.ctx, users.Id)
if err != nil && !errors.Is(err, sql.ErrNoRows) {
return nil, errors.New("failed to query enterprise auth info")
}
if enterprise == nil {
if users.AuthStatus == "approved" {
enterprise, findEntErr := l.svcCtx.EnterpriseModel.FindOneByUserId(l.ctx, users.Id)
if findEntErr != nil && !errors.Is(findEntErr, sql.ErrNoRows) {
return nil, errors.New("failed to query enterprise auth info")
}
wallet, findWalletErr := l.svcCtx.WalletsModel.FindOne(l.ctx, in.UserId)
if findWalletErr != nil {
return nil, findWalletErr
}
// 正常返回用户和企业信息
return &user.UserInfoResp{
Username: users.Username,
Phone: users.Phone,
EnterpriseAuthStatus: users.AuthStatus,
EnterpriseName: enterprise.EnterpriseName,
CreditCode: enterprise.CreditCode,
LegalPerson: enterprise.LegalPerson,
Balance: wallet.Balance,
}, nil
}
// 正常返回用户和企业信息
return &user.UserInfoResp{
Username: users.Username,
Phone: users.Phone,
EnterpriseAuthStatus: users.AuthStatus,
EnterpriseName: enterprise.EnterpriseName,
CreditCode: enterprise.CreditCode,
LegalPerson: enterprise.LegalPerson,
}, nil
}

View File

@@ -25,7 +25,12 @@ func NewGetWalletLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWall
// 查询钱包信息
func (l *GetWalletLogic) GetWallet(in *user.GetWalletRequest) (*user.GetWalletResponse, error) {
// todo: add your logic here and delete this line
return &user.GetWalletResponse{}, nil
wallet, err := l.svcCtx.WalletsModel.FindOne(l.ctx, in.Id)
if err != nil {
return nil, err
}
return &user.GetWalletResponse{
UserId: wallet.UserId,
Balance: wallet.Balance,
}, nil
}