...
|
...
|
@@ -37,7 +37,7 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
|
|
// 返回兑换活动清单榜单
|
|
|
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
|
|
|
var retPeople []struct {
|
|
|
Uid int
|
|
|
Uid int64
|
|
|
EmployeeName string
|
|
|
SuMoney float64
|
|
|
Cash float64
|
...
|
...
|
@@ -45,7 +45,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
|
}
|
|
|
|
|
|
var retEmployee []struct {
|
|
|
Uid int
|
|
|
Uid int64
|
|
|
EmployeeName string
|
|
|
SuMoney float64
|
|
|
Cash float64
|
...
|
...
|
@@ -53,13 +53,13 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
|
}
|
|
|
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
exchangeCashPersonListModels := new(models.ExchangeCashPersonList)
|
|
|
|
|
|
// 清单人员排名
|
|
|
exchangeCashPersonListModels := new(models.ExchangeCashPersonList)
|
|
|
queryPeople := tx.Model(exchangeCashPersonListModels)
|
|
|
queryPeople = queryPeople.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
|
|
|
queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.uid AS uid")
|
|
|
queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
|
|
|
//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")
|
...
|
...
|
@@ -71,7 +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("exchange_cash_person_list.employee_name")
|
|
|
//queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name")
|
|
|
if offset, ok := queryOptions["offset"]; ok {
|
|
|
offset := offset.(int)
|
|
|
if offset > -1 {
|
...
|
...
|
@@ -88,7 +88,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
|
} else {
|
|
|
queryPeople = queryPeople.Limit(20)
|
|
|
}
|
|
|
if err := queryPeople.Order("su_money DESC").Select(&retPeople); err != nil {
|
|
|
if err := queryPeople.Order("ranking ASC").Select(&retPeople); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
|
...
|
...
|
@@ -96,7 +96,7 @@ 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("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")
|
...
|
...
|
@@ -107,19 +107,20 @@ 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("exchange_cash_person_list.employee_name")
|
|
|
//queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name")
|
|
|
queryPeopleAllWith := queryPeopleAll.Order("su_money DESC")
|
|
|
queryEmployee := tx.Model()
|
|
|
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")
|
|
|
//queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name")
|
|
|
queryEmployee = queryEmployee.ColumnExpr("t.cash AS cash")
|
|
|
queryEmployee = queryEmployee.ColumnExpr("t.su_money AS su_money")
|
|
|
queryEmployee = queryEmployee.ColumnExpr("t.ranking AS ranking")
|
|
|
if uid, ok := queryOptions["uid"]; ok {
|
|
|
queryEmployee = queryEmployee.Where("t.uid::bigint = ?", uid)
|
|
|
}
|
|
|
|
|
|
if err := queryEmployee.Select(&retEmployee); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
|