作者 陈志颖

feat:增加修改手机号

... ... @@ -17,11 +17,11 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
)
// 任务服务
// TaskService 任务服务
type TaskService struct {
}
// 对抢单任务进行确认
// ConfirmRobTask 对抢单任务进行确认
func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) {
if err := confirmRobTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -935,7 +935,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if sponsorInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+ sponsorInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+sponsorInvalid.EmployeeInfo.EmployeeName)
}
// 获取任务指派人
... ... @@ -959,7 +959,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
}
assignedPerson = employee.EmployeeInfo
}
... ... @@ -1308,7 +1308,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
}
updateData["assignedPerson"] = employee.EmployeeInfo
} else {
... ...
... ... @@ -49,6 +49,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
var uid int64
var employeeName string
var employeeAccount string
var oldPhone string
var newPhone string
var employeeAvatarUrl string
var isPrincipal bool
var status int
... ... @@ -74,6 +76,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
if value, ok := data["avatar"]; ok {
employeeAvatarUrl = value.(string)
}
if value, ok := data["oldPhone"]; ok {
oldPhone = value.(string)
}
if value, ok := data["newPhone"]; ok {
newPhone = value.(string)
}
if value, ok := data["admin_type"]; ok {
if int(value.(float64)) == 2 {
isPrincipal = true
... ... @@ -234,7 +242,6 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
if _, err := employeeRepository.Save(employee); err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//TODO 业务数据修改
break
case "batchDelete":
err := employeeDao.BatchRemove(uids)
... ... @@ -248,6 +255,15 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
break
case "changePhone": // TODO 修改手机号
// 修改用户数据
err := employeeDao.ChangePhone(oldPhone, newPhone)
if err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
//TODO 修改业务数据
break
default:
return false, nil
}
... ...
... ... @@ -10,7 +10,7 @@ type BidInfosDao struct {
}
//TODO ChangeBidInfosSuccessfulBidderAccount
func (dao *BidInfosDao) ChangeBidInfosSuccessfulBidderAccount() {
func (dao *BidInfosDao) ChangeBidInfosSuccessfulBidderAccount(uid int64, newAccount string) {
}
... ...
... ... @@ -57,6 +57,18 @@ func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string)
return nil
}
// ChangePhone TODO 修改用户手机号
func (dao *EmployeeDao) ChangePhone(oldPhone string, newPhone string) error {
tx := dao.transactionContext.PgTx
if _, err := tx.QueryOne(
pg.Scan(),
"UPDATE employees SET employee_account=? WHERE employee_account=?",
oldPhone, newPhone); err != nil {
return err
}
return nil
}
// 更新用户素币
func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error {
tx := dao.transactionContext.PgTx
... ... @@ -139,7 +151,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
}
// 计算系统已兑换现金素币、未兑换素币
func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] interface{}, error) {
func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string]interface{}, error) {
var systemUnExchangeSuMoney float64
var systemExchangedSuMoney float64
var systemExchangedSuMoneyRestore float64
... ... @@ -172,14 +184,14 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int
Select(&systemExchangedSuMoneyRestore); err != nil {
return nil, err
}
return map[string] interface{} {
return map[string]interface{}{
"systemUnExchangeSuMoney": systemUnExchangeSuMoney,
"systemExchangedSuMoney": systemExchangedSuMoney - systemExchangedSuMoneyRestore,
},nil
}, nil
}
// 计算现金池已兑换现金、未兑换现金
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interface{}, error) {
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string]interface{}, error) {
tx := dao.transactionContext.PgTx
var (
systemUnExchangeCash float64
... ... @@ -192,7 +204,7 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
Where("cash_pool.company_id = ?", companyId).
Order("id DESC").
Limit(1).
Select(&systemExchangedCash) ; err != nil {
Select(&systemExchangedCash); err != nil {
return nil, err
}
// 系统未兑换现金
... ... @@ -201,10 +213,10 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
Where("cash_pool.company_id = ?", companyId).
Order("id DESC").
Limit(1).
Select(&systemUnExchangeCash) ; err != nil {
Select(&systemUnExchangeCash); err != nil {
return nil, err
}
return map[string] interface{} {
return map[string]interface{}{
"systemUnExchangeCash": systemUnExchangeCash,
"systemExchangedCash": systemExchangedCash,
}, nil
... ...
... ... @@ -9,7 +9,7 @@ type SentNotificationDao struct {
transactionContext *pgTransaction.TransactionContext
}
//TODO ChangeSentNotificationReceiverAccount
// ChangeSentNotificationReceiverAccount TODO
func (dao *SentNotificationDao) ChangeSentNotificationReceiverAccount() {
}
... ...