作者 陈志颖

fix:优化游客公司管理、增加合伙人编号、账号状态优化

... ... @@ -640,13 +640,13 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
switch request.IdType {
case int(protocolx.AdminTypePartner):
// 用户信息检索
if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
userId = p.Id
if !p.IsEnable() {
err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用
return
}
}
//if u, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
// userId = u.Id
// if !u.IsEnable() {
// err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用
// return
// }
//}
// 合伙人检索
if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
userId = p.Id
... ...
... ... @@ -218,6 +218,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
mapCompanyAdminUsers[adminUsers[i].CompanyId] = adminUsers[i]
}
}
var companys = make([]*Company, 0)
for i := range companyList {
c := companyList[i]
... ... @@ -255,10 +256,21 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
}
companys = append(companys, item)
}
if len(companys) > 0 {
svr.HasAvailableCompany = true
}
if len(companys) > 1 {
var companies = make([]*Company, 0)
for _, company := range companys {
if company.CompanyBase.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
companies = append(companies, company)
}
}
companys = companies
}
response["companys"] = companys
return response, nil
}
... ... @@ -394,27 +406,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
senior, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2, "deleteAtIsNull": true}) // 用户是否是高管
fmt.Print(partnerInfo, "\n")
fmt.Print(user, "\n")
fmt.Print(senior, "\n")
fmt.Print("存在合伙人身份:", partnerInfo != nil, "\n")
fmt.Print("用户存在:", user != nil, "\n")
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",
Status: 1,
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}},
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).
... ... @@ -451,7 +463,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
CooperateTime: time.Now(),
CreateAt: time.Now(),
UpdateAt: time.Now(),
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1}},
PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
})
}
... ...