|
@@ -334,7 +334,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -334,7 +334,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
334
|
}
|
334
|
}
|
335
|
|
335
|
|
336
|
tx := dao.transactionContext.PgTx
|
336
|
tx := dao.transactionContext.PgTx
|
337
|
-
|
|
|
338
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
337
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
339
|
|
338
|
|
340
|
// 财富值排行榜
|
339
|
// 财富值排行榜
|
|
@@ -421,8 +420,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -421,8 +420,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
421
|
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
420
|
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
422
|
queryContributions = queryContributions.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions")
|
421
|
queryContributions = queryContributions.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions")
|
423
|
queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking")
|
422
|
queryContributions = queryContributions.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking")
|
424
|
- //queryContributions = queryContributions.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
|
|
|
425
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
423
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
|
|
424
|
+ queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
426
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
425
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
427
|
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
|
426
|
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
|
428
|
}
|
427
|
}
|
|
@@ -432,7 +431,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -432,7 +431,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
432
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
431
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
433
|
queryContributions = queryContributions.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
432
|
queryContributions = queryContributions.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
434
|
}
|
433
|
}
|
435
|
- queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
|
|
436
|
if offset, ok := queryOptions["offset"]; ok {
|
434
|
if offset, ok := queryOptions["offset"]; ok {
|
437
|
offset := offset.(int)
|
435
|
offset := offset.(int)
|
438
|
if offset > -1 {
|
436
|
if offset > -1 {
|
|
@@ -460,7 +458,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -460,7 +458,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
460
|
queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
458
|
queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
461
|
queryContributionsWith = queryContributionsWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions")
|
459
|
queryContributionsWith = queryContributionsWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) AS employees_contributions")
|
462
|
queryContributionsWith = queryContributionsWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking")
|
460
|
queryContributionsWith = queryContributionsWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type = 4 THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking")
|
463
|
- //queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
|
|
|
464
|
queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
|
461
|
queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
|
465
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
462
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
466
|
queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
|
463
|
queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
|
|
@@ -471,7 +468,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -471,7 +468,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
471
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
468
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
472
|
queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
469
|
queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
473
|
}
|
470
|
}
|
474
|
- contributionsWith := queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
471
|
+ contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
475
|
querySelfContributions := tx.Model()
|
472
|
querySelfContributions := tx.Model()
|
476
|
querySelfContributions = querySelfContributions.With("t", contributionsWith)
|
473
|
querySelfContributions = querySelfContributions.With("t", contributionsWith)
|
477
|
querySelfContributions = querySelfContributions.Table("t")
|
474
|
querySelfContributions = querySelfContributions.Table("t")
|