合并分支 'dev' 到 'test'
fix:用户注册问题 查看合并请求 !31
正在显示
5 个修改的文件
包含
28 行增加
和
13 行删除
@@ -450,8 +450,8 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -450,8 +450,8 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
450 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() | 450 | rsp.Partner, _ = loginSvr.PartnerStaticInfo() |
451 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() | 451 | rsp.Manager, _ = loginSvr.ManagerStaticInfo() |
452 | 452 | ||
453 | - if !loginSvr.HasAvailableCompany { | ||
454 | - err = protocol.NewErrWithMessage(10008) //账号禁用 | 453 | + if !loginSvr.HasAvailableCompany && !loginSvr.HasAvailableManagerCompany { // 判断合伙人或者高管是否有可访问的公司 |
454 | + err = protocol.NewErrWithMessage(10008) //账号禁用, 抱歉,企业管理员未帮您开通权限。如需访问,请联系企业管理员 | ||
455 | return | 455 | return |
456 | } | 456 | } |
457 | 457 | ||
@@ -481,14 +481,24 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -481,14 +481,24 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
481 | v = map[string]interface{}{"center": rsp} | 481 | v = map[string]interface{}{"center": rsp} |
482 | } else { | 482 | } else { |
483 | var companies []interface{} | 483 | var companies []interface{} |
484 | - for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) { | ||
485 | - companies = append(companies, company) | 484 | + |
485 | + if rsp.Partner.(map[string]interface{})["companys"] != nil { | ||
486 | + for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) { | ||
487 | + companies = append(companies, company) | ||
488 | + } | ||
489 | + } else { | ||
490 | + companies = []interface{}{} | ||
486 | } | 491 | } |
487 | - for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) { | ||
488 | - companies = append(companies, company) | 492 | + |
493 | + if rsp.Manager.(map[string]interface{})["companys"] != nil { | ||
494 | + for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) { | ||
495 | + companies = append(companies, company) | ||
496 | + } | ||
489 | } | 497 | } |
498 | + | ||
490 | rsp.Partner.(map[string]interface{})["companys"] = companies | 499 | rsp.Partner.(map[string]interface{})["companys"] = companies |
491 | rsp.Manager.(map[string]interface{})["companys"] = []struct{}{} | 500 | rsp.Manager.(map[string]interface{})["companys"] = []struct{}{} |
501 | + | ||
492 | v = map[string]interface{}{"center": rsp} | 502 | v = map[string]interface{}{"center": rsp} |
493 | } | 503 | } |
494 | 504 |
@@ -18,7 +18,7 @@ var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52" | @@ -18,7 +18,7 @@ var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52" | ||
18 | var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-test.fjmaimaimai.com" | 18 | var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-test.fjmaimaimai.com" |
19 | var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块 | 19 | var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块 |
20 | 20 | ||
21 | -var DEFAULT_GUEST_COMPANY int = 10011 | 21 | +var DEFAULT_GUEST_COMPANY int = 358 |
22 | 22 | ||
23 | var SHARE_SHOP_PREVIEW_IMADGE = "https://media.fjmaimaimai.com/image/default/3E0C7050C13147CE8C7AF86C75F904E9-6-2.jpg" //分享店铺预览图 | 23 | var SHARE_SHOP_PREVIEW_IMADGE = "https://media.fjmaimaimai.com/image/default/3E0C7050C13147CE8C7AF86C75F904E9-6-2.jpg" //分享店铺预览图 |
24 | var WEHAT_MINI_PROGRAM_VERSION_TYPE = 2 //0:正式版 1:开发版 2:体验版 | 24 | var WEHAT_MINI_PROGRAM_VERSION_TYPE = 2 //0:正式版 1:开发版 2:体验版 |
@@ -24,7 +24,8 @@ type PgLoginService struct { | @@ -24,7 +24,8 @@ type PgLoginService struct { | ||
24 | Users []*domain.Users | 24 | Users []*domain.Users |
25 | transactionContext *transaction.TransactionContext | 25 | transactionContext *transaction.TransactionContext |
26 | // 标识:登录的账号信息是否有可用的公司, true:有 false:没有 | 26 | // 标识:登录的账号信息是否有可用的公司, true:有 false:没有 |
27 | - HasAvailableCompany bool | 27 | + HasAvailableCompany bool |
28 | + HasAvailableManagerCompany bool | ||
28 | } | 29 | } |
29 | 30 | ||
30 | func (svr *PgLoginService) Init(phone string) (err error) { | 31 | func (svr *PgLoginService) Init(phone string) (err error) { |
@@ -294,7 +295,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { | @@ -294,7 +295,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { | ||
294 | companys = append(companys, item) | 295 | companys = append(companys, item) |
295 | } | 296 | } |
296 | if len(companys) > 0 { | 297 | if len(companys) > 0 { |
297 | - svr.HasAvailableCompany = true | 298 | + svr.HasAvailableManagerCompany = true |
298 | } | 299 | } |
299 | 300 | ||
300 | response["companys"] = companys | 301 | response["companys"] = companys |
@@ -370,15 +371,18 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 { | @@ -370,15 +371,18 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 { | ||
370 | func (svr *PgLoginService) RegistryUser(phone string) error { | 371 | func (svr *PgLoginService) RegistryUser(phone string) error { |
371 | var ( | 372 | var ( |
372 | PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext) | 373 | PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext) |
374 | + UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext) | ||
373 | ) | 375 | ) |
374 | 376 | ||
375 | - partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone}) | 377 | + partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone}) // 合伙人是否存在 |
378 | + user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone}) // 用户是否存在 | ||
379 | + _, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2}) // 用户是否是高管 | ||
376 | 380 | ||
377 | - if partnerInfo != nil { | 381 | + if partnerInfo != nil && user != nil { // 用户存在且合伙人存在,不注册合伙人 |
378 | return nil | 382 | return nil |
379 | } | 383 | } |
380 | 384 | ||
381 | - if errPartner != nil { | 385 | + if errPartner != nil && errUser == nil && errSenior == nil { // 合伙人不存在、用户存在且不是高管,注册合伙人 |
382 | id := time.Now().Unix() | 386 | id := time.Now().Unix() |
383 | errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ | 387 | errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ |
384 | Id: id, | 388 | Id: id, |
@@ -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 | + query.SetWhere("is_senior = ?", "isSenior") | ||
58 | 59 | ||
59 | if err := query.First(); err != nil { | 60 | if err := query.First(); err != nil { |
60 | return nil, fmt.Errorf("query row not found") | 61 | return nil, fmt.Errorf("query row not found") |
-
请 注册 或 登录 后发表评论