正在显示
1 个修改的文件
包含
17 行增加
和
5 行删除
@@ -72,10 +72,6 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac | @@ -72,10 +72,6 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac | ||
72 | } | 72 | } |
73 | queryPeople = queryPeople.Group("exchange_cash_person_list.uid") | 73 | queryPeople = queryPeople.Group("exchange_cash_person_list.uid") |
74 | queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name") | 74 | queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name") |
75 | - | ||
76 | - // 子清单查询 | ||
77 | - queryPeopleWith := queryPeople.Order("su_money DESC") | ||
78 | - | ||
79 | if offset, ok := queryOptions["offset"]; ok { | 75 | if offset, ok := queryOptions["offset"]; ok { |
80 | offset := offset.(int) | 76 | offset := offset.(int) |
81 | if offset > -1 { | 77 | if offset > -1 { |
@@ -97,8 +93,24 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac | @@ -97,8 +93,24 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac | ||
97 | } | 93 | } |
98 | 94 | ||
99 | // 个人清单排名 | 95 | // 个人清单排名 |
96 | + queryPeopleAll := tx.Model(exchangeCashPersonListModels) | ||
97 | + queryPeopleAll = queryPeopleAll.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid") | ||
98 | + queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.uid AS uid") | ||
99 | + queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name") | ||
100 | + queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash") | ||
101 | + queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money") | ||
102 | + queryPeopleAll = queryPeopleAll.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC) AS ranking") | ||
103 | + if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { | ||
104 | + queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId) | ||
105 | + } | ||
106 | + if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){ | ||
107 | + queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId) | ||
108 | + } | ||
109 | + queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid") | ||
110 | + queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name") | ||
111 | + queryPeopleAllWith := queryPeopleAll.Order("su_money DESC") | ||
100 | queryEmployee := tx.Model() | 112 | queryEmployee := tx.Model() |
101 | - queryEmployee = queryEmployee.With("t", queryPeopleWith) | 113 | + queryEmployee = queryEmployee.With("t", queryPeopleAllWith) |
102 | queryEmployee = queryEmployee.Table("t") | 114 | queryEmployee = queryEmployee.Table("t") |
103 | queryEmployee = queryEmployee.ColumnExpr("t.uid AS uid") | 115 | queryEmployee = queryEmployee.ColumnExpr("t.uid AS uid") |
104 | queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name") | 116 | queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name") |
-
请 注册 或 登录 后发表评论