...
|
...
|
@@ -21,15 +21,18 @@ import ( |
|
|
type PgLoginService struct {
|
|
|
Phone string
|
|
|
eda.EventCenterPublisher
|
|
|
PartnerInfo []*domain.PartnerInfo
|
|
|
NormalPartnerInfo []*domain.PartnerInfo
|
|
|
IsPartnerInfo []*domain.PartnerInfo
|
|
|
Users []*domain.Users
|
|
|
IsSenior []*domain.Users
|
|
|
PartnerInfo []*domain.PartnerInfo // 所有公司有效合伙人
|
|
|
GuestPartnerInfo []*domain.PartnerInfo // 游客公司合伙人
|
|
|
GuestPartnerInfoAvailable []*domain.PartnerInfo // 游客公司有效合伙人
|
|
|
NormalPartnerInfo []*domain.PartnerInfo // 所有公司合伙人
|
|
|
IsPartnerInfo []*domain.PartnerInfo // 真实公司有效合伙人
|
|
|
Users []*domain.Users // 所有公司有效用户
|
|
|
NormalUsers []*domain.Users // 所有公司用户
|
|
|
IsSenior []*domain.Users // 所有公司有效高管
|
|
|
transactionContext *transaction.TransactionContext
|
|
|
// 标识:登录的账号信息是否有可用的公司, true:有 false:没有
|
|
|
HasAvailableCompany bool
|
|
|
HasAvailableManagerCompany bool
|
|
|
HasAvailableCompany bool // 是否有可访问的合伙公司
|
|
|
HasAvailableManagerCompany bool // 是否有可访问的高管公司
|
|
|
}
|
|
|
|
|
|
func (svr *PgLoginService) Init(phone string) (err error) {
|
...
|
...
|
@@ -40,8 +43,25 @@ func (svr *PgLoginService) Init(phone string) (err error) { |
|
|
|
|
|
svr.Phone = phone
|
|
|
|
|
|
// 所有公司合伙人
|
|
|
_, 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.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
|
|
|
// 所有公司有效用户
|
|
|
_, 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})
|
|
|
|
|
|
return nil
|
|
|
}
|
...
|
...
|
@@ -140,7 +160,7 @@ func (svr *PgLoginService) PartnerLogin(phone string, password string) (err erro |
|
|
return
|
|
|
}
|
|
|
if !strings.EqualFold(svr.PartnerInfo[0].Password, password) {
|
|
|
err = protocol.NewCustomMessage(1, "密码输入有误!")
|
|
|
err = protocol.NewCustomMessage(1, "密码输入错误!")
|
|
|
return
|
|
|
}
|
|
|
return
|
...
|
...
|
@@ -479,30 +499,30 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
fmt.Print("用户高管?", isUserSenior, "\n")
|
|
|
|
|
|
// 用户在正常公司存在且无效或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司存在且无效,更新游客公司合伙人状态
|
|
|
if (isUser && !isUserAvailable || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) && (isGuestPartner && !isGuestPartnerAvailable) {
|
|
|
_, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{
|
|
|
CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
PartnerName: phone,
|
|
|
Account: phone,
|
|
|
Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
PartnerCategory: 1,
|
|
|
RegionInfo: &domain.RegionInfo{
|
|
|
RegionName: "客户区域",
|
|
|
RegionId: 0,
|
|
|
},
|
|
|
Status: 1,
|
|
|
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}}}).
|
|
|
Where("partner_info.account = ?", phone).
|
|
|
Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).
|
|
|
Update()
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
//if (isUser && !isUserAvailable || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) && (isGuestPartner && !isGuestPartnerAvailable) {
|
|
|
// _, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{
|
|
|
// CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
// PartnerName: phone,
|
|
|
// Account: phone,
|
|
|
// Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
// PartnerCategory: 1,
|
|
|
// RegionInfo: &domain.RegionInfo{
|
|
|
// RegionName: "客户区域",
|
|
|
// RegionId: 0,
|
|
|
// },
|
|
|
// Status: 1,
|
|
|
// 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}}}).
|
|
|
// Where("partner_info.account = ?", phone).
|
|
|
// Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).
|
|
|
// Update()
|
|
|
// if err != nil {
|
|
|
// return err
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
// 合伙人存在、用户存在、是高管(高管合伙人)
|
|
|
// 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil
|
...
|
...
|
@@ -511,6 +531,9 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
//if partnerInfo != nil && user != nil && senior != nil || partnerInfo != nil && user != nil && senior == nil || guestInfo != nil {
|
|
|
// return nil
|
|
|
//}
|
|
|
if guestInfo != nil {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 用户在正常公司存在且无效或者存在非高管或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司不存在、注册合伙人到游客公司
|
|
|
if !isGuestPartner && (isUser && !isUserAvailable || isUser && !isUserSenior || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) {
|
...
|
...
|
|