...
|
...
|
@@ -3,9 +3,11 @@ package service |
|
|
import (
|
|
|
"encoding/json"
|
|
|
"github.com/linmadan/egglib-go/core/application"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/unifiedUserCenter/command"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
|
|
|
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -27,8 +29,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var employeeRepository domain.EmployeeRepository
|
|
|
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -37,6 +40,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
} else {
|
|
|
employeeRepository = value
|
|
|
}
|
|
|
|
|
|
var employeeDao *dao.EmployeeDao
|
|
|
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -45,6 +49,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
} else {
|
|
|
employeeDao = value
|
|
|
}
|
|
|
|
|
|
var cashPoolDao *dao.CashPoolDao
|
|
|
if value, err := factory.CreateCashPoolDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
@@ -53,6 +58,21 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
} else {
|
|
|
cashPoolDao = value
|
|
|
}
|
|
|
|
|
|
// 修改手机号事件订阅初始化
|
|
|
var changePhoneService service.ChangePhoneService
|
|
|
if value, err := factory.CreateChangePhoneService(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
changePhoneService = value
|
|
|
err := changePhoneService.Subscribe(&subscriber.WorthServiceSubscriber{})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var companyId int64
|
|
|
var uid int64
|
|
|
var employeeName string
|
...
|
...
|
@@ -84,10 +104,10 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
if value, ok := data["avatar"]; ok {
|
|
|
employeeAvatarUrl = value.(string)
|
|
|
}
|
|
|
if value, ok := data["oldPhone"]; ok {
|
|
|
if value, ok := data["old_phone"]; ok {
|
|
|
oldPhone = value.(string)
|
|
|
}
|
|
|
if value, ok := data["newPhone"]; ok {
|
|
|
if value, ok := data["new_phone"]; ok {
|
|
|
newPhone = value.(string)
|
|
|
}
|
|
|
if value, ok := data["admin_type"]; ok {
|
...
|
...
|
@@ -115,6 +135,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
editEmployees = append(editEmployees, editEmployee.(map[string]interface{}))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if syncEmployeeCallbackCommand.Module == "employee" {
|
|
|
switch syncEmployeeCallbackCommand.Action {
|
|
|
case "import":
|
...
|
...
|
@@ -263,7 +284,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
break
|
|
|
case "changePhone": // TODO 修改手机号
|
|
|
case "changePhoneAllCompany": // 修改手机号
|
|
|
// 修改用户数据
|
|
|
err := employeeDao.ChangePhone(oldPhone, newPhone)
|
|
|
if err != nil {
|
...
|
...
|
@@ -274,6 +295,10 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s |
|
|
if errUpdateExchangeCashPersonList != nil {
|
|
|
return false, application.ThrowError(application.TRANSACTION_ERROR, errUpdateExchangeCashPersonList.Error())
|
|
|
}
|
|
|
// 发布修改手机号事件
|
|
|
if err := changePhoneService.ChangePhone(oldPhone, newPhone); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
break
|
|
|
default:
|
|
|
return false, nil
|
...
|
...
|
|