作者 陈志颖

合并分支 'dev' 到 'master'

Dev



查看合并请求 !5
1 appname = partner 1 appname = partner
2 runmode = "${RUN_MODE||dev}" 2 runmode = "${RUN_MODE||dev}"
3 -httpport = "${HTTP_PORT||8080}" 3 +httpport = "${HTTP_PORT||8082}"
4 4
5 #开启监控 5 #开启监控
6 EnableAdmin = false 6 EnableAdmin = false
@@ -11,5 +11,5 @@ require ( @@ -11,5 +11,5 @@ require (
11 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 11 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
12 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect 12 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
13 github.com/shopspring/decimal v1.2.0 13 github.com/shopspring/decimal v1.2.0
14 - github.com/tiptok/gocomm v1.0.2 14 + github.com/tiptok/gocomm v1.0.5
15 ) 15 )
@@ -19,6 +19,7 @@ import ( @@ -19,6 +19,7 @@ import (
19 "time" 19 "time"
20 ) 20 )
21 21
  22 +// 该方法废弃
22 func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp *protocol.LoginResponse, err error) { 23 func Login(header *protocol.RequestHeader, request *protocol.LoginRequest) (rsp *protocol.LoginResponse, err error) {
23 var ( 24 var (
24 transactionContext, _ = factory.CreateTransactionContext(nil) 25 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -222,7 +223,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT @@ -222,7 +223,7 @@ func RefreshToken(request *protocol.RefreshTokenRequest) (rsp *protocol.RefreshT
222 return 223 return
223 } 224 }
224 225
225 -//验证短信验证码 T 226 +// 验证短信验证码 T
226 func CheckSmsCode(phone, code string) (result bool, err error) { 227 func CheckSmsCode(phone, code string) (result bool, err error) {
227 sms, _ := factory.CreateSmsCodeService() 228 sms, _ := factory.CreateSmsCodeService()
228 var data map[string]interface{} 229 var data map[string]interface{}
@@ -236,7 +237,7 @@ func CheckSmsCode(phone, code string) (result bool, err error) { @@ -236,7 +237,7 @@ func CheckSmsCode(phone, code string) (result bool, err error) {
236 return 237 return
237 } 238 }
238 239
239 -//验证手机号码(修改手机号码、重置密码的前一步) 240 +// 验证手机号码(修改手机号码、重置密码的前一步)
240 func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthCheckSmsCodeRequest) (rsp *protocol.AuthCheckSmsCodeResponse, err error) { 241 func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthCheckSmsCodeRequest) (rsp *protocol.AuthCheckSmsCodeResponse, err error) {
241 var () 242 var ()
242 if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil { 243 if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
@@ -248,7 +249,7 @@ func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthChec @@ -248,7 +249,7 @@ func AuthCheckSmsCode(header *protocol.RequestHeader, request *protocol.AuthChec
248 return 249 return
249 } 250 }
250 251
251 -//注销登录 252 +// 注销登录
252 func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rsp *protocol.RevokeResponse, err error) { 253 func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rsp *protocol.RevokeResponse, err error) {
253 //auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(header.UserId)) 254 //auth := userAuth.NewRedisUserAuth(userAuth.WithUserId(header.UserId))
254 //rsp = &protocol.RevokeResponse{} 255 //rsp = &protocol.RevokeResponse{}
@@ -263,7 +264,7 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs @@ -263,7 +264,7 @@ func Revoke(header *protocol.RequestHeader, request *protocol.RevokeRequest) (rs
263 return 264 return
264 } 265 }
265 266
266 -//注销登录 267 +// 注销登录
267 func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.RevokeResponse, err error) { 268 func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.RevokeResponse, err error) {
268 var ( 269 var (
269 transactionContext, _ = factory.CreateTransactionContext(nil) 270 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -300,7 +301,8 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol. @@ -300,7 +301,8 @@ func UCenterRevoke(header *protocol.RequestHeader, userId int64) (rsp *protocol.
300 return 301 return
301 } 302 }
302 303
303 -func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) { 304 +// 企业平台-多公司登录
  305 +func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCompanysRequest) (v interface{}, err error) {
304 var ( 306 var (
305 transactionContext, _ = factory.CreateTransactionContext(nil) 307 transactionContext, _ = factory.CreateTransactionContext(nil)
306 imInfo *domain.ImInfo 308 imInfo *domain.ImInfo
@@ -320,14 +322,14 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -320,14 +322,14 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
320 defer func() { 322 defer func() {
321 transactionContext.RollbackTransaction() 323 transactionContext.RollbackTransaction()
322 }() 324 }()
323 - 325 + // 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
324 if request.GrantType == protocol.LoginBySmsCode { 326 if request.GrantType == protocol.LoginBySmsCode {
325 e := loginSvr.RegistryGuest(request.Phone) 327 e := loginSvr.RegistryGuest(request.Phone)
326 if e != nil { 328 if e != nil {
327 log.Error(e) 329 log.Error(e)
328 } 330 }
329 } 331 }
330 - 332 + // loginSvr 初始化
331 loginSvr.Init(request.Phone) 333 loginSvr.Init(request.Phone)
332 if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 { 334 if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 {
333 err = protocol.NewErrWithMessage(10001) 335 err = protocol.NewErrWithMessage(10001)
@@ -367,22 +369,21 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -367,22 +369,21 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
367 break 369 break
368 } 370 }
369 371
370 - //获取统计信息 372 + // 获取统计信息(合伙人/高管)
371 rsp.Partner, _ = loginSvr.PartnerStaticInfo() 373 rsp.Partner, _ = loginSvr.PartnerStaticInfo()
372 rsp.Manager, _ = loginSvr.ManagerStaticInfo() 374 rsp.Manager, _ = loginSvr.ManagerStaticInfo()
373 - //没有有效人的时候  
374 - if !loginSvr.AvailableCompany { 375 + if !loginSvr.HasAvailableCompany {
375 err = protocol.NewErrWithMessage(10008) //账号禁用 376 err = protocol.NewErrWithMessage(10008) //账号禁用
376 return 377 return
377 } 378 }
378 379
  380 + // 初始化网易IM信息
379 var nickName string 381 var nickName string
380 if len(loginSvr.Users) > 0 { 382 if len(loginSvr.Users) > 0 {
381 nickName = loginSvr.Users[0].Name 383 nickName = loginSvr.Users[0].Name
382 } else if len(loginSvr.PartnerInfo) > 0 { 384 } else if len(loginSvr.PartnerInfo) > 0 {
383 nickName = loginSvr.PartnerInfo[0].PartnerName 385 nickName = loginSvr.PartnerInfo[0].PartnerName
384 } 386 }
385 - //初始化im信息  
386 if imInfo, err = InitOrUpdateUserIMInfo(int64(phoneId), nickName, transactionContext); err != nil { 387 if imInfo, err = InitOrUpdateUserIMInfo(int64(phoneId), nickName, transactionContext); err != nil {
387 log.Error(err) 388 log.Error(err)
388 return 389 return
@@ -397,12 +398,13 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -397,12 +398,13 @@ func CenterCompanys(header *protocol.RequestHeader, request *protocolx.CenterCom
397 //添加手机对应的凭证 398 //添加手机对应的凭证
398 userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials) 399 userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
399 400
400 - err = transactionContext.CommitTransaction()  
401 v = map[string]interface{}{"center": rsp} 401 v = map[string]interface{}{"center": rsp}
  402 + err = transactionContext.CommitTransaction()
402 return 403 return
403 } 404 }
404 405
405 -func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) { 406 +// 企业平台-多公司登录 - 通过凭证
  407 +func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protocolx.CompanysRequest) (rsp *protocolx.CompanysResponse, err error) {
406 var ( 408 var (
407 transactionContext, _ = factory.CreateTransactionContext(nil) 409 transactionContext, _ = factory.CreateTransactionContext(nil)
408 loginSvr = domain_service.NewPgLoginService(transactionContext) 410 loginSvr = domain_service.NewPgLoginService(transactionContext)
@@ -428,11 +430,12 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest @@ -428,11 +430,12 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest
428 return 430 return
429 } 431 }
430 } 432 }
  433 +
  434 + // loginSvr 初始化
431 loginSvr.Init(claim.Phone) 435 loginSvr.Init(claim.Phone)
432 rsp.Partner, _ = loginSvr.PartnerStaticInfo() 436 rsp.Partner, _ = loginSvr.PartnerStaticInfo()
433 rsp.Manager, _ = loginSvr.ManagerStaticInfo() 437 rsp.Manager, _ = loginSvr.ManagerStaticInfo()
434 - //没有有效人的时候  
435 - if !loginSvr.AvailableCompany { 438 + if !loginSvr.HasAvailableCompany {
436 err = protocol.NewErrWithMessage(4140, err) //账号禁用 439 err = protocol.NewErrWithMessage(4140, err) //账号禁用
437 return 440 return
438 } 441 }
@@ -441,6 +444,7 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest @@ -441,6 +444,7 @@ func Companys(header *protocol.RequestHeader, request *protocolx.CompanysRequest
441 return 444 return
442 } 445 }
443 446
  447 +// 登录
444 func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (rsp *protocol.LoginResponse, err error) { 448 func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (rsp *protocol.LoginResponse, err error) {
445 var ( 449 var (
446 claim *utils.UserTokenClaims 450 claim *utils.UserTokenClaims
@@ -483,12 +487,12 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( @@ -483,12 +487,12 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
483 return 487 return
484 } 488 }
485 } 489 }
486 - //验证公司模块权限  
487 - if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2, "deleteAtIsNull": true}); e == nil {  
488 - if len(adminUsers) > 0 {  
489 - au := adminUsers[0]  
490 - if code, e := adminApiGateway.UserAuth(au.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {  
491 - log.Debug("【合伙人检查权限】", claim.Phone, "【公司】", request.Cid, au.Id, code, e.Error()) 490 + //合伙人 需要验证对应公司模块权限(查询该公司的主管理员是否有权限)
  491 + if _, admins, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": []int64{int64(request.Cid)}, "adminType": 2, "deleteAtIsNull": true}); e == nil {
  492 + if len(admins) > 0 {
  493 + admin := admins[0]
  494 + if code, e := adminApiGateway.UserAuth(admin.Id, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
  495 + log.Debug("【合伙人检查权限】", claim.Phone, "【公司】", request.Cid, admin.Id, code, e.Error())
492 err = protocol.NewErrWithMessage(10008, err) // 抱歉,企业管理员未帮您开通权限 496 err = protocol.NewErrWithMessage(10008, err) // 抱歉,企业管理员未帮您开通权限
493 return 497 return
494 } 498 }
@@ -503,7 +507,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( @@ -503,7 +507,7 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
503 return 507 return
504 } 508 }
505 } 509 }
506 - //校验模块权限 510 + //高管 需要校验高管是否模块权限
507 if userId != 0 { 511 if userId != 0 {
508 if code, e := adminApiGateway.UserAuth(userId, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 { 512 if code, e := adminApiGateway.UserAuth(userId, constant.BUSINESS_ADMIN_PLATFORM_ID); e != nil || code != 0 {
509 log.Debug("【检查权限】", userId, "【公司】", request.Cid, "【错误】:", code, e.Error()) 513 log.Debug("【检查权限】", userId, "【公司】", request.Cid, "【错误】:", code, e.Error())
@@ -520,7 +524,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) ( @@ -520,7 +524,8 @@ func LoginV2(header *protocol.RequestHeader, request *protocol.LoginRequestV2) (
520 err = protocol.NewErrWithMessage(10001, err) //账号不存在 524 err = protocol.NewErrWithMessage(10001, err) //账号不存在
521 return 525 return
522 } 526 }
523 - //根据simnum + cid 527 +
  528 + // 生成授权码
524 userClaims := utils.UserTokenClaims{ 529 userClaims := utils.UserTokenClaims{
525 UserId: userId, 530 UserId: userId,
526 CompanyId: int64(request.Cid), 531 CompanyId: int64(request.Cid),
@@ -2,6 +2,7 @@ package company @@ -2,6 +2,7 @@ package company
2 2
3 import ( 3 import (
4 "github.com/tiptok/gocomm/pkg/log" 4 "github.com/tiptok/gocomm/pkg/log"
  5 + "github.com/tiptok/gocomm/sync/task"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
@@ -11,6 +12,7 @@ import ( @@ -11,6 +12,7 @@ import (
11 "strings" 12 "strings"
12 ) 13 )
13 14
  15 +// 公司属性 合伙人类型/区域
14 func Property(header *protocol.RequestHeader, request *protocolx.PropertyRequest) (rsp *protocolx.PropertyResponse, err error) { 16 func Property(header *protocol.RequestHeader, request *protocolx.PropertyRequest) (rsp *protocolx.PropertyResponse, err error) {
15 var ( 17 var (
16 transactionContext, _ = factory.CreateTransactionContext(nil) 18 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -24,14 +26,19 @@ func Property(header *protocol.RequestHeader, request *protocolx.PropertyRequest @@ -24,14 +26,19 @@ func Property(header *protocol.RequestHeader, request *protocolx.PropertyRequest
24 transactionContext.RollbackTransaction() 26 transactionContext.RollbackTransaction()
25 }() 27 }()
26 28
27 - //用户查询区域  
28 - if (request.Action & 0x01) > 0 {  
29 - rsp.Districts, _ = getDistricts(header.UserId, transactionContext)  
30 - }  
31 - //查询合伙人类型  
32 - if (request.Action & 0x02) > 0 {  
33 - rsp.JoinWays, _ = getJoinWays(transactionContext)  
34 - } 29 + //并行查询区域/合伙人类型
  30 + task.Parallel(
  31 + func() {
  32 + if (request.Action & 0x01) > 0 {
  33 + rsp.Districts, _ = getDistricts(header.UserId, transactionContext)
  34 + }
  35 + },
  36 + func() {
  37 + if (request.Action & 0x02) > 0 {
  38 + rsp.JoinWays, _ = getJoinWays(transactionContext)
  39 + }
  40 + },
  41 + )
35 err = transactionContext.CommitTransaction() 42 err = transactionContext.CommitTransaction()
36 return 43 return
37 } 44 }
@@ -145,9 +152,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont @@ -145,9 +152,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
145 UsersRepository, _ = factory.CreateUsersRepository(transactionContext) 152 UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
146 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext) 153 PartnerInfoDao, _ = factory.CreatePartnerInfoDao(transactionContext)
147 OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext) 154 OrderBaseDao, _ = factory.CreateOrderBaseDao(transactionContext)
148 - //BusinessBonusDao, _ = factory.CreateBusinessBonusDao(transactionContext)  
149 - //user *domain.Users  
150 - partnerIds []int64 155 + partnerIds []int64
151 ) 156 )
152 if user, e := UsersRepository.FindOne(map[string]interface{}{"id": userId}); e != nil || user == nil { 157 if user, e := UsersRepository.FindOne(map[string]interface{}{"id": userId}); e != nil || user == nil {
153 return struct { 158 return struct {
@@ -156,10 +161,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont @@ -156,10 +161,7 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
156 partnerIds = user.AccessPartnerIds() 161 partnerIds = user.AccessPartnerIds()
157 } 162 }
158 Statistics := make(map[string]interface{}) 163 Statistics := make(map[string]interface{})
159 - //Statistics["developDividend"] = 0  
160 - //Statistics["developOrdersMoney"] = 0  
161 - //Statistics["appDividend"] = 0  
162 - //Statistics["appOrdersMoney"] = 0 164 + // TODO:分组统计
163 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil { 165 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.Career}); e == nil {
164 Statistics["careerCount"] = count 166 Statistics["careerCount"] = count
165 } 167 }
@@ -188,11 +190,6 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont @@ -188,11 +190,6 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
188 Statistics["appOrdersMoney"] = bonus.TotalOrderAmount 190 Statistics["appOrdersMoney"] = bonus.TotalOrderAmount
189 Statistics["appDividend"] = bonus.Bonus 191 Statistics["appDividend"] = bonus.Bonus
190 } 192 }
191 - //if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, IsDisable: 1}); e == nil {  
192 - // Statistics["businessDividend"] = businessBonus.Bonus  
193 - // Statistics["businessOrdersMoney"] = businessBonus.TotalOrderAmount  
194 - //}  
195 -  
196 Statistics["totalCount"] = len(partnerIds) 193 Statistics["totalCount"] = len(partnerIds)
197 return Statistics, nil 194 return Statistics, nil
198 } 195 }
@@ -218,6 +215,32 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo @@ -218,6 +215,32 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo
218 } 215 }
219 } 216 }
220 217
  218 + queryOption := newQueryOption(request)
  219 +
  220 + if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {
  221 + var array []interface{}
  222 + for i := range partners {
  223 + mapPartner := make(map[string]interface{})
  224 + p := partners[i]
  225 + mapPartner["uid"] = p.Id
  226 + mapPartner["uname"] = p.PartnerName
  227 + mapPartner["joinWays"] = newJoinWays(mapCategoryInfo, p)
  228 + if p.RegionInfo != nil {
  229 + mapPartner["district"] = protocolx.Districts{Id: p.RegionInfo.RegionId, Name: p.RegionInfo.RegionName}
  230 + }
  231 + mapPartner["cooperationTime"] = p.CooperateTime.Unix() * 1000
  232 + mapPartner["dividend"] = utils.Decimal(p.Bonus)
  233 + mapPartner["ordersCount"] = p.Total
  234 + mapPartner["ordersMoney"] = utils.Decimal(p.Amount)
  235 + array = append(array, mapPartner)
  236 + }
  237 + return array, nil
  238 + }
  239 + return nil, nil
  240 +}
  241 +
  242 +// 查询参数
  243 +func newQueryOption(request *protocolx.PartnersRequest) map[string]interface{} {
221 queryOption := make(map[string]interface{}) 244 queryOption := make(map[string]interface{})
222 245
223 if len(request.Districts) > 0 { 246 if len(request.Districts) > 0 {
@@ -247,33 +270,16 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo @@ -247,33 +270,16 @@ func getPartners(userId int64, request *protocolx.PartnersRequest, transactionCo
247 if request.SortBy != 0 { 270 if request.SortBy != 0 {
248 queryOption["sortByBonus"] = domain.ASC 271 queryOption["sortByBonus"] = domain.ASC
249 } 272 }
  273 + return queryOption
  274 +}
250 275
251 - if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {  
252 - var array []interface{}  
253 - for i := range partners {  
254 - mapPartners := make(map[string]interface{})  
255 - p := partners[i]  
256 - mapPartners["uid"] = p.Id  
257 - mapPartners["uname"] = p.PartnerName  
258 -  
259 - var joinWays []protocolx.JoinWays  
260 - for j := range p.PartnerCategoryInfos {  
261 - c := p.PartnerCategoryInfos[j]  
262 - if v, ok := mapCategoryInfo[c.Id]; ok {  
263 - joinWays = append(joinWays, protocolx.JoinWays{Type: v.Id, Name: v.Name})  
264 - }  
265 - }  
266 - mapPartners["joinWays"] = joinWays  
267 - if p.RegionInfo != nil {  
268 - mapPartners["district"] = protocolx.Districts{Id: p.RegionInfo.RegionId, Name: p.RegionInfo.RegionName}  
269 - }  
270 - mapPartners["cooperationTime"] = p.CooperateTime.Unix() * 1000  
271 - mapPartners["dividend"] = utils.Decimal(p.Bonus)  
272 - mapPartners["ordersCount"] = p.Total  
273 - mapPartners["ordersMoney"] = utils.Decimal(p.Amount)  
274 - array = append(array, mapPartners) 276 +func newJoinWays(mapCategoryInfo map[int64]*domain.PartnerCategoryInfo, p *domain.PartnerStatics) []protocolx.JoinWays {
  277 + var joinWays []protocolx.JoinWays
  278 + for j := range p.PartnerCategoryInfos {
  279 + c := p.PartnerCategoryInfos[j]
  280 + if v, ok := mapCategoryInfo[c.Id]; ok {
  281 + joinWays = append(joinWays, protocolx.JoinWays{Type: v.Id, Name: v.Name})
275 } 282 }
276 - return array, nil  
277 } 283 }
278 - return nil, nil 284 + return joinWays
279 } 285 }
@@ -48,8 +48,8 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction @@ -48,8 +48,8 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction
48 } 48 }
49 49
50 var company *domain.Company 50 var company *domain.Company
51 - var CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)  
52 - if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": user.CompanyId}); err != nil { 51 + var CompanyRepository, _ = factory.CreateCompanyRepository(transactionContext)
  52 + if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": user.CompanyId}); err != nil {
53 return nil, err 53 return nil, err
54 } 54 }
55 55
@@ -63,7 +63,31 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction @@ -63,7 +63,31 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction
63 } 63 }
64 } 64 }
65 65
  66 + queryOption := newQueryOptionV2(request)
  67 + if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {
  68 + var array []interface{}
  69 + for i := range partners {
  70 + mapPartners := make(map[string]interface{})
  71 + p := partners[i]
  72 + mapPartners["uid"] = p.Id
  73 + mapPartners["uname"] = p.PartnerName
  74 + mapPartners["joinWays"] = newJoinWays(mapCategoryInfo, p)
  75 + mapPartners["dividend"] = utils.Decimal(p.Bonus)
  76 + mapPartners["ordersCount"] = p.Total
  77 + mapPartners["ordersMoney"] = utils.Decimal(p.Amount)
  78 + mapPartners["phone"] = p.Account
  79 + mapPartners["company"] = newCompany(company, p)
  80 + array = append(array, mapPartners)
  81 + }
  82 + return array, nil
  83 + }
  84 + return nil, nil
  85 +}
  86 +
  87 +// 查询参数
  88 +func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{} {
66 queryOption := make(map[string]interface{}) 89 queryOption := make(map[string]interface{})
  90 +
67 if len(request.Districts) > 0 { 91 if len(request.Districts) > 0 {
68 var districts []string 92 var districts []string
69 for i := 0; i < len(request.Districts); i++ { 93 for i := 0; i < len(request.Districts); i++ {
@@ -84,6 +108,9 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction @@ -84,6 +108,9 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction
84 if request.EndTime > 0 { 108 if request.EndTime > 0 {
85 queryOption["endTime"] = request.EndTime / 1000 109 queryOption["endTime"] = request.EndTime / 1000
86 } 110 }
  111 + if request.Keyword != "" {
  112 + queryOption["keyword"] = request.Keyword
  113 + }
87 queryOption["limit"] = request.PageSize 114 queryOption["limit"] = request.PageSize
88 queryOption["offset"] = request.PageSize * request.PageIndex 115 queryOption["offset"] = request.PageSize * request.PageIndex
89 116
@@ -91,77 +118,23 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction @@ -91,77 +118,23 @@ func getPartnersV2(userId int64, request *protocolx.PartnersRequest, transaction
91 if request.SortBy != 0 { 118 if request.SortBy != 0 {
92 queryOption["sortByBonus"] = domain.ASC 119 queryOption["sortByBonus"] = domain.ASC
93 } 120 }
94 -  
95 - if partners, e := PartnerInfo.Partners(user.AccessPartnerIds(), queryOption); e == nil {  
96 - var array []interface{}  
97 - for i := range partners {  
98 - mapPartners := make(map[string]interface{})  
99 - p := partners[i]  
100 - mapPartners["uid"] = p.Id  
101 - mapPartners["uname"] = p.PartnerName  
102 -  
103 - var joinWays []protocolx.JoinWays  
104 - for j := range p.PartnerCategoryInfos {  
105 - c := p.PartnerCategoryInfos[j]  
106 - if v, ok := mapCategoryInfo[c.Id]; ok {  
107 - joinWays = append(joinWays, protocolx.JoinWays{Type: v.Id, Name: v.Name})  
108 - }  
109 - }  
110 - mapPartners["joinWays"] = joinWays  
111 -  
112 - mapPartners["dividend"] = utils.Decimal(p.Bonus)  
113 - mapPartners["ordersCount"] = p.Total  
114 - mapPartners["ordersMoney"] = utils.Decimal(p.Amount)  
115 - mapPartners["phone"] = p.Account  
116 -  
117 - partnerCompany := userx.Company{  
118 - Id: company.Id,  
119 - Name: company.Name,  
120 - Phone: company.Phone,  
121 - SerialNo: p.Id,  
122 - CooperateTime: p.CooperateTime.Unix() * 1000,  
123 - MiniProgram: nil,  
124 - District: map[string]interface{}{"id": p.RegionInfo.RegionId, "name": p.RegionInfo.RegionName},  
125 - }  
126 - if len(p.Salesman) > 0 {  
127 - partnerCompany.Salesman = map[string]interface{}{"uname": p.Salesman[0].Name, "phone": p.Salesman[0].Telephone}  
128 - } else {  
129 - partnerCompany.Salesman = map[string]interface{}{}  
130 - }  
131 - mapPartners["company"] = partnerCompany  
132 -  
133 - array = append(array, mapPartners)  
134 - }  
135 - return array, nil  
136 - }  
137 - return nil, nil 121 + return queryOption
138 } 122 }
139 123
140 -func funcPartnerCompanyInfo(companyId int64, transactionContext *transaction.TransactionContext) (partnerCompany userx.Company, err error) {  
141 - var (  
142 - CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)  
143 - company *domain.Company  
144 - )  
145 - if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": companyId}); err != nil {  
146 - return 124 +func newCompany(company *domain.Company, p *domain.PartnerStatics) userx.Company {
  125 + partnerCompany := userx.Company{
  126 + Id: company.Id,
  127 + Name: company.Name,
  128 + Phone: company.Phone,
  129 + SerialNo: p.Id,
  130 + CooperateTime: p.CooperateTime.Unix() * 1000,
  131 + MiniProgram: nil,
  132 + District: map[string]interface{}{"id": p.RegionInfo.RegionId, "name": p.RegionInfo.RegionName},
147 } 133 }
148 -  
149 - partnerCompany = userx.Company{  
150 - Id: company.Id,  
151 - Name: company.Name,  
152 - Phone: company.Phone,  
153 - //SerialNo: partnerInfo.Id,  
154 - //CooperateTime: partnerInfo.CooperateTime.Unix() * 1000,  
155 - MiniProgram: nil,  
156 - //District: map[string]interface{}{"id": partnerInfo.RegionInfo.RegionId, "name": partnerInfo.RegionInfo.RegionName}, 134 + if len(p.Salesman) > 0 {
  135 + partnerCompany.Salesman = map[string]interface{}{"uname": p.Salesman[0].Name, "phone": p.Salesman[0].Telephone}
  136 + } else {
  137 + partnerCompany.Salesman = map[string]interface{}{}
157 } 138 }
158 -  
159 - //if len(partnerInfo.Salesman) > 0 {  
160 - // u.CooperateCompany.Salesman = map[string]interface{}{"uname": partnerInfo.Salesman[0].Name, "phone": partnerInfo.Salesman[0].Telephone}  
161 - //} else {  
162 - // u.CooperateCompany.Salesman = map[string]interface{}{}  
163 - //}  
164 - //rspMap["user"] = u  
165 - //rsp = rspMap  
166 - return 139 + return partnerCompany
167 } 140 }
@@ -12,9 +12,9 @@ import ( @@ -12,9 +12,9 @@ import (
12 // 分红统计 12 // 分红统计
13 func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatisticsRequest) (rsp *protocol.DividendStatisticsResponse, err error) { 13 func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatisticsRequest) (rsp *protocol.DividendStatisticsResponse, err error) {
14 var ( 14 var (
15 - transactionContext, _ = factory.CreateTransactionContext(nil)  
16 - OrderBaseResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)  
17 - BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext) 15 + transactionContext, _ = factory.CreateTransactionContext(nil)
  16 + OrderBaseResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)
  17 + //BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext)
18 ) 18 )
19 if err = transactionContext.StartTransaction(); err != nil { 19 if err = transactionContext.StartTransaction(); err != nil {
20 return nil, err 20 return nil, err
@@ -40,17 +40,17 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -40,17 +40,17 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
40 bonusQuarters := QuartersBonusStatics(orderBetween, 0) 40 bonusQuarters := QuartersBonusStatics(orderBetween, 0)
41 41
42 // 业务分红统计 42 // 业务分红统计
43 - if bonus, e := BusinessBonusRepository.FindOne(map[string]interface{}{"partner_id": request.PartnerId, "isDisable": 1}); e == nil {  
44 - bonusAll.Receivable += bonus.Bonus  
45 - bonusAll.Received += bonus.BonusHas  
46 - bonusAll.Outstanding += bonus.BonusNot  
47 - if bonus.UpdateAt.Unix() >= (request.StartTime/1000) && bonus.UpdateAt.Unix() < (request.EndTime/1000) {  
48 - q := quarter(bonus.UpdateAt)  
49 - bonusQuarters[q].Receivable += bonus.Bonus  
50 - bonusQuarters[q].Received += bonus.BonusHas  
51 - bonusQuarters[q].Outstanding += bonus.BonusNot  
52 - }  
53 - } 43 + //if bonus, e := BusinessBonusRepository.FindOne(map[string]interface{}{"partner_id": request.PartnerId, "isDisable": 1}); e == nil {
  44 + // bonusAll.Receivable += bonus.Bonus
  45 + // bonusAll.Received += bonus.BonusHas
  46 + // bonusAll.Outstanding += bonus.BonusNot
  47 + // if bonus.UpdateAt.Unix() >= (request.StartTime/1000) && bonus.UpdateAt.Unix() < (request.EndTime/1000) {
  48 + // q := quarter(bonus.UpdateAt)
  49 + // bonusQuarters[q].Receivable += bonus.Bonus
  50 + // bonusQuarters[q].Received += bonus.BonusHas
  51 + // bonusQuarters[q].Outstanding += bonus.BonusNot
  52 + // }
  53 + //}
54 54
55 rsp = &protocol.DividendStatisticsResponse{} 55 rsp = &protocol.DividendStatisticsResponse{}
56 rsp.Statistics = protocol.DividendStatistics{ 56 rsp.Statistics = protocol.DividendStatistics{
@@ -124,16 +124,17 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR @@ -124,16 +124,17 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
124 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)} 124 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)}
125 125
126 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{ 126 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{
127 - OrderTypes: domain.UserOrderTypes(domain.Career),  
128 - PartnerId: request.PartnerId,  
129 - DetailAction: request.DetailAction,  
130 - DividendAction: request.DividendAction,  
131 - //IsDisable: "0", 127 + OrderTypes: domain.UserOrderTypes(domain.Career),
  128 + PartnerId: request.PartnerId,
  129 + DetailAction: request.DetailAction,
  130 + DividendAction: request.DividendAction,
132 StartTime: request.StartTime, 131 StartTime: request.StartTime,
133 EndTime: request.EndTime, 132 EndTime: request.EndTime,
134 Offset: request.PageIndex * request.PageSize, 133 Offset: request.PageIndex * request.PageSize,
135 Limit: request.PageSize, 134 Limit: request.PageSize,
136 - SortByUpdateTime: domain.DESC, 135 + //SortByUpdateTime: domain.DESC,
  136 + SortByCreateTime: domain.DESC,
  137 + JoinWays: request.JoinWays,
137 }) 138 })
138 if err != nil { 139 if err != nil {
139 return 140 return
@@ -145,7 +146,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR @@ -145,7 +146,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
145 item := &protocol.DividendOrderListItem{ 146 item := &protocol.DividendOrderListItem{
146 Id: o.Id, 147 Id: o.Id,
147 DeliveryNo: o.DeliveryCode, 148 DeliveryNo: o.DeliveryCode,
148 - OrderAmount: s.PlanOrderAmount, //s.OrderAmount(), 149 + OrderAmount: s.PlanOrderAmount,
149 DividendReceivable: utils.Decimal(s.OrderTotalReceivable()), 150 DividendReceivable: utils.Decimal(s.OrderTotalReceivable()),
150 } 151 }
151 rsp.List = append(rsp.List, item) 152 rsp.List = append(rsp.List, item)
@@ -177,7 +177,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic @@ -177,7 +177,7 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
177 func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (rsp *protocol.OrderListResponse, err error) { 177 func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (rsp *protocol.OrderListResponse, err error) {
178 var ( 178 var (
179 transactionContext, _ = factory.CreateTransactionContext(nil) 179 transactionContext, _ = factory.CreateTransactionContext(nil)
180 - OrderResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext) 180 + OrderRepository, _ = factory.CreateOrderBaseRepository(transactionContext)
181 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) 181 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext)
182 orders []*domain.OrderBase 182 orders []*domain.OrderBase
183 total int64 183 total int64
@@ -197,9 +197,12 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -197,9 +197,12 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
197 queryOption := &domain.OrderQueryOption{ 197 queryOption := &domain.OrderQueryOption{
198 Limit: request.PageSize, 198 Limit: request.PageSize,
199 Offset: request.PageSize * request.PageIndex, 199 Offset: request.PageSize * request.PageIndex,
200 - SortByUpdateTime: domain.DESC, 200 + //SortByUpdateTime: domain.DESC,
  201 + SortByCreateTime: domain.DESC,
201 PartnerId: request.PartnerId, 202 PartnerId: request.PartnerId,
202 PartnerCategoryId: request.JoinWay, 203 PartnerCategoryId: request.JoinWay,
  204 + OrderType: request.OrderType,
  205 + OrderTypes: request.OrderTypes,
203 } 206 }
204 if request.StartTime > 0 { 207 if request.StartTime > 0 {
205 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) 208 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0)
@@ -207,9 +210,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -207,9 +210,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
207 if request.EndTime > 0 { 210 if request.EndTime > 0 {
208 queryOption.EndTime = time.Unix(request.EndTime/1000, 0) 211 queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
209 } 212 }
210 - queryOption.OrderType = request.OrderType  
211 - queryOption.OrderTypes = request.OrderTypes  
212 - total, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption)) 213 + total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption))
213 if len(orders) != 0 { 214 if len(orders) != 0 {
214 for i := range orders { 215 for i := range orders {
215 item := DomainOrderToOrderListItem(orders[i]) 216 item := DomainOrderToOrderListItem(orders[i])
@@ -221,12 +222,11 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -221,12 +222,11 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
221 } 222 }
222 } 223 }
223 224
224 - // 查询统计数据 225 + // 【特殊处理1】 查询第0页时,需要查询累计实发订单数
225 if request.PageIndex == 0 { 226 if request.PageIndex == 0 {
226 var ( 227 var (
227 cumulativeQuantity int 228 cumulativeQuantity int
228 ) 229 )
229 - //累计实发订单  
230 cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ 230 cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
231 EndTime: time.Now().Unix() * 1000, 231 EndTime: time.Now().Unix() * 1000,
232 OrderTypes: domain.UserOrderTypes(domain.Career), 232 OrderTypes: domain.UserOrderTypes(domain.Career),
@@ -235,7 +235,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -235,7 +235,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
235 }) 235 })
236 rsp.Total = cumulativeQuantity 236 rsp.Total = cumulativeQuantity
237 } 237 }
238 - // 今天累计数量特殊处理,不需要返回所有订单总数(因为要复用rsp.Total字段) 238 + //【特殊处理2】 今天累计数量特殊处理 当前查询时间段内所有订单总数(复用rsp.Total字段)
239 if request.StartTime > 0 && request.EndTime > 0 { 239 if request.StartTime > 0 && request.EndTime > 0 {
240 zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix() 240 zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix()
241 if request.StartTime == (zero * 1000) { 241 if request.StartTime == (zero * 1000) {
@@ -249,13 +249,17 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -249,13 +249,17 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
249 func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem { 249 func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem {
250 bonusStatic := order.OrderBonusStatic() 250 bonusStatic := order.OrderBonusStatic()
251 return &protocol.OrderListItem{ 251 return &protocol.OrderListItem{
252 - Id: order.Id,  
253 - OrderType: order.OrderType,  
254 - OrderNo: order.OrderCode,  
255 - DeliveryNo: order.DeliveryCode,  
256 - OrderAmount: order.PlanOrderAmount,  
257 - UpdateTime: order.UpdateTime.Unix() * 1000,  
258 - MyDividend: bonusStatic.OrderTotalReceivable(),  
259 - IsRead: order.IsRead(), 252 + Id: order.Id,
  253 + OrderType: order.OrderType,
  254 + OrderNo: order.OrderCode,
  255 + DeliveryNo: order.DeliveryCode,
  256 + OrderDistrict: map[string]interface{}{
  257 + "id": order.RegionInfo.RegionId,
  258 + "name": order.RegionInfo.RegionName,
  259 + },
  260 + OrderAmount: order.PlanOrderAmount,
  261 + UpdateTime: order.UpdateTime.Unix() * 1000,
  262 + MyDividend: bonusStatic.OrderTotalReceivable(),
  263 + IsRead: order.IsRead(),
260 } 264 }
261 } 265 }
1 package order 1 package order
2 2
3 import ( 3 import (
  4 + "github.com/tiptok/gocomm/sync/task"
4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" 5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
@@ -23,9 +24,8 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist @@ -23,9 +24,8 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
23 rsp = &protocol.OrderStatisticsResponse{} 24 rsp = &protocol.OrderStatisticsResponse{}
24 25
25 //事业分红/业务分红 26 //事业分红/业务分红
26 - var total float64 //,developBonus,appBonus,careerBonus, businessBonus, 27 + var total float64
27 if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil { 28 if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil {
28 - //careerBonus = bonus.Bonus  
29 total += bonus.Bonus 29 total += bonus.Bonus
30 } 30 }
31 calcOrderStatic := func(catId int, total float64) protocol.OrderStatic { 31 calcOrderStatic := func(catId int, total float64) protocol.OrderStatic {
@@ -55,10 +55,12 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist @@ -55,10 +55,12 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
55 CumulativeMoney: utils.Decimal(cumulativeMoney), 55 CumulativeMoney: utils.Decimal(cumulativeMoney),
56 } 56 }
57 } 57 }
58 - rsp.Career = calcOrderStatic(domain.Career, total)  
59 - rsp.Business = calcOrderStatic(domain.Business, total)  
60 - rsp.Develop = calcOrderStatic(domain.Develop, total)  
61 - rsp.App = calcOrderStatic(domain.App, total) 58 + task.Parallel(
  59 + func() { rsp.Career = calcOrderStatic(domain.Career, total) },
  60 + func() { rsp.Business = calcOrderStatic(domain.Business, total) },
  61 + func() { rsp.Develop = calcOrderStatic(domain.Develop, total) },
  62 + func() { rsp.App = calcOrderStatic(domain.App, total) },
  63 + )
62 64
63 err = transactionContext.CommitTransaction() 65 err = transactionContext.CommitTransaction()
64 return 66 return
@@ -12,6 +12,7 @@ import ( @@ -12,6 +12,7 @@ import (
12 protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/partner" 12 protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/partner"
13 ) 13 )
14 14
  15 +// 模块已废弃
15 func Detail(header *protocol.RequestHeader, request *protocolx.DetailRequest) (rsp *protocolx.DetailResponse, err error) { 16 func Detail(header *protocol.RequestHeader, request *protocolx.DetailRequest) (rsp *protocolx.DetailResponse, err error) {
16 var ( 17 var (
17 transactionContext, _ = factory.CreateTransactionContext(nil) 18 transactionContext, _ = factory.CreateTransactionContext(nil)
@@ -22,14 +22,14 @@ import ( @@ -22,14 +22,14 @@ import (
22 //用户信息 22 //用户信息
23 func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) { 23 func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp *protocol.UserInfoResponse, err error) {
24 var ( 24 var (
25 - partnerInfo *domain.PartnerInfo  
26 - transactionContext, _ = factory.CreateTransactionContext(nil)  
27 - CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)  
28 - PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)  
29 - UsersRepository, _ = factory.CreateUsersRepository(transactionContext)  
30 - ImInfoRepository, _ = factory.CreateImInfoRepository(transactionContext)  
31 - company *domain.Company  
32 - user *domain.Users 25 + partnerInfo *domain.PartnerInfo
  26 + transactionContext, _ = factory.CreateTransactionContext(nil)
  27 + CompanyRepository, _ = factory.CreateCompanyRepository(transactionContext)
  28 + PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
  29 + UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
  30 + ImInfoRepository, _ = factory.CreateImInfoRepository(transactionContext)
  31 + company *domain.Company
  32 + user *domain.Users
33 ) 33 )
34 if err = transactionContext.StartTransaction(); err != nil { 34 if err = transactionContext.StartTransaction(); err != nil {
35 return nil, err 35 return nil, err
@@ -44,7 +44,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) @@ -44,7 +44,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
44 err = protocol.NewErrWithMessage(502, err) //账号不存在 44 err = protocol.NewErrWithMessage(502, err) //账号不存在
45 return 45 return
46 } 46 }
47 - if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { 47 + if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
48 return 48 return
49 } 49 }
50 rsp.User = protocol.User{ 50 rsp.User = protocol.User{
@@ -72,7 +72,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest) @@ -72,7 +72,7 @@ func UserInfo(header *protocol.RequestHeader, request *protocol.UserInfoRequest)
72 err = protocol.NewErrWithMessage(502, err) //账号不存在 72 err = protocol.NewErrWithMessage(502, err) //账号不存在
73 return 73 return
74 } 74 }
75 - if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { 75 + if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
76 return 76 return
77 } 77 }
78 rsp.User = protocol.User{ 78 rsp.User = protocol.User{
@@ -188,13 +188,13 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -188,13 +188,13 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
188 188
189 func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp interface{}, err error) { 189 func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoRequest) (rsp interface{}, err error) {
190 var ( 190 var (
191 - partnerInfo *domain.PartnerInfo  
192 - transactionContext, _ = factory.CreateTransactionContext(nil)  
193 - CompanyResponsitory, _ = factory.CreateCompanyRepository(transactionContext)  
194 - PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)  
195 - UsersRepository, _ = factory.CreateUsersRepository(transactionContext)  
196 - company *domain.Company  
197 - user *domain.Users 191 + partnerInfo *domain.PartnerInfo
  192 + transactionContext, _ = factory.CreateTransactionContext(nil)
  193 + CompanyRepository, _ = factory.CreateCompanyRepository(transactionContext)
  194 + PartnerInfoService, _ = factory.CreatePartnerInfoRepositoryIn(transactionContext)
  195 + UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
  196 + company *domain.Company
  197 + user *domain.Users
198 ) 198 )
199 if err = transactionContext.StartTransaction(); err != nil { 199 if err = transactionContext.StartTransaction(); err != nil {
200 return nil, err 200 return nil, err
@@ -209,7 +209,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques @@ -209,7 +209,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques
209 err = protocol.NewErrWithMessage(502, err) //账号不存在 209 err = protocol.NewErrWithMessage(502, err) //账号不存在
210 return 210 return
211 } 211 }
212 - if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { 212 + if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
213 return 213 return
214 } 214 }
215 var miniProgram map[string]interface{} 215 var miniProgram map[string]interface{}
@@ -253,7 +253,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques @@ -253,7 +253,7 @@ func UserInfoV2(header *protocol.RequestHeader, request *protocol.UserInfoReques
253 err = protocol.NewErrWithMessage(502, err) //账号不存在 253 err = protocol.NewErrWithMessage(502, err) //账号不存在
254 return 254 return
255 } 255 }
256 - if company, err = CompanyResponsitory.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil { 256 + if company, err = CompanyRepository.FindOne(map[string]interface{}{"id": header.CompanyId}); err != nil {
257 return 257 return
258 } 258 }
259 rspMap["user"] = userx.User{ 259 rspMap["user"] = userx.User{
@@ -2,11 +2,11 @@ package constant @@ -2,11 +2,11 @@ package constant
2 2
3 import "os" 3 import "os"
4 4
5 -var POSTGRESQL_DB_NAME = "partner_dev" //partner  
6 -var POSTGRESQL_USER = "postgres" //  
7 -var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123  
8 -var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1  
9 -var POSTGRESQL_PORT = "31543" //5432 5 +var POSTGRESQL_DB_NAME = "partner_dev" //partner_test/partner_dev
  6 +var POSTGRESQL_USER = "postgres" //postgres
  7 +var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123/1993618jack
  8 +var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1/114.55.200.59
  9 +var POSTGRESQL_PORT = "31543" //5432/31543
10 var DISABLE_CREATE_TABLE = true 10 var DISABLE_CREATE_TABLE = true
11 var DISABLE_SQL_GENERATE_PRINT = false 11 var DISABLE_SQL_GENERATE_PRINT = false
12 12
@@ -4,7 +4,7 @@ import "os" @@ -4,7 +4,7 @@ import "os"
4 4
5 var REDIS_HOST = "127.0.0.1" 5 var REDIS_HOST = "127.0.0.1"
6 var REDIS_PORT = "6379" 6 var REDIS_PORT = "6379"
7 -var REDIS_AUTH = "123456" 7 +var REDIS_AUTH = ""
8 8
9 func init() { 9 func init() {
10 if os.Getenv("REDIS_HOST") != "" { 10 if os.Getenv("REDIS_HOST") != "" {
@@ -2,6 +2,7 @@ package domain @@ -2,6 +2,7 @@ package domain
2 2
3 import ( 3 import (
4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
  5 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company"
5 "time" 6 "time"
6 ) 7 )
7 8
@@ -145,8 +146,10 @@ func (m *OrderBase) OrderBonusStatic() *OrderStatics { @@ -145,8 +146,10 @@ func (m *OrderBase) OrderBonusStatic() *OrderStatics {
145 } 146 }
146 147
147 type OrderQueryOption struct { 148 type OrderQueryOption struct {
148 - PartnerId int64 `json:"partnerId,omitempty"`  
149 - OrderType int `json:"orderType,omitempty"` 149 + PartnerId int64 `json:"partnerId,omitempty"`
  150 + // 订单类型 单个
  151 + OrderType int `json:"orderType,omitempty"`
  152 + // 订单类型 多个
150 OrderTypes []int `json:"orderTypes,omitempty"` 153 OrderTypes []int `json:"orderTypes,omitempty"`
151 OrderStatus int `json:"orderStatus,omitempty"` 154 OrderStatus int `json:"orderStatus,omitempty"`
152 BeginTime time.Time `json:"beginTime,omitempty"` 155 BeginTime time.Time `json:"beginTime,omitempty"`
@@ -171,6 +174,8 @@ type DividendOrdersQueryOption struct { @@ -171,6 +174,8 @@ type DividendOrdersQueryOption struct {
171 Offset int `json:"offset,omitempty"` 174 Offset int `json:"offset,omitempty"`
172 Limit int `json:"limit,omitempty"` 175 Limit int `json:"limit,omitempty"`
173 SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` 176 SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`
  177 + SortByCreateTime string `json:"sortByCreateTime,omitempty"`
  178 + JoinWays []*company.JoinWays `json:"joinWays,omitempty"` // 合伙类型
174 } 179 }
175 180
176 //买家 181 //买家
@@ -32,6 +32,7 @@ type OrderBonusQuery struct { @@ -32,6 +32,7 @@ type OrderBonusQuery struct {
32 OrderType int `json:"orderType,omitempty"` 32 OrderType int `json:"orderType,omitempty"`
33 OrderTypes []int `json:"orderTypes,omitempty"` 33 OrderTypes []int `json:"orderTypes,omitempty"`
34 PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型 34 PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型
  35 + //IsGroupByPartnerCategoryId bool `json:"isGroupByPartnerCategoryId,omitempty"`
35 } 36 }
36 37
37 // 订单分红统计-应答 38 // 订单分红统计-应答
@@ -44,4 +45,5 @@ type OrderBonusResponse struct { @@ -44,4 +45,5 @@ type OrderBonusResponse struct {
44 BonusExpense float64 `json:"bonusExpense,omitempty"` 45 BonusExpense float64 `json:"bonusExpense,omitempty"`
45 // 订单金额 46 // 订单金额
46 TotalOrderAmount float64 `json:"totalOrderAmount"` 47 TotalOrderAmount float64 `json:"totalOrderAmount"`
  48 + //PartnerCategory *PartnerCategoryInfo
47 } 49 }
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
  10 + "strings"
10 "time" 11 "time"
11 ) 12 )
12 13
@@ -62,6 +63,7 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d @@ -62,6 +63,7 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
62 q.ColumnExpr("sum((case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end)) bonus") 63 q.ColumnExpr("sum((case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end)) bonus")
63 q.ColumnExpr("sum(partner_bonus_expense) bonus_expense") 64 q.ColumnExpr("sum(partner_bonus_expense) bonus_expense")
64 q.ColumnExpr("sum(plan_order_amount) total_order_amount") 65 q.ColumnExpr("sum(plan_order_amount) total_order_amount")
  66 + //q.ColumnExpr("partner_category")
65 if option.PartnerId > 0 { 67 if option.PartnerId > 0 {
66 q.Where(`"order_base".partner_id =?`, option.PartnerId) 68 q.Where(`"order_base".partner_id =?`, option.PartnerId)
67 } 69 }
@@ -80,6 +82,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d @@ -80,6 +82,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
80 if option.PartnerCategoryId > 0 { 82 if option.PartnerCategoryId > 0 {
81 q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId) 83 q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId)
82 } 84 }
  85 + //if option.IsGroupByPartnerCategoryId{
  86 + // q.Group(`partner_category`)
  87 + //}
83 err = q.Select(&rsp.Total, &rsp.Bonus, &rsp.BonusExpense, &rsp.TotalOrderAmount) 88 err = q.Select(&rsp.Total, &rsp.Bonus, &rsp.BonusExpense, &rsp.TotalOrderAmount)
84 return 89 return
85 } 90 }
@@ -105,6 +110,20 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption @@ -105,6 +110,20 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption
105 if option.EndTime > 0 { 110 if option.EndTime > 0 {
106 q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) 111 q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0))
107 } 112 }
  113 + if len(option.JoinWays) > 0 {
  114 + var joinWays []int64
  115 + for i := 0; i < len(option.JoinWays); i++ {
  116 + joinWays = append(joinWays, option.JoinWays[i].Type)
  117 + }
  118 + var filterJoinWays = strings.Builder{}
  119 + for i := range joinWays {
  120 + filterJoinWays.WriteString(fmt.Sprintf(` partner_category @>'{"id":%v}'`, joinWays[i]))
  121 + if i != (len(joinWays) - 1) {
  122 + filterJoinWays.WriteString(" or ")
  123 + }
  124 + }
  125 + q.Where(filterJoinWays.String())
  126 + }
108 //if len(option.IsDisable) > 0 { 127 //if len(option.IsDisable) > 0 {
109 // value, _ := strconv.Atoi(option.IsDisable) 128 // value, _ := strconv.Atoi(option.IsDisable)
110 // q.Where(`"order_base".is_disable =?`, value) 129 // q.Where(`"order_base".is_disable =?`, value)
@@ -125,7 +144,11 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption @@ -125,7 +144,11 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption
125 q.Offset(option.Offset) 144 q.Offset(option.Offset)
126 } 145 }
127 if len(option.SortByUpdateTime) > 0 { 146 if len(option.SortByUpdateTime) > 0 {
128 - q.Order(fmt.Sprintf("order_base.id %v", option.SortByUpdateTime)) 147 + //q.Order(fmt.Sprintf("order_base.id %v", option.SortByUpdateTime))
  148 + q.Order(fmt.Sprintf("order_base.update_time %v", option.SortByUpdateTime))
  149 + }
  150 + if len(option.SortByCreateTime) > 0 {
  151 + q.Order(fmt.Sprintf("order_base.create_time %v", option.SortByCreateTime))
129 } 152 }
130 count, err = q.Distinct().SelectAndCount() 153 count, err = q.Distinct().SelectAndCount()
131 for i := range orders { 154 for i := range orders {
@@ -96,6 +96,9 @@ func (dao *PartnerInfoDao) Partners(partnerIds []int64, queryOptions map[string] @@ -96,6 +96,9 @@ func (dao *PartnerInfoDao) Partners(partnerIds []int64, queryOptions map[string]
96 if endTime, ok := queryOptions["endTime"]; ok { 96 if endTime, ok := queryOptions["endTime"]; ok {
97 filterPartners.WriteString(fmt.Sprintf(" and cooperate_time<to_timestamp(%v)", endTime)) 97 filterPartners.WriteString(fmt.Sprintf(" and cooperate_time<to_timestamp(%v)", endTime))
98 } 98 }
  99 + if keyword, ok := queryOptions["keyword"]; ok && keyword.(string) != "" {
  100 + filterPartners.WriteString(fmt.Sprintf(` and partner_name LIKE '%v'`, fmt.Sprintf("%%%s%%", "%%" + keyword.(string) + "%")))
  101 + }
99 102
100 sql.WriteString(fmt.Sprintf(` 103 sql.WriteString(fmt.Sprintf(`
101 SELECT A.*,B.total,B.amount,COALESCE(B.bonus,0) bonus,B.bonus_expense 104 SELECT A.*,B.total,B.amount,COALESCE(B.bonus,0) bonus,B.bonus_expense
@@ -23,7 +23,8 @@ type PgLoginService struct { @@ -23,7 +23,8 @@ type PgLoginService struct {
23 PartnerInfo []*domain.PartnerInfo 23 PartnerInfo []*domain.PartnerInfo
24 Users []*domain.Users 24 Users []*domain.Users
25 transactionContext *transaction.TransactionContext 25 transactionContext *transaction.TransactionContext
26 - AvailableCompany bool 26 + // 标识:登录的账号信息是否有可用的公司, true:有 false:没有
  27 + HasAvailableCompany bool
27 } 28 }
28 29
29 func (svr *PgLoginService) Init(phone string) (err error) { 30 func (svr *PgLoginService) Init(phone string) (err error) {
@@ -166,7 +167,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { @@ -166,7 +167,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
166 companys = append(companys, item) 167 companys = append(companys, item)
167 } 168 }
168 if len(companys) > 0 { 169 if len(companys) > 0 {
169 - svr.AvailableCompany = true 170 + svr.HasAvailableCompany = true
170 } 171 }
171 172
172 response["companys"] = companys 173 response["companys"] = companys
@@ -218,7 +219,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { @@ -218,7 +219,7 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
218 companys = append(companys, item) 219 companys = append(companys, item)
219 } 220 }
220 if len(companys) > 0 { 221 if len(companys) > 0 {
221 - svr.AvailableCompany = true 222 + svr.HasAvailableCompany = true
222 } 223 }
223 224
224 response["companys"] = companys 225 response["companys"] = companys
@@ -341,7 +342,7 @@ type joinWay struct { @@ -341,7 +342,7 @@ type joinWay struct {
341 342
342 func NewPgLoginService(ctx *transaction.TransactionContext) *PgLoginService { 343 func NewPgLoginService(ctx *transaction.TransactionContext) *PgLoginService {
343 return &PgLoginService{ 344 return &PgLoginService{
344 - transactionContext: ctx,  
345 - AvailableCompany: false, 345 + transactionContext: ctx,
  346 + HasAvailableCompany: false,
346 } 347 }
347 } 348 }
@@ -77,8 +77,7 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{}) @@ -77,8 +77,7 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{})
77 var OrderBaseModels []*models.OrderBase 77 var OrderBaseModels []*models.OrderBase
78 OrderBases := make([]*domain.OrderBase, 0) 78 OrderBases := make([]*domain.OrderBase, 0)
79 query := NewQuery(tx.Model(&OrderBaseModels), queryOptions) 79 query := NewQuery(tx.Model(&OrderBaseModels), queryOptions)
80 - query.  
81 - SetWhere(`"order_base".partner_id= ?`, "partnerId"). 80 + query.SetWhere(`"order_base".partner_id= ?`, "partnerId").
82 SetWhere(`"order_base".order_type= ?`, "orderType"). 81 SetWhere(`"order_base".order_type= ?`, "orderType").
83 SetWhere(`"order_base".create_time >= ?`, "beginTime"). 82 SetWhere(`"order_base".create_time >= ?`, "beginTime").
84 SetWhere(`"order_base".create_time < ?`, "endTime"). 83 SetWhere(`"order_base".create_time < ?`, "endTime").
@@ -183,7 +183,7 @@ func (this *AuthController) CenterCompanys() { @@ -183,7 +183,7 @@ func (this *AuthController) CenterCompanys() {
183 return 183 return
184 } 184 }
185 header := this.GetRequestHeader(this.Ctx) 185 header := this.GetRequestHeader(this.Ctx)
186 - data, err := auth.CenterCompanys(header, request) 186 + data, err := auth.CompaniesLogin(header, request)
187 if err != nil { 187 if err != nil {
188 log.Error(err) 188 log.Error(err)
189 } 189 }
@@ -211,7 +211,7 @@ func (this *AuthController) Companys() { @@ -211,7 +211,7 @@ func (this *AuthController) Companys() {
211 return 211 return
212 } 212 }
213 header := this.GetRequestHeader(this.Ctx) 213 header := this.GetRequestHeader(this.Ctx)
214 - data, err := auth.Companys(header, request) 214 + data, err := auth.CompaniesLoginByCredential(header, request)
215 if err != nil { 215 if err != nil {
216 log.Error(err) 216 log.Error(err)
217 } 217 }
@@ -26,8 +26,8 @@ func CreateResponseLogFilter(logger *logs.BeeLogger) func(ctx *context.Context) @@ -26,8 +26,8 @@ func CreateResponseLogFilter(logger *logs.BeeLogger) func(ctx *context.Context)
26 return func(ctx *context.Context) { 26 return func(ctx *context.Context) {
27 requestId := ctx.Request.Header.Get("requestId") 27 requestId := ctx.Request.Header.Get("requestId")
28 body, _ := json.Marshal(ctx.Input.GetData("outputData")) 28 body, _ := json.Marshal(ctx.Input.GetData("outputData"))
29 - if len(body) > 1000 {  
30 - body = body[:1000] 29 + if len(body) > 10000 {
  30 + body = body[:10000]
31 } 31 }
32 logger.Debug(fmt.Sprintf("<====Send RequestId:%v BodyData:%s", requestId, body)) 32 logger.Debug(fmt.Sprintf("<====Send RequestId:%v BodyData:%s", requestId, body))
33 } 33 }
@@ -29,7 +29,7 @@ type LoginResponse struct { @@ -29,7 +29,7 @@ type LoginResponse struct {
29 29
30 type LoginRequestV2 struct { 30 type LoginRequestV2 struct {
31 Cid int `json:"cid"` 31 Cid int `json:"cid"`
32 - IdType int `json:"idType"` 32 + IdType int `json:"idType"` // 用户类型 1:合伙人 2:高管
33 Credentials string `json:"credentials"` // 登录类型 1:密码 2:验证码 33 Credentials string `json:"credentials"` // 登录类型 1:密码 2:验证码
34 ClientId string `json:"clientId"` 34 ClientId string `json:"clientId"`
35 } 35 }
@@ -15,4 +15,6 @@ type PartnersRequest struct { @@ -15,4 +15,6 @@ type PartnersRequest struct {
15 JoinWays []JoinWays `json:"joinWays"` 15 JoinWays []JoinWays `json:"joinWays"`
16 // 分红排序(0.从多到少 1.从少到多) 16 // 分红排序(0.从多到少 1.从少到多)
17 SortBy int `json:"sortBy"` 17 SortBy int `json:"sortBy"`
  18 + // 合伙人姓名
  19 + Keyword string `json:"keyword"`
18 } 20 }
1 package protocol 1 package protocol
2 2
  3 +import "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company"
  4 +
3 const ( 5 const (
4 BonusTotal = iota //0 累计分红 6 BonusTotal = iota //0 累计分红
5 BonusOutstanding //1 分红支出 7 BonusOutstanding //1 分红支出
@@ -38,6 +40,9 @@ type DividendOrdersRequest struct { @@ -38,6 +40,9 @@ type DividendOrdersRequest struct {
38 StartTime int64 `json:"startTime"` 40 StartTime int64 `json:"startTime"`
39 EndTime int64 `json:"endTime" valid:"Required"` 41 EndTime int64 `json:"endTime" valid:"Required"`
40 42
  43 + // 合作类型(空或不传,即所有类型)
  44 + JoinWays []*company.JoinWays `json:"joinWays"`
  45 +
41 PageIndex int `json:"pageIndex,omitempty"` 46 PageIndex int `json:"pageIndex,omitempty"`
42 PageSize int `json:"pageSize,omitempty"` 47 PageSize int `json:"pageSize,omitempty"`
43 48
@@ -24,6 +24,7 @@ type OrderDetailResponse struct { @@ -24,6 +24,7 @@ type OrderDetailResponse struct {
24 // MyDividend float64 `json:"myDividend"` 24 // MyDividend float64 `json:"myDividend"`
25 // MyDividendPercent float64 `json:"myDividendPercent"` 25 // MyDividendPercent float64 `json:"myDividendPercent"`
26 //} 26 //}
  27 +
27 type OrderDetail struct { 28 type OrderDetail struct {
28 Id int64 `json:"id"` 29 Id int64 `json:"id"`
29 OrderNo string `json:"orderNo"` //订单号 30 OrderNo string `json:"orderNo"` //订单号
@@ -36,6 +37,7 @@ type OrderDetail struct { @@ -36,6 +37,7 @@ type OrderDetail struct {
36 Products interface{} `json:"products"` 37 Products interface{} `json:"products"`
37 Total interface{} `json:"total"` 38 Total interface{} `json:"total"`
38 } 39 }
  40 +
39 type Customer struct { 41 type Customer struct {
40 Uname string `json:"uname"` 42 Uname string `json:"uname"`
41 Phone string `json:"phone"` 43 Phone string `json:"phone"`
@@ -110,8 +112,11 @@ type OrderListItem struct { @@ -110,8 +112,11 @@ type OrderListItem struct {
110 OrderStatus int `json:"-"` 112 OrderStatus int `json:"-"`
111 //实际订单数量 113 //实际订单数量
112 OrderActualCount int `json:"-"` 114 OrderActualCount int `json:"-"`
  115 + // 订单区域
  116 + OrderDistrict map[string]interface{} `json:"orderDistrict"`
113 //订单金额 117 //订单金额
114 OrderAmount float64 `json:"orderAmount"` 118 OrderAmount float64 `json:"orderAmount"`
  119 + // 订单更新时间
115 UpdateTime int64 `json:"updateTime"` 120 UpdateTime int64 `json:"updateTime"`
116 //我的分红 121 //我的分红
117 MyDividend float64 `json:"dividendReceivable"` 122 MyDividend float64 `json:"dividendReceivable"`