|
@@ -432,18 +432,18 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -432,18 +432,18 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
432
|
|
432
|
|
433
|
/**********************************************贡献值排行榜****************************************/
|
433
|
/**********************************************贡献值排行榜****************************************/
|
434
|
|
434
|
|
435
|
- // 减少的贡献值
|
435
|
+ // 贡献值
|
436
|
queryContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
|
436
|
queryContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
|
437
|
queryContributionsDecrease = queryContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
437
|
queryContributionsDecrease = queryContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
438
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
438
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
439
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
439
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
440
|
- queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_contributions_decrease")
|
440
|
+ queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_contributions")
|
441
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
|
441
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
|
442
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
442
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
443
|
queryContributionsDecrease = queryContributionsDecrease.Where("e.company_id = ?", companyId)
|
443
|
queryContributionsDecrease = queryContributionsDecrease.Where("e.company_id = ?", companyId)
|
444
|
}
|
444
|
}
|
445
|
queryContributionsDecrease = queryContributionsDecrease.Where(`e.status = ?`, 1)
|
445
|
queryContributionsDecrease = queryContributionsDecrease.Where(`e.status = ?`, 1)
|
446
|
- queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.record_type = ?`, 4)
|
446
|
+ queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
|
447
|
if startTime, ok := queryOptions["startTime"]; ok {
|
447
|
if startTime, ok := queryOptions["startTime"]; ok {
|
448
|
queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time > ?`, startTime)
|
448
|
queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time > ?`, startTime)
|
449
|
}
|
449
|
}
|
|
@@ -454,19 +454,18 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -454,19 +454,18 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
454
|
// 贡献值子查询
|
454
|
// 贡献值子查询
|
455
|
contributionsDecrease := queryContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
455
|
contributionsDecrease := queryContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
456
|
|
456
|
|
457
|
- // 贡献值排行榜
|
457
|
+ // 减少的贡献值
|
458
|
queryContributions := tx.Model()
|
458
|
queryContributions := tx.Model()
|
459
|
queryContributions = queryContributions.With("t", contributionsDecrease)
|
459
|
queryContributions = queryContributions.With("t", contributionsDecrease)
|
460
|
queryContributions = queryContributions.Table("t")
|
460
|
queryContributions = queryContributions.Table("t")
|
461
|
queryContributions = queryContributions.Table("su_money_transaction_records")
|
461
|
queryContributions = queryContributions.Table("su_money_transaction_records")
|
462
|
queryContributions = queryContributions.Join("JOIN employees AS e ON e.uid = (su_money_transaction_records.employee->>'uid')::bigint")
|
462
|
queryContributions = queryContributions.Join("JOIN employees AS e ON e.uid = (su_money_transaction_records.employee->>'uid')::bigint")
|
463
|
- queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid")
|
|
|
464
|
- queryContributions = queryContributions.ColumnExpr("su_money_transaction_records.employee->>'employeeName' AS employee_name")
|
|
|
465
|
- queryContributions = queryContributions.ColumnExpr(`(sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease) AS employees_contributions`)
|
|
|
466
|
- queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_records.su_money) - t.employee_contributions_decrease DESC) AS ranking")
|
|
|
467
|
- queryContributions = queryContributions.Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3}))
|
463
|
+ queryContributions = queryContributions.ColumnExpr("t.uid AS uid")
|
|
|
464
|
+ queryContributions = queryContributions.ColumnExpr("t.employee_name AS employee_name")
|
|
|
465
|
+ queryContributions = queryContributions.ColumnExpr(`t.employee_contributions - sum(su_money_transaction_records.su_money) AS employees_contributions`)
|
|
|
466
|
+ queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY t.employee_contributions - sum(su_money_transaction_records.su_money) DESC) AS ranking")
|
|
|
467
|
+ queryContributions = queryContributions.Where(`su_money_transaction_records.record_type = ?`, 4)
|
468
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
468
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
469
|
- queryContributions = queryContributions.Where("su_money_transaction_records.employee->>'uid' = t.uid")
|
|
|
470
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
469
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
471
|
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
|
470
|
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
|
472
|
}
|
471
|
}
|
|
@@ -476,7 +475,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -476,7 +475,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
476
|
if endTime, ok := queryOptions["endTime"]; ok {
|
475
|
if endTime, ok := queryOptions["endTime"]; ok {
|
477
|
queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
|
476
|
queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
|
478
|
}
|
477
|
}
|
479
|
- queryContributions = queryContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
|
478
|
+ queryContributions = queryContributions.GroupExpr("t.uid, t.employee_name, t.employee_contributions")
|
480
|
|
479
|
|
481
|
// 个人贡献值子查询
|
480
|
// 个人贡献值子查询
|
482
|
queryContributionsWith := queryContributions.Order("employees_contributions DESC")
|
481
|
queryContributionsWith := queryContributions.Order("employees_contributions DESC")
|