...
|
...
|
@@ -196,25 +196,33 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques |
|
|
UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
|
|
|
company *domain.Company
|
|
|
user *domain.Users
|
|
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
|
|
)
|
|
|
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
rsp = &protocol.UserInfoResponse{}
|
|
|
rspMap := make(map[string]interface{})
|
|
|
|
|
|
// 获取合伙人信息
|
|
|
funcPartnerInfo := func() {
|
|
|
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": header.UserId}); err != nil {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
var miniProgram map[string]interface{}
|
|
|
|
|
|
if len(company.Applets) > 0 {
|
|
|
if company.Applets[0].Valid() {
|
|
|
miniProgram = make(map[string]interface{})
|
...
|
...
|
@@ -228,6 +236,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques |
|
|
miniProgram["title"] = company.Applets[0].Name
|
|
|
}
|
|
|
}
|
|
|
|
|
|
u := userx.User{
|
|
|
Id: partnerInfo.Id,
|
|
|
PartnerName: partnerInfo.PartnerName,
|
...
|
...
|
@@ -265,18 +274,22 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques |
|
|
} else {
|
|
|
u.CooperateCompany.Salesman = map[string]interface{}{}
|
|
|
}
|
|
|
|
|
|
rspMap["user"] = u
|
|
|
rsp = rspMap
|
|
|
}
|
|
|
|
|
|
// 获取管理员信息
|
|
|
funcManagerInfo := func() {
|
|
|
if user, err = UsersRepository.FindOne(map[string]interface{}{"id": header.UserId}); err != nil {
|
|
|
err = protocol.NewErrWithMessage(502, err) //账号不存在
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
rspMap["user"] = userx.User{
|
|
|
Id: user.Id,
|
|
|
PartnerName: user.Name,
|
...
|
...
|
@@ -288,12 +301,26 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques |
|
|
MiniProgram: nil,
|
|
|
},
|
|
|
}
|
|
|
|
|
|
rsp = rspMap
|
|
|
}
|
|
|
|
|
|
phone := strconv.Itoa(header.SimNum)
|
|
|
|
|
|
// 判断是否高管
|
|
|
ok, loginErr := loginSvr.CheckIsSenior(phone, 0)
|
|
|
if loginErr != nil {
|
|
|
err = protocol.NewErrWithMessage(10001)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
switch header.AdminType {
|
|
|
case int(protocolx.AdminTypePartner):
|
|
|
if ok { // 身份为高管,则默认登录合伙人
|
|
|
funcPartnerInfo()
|
|
|
} else { // 身份非高管
|
|
|
funcManagerInfo()
|
|
|
}
|
|
|
break
|
|
|
case int(protocolx.AdminTypeManager):
|
|
|
funcManagerInfo()
|
...
|
...
|
@@ -302,6 +329,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques |
|
|
funcPartnerInfo()
|
|
|
break
|
|
|
}
|
|
|
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
return
|
|
|
}
|
...
|
...
|
|