|
@@ -589,7 +589,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -589,7 +589,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
589
|
}
|
589
|
}
|
590
|
}
|
590
|
}
|
591
|
|
591
|
|
592
|
-// ConfirmMoneyIncentivesEstimate TODO 确定金额激励分红预算
|
592
|
+// ConfirmMoneyIncentivesEstimate 确定金额激励分红预算
|
593
|
func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentivesEstimate(confirmMoneyIncentivesEstimateCommand *command.ConfirmMoneyIncentivesEstimateCommand) (interface{}, error) {
|
593
|
func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentivesEstimate(confirmMoneyIncentivesEstimateCommand *command.ConfirmMoneyIncentivesEstimateCommand) (interface{}, error) {
|
594
|
if err := confirmMoneyIncentivesEstimateCommand.ValidateCommand(); err != nil {
|
594
|
if err := confirmMoneyIncentivesEstimateCommand.ValidateCommand(); err != nil {
|
595
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
595
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
|
@@ -628,6 +628,58 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives |
|
@@ -628,6 +628,58 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives |
628
|
cooperationContractRepository = value
|
628
|
cooperationContractRepository = value
|
629
|
}
|
629
|
}
|
630
|
|
630
|
|
|
|
631
|
+ // 分红预算单DAO初始化
|
|
|
632
|
+ var dividendsEstimateDao *dao.DividendsEstimateDao
|
|
|
633
|
+ if value, err := factory.CreateDividendsEstimateDao(map[string]interface{}{
|
|
|
634
|
+ "transactionContext": transactionContext,
|
|
|
635
|
+ }); err != nil {
|
|
|
636
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
637
|
+ } else {
|
|
|
638
|
+ dividendsEstimateDao = value
|
|
|
639
|
+ }
|
|
|
640
|
+
|
|
|
641
|
+ // 公司REST服务初始化
|
|
|
642
|
+ var companyService service.CompanyService
|
|
|
643
|
+ if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
|
|
|
644
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
645
|
+ } else {
|
|
|
646
|
+ companyService = value
|
|
|
647
|
+ }
|
|
|
648
|
+
|
|
|
649
|
+ // 获取公司信息
|
|
|
650
|
+ var company *domain.Company
|
|
|
651
|
+ if data, err := companyService.CompanyFrom(confirmMoneyIncentivesEstimateCommand.CompanyId); err != nil {
|
|
|
652
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
653
|
+ } else {
|
|
|
654
|
+ company = data
|
|
|
655
|
+ }
|
|
|
656
|
+
|
|
|
657
|
+ // 组织机构REST服务初始化
|
|
|
658
|
+ var organizationService service.OrgService
|
|
|
659
|
+ if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
|
|
|
660
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
661
|
+ } else {
|
|
|
662
|
+ organizationService = value
|
|
|
663
|
+ }
|
|
|
664
|
+
|
|
|
665
|
+ // 获取组织机构信息
|
|
|
666
|
+ var organization *domain.Org
|
|
|
667
|
+ if data, err := organizationService.OrgFrom(confirmMoneyIncentivesEstimateCommand.CompanyId, confirmMoneyIncentivesEstimateCommand.OrgId); err != nil {
|
|
|
668
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
669
|
+ } else {
|
|
|
670
|
+ organization = data
|
|
|
671
|
+ }
|
|
|
672
|
+
|
|
|
673
|
+ // 分红预算仓储初始化
|
|
|
674
|
+ var dividendsEstimateRepository domain.DividendsEstimateRepository
|
|
|
675
|
+ if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
|
|
|
676
|
+ "transactionContext": transactionContext,
|
|
|
677
|
+ }); err != nil {
|
|
|
678
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
679
|
+ } else {
|
|
|
680
|
+ dividendsEstimateRepository = value
|
|
|
681
|
+ }
|
|
|
682
|
+
|
631
|
cooperationContractId, _ := strconv.ParseInt(confirmMoneyIncentivesEstimateCommand.CooperationContractId, 10, 64)
|
683
|
cooperationContractId, _ := strconv.ParseInt(confirmMoneyIncentivesEstimateCommand.CooperationContractId, 10, 64)
|
632
|
undertakerUIDs, _ := utils.SliceAtoi(confirmMoneyIncentivesEstimateCommand.UndertakerUids)
|
684
|
undertakerUIDs, _ := utils.SliceAtoi(confirmMoneyIncentivesEstimateCommand.UndertakerUids)
|
633
|
|
685
|
|
|
@@ -640,14 +692,54 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives |
|
@@ -640,14 +692,54 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives |
640
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationContractId, 10)))
|
692
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationContractId, 10)))
|
641
|
}
|
693
|
}
|
642
|
|
694
|
|
|
|
695
|
+ var dividendsEstimates []*domain.DividendsEstimate
|
|
|
696
|
+
|
643
|
// 共创合约预算
|
697
|
// 共创合约预算
|
644
|
if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil {
|
698
|
if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil {
|
645
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
|
699
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
|
646
|
} else {
|
700
|
} else {
|
647
|
- if err3 := transactionContext.CommitTransaction(); err3 != nil {
|
701
|
+ for _, dividendsEstimateDetail := range dividendsEstimateDetails {
|
|
|
702
|
+ // 生成分红预算单号
|
|
|
703
|
+ dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber()
|
|
|
704
|
+ if err != nil {
|
|
|
705
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
706
|
+ }
|
|
|
707
|
+ dividendsEstimate := &domain.DividendsEstimate{
|
|
|
708
|
+ DividendsEstimateId: 0,
|
|
|
709
|
+ DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
|
710
|
+ DividendsAmount: dividendsEstimateDetail.DividendsAmount,
|
|
|
711
|
+ DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
|
|
|
712
|
+ DividendsEstimateTime: time.Now(),
|
|
|
713
|
+ DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
|
|
|
714
|
+ DividendsType: domain.MONEY_INCENTIVES,
|
|
|
715
|
+ DividendsTypeName: "金额激励",
|
|
|
716
|
+ OrderOrReturnedOrderNum: "",
|
|
|
717
|
+ CooperationContractNumber: cooperationContract.CooperationContractNumber,
|
|
|
718
|
+ DividendsUser: dividendsEstimateDetail.DividendsUser,
|
|
|
719
|
+ DividendsStage: dividendsEstimateDetail.DividendsStage,
|
|
|
720
|
+ Org: organization,
|
|
|
721
|
+ Company: company,
|
|
|
722
|
+ Operator: nil,
|
|
|
723
|
+ OperateTime: time.Now(),
|
|
|
724
|
+ IsCanceled: false,
|
|
|
725
|
+ CreatedAt: time.Now(),
|
|
|
726
|
+ DeletedAt: time.Time{},
|
|
|
727
|
+ UpdatedAt: time.Time{},
|
|
|
728
|
+ }
|
|
|
729
|
+ dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
|
|
|
730
|
+ }
|
|
|
731
|
+ var dividendsEstimatesSaved []*domain.DividendsEstimate
|
|
|
732
|
+ for _, dividendsEstimate := range dividendsEstimates {
|
|
|
733
|
+ if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil {
|
|
|
734
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
735
|
+ } else {
|
|
|
736
|
+ dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimateSaved)
|
|
|
737
|
+ }
|
|
|
738
|
+ }
|
|
|
739
|
+ if err := transactionContext.CommitTransaction(); err != nil {
|
648
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
740
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
649
|
}
|
741
|
}
|
650
|
- return dividendsEstimateDetails, nil
|
742
|
+ return dividendsEstimatesSaved, nil
|
651
|
}
|
743
|
}
|
652
|
}
|
744
|
}
|
653
|
|
745
|
|