| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- package user
- import (
- "context"
- "git.i2edu.net/i2/i2-bill-api/internal/svc"
- "git.i2edu.net/i2/i2-bill-api/internal/types"
- "git.i2edu.net/i2/i2-bill-api/model"
- "git.i2edu.net/i2/i2-bill-erp/transform"
- "git.i2edu.net/i2/go-zero/core/logx"
- )
- type GetUserLogic struct {
- logx.Logger
- ctx context.Context
- svcCtx *svc.ServiceContext
- UserId int64
- SessionKey string
- }
- func NewGetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetUserLogic {
- return GetUserLogic{
- Logger: logx.WithContext(ctx),
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
- func (l *GetUserLogic) GetUser() (*types.InfoResponse, error) {
- var user model.User
- err := l.svcCtx.SqlConn.QueryRowPartial(&user, "select id, erp_id, avatar, birthday, username, nickname, gender, mobile from i2bill_user where `id` = ? limit 1", l.UserId)
- if err != nil {
- logx.Error(err)
- return nil, err
- }
- // 每次都去查找, 暂时没有绑定 erp mk
- // resp, err := l.svcCtx.Transformer.GetUser(l.ctx, &transform.UserRequest{Id: user.ErpId, Phone: user.Mobile})
- resp, err := l.svcCtx.Transformer.GetUser(l.ctx, &transform.UserRequest{Phone: user.Mobile})
- if err != nil {
- logx.Error(err)
- return nil, err
- }
- if resp.ErpRoleType != 1 {
- //是不是 兼职
- res, err := l.svcCtx.DB.SQL("select * from i2bill_mkt_part_time_user where del_flag = 0 and user_id = ? and check_state = ?", l.UserId, 57).Query().List()
- if err != nil {
- logx.Error(err)
- return nil, err
- }
- if len(res) > 0 {
- resp.ErpRoleType = 2
- }
- }
- info := &types.InfoResponse{}
- info.ID = user.Id
- info.Avatar = user.Avatar
- info.Birthday = user.Birthday
- info.NickName = user.Nickname
- info.Mobile = user.Mobile
- info.UserName = resp.UserName
- info.Gender = resp.Gender
- info.CityName = resp.CityName
- info.ErpRoleType = resp.ErpRoleType
- return info, nil
- }
|