...
|
...
|
@@ -25,12 +25,11 @@ type PgLoginService struct { |
|
|
GuestPartnerInfo []*domain.PartnerInfo // 游客公司合伙人
|
|
|
GuestPartnerInfoAvailable []*domain.PartnerInfo // 游客公司有效合伙人
|
|
|
NormalPartnerInfo []*domain.PartnerInfo // 所有公司合伙人
|
|
|
IsRealPartnerInfo []*domain.PartnerInfo // 真实公司有效合伙人
|
|
|
IsPartnerInfo []*domain.PartnerInfo // 真实公司有效合伙人
|
|
|
Users []*domain.Users // 所有公司有效用户
|
|
|
NormalUsers []*domain.Users // 所有公司用户
|
|
|
IsSenior []*domain.Users // 所有公司有效高管
|
|
|
IsRealSenior []*domain.Users // 真实公司的有效高管
|
|
|
IsRealUser []*domain.Users // 真实公司有效用户,有效高管和有效用户二者其中一个为空则非高管
|
|
|
transactionContext *transaction.TransactionContext
|
|
|
// 标识:登录的账号信息是否有可用的公司, true:有 false:没有
|
|
|
HasAvailableCompany bool // 是否有可访问的合伙公司
|
...
|
...
|
@@ -50,7 +49,7 @@ func (svr *PgLoginService) Init(phone string) (err error) { |
|
|
// 所有公司有效合伙人
|
|
|
_, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
|
|
|
// 真实公司有效合伙人
|
|
|
_, svr.IsRealPartnerInfo, 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, "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})
|
|
|
// 游客公司有效合伙人
|
...
|
...
|
@@ -64,8 +63,6 @@ func (svr *PgLoginService) Init(phone string) (err error) { |
|
|
_, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
|
|
|
// 真实公司有效高管
|
|
|
_, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
// 真实公司有效用户
|
|
|
_, svr.IsRealUser, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
return nil
|
|
|
}
|
...
|
...
|
@@ -101,7 +98,7 @@ func (svr *PgLoginService) InitPartner(phone string) (err error) { |
|
|
|
|
|
svr.Phone = phone
|
|
|
|
|
|
_, svr.IsRealPartnerInfo, 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, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
return nil
|
|
|
}
|
...
|
...
|
@@ -362,7 +359,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { |
|
|
svr.HasAvailableManagerCompany = true
|
|
|
}
|
|
|
|
|
|
if len(companys) > 1 || len(svr.IsRealPartnerInfo) > 0 { // 有真实合伙公司或高管公司时,过滤游客公司
|
|
|
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) {
|
...
|
...
|
@@ -457,7 +454,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
isUserSenior bool
|
|
|
)
|
|
|
|
|
|
partnerInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
|
|
|
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
|
|
|
if partnerInfo == nil {
|
|
|
isPartner = false
|
|
|
} else {
|
...
|
...
|
@@ -483,7 +480,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
isGuestPartnerAvailable = true
|
|
|
}
|
|
|
|
|
|
user, _ := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
|
|
|
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
|
|
|
if user == nil {
|
|
|
isUser = false
|
|
|
} else {
|
...
|
...
|
@@ -574,27 +571,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
|
|
|
// 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户
|
|
|
// 合伙人不存在、用户不存在(游客)-> 注册用户
|
|
|
//if errPartner != nil && errUser == nil && errSenior == nil || errPartner != nil && errUser != nil {
|
|
|
// id := time.Now().Unix()
|
|
|
// errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
|
// Id: id,
|
|
|
// CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
// PartnerName: phone,
|
|
|
// Account: phone,
|
|
|
// Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
// Status: 1,
|
|
|
// PartnerCategory: 1,
|
|
|
// RegionInfo: &domain.RegionInfo{
|
|
|
// RegionName: "客户区域",
|
|
|
// RegionId: 0,
|
|
|
// },
|
|
|
// 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}},
|
|
|
// })
|
|
|
//}
|
|
|
if errPartner != nil && errUser == nil {
|
|
|
id := time.Now().Unix()
|
|
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
|
Id: id,
|
|
|
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
PartnerName: phone,
|
|
|
Account: phone,
|
|
|
Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
Status: 1,
|
|
|
PartnerCategory: 1,
|
|
|
RegionInfo: &domain.RegionInfo{
|
|
|
RegionName: "客户区域",
|
|
|
RegionId: 0,
|
|
|
},
|
|
|
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}},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
return errPartner
|
|
|
}
|
...
|
...
|
@@ -630,7 +627,7 @@ func (svr *PgLoginService) RegistryGuest(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}},
|
|
|
})
|
|
|
}
|
...
|
...
|
|