作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !64
  1 +# Config file for [Air](https://github.com/cosmtrek/air) in TOML format
  2 +
  3 +# Working directory
  4 +# . or absolute path, please note that the directories following must be under root.
  5 +root = "."
  6 +tmp_dir = "tmp"
  7 +
  8 +[build]
  9 +# Just plain old shell command. You could use `make` as well.
  10 +cmd = "go build -o ./tmp/main ."
  11 +# Binary file yields from `cmd`.
  12 +bin = "tmp/main"
  13 +# Customize binary.
  14 +full_bin = "APP_ENV=dev APP_USER=air ./tmp/main"
  15 +# Watch these filename extensions.
  16 +include_ext = ["go", "tpl", "tmpl", "html"]
  17 +# Ignore these filename extensions or directories.
  18 +exclude_dir = ["assets", "tmp", "vendor", "frontend/node_modules"]
  19 +# Watch these directories if you specified.
  20 +include_dir = []
  21 +# Exclude files.
  22 +exclude_file = []
  23 +# Exclude unchanged files.
  24 +exclude_unchanged = true
  25 +# This log file places in your tmp_dir.
  26 +log = "air.log"
  27 +# It's not necessary to trigger build each time file changes if it's too frequent.
  28 +delay = 1000 # ms
  29 +# Stop running old binary when build errors occur.
  30 +stop_on_error = true
  31 +# Send Interrupt signal before killing process (windows does not support this feature)
  32 +send_interrupt = false
  33 +# Delay after sending Interrupt signal
  34 +kill_delay = 500 # ms
  35 +
  36 +[log]
  37 +# Show log time
  38 +time = false
  39 +
  40 +[color]
  41 +# Customize each part's color. If no color found, use the raw app log.
  42 +main = "magenta"
  43 +watcher = "cyan"
  44 +build = "yellow"
  45 +runner = "green"
  46 +
  47 +[misc]
  48 +# Delete tmp directory on exit
  49 +clean_on_exit = true
@@ -25,3 +25,4 @@ opp @@ -25,3 +25,4 @@ opp
25 /vendor 25 /vendor
26 /*.exe~ 26 /*.exe~
27 logs 27 logs
  28 +tmp
@@ -81,7 +81,7 @@ spec: @@ -81,7 +81,7 @@ spec:
81 - name: ABILITY_SERVICE_HOST 81 - name: ABILITY_SERVICE_HOST
82 value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" 82 value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
83 - name: MMM_OPEN_API_SERVICE_HOST 83 - name: MMM_OPEN_API_SERVICE_HOST
84 - value: "http://mmm-open-api-dev.fjmaimaimai.com" 84 + value: "https://mmm-open-api-dev.fjmaimaimai.com"
85 - name: UCENTER_SERVICE_HOST 85 - name: UCENTER_SERVICE_HOST
86 value: "https://suplus-ucenter-dev.fjmaimaimai.com" 86 value: "https://suplus-ucenter-dev.fjmaimaimai.com"
87 - name: BUSINESS_ADMIN_SERVICE_HOST 87 - name: BUSINESS_ADMIN_SERVICE_HOST
@@ -81,7 +81,7 @@ spec: @@ -81,7 +81,7 @@ spec:
81 - name: ABILITY_SERVICE_HOST 81 - name: ABILITY_SERVICE_HOST
82 value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" 82 value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
83 - name: MMM_OPEN_API_SERVICE_HOST 83 - name: MMM_OPEN_API_SERVICE_HOST
84 - value: "http://mmm-open-api-dev.fjmaimaimai.com" 84 + value: "https://mmm-open-api-dev.fjmaimaimai.com"
85 - name: UCENTER_SERVICE_HOST 85 - name: UCENTER_SERVICE_HOST
86 value: "https://suplus-ucenter-test.fjmaimaimai.com" 86 value: "https://suplus-ucenter-test.fjmaimaimai.com"
87 - name: BUSINESS_ADMIN_SERVICE_HOST 87 - name: BUSINESS_ADMIN_SERVICE_HOST
@@ -4,12 +4,24 @@ go 1.14 @@ -4,12 +4,24 @@ go 1.14
4 4
5 require ( 5 require (
6 github.com/Shopify/sarama v1.26.4 6 github.com/Shopify/sarama v1.26.4
  7 + github.com/ajg/form v1.5.1 // indirect
7 github.com/astaxie/beego v1.12.1 8 github.com/astaxie/beego v1.12.1
8 github.com/dgrijalva/jwt-go v3.2.0+incompatible 9 github.com/dgrijalva/jwt-go v3.2.0+incompatible
  10 + github.com/gavv/httpexpect v2.0.0+incompatible
9 github.com/gin-gonic/gin v1.5.0 11 github.com/gin-gonic/gin v1.5.0
10 github.com/go-pg/pg/v10 v10.0.0-beta.2 12 github.com/go-pg/pg/v10 v10.0.0-beta.2
  13 + github.com/imkira/go-interpol v1.1.0 // indirect
11 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 14 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
  15 + github.com/moul/http2curl v1.0.0 // indirect
  16 + github.com/onsi/ginkgo v1.15.0
  17 + github.com/onsi/gomega v1.10.5
  18 + github.com/sergi/go-diff v1.1.0 // indirect
12 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect 19 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
13 github.com/shopspring/decimal v1.2.0 20 github.com/shopspring/decimal v1.2.0
14 github.com/tiptok/gocomm v1.0.5 21 github.com/tiptok/gocomm v1.0.5
  22 + github.com/valyala/fasthttp v1.19.0 // indirect
  23 + github.com/xeipuuv/gojsonschema v1.2.0 // indirect
  24 + github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
  25 + github.com/yudai/gojsondiff v1.0.0 // indirect
  26 + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
15 ) 27 )
@@ -302,7 +302,13 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol. @@ -302,7 +302,13 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.
302 return 302 return
303 } 303 }
304 304
305 -// 企业平台-密码校验 305 +/**
  306 + * @Author SteveChan
  307 + * @Description 企业平台-密码登录校验
  308 + * @Date 11:06 2021/2/5
  309 + * @Param
  310 + * @return
  311 + **/
306 func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginRequest) (v interface{}, err error) { 312 func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginRequest) (v interface{}, err error) {
307 var ( 313 var (
308 transactionContext, _ = factory.CreateTransactionContext(nil) 314 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -346,7 +352,7 @@ func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginReques @@ -346,7 +352,7 @@ func PasswordLogin(header *protocol.RequestHeader, request *protocol.LoginReques
346 352
347 /** 353 /**
348 * @Author SteveChan 354 * @Author SteveChan
349 - * @Description // 企业平台-多公司登录,判断是否高管 355 + * @Description //TODO 企业平台-多公司登录,判断是否高管,优化游客登录
350 * @Date 15:01 2021/1/12 356 * @Date 15:01 2021/1/12
351 * @Param 357 * @Param
352 * @return 358 * @return
@@ -369,19 +375,19 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -369,19 +375,19 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
369 375
370 rsp := &protocolx.CenterCompanysResponse{} 376 rsp := &protocolx.CenterCompanysResponse{}
371 377
372 - // 启动事务  
373 if err = transactionContext.StartTransaction(); err != nil { 378 if err = transactionContext.StartTransaction(); err != nil {
374 log.Error(err) 379 log.Error(err)
375 return nil, err 380 return nil, err
376 } 381 }
377 382
378 defer func() { 383 defer func() {
379 - transactionContext.RollbackTransaction() 384 + _ = transactionContext.RollbackTransaction()
380 }() 385 }()
381 386
382 - // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去 387 + //TODO 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
383 if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword { 388 if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {
384 userErr := loginSvr.RegistryGuest(request.Phone) 389 userErr := loginSvr.RegistryGuest(request.Phone)
  390 + //userErr := loginSvr.OperateGuest(request.Phone)
385 if userErr != nil { 391 if userErr != nil {
386 log.Error(userErr) 392 log.Error(userErr)
387 } 393 }
@@ -490,7 +496,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -490,7 +496,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
490 496
491 /** 497 /**
492 * @Author SteveChan 498 * @Author SteveChan
493 - * @Description // 企业平台-多公司登录 - 通过凭证,判断是否高管 499 + * @Description //TODO 企业平台-多公司登录 - 通过凭证,判断是否高管
494 * @Date 15:00 2021/1/12 500 * @Date 15:00 2021/1/12
495 * @Param 501 * @Param
496 * @return 502 * @return
@@ -555,7 +561,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco @@ -555,7 +561,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
555 561
556 /** 562 /**
557 * @Author SteveChan 563 * @Author SteveChan
558 - * @Description //TODO 登录 564 + * @Description 登录
559 * @Date 15:05 2021/1/15 565 * @Date 15:05 2021/1/15
560 * @Param 566 * @Param
561 * @return 567 * @return
@@ -575,7 +581,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( @@ -575,7 +581,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
575 return nil, err 581 return nil, err
576 } 582 }
577 defer func() { 583 defer func() {
578 - transactionContext.RollbackTransaction() 584 + _ = transactionContext.RollbackTransaction()
579 }() 585 }()
580 if claim, err = utils.ParseJWTToken(request.Credentials); err != nil { 586 if claim, err = utils.ParseJWTToken(request.Credentials); err != nil {
581 err = protocol.NewErrWithMessage(4140, err) 587 err = protocol.NewErrWithMessage(4140, err)
@@ -66,6 +66,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -66,6 +66,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
66 //if request.EndTime > last.Unix()*1000 { 66 //if request.EndTime > last.Unix()*1000 {
67 // request.EndTime = last.Unix() * 1000 67 // request.EndTime = last.Unix() * 1000
68 //} 68 //}
  69 +
69 fmt.Print("StartTime: ", request.StartTime, "\n") 70 fmt.Print("StartTime: ", request.StartTime, "\n")
70 fmt.Print("EndTime: ", request.EndTime, "\n") 71 fmt.Print("EndTime: ", request.EndTime, "\n")
71 72
@@ -15,7 +15,7 @@ var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897" @@ -15,7 +15,7 @@ var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897"
15 var UCENTER_SERVICE_HOST = "https://suplus-ucenter-test.fjmaimaimai.com" 15 var UCENTER_SERVICE_HOST = "https://suplus-ucenter-test.fjmaimaimai.com"
16 var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52" 16 var UCENTER_APP_KEY = "0c2c2a23dfc64ae230f5c54ab243ab52"
17 17
18 -var BUSINESS_ADMIN_SERVICE_HOST = "http://suplus-business-admin-test.fjmaimaimai.com" 18 +var BUSINESS_ADMIN_SERVICE_HOST = "https://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 = 358 21 var DEFAULT_GUEST_COMPANY int = 358
@@ -48,20 +48,23 @@ func (svr *PgLoginService) Init(phone string) (err error) { @@ -48,20 +48,23 @@ func (svr *PgLoginService) Init(phone string) (err error) {
48 _, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"}) 48 _, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
49 // 所有公司有效合伙人 49 // 所有公司有效合伙人
50 _, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"}) 50 _, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
  51 +
51 // 真实公司有效合伙人 52 // 真实公司有效合伙人
52 _, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY}) 53 _, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
  54 +
53 // 游客公司合伙人 55 // 游客公司合伙人
54 _, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY}) 56 _, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
55 // 游客公司有效合伙人 57 // 游客公司有效合伙人
56 _, svr.GuestPartnerInfoAvailable, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY}) 58 _, svr.GuestPartnerInfoAvailable, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
57 59
58 - // 所有公司用户 60 + // 所有公司非删除用户
59 _, svr.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true}) 61 _, svr.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
60 - // 所有公司有效用户 62 + // 所有公司非删除非禁用用户
61 _, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true}) 63 _, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
62 // 所有公司有效高管 64 // 所有公司有效高管
63 _, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1}) 65 _, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
64 - // 真实公司有效高管 66 +
  67 + // 真实公司非禁用非删除高管
65 _, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY}) 68 _, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
66 69
67 return nil 70 return nil
@@ -576,8 +579,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -576,8 +579,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
576 CooperateTime: time.Now(), 579 CooperateTime: time.Now(),
577 CreateAt: time.Now(), 580 CreateAt: time.Now(),
578 UpdateAt: time.Now(), 581 UpdateAt: time.Now(),
579 - PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},  
580 - Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}, 582 + PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
  583 + Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
581 }) 584 })
582 } 585 }
583 586
@@ -600,14 +603,74 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -600,14 +603,74 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
600 CooperateTime: time.Now(), 603 CooperateTime: time.Now(),
601 CreateAt: time.Now(), 604 CreateAt: time.Now(),
602 UpdateAt: time.Now(), 605 UpdateAt: time.Now(),
603 - PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},  
604 - Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}, 606 + PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
  607 + Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
605 }) 608 })
606 } 609 }
607 610
608 return errPartner 611 return errPartner
609 } 612 }
610 613
  614 +/**
  615 + * @Author SteveChan
  616 + * @Description //TODO 操作游客
  617 + * @Date 15:20 2021/2/7
  618 + * @Param
  619 + * @return
  620 + **/
  621 +func (svr *PgLoginService) OperateGuest(phone string) error {
  622 + var (
  623 + PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
  624 + UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
  625 + )
  626 +
  627 + // 真实公司检索合伙人身份(账号未禁用)
  628 + partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "status": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
  629 +
  630 + // 真实公司检索用户身份(账号未删除且是高管)
  631 + user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 1, "deleteAtIsNull": true, "isNot": constant.DEFAULT_GUEST_COMPANY})
  632 +
  633 + // 存在合伙人或者用户身份,不进行游客注册操作
  634 + if partnerInfo != nil || user != nil {
  635 + return nil
  636 + }
  637 +
  638 + if errUser != nil && errPartner != nil { // 合伙人身份和用户身份均不存在,注册游客合伙人
  639 + id := time.Now().Unix()
  640 + _, errInsert := svr.transactionContext.PgDd.Model(models.PartnerInfo{
  641 + Id: id,
  642 + CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
  643 + PartnerName: phone,
  644 + Account: phone,
  645 + Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
  646 + Status: 1,
  647 + PartnerCategory: 1,
  648 + RegionInfo: &domain.RegionInfo{
  649 + RegionName: "客户区域",
  650 + RegionId: 0,
  651 + },
  652 + CooperateTime: time.Now(),
  653 + CreateAt: time.Now(),
  654 + UpdateAt: time.Now(),
  655 + PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
  656 + Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
  657 + }).Insert()
  658 + if errInsert != nil {
  659 + return errInsert
  660 + }
  661 + } else { // 真实公司存在合伙人或者高管用户,删除游客合伙人
  662 + _, errDelete := svr.transactionContext.PgDd.Model((*models.PartnerInfo)(nil)).
  663 + Where("account = ?", phone).
  664 + Where("company_id = ?", constant.DEFAULT_GUEST_COMPANY).
  665 + Delete()
  666 + if errDelete != nil {
  667 + return errDelete
  668 + }
  669 + }
  670 +
  671 + return nil
  672 +}
  673 +
611 // 注册游客到指定的公司 674 // 注册游客到指定的公司
612 func (svr *PgLoginService) RegistryGuest(phone string) error { 675 func (svr *PgLoginService) RegistryGuest(phone string) error {
613 var ( 676 var (
@@ -622,6 +685,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { @@ -622,6 +685,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error {
622 return nil 685 return nil
623 } 686 }
624 687
  688 + // 注册用户
625 if errUser != nil && errPartner != nil { 689 if errUser != nil && errPartner != nil {
626 id := time.Now().Unix() 690 id := time.Now().Unix()
627 errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ 691 errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
@@ -639,11 +703,13 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { @@ -639,11 +703,13 @@ func (svr *PgLoginService) RegistryGuest(phone string) error {
639 CooperateTime: time.Now(), 703 CooperateTime: time.Now(),
640 CreateAt: time.Now(), 704 CreateAt: time.Now(),
641 UpdateAt: time.Now(), 705 UpdateAt: time.Now(),
642 - PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},  
643 - Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}, 706 + PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
  707 + Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
644 }) 708 })
645 } 709 }
646 710
  711 + // 删除用户
  712 +
647 return errPartner 713 return errPartner
648 } 714 }
649 715
@@ -44,20 +44,52 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone @@ -44,20 +44,52 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone
44 } 44 }
45 return 45 return
46 } 46 }
  47 +
  48 +/**
  49 + * @Author SteveChan
  50 + * @Description 密码校验增加多公司
  51 + * @Date 11:52 2021/2/7
  52 + * @Param
  53 + * @return
  54 + **/
47 func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, phone string) (err error) { 55 func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, phone string) (err error) {
48 var ( 56 var (
49 - partnerInfo *domain.PartnerInfo 57 + //partnerInfo *domain.PartnerInfo
  58 + partnerInfos []*domain.PartnerInfo
50 PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext) 59 PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext)
51 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext) 60 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
52 ) 61 )
53 - if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": phone}); err != nil { 62 +
  63 + // 查询账号信息
  64 + if _, partnerInfos, err = PartnerInfoService.Find(map[string]interface{}{"account": phone}); err != nil {
54 err = errUserNotFound //账号不存在 65 err = errUserNotFound //账号不存在
55 return 66 return
56 } 67 }
57 - if !strings.EqualFold(partnerInfo.Password, oldPwd) { 68 +
  69 + //多公司密码校验
  70 + var misMatch bool
  71 + for _, partnerInfo := range partnerInfos {
  72 + if !strings.EqualFold(partnerInfo.Password, oldPwd) {
  73 + misMatch = true
  74 + } else {
  75 + misMatch = false
  76 + break
  77 + }
  78 + }
  79 + if misMatch {
58 err = fmt.Errorf("旧密码不正确") //账号不存在 80 err = fmt.Errorf("旧密码不正确") //账号不存在
59 return 81 return
60 } 82 }
  83 +
  84 + //if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"account": phone}); err != nil {
  85 + // err = errUserNotFound //账号不存在
  86 + // return
  87 + //}
  88 + //if !strings.EqualFold(partnerInfo.Password, oldPwd) {
  89 + // err = fmt.Errorf("旧密码不正确") //账号不存在
  90 + // return
  91 + //}
  92 +
61 if err = PartnerInfoDao.Update(map[string]interface{}{ 93 if err = PartnerInfoDao.Update(map[string]interface{}{
62 "oldAccount": phone, 94 "oldAccount": phone,
63 "Password": newPwd, 95 "Password": newPwd,
@@ -33,7 +33,7 @@ type PartnerInfo struct { @@ -33,7 +33,7 @@ type PartnerInfo struct {
33 //关联业务员 33 //关联业务员
34 Salesman []*domain.Salesman 34 Salesman []*domain.Salesman
35 //合伙人分类信息 35 //合伙人分类信息
36 - PartnerCategoryInfos []*PartnerCategoryInfo 36 + PartnerCategoryInfos []*domain.PartnerCategoryInfo
37 //备注 37 //备注
38 Remark string 38 Remark string
39 } 39 }
@@ -56,6 +56,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{}) @@ -56,6 +56,7 @@ func (repository *UsersRepository) FindOne(queryOptions map[string]interface{})
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 query.SetWhere("is_senior = ?", "isSenior")
  59 + query.SetWhere("company_id <> ?", "isNot")
59 60
60 if err := query.First(); err != nil { 61 if err := query.First(); err != nil {
61 return nil, fmt.Errorf("query row not found") 62 return nil, fmt.Errorf("query row not found")
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  8 +
  9 +import (
  10 + "github.com/astaxie/beego"
  11 + "github.com/onsi/ginkgo"
  12 + "github.com/onsi/gomega"
  13 + "net/http"
  14 + "net/http/httptest"
  15 + "testing"
  16 +
  17 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego APPSVR Auth Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  8 +
  9 +import (
  10 + "github.com/gavv/httpexpect"
  11 + "github.com/go-pg/pg/v10"
  12 + . "github.com/onsi/ginkgo"
  13 + . "github.com/onsi/gomega"
  14 + pG "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg"
  15 + "net/http"
  16 +)
  17 +
  18 +var _ = Describe("返回员工", func() {
  19 + var employeeId int64
  20 + BeforeEach(func() {
  21 + _, err := pG.DB.QueryOne(
  22 + pg.Scan(&employeeId),
  23 + "INSERT INTO partner (id, company_id, uid, employee_name, employee_account, employee_avatar_url, su_money, status, permissions) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
  24 + 1, 101, 2499036607974745088, "employee_name", "employee_account", "employee_avatar_url", 1000.00, 1, pg.Array([]int{1, 3}))
  25 + Expect(err).NotTo(HaveOccurred())
  26 + })
  27 + Describe("根据employeeId参数返回员工", func() {
  28 + Context("传入有效的employeeId", func() {
  29 + It("返回员工数据", func() {
  30 + httpExpect := httpexpect.New(GinkgoT(), server.URL)
  31 + httpExpect.GET("/employees/2499036607974745088").
  32 + Expect().
  33 + Status(http.StatusOK).
  34 + JSON().
  35 + Object().
  36 + ContainsKey("code").ValueEqual("code", 0).
  37 + ContainsKey("msg").ValueEqual("msg", "ok").
  38 + ContainsKey("data").Value("data").Object()
  39 + })
  40 + })
  41 + })
  42 + AfterEach(func() {
  43 + _, err := pG.DB.Exec("DELETE FROM employees WHERE true")
  44 + Expect(err).NotTo(HaveOccurred())
  45 + })
  46 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package auth
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package company
  8 +
  9 +import (
  10 + "github.com/astaxie/beego"
  11 + "github.com/onsi/ginkgo"
  12 + "github.com/onsi/gomega"
  13 + "net/http"
  14 + "net/http/httptest"
  15 + "testing"
  16 +
  17 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego Port Company Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package dividend
  8 +
  9 +import (
  10 + "github.com/astaxie/beego"
  11 + "github.com/onsi/ginkgo"
  12 + "github.com/onsi/gomega"
  13 + "net/http"
  14 + "net/http/httptest"
  15 + "testing"
  16 +
  17 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego Port Dividend Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package order
  8 +
  9 +import (
  10 + "github.com/astaxie/beego"
  11 + "github.com/onsi/ginkgo"
  12 + "github.com/onsi/gomega"
  13 + "net/http"
  14 + "net/http/httptest"
  15 + "testing"
  16 +
  17 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego Port Order Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package partner
  8 +
  9 +import (
  10 + "github.com/astaxie/beego"
  11 + "github.com/onsi/ginkgo"
  12 + "github.com/onsi/gomega"
  13 + "net/http"
  14 + "net/http/httptest"
  15 + "testing"
  16 +
  17 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego Port Partner Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})
  1 +/**
  2 + @author: stevechan
  3 + @date: 2021/2/7
  4 + @note:
  5 +**/
  6 +
  7 +package user
  8 +
  9 +import (
  10 + "github.com/astaxie/beego"
  11 + "github.com/onsi/ginkgo"
  12 + "github.com/onsi/gomega"
  13 + "net/http"
  14 + "net/http/httptest"
  15 + "testing"
  16 +
  17 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg"
  18 + _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr"
  19 +)
  20 +
  21 +func TestConfig(t *testing.T) {
  22 + gomega.RegisterFailHandler(ginkgo.Fail)
  23 + ginkgo.RunSpecs(t, "Beego Port User Correlations Test Case Suite")
  24 +}
  25 +
  26 +var handler http.Handler
  27 +var server *httptest.Server
  28 +
  29 +var _ = ginkgo.BeforeSuite(func() {
  30 + handler = beego.BeeApp.Handlers
  31 + server = httptest.NewServer(handler)
  32 +})
  33 +
  34 +var _ = ginkgo.AfterSuite(func() {
  35 + server.Close()
  36 +})