|
@@ -2,6 +2,7 @@ package dao |
|
@@ -2,6 +2,7 @@ package dao |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
|
|
5
|
+ "github.com/go-pg/pg"
|
5
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
6
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
6
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
|
7
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
|
7
|
)
|
8
|
)
|
|
@@ -19,13 +20,13 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
|
@@ -19,13 +20,13 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
19
|
if err := tx.Model(exchangeCashPersonListModels).
|
20
|
if err := tx.Model(exchangeCashPersonListModels).
|
20
|
ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money").
|
21
|
ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money").
|
21
|
Where("exchange_cash_person_list.activity_id = ?", activityId).
|
22
|
Where("exchange_cash_person_list.activity_id = ?", activityId).
|
22
|
- Select(&activityExchangedSuMoney); err !=nil {
|
23
|
+ Select(&activityExchangedSuMoney); err != nil {
|
23
|
return nil, err
|
24
|
return nil, err
|
24
|
}
|
25
|
}
|
25
|
if err := tx.Model(exchangeCashPersonListModels).
|
26
|
if err := tx.Model(exchangeCashPersonListModels).
|
26
|
ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash").
|
27
|
ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash").
|
27
|
Where("exchange_cash_person_list.activity_id = ?", activityId).
|
28
|
Where("exchange_cash_person_list.activity_id = ?", activityId).
|
28
|
- Select(&activityExchangedCash); err !=nil {
|
29
|
+ Select(&activityExchangedCash); err != nil {
|
29
|
return nil, err
|
30
|
return nil, err
|
30
|
}
|
31
|
}
|
31
|
return map[string]interface{}{
|
32
|
return map[string]interface{}{
|
|
@@ -34,6 +35,18 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
|
@@ -34,6 +35,18 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
34
|
}, nil
|
35
|
}, nil
|
35
|
}
|
36
|
}
|
36
|
|
37
|
|
|
|
38
|
+// UpdateExchangeCashPersonListUserInfo TODO 更新素币兑换清单用户信息
|
|
|
39
|
+func (dao *CashPoolDao) UpdateExchangeCashPersonListUserInfo(oldPhone string, newPhone string) error {
|
|
|
40
|
+ tx := dao.transactionContext.PgTx
|
|
|
41
|
+ if _, err := tx.QueryOne(
|
|
|
42
|
+ pg.Scan(),
|
|
|
43
|
+ "UPDATE exchange_cash_person_lists SET employee_account = ? WHERE employee_account = ?",
|
|
|
44
|
+ newPhone, oldPhone); err != nil {
|
|
|
45
|
+ return err
|
|
|
46
|
+ }
|
|
|
47
|
+ return nil
|
|
|
48
|
+}
|
|
|
49
|
+
|
37
|
// 返回兑换活动清单榜单
|
50
|
// 返回兑换活动清单榜单
|
38
|
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
|
51
|
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
|
39
|
var retPeople []struct {
|
52
|
var retPeople []struct {
|
|
@@ -67,7 +80,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
@@ -67,7 +80,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
67
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
80
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
68
|
queryPeople = queryPeople.Where("e.company_id = ?", companyId)
|
81
|
queryPeople = queryPeople.Where("e.company_id = ?", companyId)
|
69
|
}
|
82
|
}
|
70
|
- if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
|
83
|
+ if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
|
71
|
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
84
|
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
72
|
}
|
85
|
}
|
73
|
queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
|
86
|
queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
|
|
@@ -104,7 +117,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
@@ -104,7 +117,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
104
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
117
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
105
|
queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
|
118
|
queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
|
106
|
}
|
119
|
}
|
107
|
- if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
|
120
|
+ if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
|
108
|
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
121
|
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
109
|
}
|
122
|
}
|
110
|
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
|
123
|
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
|
|
@@ -172,7 +185,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
@@ -172,7 +185,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
172
|
return nil, err
|
185
|
return nil, err
|
173
|
}
|
186
|
}
|
174
|
|
187
|
|
175
|
- return map[string]interface{} {
|
188
|
+ return map[string]interface{}{
|
176
|
"people": retPeople, // 员工排行榜
|
189
|
"people": retPeople, // 员工排行榜
|
177
|
"count": count, // 计数
|
190
|
"count": count, // 计数
|
178
|
"currentEmployee": currentEmployee, // 当前员工排名
|
191
|
"currentEmployee": currentEmployee, // 当前员工排名
|