作者 陈志颖

test:员工创建时间排名

... ... @@ -62,7 +62,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
//queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
queryPeople = queryPeople.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC) AS ranking")
queryPeople = queryPeople.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking")
//queryPeople = queryPeople.Where("e.status = ?", 1)
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryPeople = queryPeople.Where("e.company_id = ?", companyId)
... ... @@ -71,6 +71,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
queryPeople = queryPeople.Group("e.create_time")
//queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name")
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
... ... @@ -99,7 +100,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
//queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
queryPeopleAll = queryPeopleAll.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC) AS ranking")
queryPeopleAll = queryPeopleAll.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking")
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
}
... ... @@ -107,6 +108,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
queryPeopleAll = queryPeopleAll.Group("e.create_time")
//queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name")
queryPeopleAllWith := queryPeopleAll.Order("su_money DESC")
queryEmployee := tx.Model()
... ...
... ... @@ -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")
... ...