作者 陈志颖

fix:修复员工贡献值统计

@@ -249,29 +249,31 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime @@ -249,29 +249,31 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime
249 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 249 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
250 // 增加的贡献值 250 // 增加的贡献值
251 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). 251 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
252 - //Column("su_money_transaction_record.employee").  
253 - 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"). 252 + ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
  253 + ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").
  254 + ColumnExpr("sum(su_money_transaction_record.su_money) AS employees_contributions").
254 Where(`e.company_id = ?`, companyId). 255 Where(`e.company_id = ?`, companyId).
255 Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). 256 Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})).
256 Where(`e.status = ?`, 1). 257 Where(`e.status = ?`, 1).
257 Where(`su_money_transaction_record.create_time > ?`, startTime). 258 Where(`su_money_transaction_record.create_time > ?`, startTime).
258 Where(`su_money_transaction_record.create_time < ?`, endTime). 259 Where(`su_money_transaction_record.create_time < ?`, endTime).
259 Group("su_money_transaction_record.employee"). 260 Group("su_money_transaction_record.employee").
260 - Order("employees_contributions_increase DESC"). 261 + Order("employees_contributions DESC").
261 Select(&ret); err != nil { 262 Select(&ret); err != nil {
262 return nil, err 263 return nil, err
263 } 264 }
264 // 减少的贡献值 265 // 减少的贡献值
265 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint"). 266 if err := tx.Model(suMoneyTransactionRecordModel).Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint").
266 - //Column("su_money_transaction_record.employee").  
267 - 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_decrease"). 267 + ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid").
  268 + ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name").
  269 + ColumnExpr("sum(su_money_transaction_record.su_money) AS employees_contributions").
268 Where(`e.company_id = ?`, companyId). 270 Where(`e.company_id = ?`, companyId).
269 Where(`su_money_transaction_record.record_type = ?`, 4). 271 Where(`su_money_transaction_record.record_type = ?`, 4).
270 Where(`e.status = ?`, 1). 272 Where(`e.status = ?`, 1).
271 Where(`su_money_transaction_record.create_time > ?`, startTime). 273 Where(`su_money_transaction_record.create_time > ?`, startTime).
272 Where(`su_money_transaction_record.create_time < ?`, endTime). 274 Where(`su_money_transaction_record.create_time < ?`, endTime).
273 Group("su_money_transaction_record.employee"). 275 Group("su_money_transaction_record.employee").
274 - Order("employees_contributions_decrease DESC"). 276 + Order("employees_contributions DESC").
275 Select(&retDecrease); err != nil { 277 Select(&retDecrease); err != nil {
276 return nil, err 278 return nil, err
277 } 279 }