|
@@ -102,7 +102,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
|
@@ -102,7 +102,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
102
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
102
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
103
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
103
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
104
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
104
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
105
|
- //Where(`su_money_transaction_record.record_type = ?`, 2).
|
|
|
106
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
|
105
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
|
107
|
Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).
|
106
|
Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).
|
108
|
Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).
|
107
|
Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).
|
|
@@ -113,7 +112,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
|
@@ -113,7 +112,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
113
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
112
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
114
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
113
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
115
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
114
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
116
|
- //Where(`su_money_transaction_record.record_type = ?`, 2).
|
|
|
117
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).
|
115
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).
|
118
|
Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).
|
116
|
Where(`su_money_transaction_record.create_time > ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 0, 0, 0, 0, yesterday.Location())).
|
119
|
Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).
|
117
|
Where(`su_money_transaction_record.create_time < ?`, time.Date(yesterday.Year(), yesterday.Month(), yesterday.Day(), 23, 59, 59, 0, yesterday.Location())).
|
|
@@ -124,7 +122,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
|
@@ -124,7 +122,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
124
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
122
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
125
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
123
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
126
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
124
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
127
|
- //Where(`su_money_transaction_record.record_type = ?`, 2).
|
|
|
128
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
|
125
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
|
129
|
Select(&incomeSuMoney); err != nil {
|
126
|
Select(&incomeSuMoney); err != nil {
|
130
|
return nil, err
|
127
|
return nil, err
|
|
@@ -133,7 +130,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
|
@@ -133,7 +130,6 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ |
133
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
130
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
134
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
131
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS income_su_money").
|
135
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
132
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
136
|
- //Where(`su_money_transaction_record.record_type = ?`, 2).
|
|
|
137
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).
|
133
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).
|
138
|
Select(&expendSuMoney); err != nil {
|
134
|
Select(&expendSuMoney); err != nil {
|
139
|
return nil, err
|
135
|
return nil, err
|
|
@@ -323,13 +319,13 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans |
|
@@ -323,13 +319,13 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans |
323
|
|
319
|
|
324
|
// 贡献值、财富值总榜和年榜,
|
320
|
// 贡献值、财富值总榜和年榜,
|
325
|
func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) {
|
321
|
func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) {
|
326
|
- var retWealth []struct {
|
322
|
+ var retWealth []struct { // 个人财富值
|
327
|
Uid int
|
323
|
Uid int
|
328
|
EmployeeName string
|
324
|
EmployeeName string
|
329
|
EmployeeSuMoney float64
|
325
|
EmployeeSuMoney float64
|
330
|
Ranking int
|
326
|
Ranking int
|
331
|
}
|
327
|
}
|
332
|
- var retEmployeeWealth []struct {
|
328
|
+ var retEmployeeWealth []struct { // 个人贡献值
|
333
|
Uid int
|
329
|
Uid int
|
334
|
EmployeeName string
|
330
|
EmployeeName string
|
335
|
EmployeeSuMoney float64
|
331
|
EmployeeSuMoney float64
|
|
@@ -349,13 +345,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -349,13 +345,13 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
349
|
}
|
345
|
}
|
350
|
tx := dao.transactionContext.PgTx
|
346
|
tx := dao.transactionContext.PgTx
|
351
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
347
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
348
|
+
|
352
|
// 财富值榜单
|
349
|
// 财富值榜单
|
353
|
queryWealth := tx.Model(suMoneyTransactionRecordModel)
|
350
|
queryWealth := tx.Model(suMoneyTransactionRecordModel)
|
354
|
queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
351
|
queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
355
|
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
352
|
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
356
|
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
353
|
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
357
|
queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
|
354
|
queryWealth = queryWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
|
358
|
- //queryWealth = queryWealth.ColumnExpr("RANK() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC, su_money_transaction_record.create_time) AS ranking")
|
|
|
359
|
queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
|
355
|
queryWealth = queryWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
|
360
|
queryWealth = queryWealth.Where(`e.status = ?`, 1)
|
356
|
queryWealth = queryWealth.Where(`e.status = ?`, 1)
|
361
|
queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
|
357
|
queryWealth = queryWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
|
|
@@ -368,12 +364,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -368,12 +364,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
368
|
if endTime, ok := queryOptions["endTime"]; ok {
|
364
|
if endTime, ok := queryOptions["endTime"]; ok {
|
369
|
queryWealth = queryWealth.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
365
|
queryWealth = queryWealth.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
370
|
}
|
366
|
}
|
371
|
- //queryWealth = queryWealth.Group("su_money_transaction_record.employee")
|
|
|
372
|
- //queryWealth = queryWealth.Group("su_money_transaction_record.employee #>> '{uid}'")
|
|
|
373
|
-
|
|
|
374
|
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'")
|
375
|
- //queryWealth = queryWealth.Group("su_money_transaction_record.create_time")
|
|
|
376
|
- //queryWealth = queryWealth.Group(`su_money_transaction_record->'employee'->>'employeeName'`)
|
368
|
+ queryWealthWith := queryWealth.Order("employee_su_money DESC") // 个人财富值子查询
|
377
|
if offset, ok := queryOptions["offset"]; ok {
|
369
|
if offset, ok := queryOptions["offset"]; ok {
|
378
|
offset := offset.(int)
|
370
|
offset := offset.(int)
|
379
|
if offset > -1 {
|
371
|
if offset > -1 {
|
|
@@ -390,36 +382,23 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -390,36 +382,23 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
390
|
} else {
|
382
|
} else {
|
391
|
queryWealth = queryWealth.Limit(20)
|
383
|
queryWealth = queryWealth.Limit(20)
|
392
|
}
|
384
|
}
|
393
|
- if err := queryWealth.Order("employee_su_money DESC").Select(&retWealth); err != nil {
|
385
|
+ queryWealth = queryWealth.Order("employee_su_money DESC")
|
|
|
386
|
+ if err := queryWealth.Select(&retWealth); err != nil {
|
394
|
return nil, err
|
387
|
return nil, err
|
395
|
}
|
388
|
}
|
396
|
|
389
|
|
397
|
- // 当前员工财富值排名
|
|
|
398
|
- queryEmployeeWealth := tx.Model(suMoneyTransactionRecordModel)
|
|
|
399
|
- queryEmployeeWealth = queryEmployeeWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
|
|
400
|
- queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
|
401
|
- queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
|
|
402
|
- queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money")
|
|
|
403
|
- queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(su_money_transaction_record.su_money) DESC) AS ranking")
|
|
|
404
|
- queryEmployeeWealth = queryEmployeeWealth.Where(`e.status = ?`, 1)
|
|
|
405
|
- queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3}))
|
|
|
406
|
- if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
407
|
- queryEmployeeWealth = queryEmployeeWealth.Where("e.company_id = ?", companyId)
|
|
|
408
|
- }
|
|
|
409
|
- if startTime, ok := queryOptions["startTime"]; ok {
|
|
|
410
|
- queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.create_time > ?`, startTime)
|
|
|
411
|
- }
|
|
|
412
|
- if endTime, ok := queryOptions["endTime"]; ok {
|
|
|
413
|
- queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
|
|
414
|
- }
|
|
|
415
|
- //queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.employee")
|
|
|
416
|
- //queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.employee #>> '{uid}' ")
|
|
|
417
|
- //queryEmployeeWealth = queryEmployeeWealth.Group("su_money_transaction_record.create_time")
|
|
|
418
|
- queryEmployeeWealth = queryEmployeeWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
390
|
+ // 个人财富值排名
|
|
|
391
|
+ queryEmployeeWealth := tx.Model()
|
|
|
392
|
+ queryEmployeeWealth = queryEmployeeWealth.With("t", queryWealthWith)
|
|
|
393
|
+ queryEmployeeWealth = queryEmployeeWealth.Table("t")
|
|
|
394
|
+ queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("t.uid AS uid")
|
|
|
395
|
+ queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("t.employee_name AS employee_name")
|
|
|
396
|
+ queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("t.employee_su_money AS employee_su_money")
|
|
|
397
|
+ queryEmployeeWealth = queryEmployeeWealth.ColumnExpr("t.ranking AS ranking")
|
419
|
if uid, ok := queryOptions["uid"]; ok {
|
398
|
if uid, ok := queryOptions["uid"]; ok {
|
420
|
- queryEmployeeWealth = queryEmployeeWealth.Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid)
|
399
|
+ queryEmployeeWealth = queryEmployeeWealth.Where("t.uid::bigint = ?", uid)
|
421
|
}
|
400
|
}
|
422
|
- if err := queryEmployeeWealth.Order("employee_su_money DESC").Select(&retEmployeeWealth); err != nil {
|
401
|
+ if err := queryEmployeeWealth.Select(&retEmployeeWealth); err != nil {
|
423
|
return nil, err
|
402
|
return nil, err
|
424
|
}
|
403
|
}
|
425
|
var retCurrentEmployeeWealth interface{}
|
404
|
var retCurrentEmployeeWealth interface{}
|
|
@@ -429,7 +408,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -429,7 +408,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
429
|
retCurrentEmployeeWealth = retEmployeeWealth[0]
|
408
|
retCurrentEmployeeWealth = retEmployeeWealth[0]
|
430
|
}
|
409
|
}
|
431
|
|
410
|
|
432
|
- // 贡献值榜单-减少的贡献致富
|
411
|
+ // 贡献值子查询-减少的贡献值
|
433
|
queryContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
|
412
|
queryContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
|
434
|
queryContributionsDecrease = queryContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
413
|
queryContributionsDecrease = queryContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
435
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
414
|
queryContributionsDecrease = queryContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
@@ -447,8 +426,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -447,8 +426,6 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
447
|
if endTime, ok := queryOptions["endTime"]; ok {
|
426
|
if endTime, ok := queryOptions["endTime"]; ok {
|
448
|
queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
427
|
queryContributionsDecrease = queryContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
449
|
}
|
428
|
}
|
450
|
- //contributionsDecrease := queryContributionsDecrease.Group("su_money_transaction_record.employee").Group("su_money_transaction_record.create_time")
|
|
|
451
|
- //contributionsDecrease := queryContributionsDecrease.Group("su_money_transaction_record.employee #>> '{uid}'").Group("su_money_transaction_record.create_time")
|
|
|
452
|
contributionsDecrease := queryContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
429
|
contributionsDecrease := queryContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
453
|
|
430
|
|
454
|
// 贡献值排行榜
|
431
|
// 贡献值排行榜
|
|
@@ -472,11 +449,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -472,11 +449,8 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
472
|
if endTime, ok := queryOptions["endTime"]; ok {
|
449
|
if endTime, ok := queryOptions["endTime"]; ok {
|
473
|
queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
|
450
|
queryContributions = queryContributions.Where(`su_money_transaction_records.create_time < ?`, endTime)
|
474
|
}
|
451
|
}
|
475
|
- //queryContributions = queryContributions.Group("su_money_transaction_records.employee")
|
|
|
476
|
- //queryContributions = queryContributions.Group("su_money_transaction_records.employee #>> '{uid}'")
|
|
|
477
|
- //queryContributions = queryContributions.Group("t.employee_contributions_decrease")
|
|
|
478
|
- //queryContributions = queryContributions.Group("su_money_transaction_records.create_time")
|
|
|
479
|
queryContributions = queryContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
|
452
|
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") // 个人贡献值子查询
|
480
|
if offset, ok := queryOptions["offset"]; ok {
|
454
|
if offset, ok := queryOptions["offset"]; ok {
|
481
|
offset := offset.(int)
|
455
|
offset := offset.(int)
|
482
|
if offset > -1 {
|
456
|
if offset > -1 {
|
|
@@ -497,7 +471,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -497,7 +471,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
497
|
return nil, err
|
471
|
return nil, err
|
498
|
}
|
472
|
}
|
499
|
|
473
|
|
500
|
- // 当前员工贡献值-减少的贡献值排名
|
474
|
+ // 个人贡献值子查询-减少的贡献值排名
|
501
|
queryEmployeeContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
|
475
|
queryEmployeeContributionsDecrease := tx.Model(suMoneyTransactionRecordModel)
|
502
|
queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
476
|
queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
503
|
queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
477
|
queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
@@ -515,10 +489,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -515,10 +489,9 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
515
|
if endTime, ok := queryOptions["endTime"]; ok {
|
489
|
if endTime, ok := queryOptions["endTime"]; ok {
|
516
|
queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
490
|
queryEmployeeContributionsDecrease = queryEmployeeContributionsDecrease.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
517
|
}
|
491
|
}
|
518
|
- //employeeContributionsDecrease := queryEmployeeContributionsDecrease.Group("su_money_transaction_record.employee")
|
|
|
519
|
employeeContributionsDecrease := queryEmployeeContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
492
|
employeeContributionsDecrease := queryEmployeeContributionsDecrease.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
520
|
|
493
|
|
521
|
- // 当前员工贡献值排名
|
494
|
+ // 个人贡献值排名
|
522
|
queryEmployeeContributions := tx.Model()
|
495
|
queryEmployeeContributions := tx.Model()
|
523
|
queryEmployeeContributions = queryEmployeeContributions.With("t", employeeContributionsDecrease)
|
496
|
queryEmployeeContributions = queryEmployeeContributions.With("t", employeeContributionsDecrease)
|
524
|
queryEmployeeContributions = queryEmployeeContributions.Table("t")
|
497
|
queryEmployeeContributions = queryEmployeeContributions.Table("t")
|
|
@@ -542,9 +515,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -542,9 +515,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
542
|
if uid, ok := queryOptions["uid"]; ok {
|
515
|
if uid, ok := queryOptions["uid"]; ok {
|
543
|
queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.employee @> '{"uid":?}'`, uid)
|
516
|
queryEmployeeContributions = queryEmployeeContributions.Where(`su_money_transaction_records.employee @> '{"uid":?}'`, uid)
|
544
|
}
|
517
|
}
|
545
|
- //queryEmployeeContributions = queryEmployeeContributions.Group("su_money_transaction_records.employee")
|
|
|
546
|
queryEmployeeContributions = queryEmployeeContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
|
518
|
queryEmployeeContributions = queryEmployeeContributions.GroupExpr("su_money_transaction_records.employee->>'uid',su_money_transaction_records.employee->>'employeeName',t.employee_contributions_decrease")
|
547
|
- //queryEmployeeContributions = queryEmployeeContributions.Group("t.employee_contributions_decrease")
|
|
|
548
|
if err := queryEmployeeContributions.Order("employees_contributions DESC").Select(&retEmployeeContributions); err != nil {
|
519
|
if err := queryEmployeeContributions.Order("employees_contributions DESC").Select(&retEmployeeContributions); err != nil {
|
549
|
return nil, err
|
520
|
return nil, err
|
550
|
}
|
521
|
}
|