|
@@ -283,8 +283,8 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. |
|
@@ -283,8 +283,8 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. |
283
|
// }, nil
|
283
|
// }, nil
|
284
|
//}
|
284
|
//}
|
285
|
|
285
|
|
286
|
-// 排行榜统计
|
|
|
287
|
-func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
|
286
|
+// TODO 排行榜统计,增加分页
|
|
|
287
|
+func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime time.Time, endTime time.Time, offset int, limit int) (map[string]interface{}, error) {
|
288
|
var retWealth []struct {
|
288
|
var retWealth []struct {
|
289
|
Uid int
|
289
|
Uid int
|
290
|
EmployeeName string
|
290
|
EmployeeName string
|
|
@@ -302,6 +302,12 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
@@ -302,6 +302,12 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
302
|
}
|
302
|
}
|
303
|
tx := dao.transactionContext.PgTx
|
303
|
tx := dao.transactionContext.PgTx
|
304
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
304
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
305
|
+ if limit < -1 {
|
|
|
306
|
+ limit = 20
|
|
|
307
|
+ }
|
|
|
308
|
+ if offset < -1 {
|
|
|
309
|
+ offset = 0
|
|
|
310
|
+ }
|
305
|
// 员工财富值
|
311
|
// 员工财富值
|
306
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
|
312
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
|
307
|
ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
|
313
|
ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
|
|
@@ -314,6 +320,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
@@ -314,6 +320,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
314
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
320
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
315
|
Group("su_money_transaction_record.employee").
|
321
|
Group("su_money_transaction_record.employee").
|
316
|
Order("employee_su_money DESC").
|
322
|
Order("employee_su_money DESC").
|
|
|
323
|
+ Limit(limit).
|
|
|
324
|
+ Offset(offset).
|
317
|
Select(&retWealth); err != nil {
|
325
|
Select(&retWealth); err != nil {
|
318
|
return nil, err
|
326
|
return nil, err
|
319
|
}
|
327
|
}
|
|
@@ -329,6 +337,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
@@ -329,6 +337,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
329
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
337
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
330
|
Group("su_money_transaction_record.employee").
|
338
|
Group("su_money_transaction_record.employee").
|
331
|
Order("employees_contributions DESC").
|
339
|
Order("employees_contributions DESC").
|
|
|
340
|
+ Limit(limit).
|
|
|
341
|
+ Offset(offset).
|
332
|
Select(&retContributions); err != nil {
|
342
|
Select(&retContributions); err != nil {
|
333
|
return nil, err
|
343
|
return nil, err
|
334
|
}
|
344
|
}
|
|
@@ -344,6 +354,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
@@ -344,6 +354,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
344
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
354
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
345
|
Group("su_money_transaction_record.employee").
|
355
|
Group("su_money_transaction_record.employee").
|
346
|
Order("employees_contributions DESC").
|
356
|
Order("employees_contributions DESC").
|
|
|
357
|
+ Limit(limit).
|
|
|
358
|
+ Offset(offset).
|
347
|
Select(&retContributionDecrease); err != nil {
|
359
|
Select(&retContributionDecrease); err != nil {
|
348
|
return nil, err
|
360
|
return nil, err
|
349
|
}
|
361
|
}
|