增加 : 通过短信验证码登录的用户,如果不存在,默认注册一个游客账号,关联到指定公司
正在显示
6 个修改的文件
包含
60 行增加
和
1 行删除
@@ -70,6 +70,8 @@ spec: | @@ -70,6 +70,8 @@ spec: | ||
70 | value: "1" | 70 | value: "1" |
71 | - name: ERROR_BASE_CODE_MULTIPLE | 71 | - name: ERROR_BASE_CODE_MULTIPLE |
72 | value: "1000" | 72 | value: "1000" |
73 | + - name: DEFAULT_GUEST_COMPANY | ||
74 | + value: "10011" | ||
73 | - name: ABILITY_SERVICE_HOST | 75 | - name: ABILITY_SERVICE_HOST |
74 | value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" | 76 | value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" |
75 | - name: MMM_OPEN_API_SERVICE_HOST | 77 | - name: MMM_OPEN_API_SERVICE_HOST |
@@ -70,6 +70,8 @@ spec: | @@ -70,6 +70,8 @@ spec: | ||
70 | value: "1" | 70 | value: "1" |
71 | - name: ERROR_BASE_CODE_MULTIPLE | 71 | - name: ERROR_BASE_CODE_MULTIPLE |
72 | value: "1000" | 72 | value: "1000" |
73 | + - name: DEFAULT_GUEST_COMPANY | ||
74 | + value: "10011" | ||
73 | - name: ABILITY_SERVICE_HOST | 75 | - name: ABILITY_SERVICE_HOST |
74 | value: "https://ability.fjmaimaimai.com" | 76 | value: "https://ability.fjmaimaimai.com" |
75 | - name: MMM_OPEN_API_SERVICE_HOST | 77 | - name: MMM_OPEN_API_SERVICE_HOST |
@@ -70,6 +70,8 @@ spec: | @@ -70,6 +70,8 @@ spec: | ||
70 | value: "1" | 70 | value: "1" |
71 | - name: ERROR_BASE_CODE_MULTIPLE | 71 | - name: ERROR_BASE_CODE_MULTIPLE |
72 | value: "1000" | 72 | value: "1000" |
73 | + - name: DEFAULT_GUEST_COMPANY | ||
74 | + value: "10011" | ||
73 | - name: ABILITY_SERVICE_HOST | 75 | - name: ABILITY_SERVICE_HOST |
74 | value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" | 76 | value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" |
75 | - name: MMM_OPEN_API_SERVICE_HOST | 77 | - name: MMM_OPEN_API_SERVICE_HOST |
@@ -317,6 +317,14 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -317,6 +317,14 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
317 | defer func() { | 317 | defer func() { |
318 | transactionContext.RollbackTransaction() | 318 | transactionContext.RollbackTransaction() |
319 | }() | 319 | }() |
320 | + | ||
321 | + if request.GrantType == protocol.LoginBySmsCode { | ||
322 | + e := loginSvr.RegistryGuest(request.Phone) | ||
323 | + if e != nil { | ||
324 | + log.Error(e) | ||
325 | + } | ||
326 | + } | ||
327 | + | ||
320 | loginSvr.Init(request.Phone) | 328 | loginSvr.Init(request.Phone) |
321 | if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 { | 329 | if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 { |
322 | err = protocol.NewErrWithMessage(10001) | 330 | err = protocol.NewErrWithMessage(10001) |
1 | package constant | 1 | package constant |
2 | 2 | ||
3 | -import "os" | 3 | +import ( |
4 | + "os" | ||
5 | + "strconv" | ||
6 | +) | ||
4 | 7 | ||
5 | const SERVICE_NAME = "partner" | 8 | const SERVICE_NAME = "partner" |
6 | 9 | ||
@@ -14,6 +17,8 @@ var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52" | @@ -14,6 +17,8 @@ var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52" | ||
14 | var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-dev.fjmaimaimai.com" | 17 | var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-dev.fjmaimaimai.com" |
15 | var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块 | 18 | var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块 |
16 | 19 | ||
20 | +var DEFAULT_GUEST_COMPANY int = 10011 | ||
21 | + | ||
17 | func init() { | 22 | func init() { |
18 | if os.Getenv("LOG_LEVEL") != "" { | 23 | if os.Getenv("LOG_LEVEL") != "" { |
19 | LOG_LEVEL = os.Getenv("LOG_LEVEL") | 24 | LOG_LEVEL = os.Getenv("LOG_LEVEL") |
@@ -24,4 +29,7 @@ func init() { | @@ -24,4 +29,7 @@ func init() { | ||
24 | if os.Getenv("BUSINESS_ADMIN_SERVICE_HOST") != "" { | 29 | if os.Getenv("BUSINESS_ADMIN_SERVICE_HOST") != "" { |
25 | BUSINESS_ADMIN_SERVICE_HOST = os.Getenv("BUSINESS_ADMIN_SERVICE_HOST") | 30 | BUSINESS_ADMIN_SERVICE_HOST = os.Getenv("BUSINESS_ADMIN_SERVICE_HOST") |
26 | } | 31 | } |
32 | + if v := os.Getenv("DEFAULT_GUEST_COMPANY"); v != "" { | ||
33 | + DEFAULT_GUEST_COMPANY, _ = strconv.Atoi(v) | ||
34 | + } | ||
27 | } | 35 | } |
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" | 5 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" |
6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" | 6 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" |
7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao" | 7 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao" |
8 | + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" | ||
8 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" | 9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" |
9 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository" | 10 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository" |
10 | http_gateway "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr" | 11 | http_gateway "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/svr" |
@@ -13,6 +14,7 @@ import ( | @@ -13,6 +14,7 @@ import ( | ||
13 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" | 14 | "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" |
14 | protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" | 15 | protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" |
15 | "strings" | 16 | "strings" |
17 | + "time" | ||
16 | ) | 18 | ) |
17 | 19 | ||
18 | type PgLoginService struct { | 20 | type PgLoginService struct { |
@@ -282,6 +284,41 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 { | @@ -282,6 +284,41 @@ func computeBonusPercent(totalBonus float64, bonus float64) float64 { | ||
282 | return utils.Decimal(bonus / totalBonus) | 284 | return utils.Decimal(bonus / totalBonus) |
283 | } | 285 | } |
284 | 286 | ||
287 | +func (svr *PgLoginService) RegistryGuest(phone string) error { | ||
288 | + var ( | ||
289 | + PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext) | ||
290 | + UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext) | ||
291 | + ) | ||
292 | + partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone}) | ||
293 | + user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone}) | ||
294 | + if partnerInfo != nil || user != nil { | ||
295 | + return nil | ||
296 | + } | ||
297 | + if errUser != nil && errPartner != nil { | ||
298 | + id, _ := utils.NewSnowflakeId() | ||
299 | + errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ | ||
300 | + Id: id, | ||
301 | + CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), | ||
302 | + PartnerName: phone, | ||
303 | + Account: phone, | ||
304 | + Password: "7c4a8d09ca3762af61e59520943dc26494f8941b", | ||
305 | + Status: 1, | ||
306 | + PartnerCategory: 1, | ||
307 | + RegionInfo: &domain.RegionInfo{ | ||
308 | + RegionName: "客户区域", | ||
309 | + RegionId: 0, | ||
310 | + }, | ||
311 | + CooperateTime: time.Now(), | ||
312 | + CreateAt: time.Now(), | ||
313 | + UpdateAt: time.Now(), | ||
314 | + PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1}}, | ||
315 | + Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}, | ||
316 | + }) | ||
317 | + } | ||
318 | + | ||
319 | + return errPartner | ||
320 | +} | ||
321 | + | ||
285 | type Company struct { | 322 | type Company struct { |
286 | protocol.CompanyBase | 323 | protocol.CompanyBase |
287 | // 收入占比 | 324 | // 收入占比 |
-
请 注册 或 登录 后发表评论