作者 陈志颖

合并分支 'dev' 到 'test'

fix:登录提示



查看合并请求 !39
... ... @@ -357,8 +357,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
transactionContext, _ = factory.CreateTransactionContext(nil)
imInfo *domain.ImInfo
loginSvr = domain_service.NewPgLoginService(transactionContext)
//isSenior bool
//isPartner bool
)
// 转换手机号码
... ... @@ -391,29 +389,25 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
// loginSvr 初始化
_ = loginSvr.Init(request.Phone)
if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 {
err = protocol.NewErrWithMessage(10001)
return
}
// 高管标志位初始化
_ = loginSvr.InitSenior(request.Phone)
//if len(loginSvr.IsSenior) == 0 {
// isSenior = false
//} else {
// isSenior = true
//}
// 合伙人标志位初始化
_ = loginSvr.InitPartner(request.Phone)
//if len(loginSvr.IsPartnerInfo) == 0 {
// isPartner = false
//} else {
// isPartner = true
//}
//fmt.Print(isPartner, "\n")
//fmt.Print(isSenior, "\n")
// 普通合伙人标志位
_ = loginSvr.InitNormal(request.Phone)
if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 && len(loginSvr.NormalPartnerInfo) == 0 {
err = protocol.NewErrWithMessage(10001)
return
}
if len(loginSvr.PartnerInfo) == 0 {
err = protocol.NewErrWithMessage(10008)
return
}
switch request.GrantType {
case protocol.LoginByPassword:
... ... @@ -480,39 +474,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
// 添加手机对应的凭证
userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
// 判断是否高管
//if isSenior && isPartner { // 高管且合伙人
// v = map[string]interface{}{"center": rsp}
//} else if isSenior && !isPartner { // 高管非合伙人
// var companies []interface{}
// if len(rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase)) > 0 {
// for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase) {
// companies = append(companies, company)
// }
// } else {
// companies = []interface{}{}
// }
//
// rsp.Partner.(map[string]interface{})["companys"] = []struct{}{}
// rsp.Manager.(map[string]interface{})["companys"] = companies
//
// v = map[string]interface{}{"center": rsp}
//} else { // 非高管合伙人
// var companies []interface{}
// if len(rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company)) > 0 {
// for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
// companies = append(companies, company)
// }
// } else {
// companies = []interface{}{}
// }
//
// rsp.Partner.(map[string]interface{})["companys"] = companies
// rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
//
// v = map[string]interface{}{"center": rsp}
//}
v = map[string]interface{}{"center": rsp}
err = transactionContext.CommitTransaction()
... ... @@ -531,8 +492,6 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
transactionContext, _ = factory.CreateTransactionContext(nil)
loginSvr = domain_service.NewPgLoginService(transactionContext)
claim *utils.UserTokenClaims
//isSenior bool
//isPartner bool
)
rsp = &protocolx.CompanysResponse{}
if err = transactionContext.StartTransaction(); err != nil {
... ... @@ -562,38 +521,13 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
// 高管标志位初始化
_ = loginSvr.InitSenior(claim.Phone)
//if len(loginSvr.IsSenior) == 0 {
// isSenior = false
//} else {
// isSenior = true
//}
// 合伙人标志位初始化
_ = loginSvr.InitPartner(claim.Phone)
//if len(loginSvr.IsPartnerInfo) == 0 {
// isPartner = false
//} else {
// isPartner = true
//}
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
//if !isSenior { // 非高管普通用户, 显示游客公司
// var companies []interface{}
// if len(rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company)) > 0 {
// for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
// companies = append(companies, company)
// }
// } else {
// companies = []interface{}{}
// }
// rsp.Partner.(map[string]interface{})["companys"] = companies
// rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
//} else if isSenior && !isPartner { // 高管非合伙人,显示高管公司
// rsp.Partner.(map[string]interface{})["companys"] = []struct{}{}
//}
if !loginSvr.HasAvailableCompany && !loginSvr.HasAvailableManagerCompany {
err = protocol.NewErrWithMessage(4140, err) //账号禁用
return
... ...
... ... @@ -22,6 +22,7 @@ type PgLoginService struct {
Phone string
eda.EventCenterPublisher
PartnerInfo []*domain.PartnerInfo
NormalPartnerInfo []*domain.PartnerInfo
IsPartnerInfo []*domain.PartnerInfo
Users []*domain.Users
IsSenior []*domain.Users
... ... @@ -45,6 +46,18 @@ func (svr *PgLoginService) Init(phone string) (err error) {
return nil
}
func (svr *PgLoginService) InitNormal(phone string) (err error) {
var (
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
)
svr.Phone = phone
_, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
return nil
}
func (svr *PgLoginService) InitSenior(phone string) (err error) {
var (
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
... ... @@ -411,30 +424,30 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
fmt.Print("高管:", senior != nil, "\n")
// 游客公司合伙人存在,更新合伙人
if guestInfo != nil {
_, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
PartnerName: phone,
Account: phone,
Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
PartnerCategory: 1,
RegionInfo: &domain.RegionInfo{
RegionName: "客户区域",
RegionId: 0,
},
Status: guestInfo.Status,
CooperateTime: time.Now(),
CreateAt: time.Now(),
UpdateAt: time.Now(),
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}}).
Where("partner_info.account = ?", phone).
Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).
Update()
if err != nil {
return err
}
}
//if guestInfo != nil {
// _, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{
// CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
// PartnerName: phone,
// Account: phone,
// Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
// PartnerCategory: 1,
// RegionInfo: &domain.RegionInfo{
// RegionName: "客户区域",
// RegionId: 0,
// },
// Status: guestInfo.Status,
// CooperateTime: time.Now(),
// CreateAt: time.Now(),
// UpdateAt: time.Now(),
// PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
// Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}}).
// Where("partner_info.account = ?", phone).
// Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).
// Update()
// if err != nil {
// return err
// }
//}
// 合伙人存在、用户存在、是高管(高管合伙人)
// 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil
... ...