作者 陈志颖

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

@@ -45,6 +45,14 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -45,6 +45,14 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
45 } else { 45 } else {
46 employeeDao = value 46 employeeDao = value
47 } 47 }
  48 + var cashPoolDao *dao.CashPoolDao
  49 + if value, err := factory.CreateCashPoolDao(map[string]interface{}{
  50 + "transactionContext": transactionContext,
  51 + }); err != nil {
  52 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  53 + } else {
  54 + cashPoolDao = value
  55 + }
48 var companyId int64 56 var companyId int64
49 var uid int64 57 var uid int64
50 var employeeName string 58 var employeeName string
@@ -261,8 +269,11 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -261,8 +269,11 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
261 if err != nil { 269 if err != nil {
262 return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 270 return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
263 } 271 }
264 - //TODO 修改业务数据  
265 - 272 + // 修改业务数据-素币兑换清单
  273 + errUpdateExchangeCashPersonList := cashPoolDao.UpdateExchangeCashPersonListUserInfo(oldPhone, newPhone)
  274 + if errUpdateExchangeCashPersonList != nil {
  275 + return false, application.ThrowError(application.TRANSACTION_ERROR, errUpdateExchangeCashPersonList.Error())
  276 + }
266 break 277 break
267 default: 278 default:
268 return false, nil 279 return false, nil
@@ -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, // 当前员工排名
@@ -63,7 +63,7 @@ func (dao *EmployeeDao) ChangePhone(oldPhone string, newPhone string) error { @@ -63,7 +63,7 @@ func (dao *EmployeeDao) ChangePhone(oldPhone string, newPhone string) error {
63 if _, err := tx.QueryOne( 63 if _, err := tx.QueryOne(
64 pg.Scan(), 64 pg.Scan(),
65 "UPDATE employees SET employee_account=? WHERE employee_account=?", 65 "UPDATE employees SET employee_account=? WHERE employee_account=?",
66 - oldPhone, newPhone); err != nil { 66 + newPhone, oldPhone); err != nil {
67 return err 67 return err
68 } 68 }
69 return nil 69 return nil