作者 陈志颖

fix:验收任务完善员工信息

... ... @@ -2593,13 +2593,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
activityFoundExchangedCash := activityFound.ExchangedCash
// 判断当前人员状态
// 判断当前员工是否有效
getEmployee := map[string]interface{}{
"uid": personFound.EmployeeInfo.Uid,
"companyId": activityFound.CompanyId,
}
// 判断当前员工是否有效
employeeFound, err := employeeRepository.FindOne(getEmployee)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -40,6 +40,8 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand *
operationSuMoneyService = value
}
if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -309,6 +309,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
if err := acceptanceTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -320,6 +321,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
transactionContext.RollbackTransaction()
}()
// 验收服务初始化
var acceptanceTaskService service.AcceptanceTaskService
if value, err := factory.CreateAcceptanceTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -330,6 +332,31 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
// 员工仓储初始化
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeRepository = value
}
// 填充员工信息
for i, taskPercentage := range acceptanceTaskCommand.TaskPercentage {
getEmployee := map[string]interface{}{
"uid": taskPercentage.Contributor.Uid,
}
employeeFound, err := employeeRepository.FindOne(getEmployee)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employeeFound == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工")
}
acceptanceTaskCommand.TaskPercentage[i].Contributor = employeeFound.EmployeeInfo
}
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.SuMoney, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
... ... @@ -171,7 +171,7 @@ func (service *AcceptanceTaskService) Acceptance(taskId int64, operatorUid int64
}
}
}
if task, err := taskRepository.Save(task); err != nil {
if task, err := taskRepository.Save(task); err != nil {
return nil, err
} else {
taskAcceptancedEvent := new(event.TaskAcceptanced)
... ...
... ... @@ -69,7 +69,7 @@ func (repository *EmployeeRepository) FindOne(queryOptions map[string]interface{
if companyId, ok := queryOptions["companyId"]; ok {
query = query.Where("employee.company_id = ?", companyId)
}
if status, ok := queryOptions["status"]; ok {
if status, ok := queryOptions["status"]; ok && status.(int) != 0 {
query = query.Where(`employee.status = ?`, status) // 筛除已离职员工
}
if err := query.First(); err != nil {
... ... @@ -102,7 +102,7 @@ func (repository *EmployeeRepository) FindByIds(queryOptions map[string]interfac
query = query.Where("employee.company_id = ?", companyId)
}
}
if status, ok := queryOptions["status"]; ok {
if status, ok := queryOptions["status"]; ok && status.(int) != 0 {
query = query.Where(`employee.status = ?`, status)
}
if count, err := query.Order("uid DESC").SelectAndCount(); err != nil {
... ...