作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !26
@@ -380,11 +380,19 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -380,11 +380,19 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
380 transactionContext.RollbackTransaction() 380 transactionContext.RollbackTransaction()
381 }() 381 }()
382 382
383 - // 通过短信验证码登录的游客或者普通用户,注册一个账号到配置的公司去(ios审核使用)  
384 - if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {  
385 - e := loginSvr.RegistryGuest(request.Phone)  
386 - if e != nil {  
387 - log.Error(e) 383 + // 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
  384 + if request.GrantType == protocol.LoginBySmsCode {
  385 + guestErr := loginSvr.RegistryGuest(request.Phone)
  386 + if guestErr != nil {
  387 + log.Error(guestErr)
  388 + }
  389 + }
  390 +
  391 + // 通过密码登录的普通用户,注册一个账号到配置的公司去
  392 + if request.GrantType == protocol.LoginByPassword {
  393 + userErr := loginSvr.RegistryUser(request.Phone)
  394 + if userErr != nil {
  395 + log.Error(userErr)
388 } 396 }
389 } 397 }
390 398
@@ -68,6 +68,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) @@ -68,6 +68,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
68 rsp.User.Salesman = map[string]interface{}{} 68 rsp.User.Salesman = map[string]interface{}{}
69 } 69 }
70 } 70 }
  71 +
71 funcManagerInfo := func() { 72 funcManagerInfo := func() {
72 if user, err = UsersRepository.FindOne(map[string]interface{}{"id": header.UserId}); err != nil { 73 if user, err = UsersRepository.FindOne(map[string]interface{}{"id": header.UserId}); err != nil {
73 err = protocol.NewErrWithMessage(502, err) //账号不存在 74 err = protocol.NewErrWithMessage(502, err) //账号不存在
@@ -362,32 +362,27 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 { @@ -362,32 +362,27 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 {
362 362
363 /** 363 /**
364 * @Author SteveChan 364 * @Author SteveChan
365 - * @Description //TODO 注册用户到合伙人 365 + * @Description // 注册用户到合伙人
366 * @Date 13:52 2021/1/13 366 * @Date 13:52 2021/1/13
367 * @Param 367 * @Param
368 * @return 368 * @return
369 **/ 369 **/
370 -func (svr *PgLoginService) RegistryPartner(phone string, users []*domain.Users) error { 370 +func (svr *PgLoginService) RegistryUser(phone string) error {
371 var ( 371 var (
372 PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext) 372 PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
373 - //UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)  
374 ) 373 )
375 374
376 partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone}) 375 partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone})
377 376
378 - //user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone})  
379 -  
380 if partnerInfo != nil { 377 if partnerInfo != nil {
381 return nil 378 return nil
382 } 379 }
383 380
384 - for _, user := range users {  
385 - if user.IsSenior == 2 { // 插入合伙人到非高管公司  
386 if errPartner != nil { 381 if errPartner != nil {
387 id := time.Now().Unix() 382 id := time.Now().Unix()
388 errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ 383 errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
389 Id: id, 384 Id: id,
390 - CompanyId: user.CompanyId, 385 + CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
391 PartnerName: phone, 386 PartnerName: phone,
392 Account: phone, 387 Account: phone,
393 Password: "7c4a8d09ca3762af61e59520943dc26494f8941b", 388 Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
@@ -404,8 +399,6 @@ func (svr *PgLoginService) RegistryPartner(phone string, users []*domain.Users) @@ -404,8 +399,6 @@ func (svr *PgLoginService) RegistryPartner(phone string, users []*domain.Users)
404 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}, 399 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
405 }) 400 })
406 } 401 }
407 - }  
408 - }  
409 402
410 return errPartner 403 return errPartner
411 } 404 }
@@ -55,6 +55,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{}) @@ -55,6 +55,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{})
55 query.SetWhere("phone = ?", "phone") 55 query.SetWhere("phone = ?", "phone")
56 query.SetWhere("company_id = ?", "companyId") 56 query.SetWhere("company_id = ?", "companyId")
57 query.SetWhere(`delete_at is null`, "deleteAtIsNull") 57 query.SetWhere(`delete_at is null`, "deleteAtIsNull")
  58 +
58 if err := query.First(); err != nil { 59 if err := query.First(); err != nil {
59 return nil, fmt.Errorf("query row not found") 60 return nil, fmt.Errorf("query row not found")
60 } 61 }