作者 陈志颖

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

@@ -205,6 +205,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -205,6 +205,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
205 if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil { 205 if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
206 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 206 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
207 } else { 207 } else {
  208 + // 更新共创项目申请人计数
  209 + cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1
  210 + if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
  211 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  212 + }
208 if err := transactionContext.CommitTransaction(); err != nil { 213 if err := transactionContext.CommitTransaction(); err != nil {
209 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 214 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
210 } 215 }
@@ -799,8 +804,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper @@ -799,8 +804,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
799 defer func() { 804 defer func() {
800 _ = transactionContext.RollbackTransaction() 805 _ = transactionContext.RollbackTransaction()
801 }() 806 }()
  807 +
802 //TODO 校验用户菜单模块权限 808 //TODO 校验用户菜单模块权限
803 809
  810 + // 共创项目仓储初始化
  811 + var cooperationProjectRepository domain.CooperationProjectRepository
  812 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  813 + "transactionContext": transactionContext,
  814 + }); err != nil {
  815 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  816 + } else {
  817 + cooperationProjectRepository = value
  818 + }
  819 +
804 // 共创申请仓储初始化 820 // 共创申请仓储初始化
805 var cooperationApplicationRepository domain.CooperationApplicationRepository 821 var cooperationApplicationRepository domain.CooperationApplicationRepository
806 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ 822 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
@@ -826,13 +842,26 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper @@ -826,13 +842,26 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
826 }); err != nil { 842 }); err != nil {
827 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 843 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
828 } 844 }
829 - if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil { 845 + if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
830 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 846 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
831 } else { 847 } else {
  848 + // 获取共创项目
  849 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationApplicationSaved.CooperationProject.CooperationProjectId})
  850 + if err != nil {
  851 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
  852 + }
  853 + if cooperationProject == nil {
  854 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", strconv.FormatInt(cooperationApplicationSaved.CooperationProject.CooperationProjectId, 10)))
  855 + }
  856 + // 更新共创项目申请统计
  857 + cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
  858 + if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
  859 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  860 + }
832 if err := transactionContext.CommitTransaction(); err != nil { 861 if err := transactionContext.CommitTransaction(); err != nil {
833 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 862 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
834 } 863 }
835 - return cooperationApplication, nil 864 + return cooperationApplicationSaved, nil
836 } 865 }
837 } 866 }
838 867
@@ -696,9 +696,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -696,9 +696,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
696 } else { 696 } else {
697 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails { 697 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
698 // 生成分红预算单号 698 // 生成分红预算单号
699 - dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber(map[string]interface{}{  
700 - "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,  
701 - }) 699 + dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
  700 + if err != nil {
  701 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  702 + }
  703 + countDividendsEstimate = countDividendsEstimate + 1
702 if err != nil { 704 if err != nil {
703 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 705 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
704 } 706 }
@@ -854,18 +856,22 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives @@ -854,18 +856,22 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
854 856
855 var dividendsEstimates []*domain.DividendsEstimate 857 var dividendsEstimates []*domain.DividendsEstimate
856 858
  859 + // 统计当前分红预算单数
  860 + count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
  861 + "companyId": confirmMoneyIncentivesEstimateCommand.CompanyId,
  862 + })
  863 + var countDividendsEstimate int64
857 // 共创合约预算 864 // 共创合约预算
858 if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil { 865 if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil {
859 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) 866 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
860 } else { 867 } else {
861 for _, dividendsEstimateDetail := range dividendsEstimateDetails { 868 for _, dividendsEstimateDetail := range dividendsEstimateDetails {
862 // 生成分红预算单号 869 // 生成分红预算单号
863 - dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber(map[string]interface{}{  
864 - "companyId": confirmMoneyIncentivesEstimateCommand.CompanyId,  
865 - }) 870 + dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
866 if err != nil { 871 if err != nil {
867 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 872 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
868 } 873 }
  874 + countDividendsEstimate = countDividendsEstimate + 1
869 dividendsEstimate := &domain.DividendsEstimate{ 875 dividendsEstimate := &domain.DividendsEstimate{
870 DividendsEstimateId: 0, 876 DividendsEstimateId: 0,
871 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 877 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
@@ -22,7 +22,7 @@ type CooperationProject struct { @@ -22,7 +22,7 @@ type CooperationProject struct {
22 CooperationMode *CooperationMode `json:"cooperationMode"` 22 CooperationMode *CooperationMode `json:"cooperationMode"`
23 // 共创项目发起部门 23 // 共创项目发起部门
24 Department *Department `json:"department"` 24 Department *Department `json:"department"`
25 - // 共创项目承接对象,1员工,2共创用户,3公开,可以多选 25 + // 共创项目承接对象,1员工,2共创用户,4公开,可以多选
26 CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"` 26 CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"`
27 // 数据所属组织机构 27 // 数据所属组织机构
28 Org *Org `json:"org"` 28 Org *Org `json:"org"`