作者 陈志颖

feat:修改素币兑换清单用户手机号

... ... @@ -45,6 +45,14 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
} else {
employeeDao = value
}
var cashPoolDao *dao.CashPoolDao
if value, err := factory.CreateCashPoolDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
cashPoolDao = value
}
var companyId int64
var uid int64
var employeeName string
... ... @@ -261,8 +269,11 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
if err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//TODO 修改业务数据
// 修改业务数据-素币兑换清单
errUpdateExchangeCashPersonList := cashPoolDao.UpdateExchangeCashPersonListUserInfo(oldPhone, newPhone)
if errUpdateExchangeCashPersonList != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, errUpdateExchangeCashPersonList.Error())
}
break
default:
return false, nil
... ...
... ... @@ -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,37 +20,49 @@ 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{}{
"activityExchangedSuMoney": activityExchangedSuMoney,
"activityExchangedCash": activityExchangedCash,
"activityExchangedCash": activityExchangedCash,
}, 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 {
Uid int64
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
SuMoney float64
Cash float64
Ranking int
}
var retEmployee []struct {
Uid int64
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
SuMoney float64
Cash float64
Ranking int
}
tx := dao.transactionContext.PgTx
... ... @@ -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,12 +185,12 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
return nil, err
}
return map[string]interface{} {
"people": retPeople, // 员工排行榜
"count": count, // 计数
"currentEmployee": currentEmployee, // 当前员工排名
"exchangedSuMoney": activityExchangedSuMoney, // 清单已兑换素币
"exchangedCash": activityExchangedCash, // 清单已兑换现金
return map[string]interface{}{
"people": retPeople, // 员工排行榜
"count": count, // 计数
"currentEmployee": currentEmployee, // 当前员工排名
"exchangedSuMoney": activityExchangedSuMoney, // 清单已兑换素币
"exchangedCash": activityExchangedCash, // 清单已兑换现金
}, nil
}
... ... @@ -189,4 +202,4 @@ func NewCashPoolDao(transactionContext *pgTransaction.TransactionContext) (*Cash
transactionContext: transactionContext,
}, nil
}
}
\ No newline at end of file
}
... ...
... ... @@ -63,7 +63,7 @@ func (dao *EmployeeDao) ChangePhone(oldPhone string, newPhone string) error {
if _, err := tx.QueryOne(
pg.Scan(),
"UPDATE employees SET employee_account=? WHERE employee_account=?",
oldPhone, newPhone); err != nil {
newPhone, oldPhone); err != nil {
return err
}
return nil
... ...