作者 陈志颖

test:员工创建时间排名

@@ -62,7 +62,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac @@ -62,7 +62,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
62 //queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name") 62 //queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
63 queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash") 63 queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
64 queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money") 64 queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
65 - queryPeople = queryPeople.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC) AS ranking") 65 + queryPeople = queryPeople.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking")
66 //queryPeople = queryPeople.Where("e.status = ?", 1) 66 //queryPeople = queryPeople.Where("e.status = ?", 1)
67 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 67 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
68 queryPeople = queryPeople.Where("e.company_id = ?", companyId) 68 queryPeople = queryPeople.Where("e.company_id = ?", companyId)
@@ -71,6 +71,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac @@ -71,6 +71,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
71 queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId) 71 queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
72 } 72 }
73 queryPeople = queryPeople.Group("exchange_cash_person_list.uid") 73 queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
  74 + queryPeople = queryPeople.Group("e.create_time")
74 //queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name") 75 //queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name")
75 if offset, ok := queryOptions["offset"]; ok { 76 if offset, ok := queryOptions["offset"]; ok {
76 offset := offset.(int) 77 offset := offset.(int)
@@ -99,7 +100,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac @@ -99,7 +100,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
99 //queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name") 100 //queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
100 queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash") 101 queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
101 queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money") 102 queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
102 - queryPeopleAll = queryPeopleAll.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC) AS ranking") 103 + queryPeopleAll = queryPeopleAll.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking")
103 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 104 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
104 queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId) 105 queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
105 } 106 }
@@ -107,6 +108,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac @@ -107,6 +108,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
107 queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId) 108 queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
108 } 109 }
109 queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid") 110 queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
  111 + queryPeopleAll = queryPeopleAll.Group("e.create_time")
110 //queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name") 112 //queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name")
111 queryPeopleAllWith := queryPeopleAll.Order("su_money DESC") 113 queryPeopleAllWith := queryPeopleAll.Order("su_money DESC")
112 queryEmployee := tx.Model() 114 queryEmployee := tx.Model()
@@ -342,10 +342,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -342,10 +342,10 @@ 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) 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, e.create_time ASC) 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', e.create_time")
349 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 349 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
350 queryWealth = queryWealth.Where("e.company_id = ?", companyId) 350 queryWealth = queryWealth.Where("e.company_id = ?", companyId)
351 } 351 }
@@ -382,7 +382,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -382,7 +382,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
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) 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, e.create_time ASC) 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)
@@ -394,7 +394,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -394,7 +394,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
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', e.create_time") 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 + queryWealthRestoreWith := queryWealthWith.GroupExpr("su_money_transaction_record.employee->>'uid', e.create_time")
398 querySelfWealth := tx.Model() 398 querySelfWealth := tx.Model()
399 querySelfWealth = querySelfWealth.With("t", queryWealthRestoreWith) 399 querySelfWealth = querySelfWealth.With("t", queryWealthRestoreWith)
400 querySelfWealth = querySelfWealth.Table("t") 400 querySelfWealth = querySelfWealth.Table("t")
@@ -421,10 +421,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -421,10 +421,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
421 queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 421 queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
422 //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")
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("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")
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.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 ASC) AS ranking")
425 queryContributions = queryContributions.Where(`e.status = ?`, 1) 425 queryContributions = queryContributions.Where(`e.status = ?`, 1)
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',su_money_transaction_record.employee->>'employeeName'")
427 - queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid'") 427 + queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid', e.create_time")
428 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 428 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
429 queryContributions = queryContributions.Where("e.company_id = ?", companyId) 429 queryContributions = queryContributions.Where("e.company_id = ?", companyId)
430 } 430 }
@@ -460,7 +460,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -460,7 +460,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
460 queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid") 460 queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
461 //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")
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("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")
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.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 ASC) AS ranking")
464 queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1) 464 queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
465 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 465 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
466 queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId) 466 queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
@@ -472,7 +472,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -472,7 +472,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
472 queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime) 472 queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
473 } 473 }
474 //contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName', e.create_time") 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'") 475 + contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid', e.create_time")
476 querySelfContributions := tx.Model() 476 querySelfContributions := tx.Model()
477 querySelfContributions = querySelfContributions.With("t", contributionsWith) 477 querySelfContributions = querySelfContributions.With("t", contributionsWith)
478 querySelfContributions = querySelfContributions.Table("t") 478 querySelfContributions = querySelfContributions.Table("t")