作者 陈志颖

fix:修复新建合约相关人错误

... ... @@ -153,6 +153,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ... @@ -162,10 +163,29 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
} else {
cooperationApplicationRepository = value
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取审核人
var verifier *domain.User
if data, err := userService.UserFrom(approvalCooperationApplicationCommand.CompanyId, approvalCooperationApplicationCommand.OrgId, approvalCooperationApplicationCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取申请人失败")
} else {
verifier = data
}
// 共创申请ID转换
cooperationApplicationId, err := strconv.ParseInt(approvalCooperationApplicationCommand.CooperationApplicationId, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请ID类型错误")
}
// 获取共创申请
cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": approvalCooperationApplicationCommand.CooperationApplicationId})
if err != nil {
... ... @@ -174,11 +194,15 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
}
if approvalCooperationApplicationCommand.Action == 1 {
cooperationApplication.CooperationApplicationStatus = 2
} else if approvalCooperationApplicationCommand.Action == 2 {
cooperationApplication.CooperationApplicationStatus = 3
}
cooperationApplication.CooperationApplicationVerifier = verifier
if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(approvalCooperationApplicationCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -207,6 +231,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ... @@ -216,10 +241,30 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
} else {
cooperationApplicationRepository = value
}
// 共创申请ID类型转换
cooperationApplicationIds, err := utils.SliceAtoi(batchApprovalCooperationApplicationCommand.CooperationApplicationIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创申请ID列表类型错误")
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取审核人
var verifier *domain.User
if data, err := userService.UserFrom(batchApprovalCooperationApplicationCommand.CompanyId, batchApprovalCooperationApplicationCommand.OrgId, batchApprovalCooperationApplicationCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取申请人失败")
} else {
verifier = data
}
// 获取共创申请
if count, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
"cooperationApplicationIds": cooperationApplicationIds,
}); err != nil {
... ... @@ -227,12 +272,13 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
} else {
if count > 0 {
for i, _ := range cooperationApplications {
cooperationApplications[i].CooperationApplicationDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription
cooperationApplications[i].CooperationApplicationVerifyDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription
if batchApprovalCooperationApplicationCommand.Action == 1 { // 同意
cooperationApplications[i].CooperationApplicationStatus = 2
} else if batchApprovalCooperationApplicationCommand.Action == 2 { // 拒绝
cooperationApplications[i].CooperationApplicationStatus = 3
}
cooperationApplications[i].CooperationApplicationVerifier = verifier
}
cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications)
if err != nil {
... ...
... ... @@ -166,6 +166,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
referrerDomain = data
}
}
// 获取业务员
var salesmanDomain *domain.Salesman
salesmanUid, _ := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
... ...
... ... @@ -125,13 +125,12 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
CreatedAt: time.Now(),
})
}
log.Logger.Info("新增的相关人", map[string]interface{}{
"relevantPeopleModel": relevantPeopleModel,
})
if len(relevantPeopleModel) > 0 {
if result, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
return nil, err
} else {
log.Logger.Info("新增的相关人", map[string]interface{}{
"relevantPeopleModel": result,
})
}
}
... ...