|
@@ -365,7 +365,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -365,7 +365,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
365
|
queryWealth = queryWealth.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
365
|
queryWealth = queryWealth.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
366
|
}
|
366
|
}
|
367
|
queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
367
|
queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
368
|
- queryWealthWith := queryWealth.Order("employee_su_money DESC") // 个人财富值子查询
|
368
|
+
|
|
|
369
|
+ // 个人财富值子查询
|
|
|
370
|
+ queryWealthWith := queryWealth.Order("employee_su_money DESC")
|
|
|
371
|
+
|
369
|
if offset, ok := queryOptions["offset"]; ok {
|
372
|
if offset, ok := queryOptions["offset"]; ok {
|
370
|
offset := offset.(int)
|
373
|
offset := offset.(int)
|
371
|
if offset > -1 {
|
374
|
if offset > -1 {
|
|
@@ -450,7 +453,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -450,7 +453,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
450
|
queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
|
453
|
queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
|
451
|
}
|
454
|
}
|
452
|
queryContributions = queryContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
|
455
|
queryContributions = queryContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
|
453
|
- //queryContributionsWith := queryContributions.Order("employees_contributions DESC") // 个人贡献值子查询
|
456
|
+
|
|
|
457
|
+ // 个人贡献值子查询
|
|
|
458
|
+ queryContributionsWith := queryContributions.Order("employees_contributions DESC")
|
|
|
459
|
+
|
454
|
if offset, ok := queryOptions["offset"]; ok {
|
460
|
if offset, ok := queryOptions["offset"]; ok {
|
455
|
offset := offset.(int)
|
461
|
offset := offset.(int)
|
456
|
if offset > -1 {
|
462
|
if offset > -1 {
|
|
@@ -471,52 +477,18 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -471,52 +477,18 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
471
|
return nil, err
|
477
|
return nil, err
|
472
|
}
|
478
|
}
|
473
|
|
479
|
|
474
|
- // 个人贡献值子查询-减少的贡献值排名
|
|
|
475
|
- queryEmployeeContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
|
|
|
476
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
|
|
477
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
|
478
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
|
|
479
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_contributions_decrease")
|
|
|
480
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
|
|
|
481
|
- if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
482
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where("e.company_id = ?", companyId)
|
|
|
483
|
- }
|
|
|
484
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`e.status = ?`, 1)
|
|
|
485
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`su_money_transaction_record.record_type = ?`, 4)
|
|
|
486
|
- if startTime, ok := queryOptions["startTime"]; ok {
|
|
|
487
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`su_money_transaction_record.create_time > ?`, startTime)
|
|
|
488
|
- }
|
|
|
489
|
- if endTime, ok := queryOptions["endTime"]; ok {
|
|
|
490
|
- queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
|
|
491
|
- }
|
|
|
492
|
- employeeContributionsDecrease := queryEmployeeContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
|
|
493
|
-
|
|
|
494
|
- // 个人贡献值排名
|
480
|
+ // 个人贡献值
|
495
|
queryEmployeeContributions := tx.Model()
|
481
|
queryEmployeeContributions := tx.Model()
|
496
|
- queryEmployeeContributions = queryEmployeeContributions.With("t", employeeContributionsDecrease)
|
482
|
+ queryEmployeeContributions = queryEmployeeContributions.With("t", queryContributionsWith)
|
497
|
queryEmployeeContributions = queryEmployeeContributions.Table("t")
|
483
|
queryEmployeeContributions = queryEmployeeContributions.Table("t")
|
498
|
- queryEmployeeContributions = queryEmployeeContributions.Table("su_money_transaction_records")
|
|
|
499
|
- queryEmployeeContributions = queryEmployeeContributions.Join("JOIN employees AS e ON e.uid = (su_money_transaction_records.employee->>'uid')::bigint")
|
|
|
500
|
- queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid")
|
|
|
501
|
- queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name")
|
|
|
502
|
- queryEmployeeContributions = queryEmployeeContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`)
|
|
|
503
|
- queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking")
|
|
|
504
|
- if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
505
|
- queryEmployeeContributions = queryContributions.Where("e.company_id = ?", companyId)
|
|
|
506
|
- }
|
|
|
507
|
- queryEmployeeContributions = queryEmployeeContributions.Where(`e.status = ?`, 1)
|
|
|
508
|
- queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))
|
|
|
509
|
- if startTime, ok := queryOptions["startTime"]; ok {
|
|
|
510
|
- queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.create_time > ?`, startTime)
|
|
|
511
|
- }
|
|
|
512
|
- if endTime, ok := queryOptions["endTime"]; ok {
|
|
|
513
|
- queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
|
|
|
514
|
- }
|
484
|
+ queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("t.uid AS uid")
|
|
|
485
|
+ queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("t.employee_name AS employee_name")
|
|
|
486
|
+ queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("t.employees_contributions AS employees_contributions")
|
|
|
487
|
+ queryEmployeeContributions = queryEmployeeContributions.ColumnExpr("t.ranking AS ranking")
|
515
|
if uid, ok := queryOptions["uid"]; ok {
|
488
|
if uid, ok := queryOptions["uid"]; ok {
|
516
|
- queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.employee @> '{"uid":?}'`, uid)
|
489
|
+ queryEmployeeContributions = queryEmployeeContributions.Where("t.uid::bigint = ?", uid)
|
517
|
}
|
490
|
}
|
518
|
- queryEmployeeContributions = queryEmployeeContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
|
|
|
519
|
- if err := queryEmployeeContributions.Order("employees_contributions DESC").Select(&retEmployeeContributions); err != nil {
|
491
|
+ if err := queryEmployeeContributions.Select(&retEmployeeContributions); err != nil {
|
520
|
return nil, err
|
492
|
return nil, err
|
521
|
}
|
493
|
}
|
522
|
var retCurrentEmployeeContributions interface{}
|
494
|
var retCurrentEmployeeContributions interface{}
|