作者 陈志颖

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,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, // 当前员工排名
... ...
... ... @@ -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
... ...