|
@@ -47,6 +47,8 @@ const ( |
|
@@ -47,6 +47,8 @@ const ( |
47
|
CreditAccountStatistics = "CreditAccountStatistics"
|
47
|
CreditAccountStatistics = "CreditAccountStatistics"
|
48
|
// 公司/个人 - 支付历史统计直方图
|
48
|
// 公司/个人 - 支付历史统计直方图
|
49
|
PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics"
|
49
|
PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics"
|
|
|
50
|
+ // 用户相关的项目合约编号列表查询
|
|
|
51
|
+ RelevantCooperationContractNumbers = "RelevantCooperationContractNumbers"
|
50
|
)
|
52
|
)
|
51
|
|
53
|
|
52
|
// CooperationStatisticsService 共创统计服务
|
54
|
// CooperationStatisticsService 共创统计服务
|
|
@@ -181,7 +183,6 @@ func (ptr *CooperationStatisticsService) getRelevantContracts(queryOptions map[s |
|
@@ -181,7 +183,6 @@ func (ptr *CooperationStatisticsService) getRelevantContracts(queryOptions map[s |
181
|
if len(numbers) == 0 {
|
183
|
if len(numbers) == 0 {
|
182
|
return []string{}, nil
|
184
|
return []string{}, nil
|
183
|
}
|
185
|
}
|
184
|
- queryOptions["cooperationContractNumbers"] = numbers
|
|
|
185
|
return numbers, err
|
186
|
return numbers, err
|
186
|
}
|
187
|
}
|
187
|
|
188
|
|
|
@@ -348,6 +349,7 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st |
|
@@ -348,6 +349,7 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st |
348
|
//企业
|
349
|
//企业
|
349
|
CompanyId int64 `json:"companyId"`
|
350
|
CompanyId int64 `json:"companyId"`
|
350
|
OrgId int64 `json:"orgId"`
|
351
|
OrgId int64 `json:"orgId"`
|
|
|
352
|
+ UserId int64 `json:"userId"`
|
351
|
//个人
|
353
|
//个人
|
352
|
UserBaseId int64 `json:"userBaseId"`
|
354
|
UserBaseId int64 `json:"userBaseId"`
|
353
|
}{}
|
355
|
}{}
|
|
@@ -363,14 +365,32 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st |
|
@@ -363,14 +365,32 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st |
363
|
Paid float64 `json:"paid"`
|
365
|
Paid float64 `json:"paid"`
|
364
|
}
|
366
|
}
|
365
|
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
367
|
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
|
|
|
368
|
+ var contractNumbers []string
|
|
|
369
|
+ var err error
|
|
|
370
|
+ if request.OrgId > 0 && request.UserId > 0 {
|
|
|
371
|
+ contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userId": request.UserId})
|
|
|
372
|
+ if err != nil {
|
|
|
373
|
+ return struct{}{}, err
|
|
|
374
|
+ }
|
|
|
375
|
+ } else if request.UserBaseId > 0 {
|
|
|
376
|
+ contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId})
|
|
|
377
|
+ if err != nil {
|
|
|
378
|
+ return struct{}{}, err
|
|
|
379
|
+ }
|
|
|
380
|
+ }
|
|
|
381
|
+
|
|
|
382
|
+ queryOptions["cooperationContractNumbers"] = contractNumbers
|
366
|
|
383
|
|
367
|
var allDividends = &CreditAccountStatisticsResponse{}
|
384
|
var allDividends = &CreditAccountStatisticsResponse{}
|
|
|
385
|
+ var annualDividends = &CreditAccountStatisticsResponse{}
|
|
|
386
|
+ var quarterDividends = &CreditAccountStatisticsResponse{}
|
|
|
387
|
+
|
|
|
388
|
+ if len(contractNumbers) > 0 {
|
368
|
if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil {
|
389
|
if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil {
|
369
|
return nil, err
|
390
|
return nil, err
|
370
|
}
|
391
|
}
|
371
|
allDividends.Accounting = allDividends.Total - allDividends.Accounted
|
392
|
allDividends.Accounting = allDividends.Total - allDividends.Accounted
|
372
|
|
393
|
|
373
|
- var annualDividends = &CreditAccountStatisticsResponse{}
|
|
|
374
|
queryOptions["beginTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local)
|
394
|
queryOptions["beginTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local)
|
375
|
queryOptions["endTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local).AddDate(1, 0, 0)
|
395
|
queryOptions["endTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local).AddDate(1, 0, 0)
|
376
|
if err := creditAccountDao.DividendsStatistics(queryOptions, annualDividends); err != nil {
|
396
|
if err := creditAccountDao.DividendsStatistics(queryOptions, annualDividends); err != nil {
|
|
@@ -378,12 +398,12 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st |
|
@@ -378,12 +398,12 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st |
378
|
}
|
398
|
}
|
379
|
annualDividends.Accounting = annualDividends.Total - annualDividends.Accounted
|
399
|
annualDividends.Accounting = annualDividends.Total - annualDividends.Accounted
|
380
|
|
400
|
|
381
|
- var quarterDividends = &CreditAccountStatisticsResponse{}
|
|
|
382
|
queryOptions["beginTime"], queryOptions["endTime"] = quarterBeginEnd()
|
401
|
queryOptions["beginTime"], queryOptions["endTime"] = quarterBeginEnd()
|
383
|
if err := creditAccountDao.DividendsStatistics(queryOptions, quarterDividends); err != nil {
|
402
|
if err := creditAccountDao.DividendsStatistics(queryOptions, quarterDividends); err != nil {
|
384
|
return nil, err
|
403
|
return nil, err
|
385
|
}
|
404
|
}
|
386
|
quarterDividends.Accounting = quarterDividends.Total - quarterDividends.Accounted
|
405
|
quarterDividends.Accounting = quarterDividends.Total - quarterDividends.Accounted
|
|
|
406
|
+ }
|
387
|
|
407
|
|
388
|
ret := map[string]interface{}{
|
408
|
ret := map[string]interface{}{
|
389
|
"allDividends": allDividends,
|
409
|
"allDividends": allDividends,
|
|
@@ -423,6 +443,8 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
|
@@ -423,6 +443,8 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
423
|
var request = struct {
|
443
|
var request = struct {
|
424
|
CompanyId int64 `json:"companyId"`
|
444
|
CompanyId int64 `json:"companyId"`
|
425
|
OrgId int64 `json:"orgId"`
|
445
|
OrgId int64 `json:"orgId"`
|
|
|
446
|
+ UserId int64 `json:"userId"`
|
|
|
447
|
+
|
426
|
UserBaseId int64 `json:"userBaseId"`
|
448
|
UserBaseId int64 `json:"userBaseId"`
|
427
|
DividendsAccountStatus int32 `json:"dividendsAccountStatus"` // 分红结算状态
|
449
|
DividendsAccountStatus int32 `json:"dividendsAccountStatus"` // 分红结算状态
|
428
|
Offset int64 `json:"offset"`
|
450
|
Offset int64 `json:"offset"`
|
|
@@ -433,10 +455,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
|
@@ -433,10 +455,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
433
|
}
|
455
|
}
|
434
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
456
|
queryOptions = tool_funs.SimpleStructToMap(&request)
|
435
|
|
457
|
|
436
|
- dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
|
|
437
|
- _, estimates, err := dividendsEstimateRepository.Find(queryOptions)
|
458
|
+ var contractNumbers []string
|
|
|
459
|
+ var err error
|
|
|
460
|
+ if request.OrgId > 0 && request.UserId > 0 {
|
|
|
461
|
+ contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userId": request.UserId})
|
438
|
if err != nil {
|
462
|
if err != nil {
|
439
|
- return nil, err
|
463
|
+ return struct{}{}, err
|
|
|
464
|
+ }
|
|
|
465
|
+ } else if request.UserBaseId > 0 {
|
|
|
466
|
+ contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId})
|
|
|
467
|
+ if err != nil {
|
|
|
468
|
+ return struct{}{}, err
|
|
|
469
|
+ }
|
440
|
}
|
470
|
}
|
441
|
type response struct {
|
471
|
type response struct {
|
442
|
// 承接人分红预算记录ID
|
472
|
// 承接人分红预算记录ID
|
|
@@ -457,6 +487,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
|
@@ -457,6 +487,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
457
|
CustomerName string `json:"customerName"`
|
487
|
CustomerName string `json:"customerName"`
|
458
|
}
|
488
|
}
|
459
|
var results = make([]response, 0)
|
489
|
var results = make([]response, 0)
|
|
|
490
|
+ if len(contractNumbers) == 0 {
|
|
|
491
|
+ return results, nil
|
|
|
492
|
+ }
|
|
|
493
|
+
|
|
|
494
|
+ queryOptions["cooperationContractNumbers"] = contractNumbers
|
|
|
495
|
+
|
|
|
496
|
+ dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
|
|
|
497
|
+ _, estimates, err := dividendsEstimateRepository.Find(queryOptions)
|
|
|
498
|
+ if err != nil {
|
|
|
499
|
+ return nil, err
|
|
|
500
|
+ }
|
|
|
501
|
+
|
460
|
dividendsOrderRepository, _ := repository.NewDividendsOrderRepository(ptr.transactionContext)
|
502
|
dividendsOrderRepository, _ := repository.NewDividendsOrderRepository(ptr.transactionContext)
|
461
|
dividendsReturnedOrderRepository, _ := repository.NewDividendsReturnedOrderRepository(ptr.transactionContext)
|
503
|
dividendsReturnedOrderRepository, _ := repository.NewDividendsReturnedOrderRepository(ptr.transactionContext)
|
462
|
for i := range estimates {
|
504
|
for i := range estimates {
|
|
@@ -469,6 +511,7 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
|
@@ -469,6 +511,7 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m |
469
|
DividendsType: item.DividendsType,
|
511
|
DividendsType: item.DividendsType,
|
470
|
DividendsUser: item.DividendsUser,
|
512
|
DividendsUser: item.DividendsUser,
|
471
|
}
|
513
|
}
|
|
|
514
|
+ // TODO:优化查询 统一查询到map里面
|
472
|
if item.DividendsType == 1 {
|
515
|
if item.DividendsType == 1 {
|
473
|
order, err := dividendsOrderRepository.FindOne(map[string]interface{}{
|
516
|
order, err := dividendsOrderRepository.FindOne(map[string]interface{}{
|
474
|
"dividendsOrderNumber": item.OrderOrReturnedOrderNum,
|
517
|
"dividendsOrderNumber": item.OrderOrReturnedOrderNum,
|
|
@@ -499,6 +542,8 @@ func (ptr *CooperationStatisticsService) CreditAccountStatistics(queryOptions ma |
|
@@ -499,6 +542,8 @@ func (ptr *CooperationStatisticsService) CreditAccountStatistics(queryOptions ma |
499
|
UserBaseId int64 `json:"userBaseId"`
|
542
|
UserBaseId int64 `json:"userBaseId"`
|
500
|
BeginTime time.Time `json:"beginTime"`
|
543
|
BeginTime time.Time `json:"beginTime"`
|
501
|
EndTime time.Time `json:"endTime"`
|
544
|
EndTime time.Time `json:"endTime"`
|
|
|
545
|
+ // 合约编号列表
|
|
|
546
|
+ CooperationContractNumbers []string `json:"cooperationContractNumbers"`
|
502
|
}{}
|
547
|
}{}
|
503
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
548
|
if err := LoadQueryObject(queryOptions, &request); err != nil {
|
504
|
return nil, err
|
549
|
return nil, err
|
|
@@ -522,3 +567,24 @@ type CreditAccountStatisticsResponse struct { |
|
@@ -522,3 +567,24 @@ type CreditAccountStatisticsResponse struct { |
522
|
Paid float64 `json:"paid"`
|
567
|
Paid float64 `json:"paid"`
|
523
|
Unpaid float64 `json:"unpaid"`
|
568
|
Unpaid float64 `json:"unpaid"`
|
524
|
}
|
569
|
}
|
|
|
570
|
+
|
|
|
571
|
+//getRelevantContracts 获取相关人的合约
|
|
|
572
|
+func (ptr *CooperationStatisticsService) RelevantCooperationContractNumbers(queryOptions map[string]interface{}) (interface{}, error) {
|
|
|
573
|
+ var request = struct {
|
|
|
574
|
+ //企业
|
|
|
575
|
+ CompanyId int64 `json:"companyId" valid:"Required"`
|
|
|
576
|
+ OrgId int64 `json:"orgId" valid:"Required"`
|
|
|
577
|
+ UserId int64 `json:"userId" valid:"Required"`
|
|
|
578
|
+ //个人
|
|
|
579
|
+ //UserBaseId int64 `json:"userBaseId"`
|
|
|
580
|
+ //Offset int `json:"offset"`
|
|
|
581
|
+ //Limit int `json:"limit"`
|
|
|
582
|
+ }{}
|
|
|
583
|
+ if err := LoadQueryObject(queryOptions, &request); err != nil {
|
|
|
584
|
+ return nil, err
|
|
|
585
|
+ }
|
|
|
586
|
+ queryOptions = tool_funs.SimpleStructToMap(&request)
|
|
|
587
|
+
|
|
|
588
|
+ contractNumbers, err := ptr.getRelevantContracts(queryOptions)
|
|
|
589
|
+ return contractNumbers, err
|
|
|
590
|
+} |