...
|
...
|
@@ -283,8 +283,8 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. |
|
|
// }, nil
|
|
|
//}
|
|
|
|
|
|
// 排行榜统计
|
|
|
func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
|
|
|
// TODO 排行榜统计,增加分页
|
|
|
func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime time.Time, endTime time.Time, offset int, limit int) (map[string]interface{}, error) {
|
|
|
var retWealth []struct {
|
|
|
Uid int
|
|
|
EmployeeName string
|
...
|
...
|
@@ -302,6 +302,12 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
|
}
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
if limit < -1 {
|
|
|
limit = 20
|
|
|
}
|
|
|
if offset < -1 {
|
|
|
offset = 0
|
|
|
}
|
|
|
// 员工财富值
|
|
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
|
|
|
ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
|
...
|
...
|
@@ -314,6 +320,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_record.employee").
|
|
|
Order("employee_su_money DESC").
|
|
|
Limit(limit).
|
|
|
Offset(offset).
|
|
|
Select(&retWealth); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -329,6 +337,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_record.employee").
|
|
|
Order("employees_contributions DESC").
|
|
|
Limit(limit).
|
|
|
Offset(offset).
|
|
|
Select(&retContributions); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -344,6 +354,8 @@ func (dao *EmployeeDao) CalculateEmployeesRankingList(companyId int, startTime t |
|
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_record.employee").
|
|
|
Order("employees_contributions DESC").
|
|
|
Limit(limit).
|
|
|
Offset(offset).
|
|
|
Select(&retContributionDecrease); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
|