作者 陈志颖

fix:修复兑换素币清单排行版

... ... @@ -72,10 +72,6 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
}
queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name")
// 子清单查询
queryPeopleWith := queryPeople.Order("su_money DESC")
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
if offset > -1 {
... ... @@ -97,8 +93,24 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
}
// 个人清单排名
queryPeopleAll := tx.Model(exchangeCashPersonListModels)
queryPeopleAll = queryPeopleAll.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.uid AS uid")
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")
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
}
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name")
queryPeopleAllWith := queryPeopleAll.Order("su_money DESC")
queryEmployee := tx.Model()
queryEmployee = queryEmployee.With("t", queryPeopleWith)
queryEmployee = queryEmployee.With("t", queryPeopleAllWith)
queryEmployee = queryEmployee.Table("t")
queryEmployee = queryEmployee.ColumnExpr("t.uid AS uid")
queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name")
... ...