|
@@ -37,7 +37,7 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
|
@@ -37,7 +37,7 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
37
|
// 返回兑换活动清单榜单
|
37
|
// 返回兑换活动清单榜单
|
38
|
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
|
38
|
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
|
39
|
var retPeople []struct {
|
39
|
var retPeople []struct {
|
40
|
- Uid int
|
40
|
+ Uid int64
|
41
|
EmployeeName string
|
41
|
EmployeeName string
|
42
|
SuMoney float64
|
42
|
SuMoney float64
|
43
|
Cash float64
|
43
|
Cash float64
|
|
@@ -45,7 +45,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
@@ -45,7 +45,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
45
|
}
|
45
|
}
|
46
|
|
46
|
|
47
|
var retEmployee []struct {
|
47
|
var retEmployee []struct {
|
48
|
- Uid int
|
48
|
+ Uid int64
|
49
|
EmployeeName string
|
49
|
EmployeeName string
|
50
|
SuMoney float64
|
50
|
SuMoney float64
|
51
|
Cash float64
|
51
|
Cash float64
|
|
@@ -53,13 +53,13 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
@@ -53,13 +53,13 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
53
|
}
|
53
|
}
|
54
|
|
54
|
|
55
|
tx := dao.transactionContext.PgTx
|
55
|
tx := dao.transactionContext.PgTx
|
|
|
56
|
+ exchangeCashPersonListModels := new(models.ExchangeCashPersonList)
|
56
|
|
57
|
|
57
|
// 清单人员排名
|
58
|
// 清单人员排名
|
58
|
- exchangeCashPersonListModels := new(models.ExchangeCashPersonList)
|
|
|
59
|
queryPeople := tx.Model(exchangeCashPersonListModels)
|
59
|
queryPeople := tx.Model(exchangeCashPersonListModels)
|
60
|
queryPeople = queryPeople.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
|
60
|
queryPeople = queryPeople.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
|
61
|
queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.uid AS uid")
|
61
|
queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.uid AS uid")
|
62
|
- queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
|
62
|
+ //queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
|
63
|
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
|
63
|
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
|
64
|
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
|
64
|
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
|
65
|
queryPeople = queryPeople.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC) AS ranking")
|
65
|
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 |
|
@@ -71,7 +71,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
71
|
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
71
|
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
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
|
if offset, ok := queryOptions["offset"]; ok {
|
75
|
if offset, ok := queryOptions["offset"]; ok {
|
76
|
offset := offset.(int)
|
76
|
offset := offset.(int)
|
77
|
if offset > -1 {
|
77
|
if offset > -1 {
|
|
@@ -88,7 +88,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
@@ -88,7 +88,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
88
|
} else {
|
88
|
} else {
|
89
|
queryPeople = queryPeople.Limit(20)
|
89
|
queryPeople = queryPeople.Limit(20)
|
90
|
}
|
90
|
}
|
91
|
- if err := queryPeople.Order("su_money DESC").Select(&retPeople); err != nil {
|
91
|
+ if err := queryPeople.Order("ranking ASC").Select(&retPeople); err != nil {
|
92
|
return nil, err
|
92
|
return nil, err
|
93
|
}
|
93
|
}
|
94
|
|
94
|
|
|
@@ -96,7 +96,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
@@ -96,7 +96,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
96
|
queryPeopleAll := tx.Model(exchangeCashPersonListModels)
|
96
|
queryPeopleAll := tx.Model(exchangeCashPersonListModels)
|
97
|
queryPeopleAll = queryPeopleAll.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
|
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")
|
98
|
queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.uid AS uid")
|
99
|
- queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
|
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")
|
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")
|
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")
|
102
|
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 |
|
@@ -107,19 +107,20 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
107
|
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
107
|
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
108
|
}
|
108
|
}
|
109
|
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
|
109
|
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
|
110
|
- queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name")
|
110
|
+ //queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name")
|
111
|
queryPeopleAllWith := queryPeopleAll.Order("su_money DESC")
|
111
|
queryPeopleAllWith := queryPeopleAll.Order("su_money DESC")
|
112
|
queryEmployee := tx.Model()
|
112
|
queryEmployee := tx.Model()
|
113
|
queryEmployee = queryEmployee.With("t", queryPeopleAllWith)
|
113
|
queryEmployee = queryEmployee.With("t", queryPeopleAllWith)
|
114
|
queryEmployee = queryEmployee.Table("t")
|
114
|
queryEmployee = queryEmployee.Table("t")
|
115
|
queryEmployee = queryEmployee.ColumnExpr("t.uid AS uid")
|
115
|
queryEmployee = queryEmployee.ColumnExpr("t.uid AS uid")
|
116
|
- queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name")
|
116
|
+ //queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name")
|
117
|
queryEmployee = queryEmployee.ColumnExpr("t.cash AS cash")
|
117
|
queryEmployee = queryEmployee.ColumnExpr("t.cash AS cash")
|
118
|
queryEmployee = queryEmployee.ColumnExpr("t.su_money AS su_money")
|
118
|
queryEmployee = queryEmployee.ColumnExpr("t.su_money AS su_money")
|
119
|
queryEmployee = queryEmployee.ColumnExpr("t.ranking AS ranking")
|
119
|
queryEmployee = queryEmployee.ColumnExpr("t.ranking AS ranking")
|
120
|
if uid, ok := queryOptions["uid"]; ok {
|
120
|
if uid, ok := queryOptions["uid"]; ok {
|
121
|
queryEmployee = queryEmployee.Where("t.uid::bigint = ?", uid)
|
121
|
queryEmployee = queryEmployee.Where("t.uid::bigint = ?", uid)
|
122
|
}
|
122
|
}
|
|
|
123
|
+
|
123
|
if err := queryEmployee.Select(&retEmployee); err != nil {
|
124
|
if err := queryEmployee.Select(&retEmployee); err != nil {
|
124
|
return nil, err
|
125
|
return nil, err
|
125
|
}
|
126
|
}
|