...
|
...
|
@@ -342,10 +342,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
|
queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
|
//queryWealth = queryWealth.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
|
|
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")
|
|
|
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")
|
|
|
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, e.create_time ASC) AS ranking")
|
|
|
queryWealth = queryWealth.Where(`e.status = ?`, 1)
|
|
|
//queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
|
|
queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
|
|
queryWealth = queryWealth.GroupExpr("su_money_transaction_record.employee->>'uid', e.create_time")
|
|
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
queryWealth = queryWealth.Where("e.company_id = ?", companyId)
|
|
|
}
|
...
|
...
|
@@ -382,7 +382,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
|
queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
|
//queryWealthWith = queryWealthWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
|
|
queryWealthWith = queryWealthWith.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")
|
|
|
queryWealthWith = queryWealthWith.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")
|
|
|
queryWealthWith = queryWealthWith.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, e.create_time ASC) AS ranking")
|
|
|
queryWealthWith = queryWealthWith.Where(`e.status = ?`, 1)
|
|
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
queryWealthWith = queryWealthWith.Where("e.company_id = ?", companyId)
|
...
|
...
|
@@ -394,7 +394,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
|
queryWealthWith = queryWealthWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
|
|
}
|
|
|
//queryWealthRestoreWith := queryWealthWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName', e.create_time")
|
|
|
queryWealthRestoreWith := queryWealthWith.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
|
|
queryWealthRestoreWith := queryWealthWith.GroupExpr("su_money_transaction_record.employee->>'uid', e.create_time")
|
|
|
querySelfWealth := tx.Model()
|
|
|
querySelfWealth = querySelfWealth.With("t", queryWealthRestoreWith)
|
|
|
querySelfWealth = querySelfWealth.Table("t")
|
...
|
...
|
@@ -421,10 +421,10 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
|
queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
|
//queryContributions = queryContributions.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
|
|
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")
|
|
|
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")
|
|
|
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, e.create_time ASC) AS ranking")
|
|
|
queryContributions = queryContributions.Where(`e.status = ?`, 1)
|
|
|
//queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName'")
|
|
|
queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
|
|
queryContributions = queryContributions.GroupExpr("su_money_transaction_record.employee->>'uid', e.create_time")
|
|
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
queryContributions = queryContributions.Where("e.company_id = ?", companyId)
|
|
|
}
|
...
|
...
|
@@ -460,7 +460,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
|
queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'uid' AS uid")
|
|
|
//queryContributionsWith = queryContributionsWith.ColumnExpr("su_money_transaction_record.employee->>'employeeName' AS employee_name")
|
|
|
queryContributionsWith = queryContributionsWith.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")
|
|
|
queryContributionsWith = queryContributionsWith.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")
|
|
|
queryContributionsWith = queryContributionsWith.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, e.create_time ASC) AS ranking")
|
|
|
queryContributionsWith = queryContributionsWith.Where(`e.status = ?`, 1)
|
|
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
queryContributionsWith = queryContributionsWith.Where("e.company_id = ?", companyId)
|
...
|
...
|
@@ -472,7 +472,7 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter |
|
|
queryContributionsWith = queryContributionsWith.Where(`su_money_transaction_record.create_time < ?`, endTime)
|
|
|
}
|
|
|
//contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid',su_money_transaction_record.employee->>'employeeName', e.create_time")
|
|
|
contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid'")
|
|
|
contributionsWith := queryContributionsWith.GroupExpr("su_money_transaction_record.employee->>'uid', e.create_time")
|
|
|
querySelfContributions := tx.Model()
|
|
|
querySelfContributions = querySelfContributions.With("t", contributionsWith)
|
|
|
querySelfContributions = querySelfContributions.Table("t")
|
...
|
...
|
|