Merge branch 'dev' into feature_review
正在显示
7 个修改的文件
包含
74 行增加
和
38 行删除
| @@ -353,10 +353,12 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | @@ -353,10 +353,12 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom | ||
| 353 | break | 353 | break |
| 354 | case protocol.LoginByCredentials: | 354 | case protocol.LoginByCredentials: |
| 355 | //凭证是否存在 | 355 | //凭证是否存在 |
| 356 | - if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | ||
| 357 | - log.Debug("凭证过期或者已失效:", request.Phone) | ||
| 358 | - err = protocol.NewErrWithMessage(4140, err) | ||
| 359 | - return | 356 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { |
| 357 | + if credential, e := userAuth.NewRedisUserCredential(request.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | ||
| 358 | + log.Debug("凭证过期或者已失效:", request.Phone) | ||
| 359 | + err = protocol.NewErrWithMessage(4140, err) | ||
| 360 | + return | ||
| 361 | + } | ||
| 360 | } | 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) |
| @@ -421,10 +423,12 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | @@ -421,10 +423,12 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco | ||
| 421 | return | 423 | return |
| 422 | } | 424 | } |
| 423 | //凭证是否存在 | 425 | //凭证是否存在 |
| 424 | - if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | ||
| 425 | - log.Debug("凭证过期或者已失效:", claim.Phone) | ||
| 426 | - err = protocol.NewErrWithMessage(4140, err) | ||
| 427 | - return | 426 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { |
| 427 | + if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | ||
| 428 | + log.Debug("凭证过期或者已失效:", claim.Phone) | ||
| 429 | + err = protocol.NewErrWithMessage(4140, err) | ||
| 430 | + return | ||
| 431 | + } | ||
| 428 | } | 432 | } |
| 429 | 433 | ||
| 430 | // loginSvr 初始化 | 434 | // loginSvr 初始化 |
| @@ -462,11 +466,13 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( | @@ -462,11 +466,13 @@ 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 | } |
| 465 | - //凭证是否存在 | ||
| 466 | - if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | ||
| 467 | - log.Debug("凭证过期或者已失效:", claim.Phone) | ||
| 468 | - err = protocol.NewErrWithMessage(4140, err) | ||
| 469 | - return | 469 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { |
| 470 | + //凭证是否存在 | ||
| 471 | + if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) { | ||
| 472 | + log.Debug("凭证过期或者已失效:", claim.Phone) | ||
| 473 | + err = protocol.NewErrWithMessage(4140, err) | ||
| 474 | + return | ||
| 475 | + } | ||
| 470 | } | 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) |
| @@ -149,10 +149,10 @@ func getJoinWays(transactionContext *transaction.TransactionContext) (joinWays [ | @@ -149,10 +149,10 @@ func getJoinWays(transactionContext *transaction.TransactionContext) (joinWays [ | ||
| 149 | // 获取公司统计 | 149 | // 获取公司统计 |
| 150 | func getStatistics(userId int64, transactionContext *transaction.TransactionContext) (interface{}, error) { | 150 | func getStatistics(userId int64, transactionContext *transaction.TransactionContext) (interface{}, error) { |
| 151 | var ( | 151 | var ( |
| 152 | - UsersRepository, _ = factory.CreateUsersRepository(transactionContext) | ||
| 153 | - PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) | ||
| 154 | - OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext) | ||
| 155 | - BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext) | 152 | + UsersRepository, _ = factory.CreateUsersRepository(transactionContext) |
| 153 | + PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) | ||
| 154 | + OrderBaseDao, _ = factory.CreateOrderBaseDao(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() { |
| 10 | - eda.RegisterSubscribe(&event.AccessTokenEvent{}, &subscriber.AuthCacheSubscribe{}) | ||
| 11 | - eda.RegisterSubscribe(&event.RefreshTokenEvent{}, &subscriber.AuthCacheSubscribe{}) | 11 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { |
| 12 | + eda.RegisterSubscribe(&event.AccessTokenEvent{}, &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,15 +40,17 @@ func CheckJWTToken(ctx *context.Context) { | @@ -39,15 +40,17 @@ 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 | ||
| 42 | - // valid token | ||
| 43 | - userPhone, _ := strconv.Atoi(u.Phone) | ||
| 44 | - tokenAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(userPhone))) | ||
| 45 | - err := tokenAuth.Check( | ||
| 46 | - userAuth.NewOptions(userAuth.WithAccessToken(token)), | ||
| 47 | - ) | ||
| 48 | - if err != nil { | ||
| 49 | - msg = protocol.NewMesage(4141) | ||
| 50 | - return | 43 | + if constant.DISENABLE_MULTI_DEVICE_LOGIN { |
| 44 | + // valid token | ||
| 45 | + userPhone, _ := strconv.Atoi(u.Phone) | ||
| 46 | + tokenAuth := userAuth.NewRedisUserAuth(userAuth.WithUserId(int64(userPhone))) | ||
| 47 | + err := tokenAuth.Check( | ||
| 48 | + userAuth.NewOptions(userAuth.WithAccessToken(token)), | ||
| 49 | + ) | ||
| 50 | + if err != nil { | ||
| 51 | + msg = protocol.NewMesage(4141) | ||
| 52 | + return | ||
| 53 | + } | ||
| 51 | } | 54 | } |
| 52 | } | 55 | } |
| 53 | return | 56 | return |
-
请 注册 或 登录 后发表评论