作者 陈志颖

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

@@ -640,13 +640,13 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( @@ -640,13 +640,13 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
640 switch request.IdType { 640 switch request.IdType {
641 case int(protocolx.AdminTypePartner): 641 case int(protocolx.AdminTypePartner):
642 // 用户信息检索 642 // 用户信息检索
643 - if p, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {  
644 - userId = p.Id  
645 - if !p.IsEnable() {  
646 - err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用  
647 - return  
648 - }  
649 - } 643 + //if u, e := UsersRepository.FindOne(map[string]interface{}{"phone": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
  644 + // userId = u.Id
  645 + // if !u.IsEnable() {
  646 + // err = protocol.NewErrWithMessage(10006, err) //当前账号已被禁用
  647 + // return
  648 + // }
  649 + //}
650 // 合伙人检索 650 // 合伙人检索
651 if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil { 651 if p, e := PartnerInfoRepository.FindOne(map[string]interface{}{"account": claim.Phone, "companyId": request.Cid, "deleteAtIsNull": true}); e == nil {
652 userId = p.Id 652 userId = p.Id
@@ -218,6 +218,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { @@ -218,6 +218,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
218 mapCompanyAdminUsers[adminUsers[i].CompanyId] = adminUsers[i] 218 mapCompanyAdminUsers[adminUsers[i].CompanyId] = adminUsers[i]
219 } 219 }
220 } 220 }
  221 +
221 var companys = make([]*Company, 0) 222 var companys = make([]*Company, 0)
222 for i := range companyList { 223 for i := range companyList {
223 c := companyList[i] 224 c := companyList[i]
@@ -255,10 +256,21 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { @@ -255,10 +256,21 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
255 } 256 }
256 companys = append(companys, item) 257 companys = append(companys, item)
257 } 258 }
  259 +
258 if len(companys) > 0 { 260 if len(companys) > 0 {
259 svr.HasAvailableCompany = true 261 svr.HasAvailableCompany = true
260 } 262 }
261 263
  264 + if len(companys) > 1 {
  265 + var companies = make([]*Company, 0)
  266 + for _, company := range companys {
  267 + if company.CompanyBase.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
  268 + companies = append(companies, company)
  269 + }
  270 + }
  271 + companys = companies
  272 + }
  273 +
262 response["companys"] = companys 274 response["companys"] = companys
263 return response, nil 275 return response, nil
264 } 276 }
@@ -394,27 +406,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -394,27 +406,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
394 user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在 406 user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
395 senior, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2, "deleteAtIsNull": true}) // 用户是否是高管 407 senior, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2, "deleteAtIsNull": true}) // 用户是否是高管
396 408
397 - fmt.Print(partnerInfo, "\n")  
398 - fmt.Print(user, "\n")  
399 - fmt.Print(senior, "\n") 409 + fmt.Print("存在合伙人身份:", partnerInfo != nil, "\n")
  410 + fmt.Print("用户存在:", user != nil, "\n")
  411 + fmt.Print("高管:", senior != nil, "\n")
400 412
401 - // 游客公司合伙人存在,更新合伙人转台 413 + // 游客公司合伙人存在,更新合伙人
402 if guestInfo != nil { 414 if guestInfo != nil {
403 _, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{ 415 _, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{
404 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), 416 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
405 PartnerName: phone, 417 PartnerName: phone,
406 Account: phone, 418 Account: phone,
407 Password: "7c4a8d09ca3762af61e59520943dc26494f8941b", 419 Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
408 - Status: 1,  
409 PartnerCategory: 1, 420 PartnerCategory: 1,
410 RegionInfo: &domain.RegionInfo{ 421 RegionInfo: &domain.RegionInfo{
411 RegionName: "客户区域", 422 RegionName: "客户区域",
412 RegionId: 0, 423 RegionId: 0,
413 }, 424 },
  425 + Status: guestInfo.Status,
414 CooperateTime: time.Now(), 426 CooperateTime: time.Now(),
415 CreateAt: time.Now(), 427 CreateAt: time.Now(),
416 UpdateAt: time.Now(), 428 UpdateAt: time.Now(),
417 - PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1}}, 429 + PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
418 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}}). 430 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}}).
419 Where("partner_info.account = ?", phone). 431 Where("partner_info.account = ?", phone).
420 Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY). 432 Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).
@@ -451,7 +463,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -451,7 +463,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
451 CooperateTime: time.Now(), 463 CooperateTime: time.Now(),
452 CreateAt: time.Now(), 464 CreateAt: time.Now(),
453 UpdateAt: time.Now(), 465 UpdateAt: time.Now(),
454 - PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1}}, 466 + PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
455 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}, 467 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
456 }) 468 })
457 } 469 }