作者 yangfu

Merge branch 'dev' into feature_review

@@ -353,11 +353,13 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -353,11 +353,13 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
353 break 353 break
354 case protocol.LoginByCredentials: 354 case protocol.LoginByCredentials:
355 //凭证是否存在 355 //凭证是否存在
  356 + if constant.DISENABLE_MULTI_DEVICE_LOGIN {
356 if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { 357 if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
357 log.Debug("凭证过期或者已失效:", request.Phone) 358 log.Debug("凭证过期或者已失效:", request.Phone)
358 err = protocol.NewErrWithMessage(4140, err) 359 err = protocol.NewErrWithMessage(4140, err)
359 return 360 return
360 } 361 }
  362 + }
361 if _, err = utils.ParseJWTToken(request.Credentials); err != nil { 363 if _, err = utils.ParseJWTToken(request.Credentials); err != nil {
362 err = protocol.NewErrWithMessage(4140, err) 364 err = protocol.NewErrWithMessage(4140, err)
363 return 365 return
@@ -421,11 +423,13 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco @@ -421,11 +423,13 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
421 return 423 return
422 } 424 }
423 //凭证是否存在 425 //凭证是否存在
  426 + if constant.DISENABLE_MULTI_DEVICE_LOGIN {
424 if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { 427 if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
425 log.Debug("凭证过期或者已失效:", claim.Phone) 428 log.Debug("凭证过期或者已失效:", claim.Phone)
426 err = protocol.NewErrWithMessage(4140, err) 429 err = protocol.NewErrWithMessage(4140, err)
427 return 430 return
428 } 431 }
  432 + }
429 433
430 // loginSvr 初始化 434 // loginSvr 初始化
431 loginSvr.Init(claim.Phone) 435 loginSvr.Init(claim.Phone)
@@ -462,12 +466,14 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( @@ -462,12 +466,14 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
462 err = protocol.NewErrWithMessage(4140, err) 466 err = protocol.NewErrWithMessage(4140, err)
463 return 467 return
464 } 468 }
  469 + if constant.DISENABLE_MULTI_DEVICE_LOGIN {
465 //凭证是否存在 470 //凭证是否存在
466 if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { 471 if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
467 log.Debug("凭证过期或者已失效:", claim.Phone) 472 log.Debug("凭证过期或者已失效:", claim.Phone)
468 err = protocol.NewErrWithMessage(4140, err) 473 err = protocol.NewErrWithMessage(4140, err)
469 return 474 return
470 } 475 }
  476 + }
471 if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil { 477 if company, e := CompanyRepository.FindOne(map[string]interface{}{"id": request.Cid, "enable": 1}); e != nil || company == nil {
472 err = protocol.NewErrWithMessage(10007, err) 478 err = protocol.NewErrWithMessage(10007, err)
473 return 479 return
@@ -152,7 +152,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont @@ -152,7 +152,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
152 UsersRepository, _ = factory.CreateUsersRepository(transactionContext) 152 UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
153 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) 153 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
154 OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext) 154 OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext)
155 - BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext) 155 + //BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext)
156 //user *domain.Users 156 //user *domain.Users
157 partnerIds []int64 157 partnerIds []int64
158 ) 158 )
@@ -163,6 +163,10 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont @@ -163,6 +163,10 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
163 partnerIds = user.AccessPartnerIds() 163 partnerIds = user.AccessPartnerIds()
164 } 164 }
165 Statistics := make(map[string]interface{}) 165 Statistics := make(map[string]interface{})
  166 + //Statistics["developDividend"] = 0
  167 + //Statistics["developOrdersMoney"] = 0
  168 + //Statistics["appDividend"] = 0
  169 + //Statistics["appOrdersMoney"] = 0
166 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil { 170 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil {
167 Statistics["careerCount"] = count 171 Statistics["careerCount"] = count
168 } 172 }
@@ -175,18 +179,27 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont @@ -175,18 +179,27 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
175 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil { 179 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil {
176 Statistics["appCount"] = count 180 Statistics["appCount"] = count
177 } 181 }
178 - if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil { 182 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Career}); e == nil {
179 Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount 183 Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount
180 Statistics["careerDividend"] = bonus.Bonus 184 Statistics["careerDividend"] = bonus.Bonus
181 } 185 }
182 - if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil {  
183 - Statistics["businessDividend"] = businessBonus.Bonus  
184 - Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount 186 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Business}); e == nil {
  187 + Statistics["businessOrdersMoney"] = bonus.TotalOrderAmount
  188 + Statistics["businessDividend"] = bonus.Bonus
185 } 189 }
186 - Statistics["developDividend"] = 0  
187 - Statistics["developOrdersMoney"] = 0  
188 - Statistics["appDividend"] = 0  
189 - Statistics["appOrdersMoney"] = 0 190 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Develop}); e == nil {
  191 + Statistics["developOrdersMoney"] = bonus.TotalOrderAmount
  192 + Statistics["developDividend"] = bonus.Bonus
  193 + }
  194 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.App}); e == nil {
  195 + Statistics["appOrdersMoney"] = bonus.TotalOrderAmount
  196 + Statistics["appDividend"] = bonus.Bonus
  197 + }
  198 + //if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil {
  199 + // Statistics["businessDividend"] = businessBonus.Bonus
  200 + // Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount
  201 + //}
  202 +
190 Statistics["totalCount"] = len(partnerIds) 203 Statistics["totalCount"] = len(partnerIds)
191 return Statistics, nil 204 return Statistics, nil
192 } 205 }
@@ -3,10 +3,13 @@ package event @@ -3,10 +3,13 @@ package event
3 import ( 3 import (
4 "github.com/tiptok/gocomm/xa/eda" 4 "github.com/tiptok/gocomm/xa/eda"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/event/subscriber" 5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/event/subscriber"
  6 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain/event"
7 ) 8 )
8 9
9 func InitEventCenter() { 10 func InitEventCenter() {
  11 + if constant.DISENABLE_MULTI_DEVICE_LOGIN {
10 eda.RegisterSubscribe(&event.AccessTokenEvent{}, &subscriber.AuthCacheSubscribe{}) 12 eda.RegisterSubscribe(&event.AccessTokenEvent{}, &subscriber.AuthCacheSubscribe{})
11 eda.RegisterSubscribe(&event.RefreshTokenEvent{}, &subscriber.AuthCacheSubscribe{}) 13 eda.RegisterSubscribe(&event.RefreshTokenEvent{}, &subscriber.AuthCacheSubscribe{})
  14 + }
12 } 15 }
@@ -212,7 +212,12 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -212,7 +212,12 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
212 total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption)) 212 total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption))
213 if len(orders) != 0 { 213 if len(orders) != 0 {
214 for i := range orders { 214 for i := range orders {
215 - rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i])) 215 + item := DomainOrderToOrderListItem(orders[i])
  216 + // 高管查看都是标记已读
  217 + if orders[i].PartnerId != header.UserId {
  218 + item.IsRead = 1
  219 + }
  220 + rsp.List = append(rsp.List, item)
216 } 221 }
217 } 222 }
218 223
@@ -19,8 +19,11 @@ var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块 @@ -19,8 +19,11 @@ var BUSINESS_ADMIN_PLATFORM_ID = "25" //合伙人模块
19 19
20 var DEFAULT_GUEST_COMPANY int = 10011 20 var DEFAULT_GUEST_COMPANY int = 10011
21 21
22 -var SHARE_SHOP_PREVIEW_IMADGE = "https://media.fjmaimaimai.com/image/default/6E0A8136F1654B24B141150487FADC04-6-2.jpg" //分享店铺预览图 22 +var SHARE_SHOP_PREVIEW_IMADGE = "https://media.fjmaimaimai.com/image/default/3E0C7050C13147CE8C7AF86C75F904E9-6-2.jpg" //分享店铺预览图
23 var WEHAT_MINI_PROGRAM_VERSION_TYPE = 2 //0:正式版 1:开发版 2:体验版 23 var WEHAT_MINI_PROGRAM_VERSION_TYPE = 2 //0:正式版 1:开发版 2:体验版
  24 +
  25 +var DISENABLE_MULTI_DEVICE_LOGIN = false //不允许多端登录 (注:正式环境需要为true 测试环境设为false,方便多个设备测试)
  26 +
24 func init() { 27 func init() {
25 if os.Getenv("LOG_LEVEL") != "" { 28 if os.Getenv("LOG_LEVEL") != "" {
26 LOG_LEVEL = os.Getenv("LOG_LEVEL") 29 LOG_LEVEL = os.Getenv("LOG_LEVEL")
@@ -32,4 +32,7 @@ func init() { @@ -32,4 +32,7 @@ func init() {
32 if os.Getenv("DISABLE_SQL_GENERATE_PRINT") != "" { 32 if os.Getenv("DISABLE_SQL_GENERATE_PRINT") != "" {
33 DISABLE_SQL_GENERATE_PRINT = true 33 DISABLE_SQL_GENERATE_PRINT = true
34 } 34 }
  35 + if POSTGRESQL_DB_NAME == "partner" {
  36 + DISENABLE_MULTI_DEVICE_LOGIN = true
  37 + }
35 } 38 }
@@ -3,6 +3,7 @@ package middleware @@ -3,6 +3,7 @@ package middleware
3 import ( 3 import (
4 "github.com/astaxie/beego/context" 4 "github.com/astaxie/beego/context"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/userAuth" 5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/userAuth"
  6 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
8 "strconv" 9 "strconv"
@@ -39,6 +40,7 @@ func CheckJWTToken(ctx *context.Context) { @@ -39,6 +40,7 @@ func CheckJWTToken(ctx *context.Context) {
39 } else { 40 } else {
40 ctx.Input.SetData("UserId", u.UserId) 41 ctx.Input.SetData("UserId", u.UserId)
41 42
  43 + if constant.DISENABLE_MULTI_DEVICE_LOGIN {
42 // valid token 44 // valid token
43 userPhone, _ := strconv.Atoi(u.Phone) 45 userPhone, _ := strconv.Atoi(u.Phone)
44 tokenAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(userPhone))) 46 tokenAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(userPhone)))
@@ -50,5 +52,6 @@ func CheckJWTToken(ctx *context.Context) { @@ -50,5 +52,6 @@ func CheckJWTToken(ctx *context.Context) {
50 return 52 return
51 } 53 }
52 } 54 }
  55 + }
53 return 56 return
54 } 57 }