|
@@ -234,7 +234,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
|
@@ -234,7 +234,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
234
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
234
|
if err := tx.Model(suMoneyTransactionRecordModel).
|
235
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS expend_su_money").
|
235
|
ColumnExpr("sum(su_money_transaction_record.su_money) AS expend_su_money").
|
236
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
236
|
Where(`su_money_transaction_record.employee @> '{"uid":?}'`, uid).
|
237
|
- Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4, 5})).
|
237
|
+ Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{1, 4})).
|
238
|
Where(`su_money_transaction_record.create_time > ?`, transactionStartTime).
|
238
|
Where(`su_money_transaction_record.create_time > ?`, transactionStartTime).
|
239
|
Where(`su_money_transaction_record.create_time < ?`, transactionEndTime).
|
239
|
Where(`su_money_transaction_record.create_time < ?`, transactionEndTime).
|
240
|
Select(&expendSuMoney); err != nil {
|
240
|
Select(&expendSuMoney); err != nil {
|
|
@@ -261,8 +261,8 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
|
@@ -261,8 +261,8 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction |
261
|
return nil, err
|
261
|
return nil, err
|
262
|
}
|
262
|
}
|
263
|
return map[string]interface{}{
|
263
|
return map[string]interface{}{
|
264
|
- "incomeSuMoney": incomeSuMoney + incomeSuMoneyExchangeRestore, // 个人素币收入
|
|
|
265
|
- "expendSuMoney": expendSuMoney, // 个人素币支出
|
264
|
+ "incomeSuMoney": incomeSuMoney, // 个人素币收入
|
|
|
265
|
+ "expendSuMoney": expendSuMoney + (expendSuMoneyExchange - incomeSuMoneyExchangeRestore), // 个人素币支出
|
266
|
}, nil
|
266
|
}, nil
|
267
|
}
|
267
|
}
|
268
|
|
268
|
|
|
@@ -340,11 +340,12 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -340,11 +340,12 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
340
|
queryWealth := tx.Model(suMoneyTransactionRecordModel)
|
340
|
queryWealth := tx.Model(suMoneyTransactionRecordModel)
|
341
|
queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
341
|
queryWealth = queryWealth.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
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) 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
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
349
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
349
|
queryWealth = queryWealth.Where("e.company_id = ?", companyId)
|
350
|
queryWealth = queryWealth.Where("e.company_id = ?", companyId)
|
350
|
}
|
351
|
}
|
|
@@ -417,11 +418,12 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
@@ -417,11 +418,12 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
417
|
queryContributions := tx.Model(suMoneyTransactionRecordModel)
|
418
|
queryContributions := tx.Model(suMoneyTransactionRecordModel)
|
418
|
queryContributions = queryContributions.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
419
|
queryContributions = queryContributions.Join("JOIN employees AS e ON e.uid = (su_money_transaction_record.employee->>'uid')::bigint")
|
419
|
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
420
|
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
420
|
- queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
421
|
+ //queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
421
|
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")
|
422
|
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")
|
422
|
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")
|
423
|
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")
|
423
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
424
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
424
|
- queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
425
|
+ //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'")
|
425
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
427
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
426
|
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
|
428
|
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
|
427
|
}
|
429
|
}
|