...
|
...
|
@@ -227,14 +227,15 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. |
|
|
}
|
|
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
|
|
|
Column("su_money_transaction_records.employee, (su_money_transaction_records.employee->>'employeeName')::text,").
|
|
|
ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid, su_money_transaction_records.employee->>'employeeName' AS employeeName, sum(su_money_transaction_records.su_money) AS employee_su_money").
|
|
|
Column("su_money_transaction_record.employee").
|
|
|
Column("(su_money_transaction_record.employee->>'employeeName')::text").
|
|
|
ColumnExpr("(su_money_transaction_record.employee->>'uid') AS uid, (su_money_transaction_record.employee->>'employeeName') AS employeeName, sum(su_money_transaction_record.su_money) AS employee_su_money").
|
|
|
Where(`e.company_id = ?`, companyId).
|
|
|
Where(`e.status = ?`, 1).
|
|
|
Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
|
|
|
Where(`su_money_transaction_records.create_time > ?`, startTime).
|
|
|
Where(`su_money_transaction_records.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_records.employee").
|
|
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
|
|
|
Where(`su_money_transaction_record.create_time > ?`, startTime).
|
|
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_record.employee").
|
|
|
Order("employee_su_money DESC").
|
|
|
Select(&ret); err != nil {
|
|
|
return nil, err
|
...
|
...
|
@@ -264,30 +265,30 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime |
|
|
//var employeesContributions []struct{}
|
|
|
suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
|
|
|
// 增加的贡献值
|
|
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_records.employee->>'uid')::bigint").
|
|
|
Column("su_money_transaction_records.employee").
|
|
|
ColumnExpr("su_money_transaction_records.employee->>'uid' AS uid, su_money_transaction_records.employee->>'employeeName' AS employeeName, sum(su_money_transaction_records.su_money) AS employees_contributions_increase").
|
|
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
|
|
|
Column("su_money_transaction_record.employee").
|
|
|
ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid, su_money_transaction_record.employee->>'employeeName' AS employeeName, sum(su_money_transaction_record.su_money) AS employees_contributions_increase").
|
|
|
Where(`e.company_id = ?`, companyId).
|
|
|
Where(`su_money_transaction_records.record_type IN (?)`, pg.In([]int{2, 3})).
|
|
|
Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
|
|
|
Where(`e.status = ?`, 1).
|
|
|
Where(`su_money_transaction_records.create_time > ?`, startTime).
|
|
|
Where(`su_money_transaction_records.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_records.employee").
|
|
|
Order("employees_contributions DESC").
|
|
|
Where(`su_money_transaction_record.create_time > ?`, startTime).
|
|
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_record.employee").
|
|
|
Order("employees_contributions_increase DESC").
|
|
|
Select(&ret); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
// 减少的贡献值
|
|
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_records.employee->>'uid')::bigint").
|
|
|
Column("su_money_transaction_records.employee").
|
|
|
ColumnExpr("sum(su_money_transaction_records.su_money) AS employees_contributions_decrease").
|
|
|
if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
|
|
|
Column("su_money_transaction_record.employee").
|
|
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS employees_contributions_decrease").
|
|
|
Where(`e.company_id = ?`, companyId).
|
|
|
Where(`su_money_transaction_records.record_type = ?`, 4).
|
|
|
Where(`su_money_transaction_record.record_type = ?`, 4).
|
|
|
Where(`e.status = ?`, 1).
|
|
|
Where(`su_money_transaction_records.create_time > ?`, startTime).
|
|
|
Where(`su_money_transaction_records.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_records.employee").
|
|
|
Order("employees_contributions DESC").
|
|
|
Where(`su_money_transaction_record.create_time > ?`, startTime).
|
|
|
Where(`su_money_transaction_record.create_time < ?`, endTime).
|
|
|
Group("su_money_transaction_record.employee").
|
|
|
Order("employees_contributions_decrease DESC").
|
|
|
Select(&retDecrease); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
|