作者 陈志颖

合并分支 'dev' 到 'test'

fix:过滤游客公司



查看合并请求 !43
@@ -29,6 +29,7 @@ type PgLoginService struct { @@ -29,6 +29,7 @@ type PgLoginService struct {
29 Users []*domain.Users // 所有公司有效用户 29 Users []*domain.Users // 所有公司有效用户
30 NormalUsers []*domain.Users // 所有公司用户 30 NormalUsers []*domain.Users // 所有公司用户
31 IsSenior []*domain.Users // 所有公司有效高管 31 IsSenior []*domain.Users // 所有公司有效高管
  32 + IsRealSenior []*domain.Users // 真实公司的有效高管
32 transactionContext *transaction.TransactionContext 33 transactionContext *transaction.TransactionContext
33 // 标识:登录的账号信息是否有可用的公司, true:有 false:没有 34 // 标识:登录的账号信息是否有可用的公司, true:有 false:没有
34 HasAvailableCompany bool // 是否有可访问的合伙公司 35 HasAvailableCompany bool // 是否有可访问的合伙公司
@@ -47,6 +48,12 @@ func (svr *PgLoginService) Init(phone string) (err error) { @@ -47,6 +48,12 @@ func (svr *PgLoginService) Init(phone string) (err error) {
47 _, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"}) 48 _, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
48 // 所有公司有效合伙人 49 // 所有公司有效合伙人
49 _, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"}) 50 _, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
  51 + // 真实公司有效合伙人
  52 + _, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
  53 + // 游客公司合伙人
  54 + _, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
  55 + // 游客公司有效合伙人
  56 + _, svr.GuestPartnerInfoAvailable, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
50 57
51 // 所有公司用户 58 // 所有公司用户
52 _, svr.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true}) 59 _, svr.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
@@ -54,14 +61,8 @@ func (svr *PgLoginService) Init(phone string) (err error) { @@ -54,14 +61,8 @@ func (svr *PgLoginService) Init(phone string) (err error) {
54 _, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true}) 61 _, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
55 // 所有公司有效高管 62 // 所有公司有效高管
56 _, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1}) 63 _, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
57 -  
58 - // 真实公司有效合伙人  
59 - _, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})  
60 -  
61 - // 游客公司合伙人  
62 - _, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})  
63 - // 游客公司有效合伙人  
64 - _, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY}) 64 + // 真实公司有效高管
  65 + _, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
65 66
66 return nil 67 return nil
67 } 68 }
@@ -294,7 +295,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { @@ -294,7 +295,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
294 svr.HasAvailableCompany = true 295 svr.HasAvailableCompany = true
295 } 296 }
296 297
297 - if len(companys) > 1 { 298 + if len(companys) > 1 || len(svr.IsRealSenior) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
298 var companies = make([]*Company, 0) 299 var companies = make([]*Company, 0)
299 for _, company := range companys { 300 for _, company := range companys {
300 if company.CompanyBase.Id != int64(constant.DEFAULT_GUEST_COMPANY) { 301 if company.CompanyBase.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
@@ -358,6 +359,16 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { @@ -358,6 +359,16 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
358 svr.HasAvailableManagerCompany = true 359 svr.HasAvailableManagerCompany = true
359 } 360 }
360 361
  362 + if len(companys) > 1 || len(svr.IsPartnerInfo) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
  363 + var companies = make([]protocol.CompanyBase, 0)
  364 + for _, company := range companys {
  365 + if company.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
  366 + companies = append(companies, company)
  367 + }
  368 + }
  369 + companys = companies
  370 + }
  371 +
361 response["companys"] = companys 372 response["companys"] = companys
362 return response, nil 373 return response, nil
363 } 374 }
@@ -77,6 +77,7 @@ func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (in @@ -77,6 +77,7 @@ func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (in
77 SetWhere(`status = ?`, "status"). 77 SetWhere(`status = ?`, "status").
78 SetWhere(`delete_at is null`, "deleteAtIsNull"). 78 SetWhere(`delete_at is null`, "deleteAtIsNull").
79 SetWhere("is_senior = ?", "isSenior"). 79 SetWhere("is_senior = ?", "isSenior").
  80 + SetWhere("company_id <> ?", "isNot").
80 SetOrder("create_at", "sortByCreateTime"). 81 SetOrder("create_at", "sortByCreateTime").
81 SetOrder("update_at", "sortByUpdateTime") 82 SetOrder("update_at", "sortByUpdateTime")
82 83