|
@@ -309,25 +309,25 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans |
|
@@ -309,25 +309,25 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans |
309
|
// 贡献值、财富值总榜和年榜,
|
309
|
// 贡献值、财富值总榜和年榜,
|
310
|
func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) {
|
310
|
func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) {
|
311
|
var retWealth []struct { // 个人财富值
|
311
|
var retWealth []struct { // 个人财富值
|
312
|
- Uid int
|
312
|
+ Uid int64
|
313
|
EmployeeName string
|
313
|
EmployeeName string
|
314
|
EmployeeSuMoney float64
|
314
|
EmployeeSuMoney float64
|
315
|
Ranking int
|
315
|
Ranking int
|
316
|
}
|
316
|
}
|
317
|
var retEmployeeWealth []struct { // 个人贡献值
|
317
|
var retEmployeeWealth []struct { // 个人贡献值
|
318
|
- Uid int
|
318
|
+ Uid int64
|
319
|
EmployeeName string
|
319
|
EmployeeName string
|
320
|
EmployeeSuMoney float64
|
320
|
EmployeeSuMoney float64
|
321
|
Ranking int
|
321
|
Ranking int
|
322
|
}
|
322
|
}
|
323
|
var retContributions []struct { // 员工贡献值
|
323
|
var retContributions []struct { // 员工贡献值
|
324
|
- Uid int
|
324
|
+ Uid int64
|
325
|
EmployeeName string
|
325
|
EmployeeName string
|
326
|
EmployeesContributions float64
|
326
|
EmployeesContributions float64
|
327
|
Ranking int
|
327
|
Ranking int
|
328
|
}
|
328
|
}
|
329
|
var retEmployeeContributions []struct { // 员工贡献值
|
329
|
var retEmployeeContributions []struct { // 员工贡献值
|
330
|
- Uid int
|
330
|
+ Uid int64
|
331
|
EmployeeName string
|
331
|
EmployeeName string
|
332
|
EmployeesContributions float64
|
332
|
EmployeesContributions float64
|
333
|
Ranking int
|
333
|
Ranking int
|
|
@@ -342,7 +342,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -342,7 +342,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
342
|
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
342
|
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
343
|
//queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
343
|
//queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
344
|
queryWealth = queryWealth.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money")
|
344
|
queryWealth = queryWealth.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money")
|
345
|
- queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end), e.create_time DESC) AS ranking")
|
345
|
+ queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking")
|
346
|
queryWealth = queryWealth.Where(`e.status = ?`, 1)
|
346
|
queryWealth = queryWealth.Where(`e.status = ?`, 1)
|
347
|
//queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
347
|
//queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
348
|
queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
348
|
queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
|
@@ -371,7 +371,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -371,7 +371,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
371
|
} else {
|
371
|
} else {
|
372
|
queryWealth = queryWealth.Limit(20)
|
372
|
queryWealth = queryWealth.Limit(20)
|
373
|
}
|
373
|
}
|
374
|
- queryWealth = queryWealth.Order("employee_su_money DESC")
|
374
|
+ queryWealth = queryWealth.Order("ranking ASC")
|
375
|
if err := queryWealth.Select(&retWealth); err != nil {
|
375
|
if err := queryWealth.Select(&retWealth); err != nil {
|
376
|
return nil, err
|
376
|
return nil, err
|
377
|
}
|
377
|
}
|
|
@@ -380,9 +380,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -380,9 +380,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
380
|
queryWealthWith := tx.Model(suMoneyTransactionRecordModel)
|
380
|
queryWealthWith := tx.Model(suMoneyTransactionRecordModel)
|
381
|
queryWealthWith = queryWealthWith.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
381
|
queryWealthWith = queryWealthWith.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
382
|
queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
382
|
queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
383
|
- queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
383
|
+ //queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
384
|
queryWealthWith = queryWealthWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money")
|
384
|
queryWealthWith = queryWealthWith.ColumnExpr("sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) AS employee_su_money")
|
385
|
- queryWealthWith = queryWealthWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end), e.create_time DESC) AS ranking")
|
385
|
+ queryWealthWith = queryWealthWith.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(case WHEN su_money_transaction_record.record_type IN (2, 3, 6) THEN su_money_transaction_record.su_money ELSE 0 end) - sum(case WHEN su_money_transaction_record.record_type IN (4, 1, 5) THEN su_money_transaction_record.su_money ELSE 0 end) DESC) AS ranking")
|
386
|
queryWealthWith = queryWealthWith.Where(`e.status = ?`, 1)
|
386
|
queryWealthWith = queryWealthWith.Where(`e.status = ?`, 1)
|
387
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
387
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
388
|
queryWealthWith = queryWealthWith.Where("e.company_id = ?", companyId)
|
388
|
queryWealthWith = queryWealthWith.Where("e.company_id = ?", companyId)
|
|
@@ -393,12 +393,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -393,12 +393,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
393
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
393
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
394
|
queryWealthWith = queryWealthWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
394
|
queryWealthWith = queryWealthWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
395
|
}
|
395
|
}
|
396
|
- queryWealthRestoreWith := queryWealthWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
396
|
+ //queryWealthRestoreWith := queryWealthWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName', e.create_time")
|
|
|
397
|
+ queryWealthRestoreWith := queryWealthWith.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
397
|
querySelfWealth := tx.Model()
|
398
|
querySelfWealth := tx.Model()
|
398
|
querySelfWealth = querySelfWealth.With("t", queryWealthRestoreWith)
|
399
|
querySelfWealth = querySelfWealth.With("t", queryWealthRestoreWith)
|
399
|
querySelfWealth = querySelfWealth.Table("t")
|
400
|
querySelfWealth = querySelfWealth.Table("t")
|
400
|
querySelfWealth = querySelfWealth.ColumnExpr("t.uid AS uid")
|
401
|
querySelfWealth = querySelfWealth.ColumnExpr("t.uid AS uid")
|
401
|
- querySelfWealth = querySelfWealth.ColumnExpr("t.employee_name AS employee_name")
|
402
|
+ //querySelfWealth = querySelfWealth.ColumnExpr("t.employee_name AS employee_name")
|
402
|
querySelfWealth = querySelfWealth.ColumnExpr("t.employee_su_money AS employee_su_money")
|
403
|
querySelfWealth = querySelfWealth.ColumnExpr("t.employee_su_money AS employee_su_money")
|
403
|
querySelfWealth = querySelfWealth.ColumnExpr("t.ranking AS ranking")
|
404
|
querySelfWealth = querySelfWealth.ColumnExpr("t.ranking AS ranking")
|
404
|
if uid, ok := queryOptions["uid"]; ok {
|
405
|
if uid, ok := queryOptions["uid"]; ok {
|
|
@@ -420,7 +421,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -420,7 +421,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
420
|
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
421
|
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
421
|
//queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
422
|
//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")
|
423
|
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), e.create_time DESC) AS ranking")
|
424
|
+ 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(`e.status = ?`, 1)
|
425
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
425
|
//queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
426
|
//queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
426
|
queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
427
|
queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
|
@@ -449,7 +450,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -449,7 +450,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
449
|
} else {
|
450
|
} else {
|
450
|
queryContributions = queryContributions.Limit(20)
|
451
|
queryContributions = queryContributions.Limit(20)
|
451
|
}
|
452
|
}
|
452
|
- if err := queryContributions.Order("employees_contributions DESC").Select(&retContributions); err != nil {
|
453
|
+ if err := queryContributions.Order("ranking ASC").Select(&retContributions); err != nil {
|
453
|
return nil, err
|
454
|
return nil, err
|
454
|
}
|
455
|
}
|
455
|
|
456
|
|
|
@@ -457,9 +458,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -457,9 +458,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
457
|
queryContributionsWith := tx.Model(suMoneyTransactionRecordModel)
|
458
|
queryContributionsWith := tx.Model(suMoneyTransactionRecordModel)
|
458
|
queryContributionsWith = queryContributionsWith.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
459
|
queryContributionsWith = queryContributionsWith.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
459
|
queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
460
|
queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
460
|
- queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
461
|
+ //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")
|
462
|
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), e.create_time AS ranking")
|
463
|
+ 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(`e.status = ?`, 1)
|
464
|
queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
|
464
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
465
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
465
|
queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
|
466
|
queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
|
|
@@ -470,12 +471,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -470,12 +471,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
470
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
471
|
if endTime, ok := queryOptions["endTime"]; ok && !endTime.(time.Time).IsZero() {
|
471
|
queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
472
|
queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
472
|
}
|
473
|
}
|
473
|
- contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
474
|
+ //contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName', e.create_time")
|
|
|
475
|
+ contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
474
|
querySelfContributions := tx.Model()
|
476
|
querySelfContributions := tx.Model()
|
475
|
querySelfContributions = querySelfContributions.With("t", contributionsWith)
|
477
|
querySelfContributions = querySelfContributions.With("t", contributionsWith)
|
476
|
querySelfContributions = querySelfContributions.Table("t")
|
478
|
querySelfContributions = querySelfContributions.Table("t")
|
477
|
querySelfContributions = querySelfContributions.ColumnExpr("t.uid AS uid")
|
479
|
querySelfContributions = querySelfContributions.ColumnExpr("t.uid AS uid")
|
478
|
- querySelfContributions = querySelfContributions.ColumnExpr("t.employee_name AS employee_name")
|
480
|
+ //querySelfContributions = querySelfContributions.ColumnExpr("t.employee_name AS employee_name")
|
479
|
querySelfContributions = querySelfContributions.ColumnExpr("t.employees_contributions AS employees_contributions")
|
481
|
querySelfContributions = querySelfContributions.ColumnExpr("t.employees_contributions AS employees_contributions")
|
480
|
querySelfContributions = querySelfContributions.ColumnExpr("t.ranking AS ranking")
|
482
|
querySelfContributions = querySelfContributions.ColumnExpr("t.ranking AS ranking")
|
481
|
if uid, ok := queryOptions["uid"]; ok {
|
483
|
if uid, ok := queryOptions["uid"]; ok {
|