作者 陈志颖

fix:过滤游客公司

... ... @@ -29,6 +29,7 @@ type PgLoginService struct {
Users []*domain.Users // 所有公司有效用户
NormalUsers []*domain.Users // 所有公司用户
IsSenior []*domain.Users // 所有公司有效高管
IsRealSenior []*domain.Users // 真实公司的有效高管
transactionContext *transaction.TransactionContext
// 标识:登录的账号信息是否有可用的公司, true:有 false:没有
HasAvailableCompany bool // 是否有可访问的合伙公司
... ... @@ -47,6 +48,12 @@ func (svr *PgLoginService) Init(phone string) (err error) {
_, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
// 所有公司有效合伙人
_, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
// 真实公司有效合伙人
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
// 游客公司合伙人
_, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
// 游客公司有效合伙人
_, svr.GuestPartnerInfoAvailable, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
// 所有公司用户
_, 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) {
_, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
// 所有公司有效高管
_, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
// 真实公司有效合伙人
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
// 游客公司合伙人
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
// 游客公司有效合伙人
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
// 真实公司有效高管
_, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
return nil
}
... ... @@ -294,7 +295,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
svr.HasAvailableCompany = true
}
if len(companys) > 1 {
if len(companys) > 1 || len(svr.IsRealSenior) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
var companies = make([]*Company, 0)
for _, company := range companys {
if company.CompanyBase.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
... ... @@ -358,6 +359,16 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
svr.HasAvailableManagerCompany = true
}
if len(companys) > 1 || len(svr.IsPartnerInfo) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
var companies = make([]protocol.CompanyBase, 0)
for _, company := range companys {
if company.Id != int64(constant.DEFAULT_GUEST_COMPANY) {
companies = append(companies, company)
}
}
companys = companies
}
response["companys"] = companys
return response, nil
}
... ...
... ... @@ -77,6 +77,7 @@ func (repository *UsersRepository) Find(queryOptions map[string]interface{}) (in
SetWhere(`status = ?`, "status").
SetWhere(`delete_at is null`, "deleteAtIsNull").
SetWhere("is_senior = ?", "isSenior").
SetWhere("company_id <> ?", "isNot").
SetOrder("create_at", "sortByCreateTime").
SetOrder("update_at", "sortByUpdateTime")
... ...