...
|
...
|
@@ -48,20 +48,23 @@ 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})
|
|
|
// 所有公司有效用户
|
|
|
// 所有公司非删除非禁用用户
|
|
|
_, 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.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
return nil
|
...
|
...
|
@@ -576,8 +579,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
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}},
|
|
|
PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
})
|
|
|
}
|
|
|
|
...
|
...
|
@@ -600,14 +603,74 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
|
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}},
|
|
|
PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
return errPartner
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description //TODO 操作游客
|
|
|
* @Date 15:20 2021/2/7
|
|
|
* @Param
|
|
|
* @return
|
|
|
**/
|
|
|
func (svr *PgLoginService) OperateGuest(phone string) error {
|
|
|
var (
|
|
|
PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
)
|
|
|
|
|
|
// 真实公司检索合伙人身份(账号未禁用)
|
|
|
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "status": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
// 真实公司检索用户身份(账号未删除且是高管)
|
|
|
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 1, "deleteAtIsNull": true, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
|
|
|
// 存在合伙人或者用户身份,不进行游客注册操作
|
|
|
if partnerInfo != nil || user != nil {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
if errUser != nil && errPartner != nil { // 合伙人身份和用户身份均不存在,注册游客合伙人
|
|
|
id := time.Now().Unix()
|
|
|
_, errInsert := svr.transactionContext.PgDd.Model(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: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
}).Insert()
|
|
|
if errInsert != nil {
|
|
|
return errInsert
|
|
|
}
|
|
|
} else { // 真实公司存在合伙人或者高管用户,删除游客合伙人
|
|
|
_, errDelete := svr.transactionContext.PgDd.Model((*models.PartnerInfo)(nil)).
|
|
|
Where("account = ?", phone).
|
|
|
Where("company_id = ?", constant.DEFAULT_GUEST_COMPANY).
|
|
|
Delete()
|
|
|
if errDelete != nil {
|
|
|
return errDelete
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 注册游客到指定的公司
|
|
|
func (svr *PgLoginService) RegistryGuest(phone string) error {
|
|
|
var (
|
...
|
...
|
@@ -622,6 +685,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 注册用户
|
|
|
if errUser != nil && errPartner != nil {
|
|
|
id := time.Now().Unix()
|
|
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
...
|
...
|
@@ -639,11 +703,13 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
|
|
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}},
|
|
|
PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 删除用户
|
|
|
|
|
|
return errPartner
|
|
|
}
|
|
|
|
...
|
...
|
|