...
|
...
|
@@ -2,6 +2,7 @@ package dao |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/go-pg/pg"
|
|
|
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
|
|
|
)
|
...
|
...
|
@@ -19,13 +20,13 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
|
|
if err := tx.Model(exchangeCashPersonListModels).
|
|
|
ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money").
|
|
|
Where("exchange_cash_person_list.activity_id = ?", activityId).
|
|
|
Select(&activityExchangedSuMoney); err !=nil {
|
|
|
Select(&activityExchangedSuMoney); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if err := tx.Model(exchangeCashPersonListModels).
|
|
|
ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash").
|
|
|
Where("exchange_cash_person_list.activity_id = ?", activityId).
|
|
|
Select(&activityExchangedCash); err !=nil {
|
|
|
Select(&activityExchangedCash); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
return map[string]interface{}{
|
...
|
...
|
@@ -34,6 +35,18 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map |
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// UpdateExchangeCashPersonListUserInfo TODO 更新素币兑换清单用户信息
|
|
|
func (dao *CashPoolDao) UpdateExchangeCashPersonListUserInfo(oldPhone string, newPhone string) error {
|
|
|
tx := dao.transactionContext.PgTx
|
|
|
if _, err := tx.QueryOne(
|
|
|
pg.Scan(),
|
|
|
"UPDATE exchange_cash_person_lists SET employee_account = ? WHERE employee_account = ?",
|
|
|
newPhone, oldPhone); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// 返回兑换活动清单榜单
|
|
|
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
|
|
|
var retPeople []struct {
|
...
|
...
|
@@ -67,7 +80,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
|
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
|
|
|
queryPeople = queryPeople.Where("e.company_id = ?", companyId)
|
|
|
}
|
|
|
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
|
|
|
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
|
|
|
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
|
|
|
}
|
|
|
queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
|
...
|
...
|
@@ -104,7 +117,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
|
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){
|
|
|
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")
|
...
|
...
|
@@ -172,7 +185,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac |
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
return map[string]interface{} {
|
|
|
return map[string]interface{}{
|
|
|
"people": retPeople, // 员工排行榜
|
|
|
"count": count, // 计数
|
|
|
"currentEmployee": currentEmployee, // 当前员工排名
|
...
|
...
|
|