作者 陈志颖

feat:增加共创项目申请人数统计

... ... @@ -205,6 +205,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// 更新共创项目申请人计数
cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1
if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -799,8 +804,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
defer func() {
_ = transactionContext.RollbackTransaction()
}()
//TODO 校验用户菜单模块权限
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ... @@ -826,13 +842,26 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
}); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationApplicationSaved.CooperationProject.CooperationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", strconv.FormatInt(cooperationApplicationSaved.CooperationProject.CooperationProjectId, 10)))
}
// 更新共创项目申请统计
cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return cooperationApplication, nil
return cooperationApplicationSaved, nil
}
}
... ...
... ... @@ -696,9 +696,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
} else {
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
})
dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
countDividendsEstimate = countDividendsEstimate + 1
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -854,18 +856,22 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
var dividendsEstimates []*domain.DividendsEstimate
// 统计当前分红预算单数
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
"companyId": confirmMoneyIncentivesEstimateCommand.CompanyId,
})
var countDividendsEstimate int64
// 共创合约预算
if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber(map[string]interface{}{
"companyId": confirmMoneyIncentivesEstimateCommand.CompanyId,
})
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate := &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
... ...
... ... @@ -22,7 +22,7 @@ type CooperationProject struct {
CooperationMode *CooperationMode `json:"cooperationMode"`
// 共创项目发起部门
Department *Department `json:"department"`
// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
// 共创项目承接对象,1员工,2共创用户,4公开,可以多选
CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"`
// 数据所属组织机构
Org *Org `json:"org"`
... ...