|
@@ -563,6 +563,24 @@ func (cooperationContractService *CooperationContractService) OperateCooperation |
|
@@ -563,6 +563,24 @@ func (cooperationContractService *CooperationContractService) OperateCooperation |
563
|
defer func() {
|
563
|
defer func() {
|
564
|
_ = transactionContext.RollbackTransaction()
|
564
|
_ = transactionContext.RollbackTransaction()
|
565
|
}()
|
565
|
}()
|
|
|
566
|
+
|
|
|
567
|
+ // 用户REST服务初始化
|
|
|
568
|
+ var userService service.UserService
|
|
|
569
|
+ if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
|
|
|
570
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
571
|
+ } else {
|
|
|
572
|
+ userService = value
|
|
|
573
|
+ }
|
|
|
574
|
+
|
|
|
575
|
+ // 获取操作人
|
|
|
576
|
+ var operator *domain.User
|
|
|
577
|
+ if data, err := userService.OperatorFrom(operateCooperationContractCommand.CompanyId, operateCooperationContractCommand.OrgId, operateCooperationContractCommand.UserId); err != nil {
|
|
|
578
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
579
|
+ } else {
|
|
|
580
|
+ operator = data
|
|
|
581
|
+ }
|
|
|
582
|
+
|
|
|
583
|
+ // 共创合约仓储初始化
|
566
|
var cooperationContractRepository domain.CooperationContractRepository
|
584
|
var cooperationContractRepository domain.CooperationContractRepository
|
567
|
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
585
|
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
568
|
"transactionContext": transactionContext,
|
586
|
"transactionContext": transactionContext,
|
|
@@ -571,6 +589,18 @@ func (cooperationContractService *CooperationContractService) OperateCooperation |
|
@@ -571,6 +589,18 @@ func (cooperationContractService *CooperationContractService) OperateCooperation |
571
|
} else {
|
589
|
} else {
|
572
|
cooperationContractRepository = value
|
590
|
cooperationContractRepository = value
|
573
|
}
|
591
|
}
|
|
|
592
|
+
|
|
|
593
|
+ // 共创合约变更记录仓储初始化
|
|
|
594
|
+ var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
|
|
|
595
|
+ if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
|
|
|
596
|
+ "transactionContext": transactionContext,
|
|
|
597
|
+ }); err != nil {
|
|
|
598
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
599
|
+ } else {
|
|
|
600
|
+ cooperationContractChangeLogRepository = value
|
|
|
601
|
+ }
|
|
|
602
|
+
|
|
|
603
|
+ // 获取共创合约
|
574
|
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": operateCooperationContractCommand.CooperationContractId})
|
604
|
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": operateCooperationContractCommand.CooperationContractId})
|
575
|
if err != nil {
|
605
|
if err != nil {
|
576
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
606
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -578,18 +608,42 @@ func (cooperationContractService *CooperationContractService) OperateCooperation |
|
@@ -578,18 +608,42 @@ func (cooperationContractService *CooperationContractService) OperateCooperation |
578
|
if cooperationContract == nil {
|
608
|
if cooperationContract == nil {
|
579
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operateCooperationContractCommand.CooperationContractId)))
|
609
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(operateCooperationContractCommand.CooperationContractId)))
|
580
|
}
|
610
|
}
|
|
|
611
|
+
|
|
|
612
|
+ // 更新共创合约
|
581
|
if err := cooperationContract.Update(map[string]interface{}{
|
613
|
if err := cooperationContract.Update(map[string]interface{}{
|
582
|
"action": operateCooperationContractCommand.Action,
|
614
|
"action": operateCooperationContractCommand.Action,
|
583
|
}); err != nil {
|
615
|
}); err != nil {
|
584
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
616
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
585
|
}
|
617
|
}
|
586
|
- if cooperationContract, err := cooperationContractRepository.UpdateOne(cooperationContract); err != nil {
|
618
|
+ if cooperationContractUpdated, err := cooperationContractRepository.UpdateOne(cooperationContract); err != nil {
|
587
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
619
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
588
|
} else {
|
620
|
} else {
|
|
|
621
|
+ // 新增共创合约变更记录
|
|
|
622
|
+ var operationType int32
|
|
|
623
|
+ if operateCooperationContractCommand.Action == 1 {
|
|
|
624
|
+ operationType = domain.PAUSE
|
|
|
625
|
+ } else if operateCooperationContractCommand.Action == 2 {
|
|
|
626
|
+ operationType = domain.RECOVER
|
|
|
627
|
+ }
|
|
|
628
|
+ newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
|
|
|
629
|
+ IncentivesRule: "",
|
|
|
630
|
+ IncentivesRuleDetail: "",
|
|
|
631
|
+ OperationType: operationType,
|
|
|
632
|
+ Undertakers: "",
|
|
|
633
|
+ CooperationContractNumber: cooperationContractUpdated.CooperationContractNumber,
|
|
|
634
|
+ Company: cooperationContractUpdated.Company,
|
|
|
635
|
+ Operator: operator,
|
|
|
636
|
+ CreatedAt: time.Now(),
|
|
|
637
|
+ }
|
|
|
638
|
+
|
|
|
639
|
+ // 保存共创合约变更记录
|
|
|
640
|
+ if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil {
|
|
|
641
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error())
|
|
|
642
|
+ }
|
589
|
if err := transactionContext.CommitTransaction(); err != nil {
|
643
|
if err := transactionContext.CommitTransaction(); err != nil {
|
590
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
644
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
591
|
}
|
645
|
}
|
592
|
- return cooperationContract, nil
|
646
|
+ return cooperationContractUpdated, nil
|
593
|
}
|
647
|
}
|
594
|
}
|
648
|
}
|
595
|
|
649
|
|
|
@@ -608,6 +662,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
|
@@ -608,6 +662,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
608
|
defer func() {
|
662
|
defer func() {
|
609
|
_ = transactionContext.RollbackTransaction()
|
663
|
_ = transactionContext.RollbackTransaction()
|
610
|
}()
|
664
|
}()
|
|
|
665
|
+
|
611
|
// 共创合约仓储初始化
|
666
|
// 共创合约仓储初始化
|
612
|
var cooperationContractRepository domain.CooperationContractRepository
|
667
|
var cooperationContractRepository domain.CooperationContractRepository
|
613
|
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
668
|
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
|
@@ -617,7 +672,37 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
|
@@ -617,7 +672,37 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
617
|
} else {
|
672
|
} else {
|
618
|
cooperationContractRepository = value
|
673
|
cooperationContractRepository = value
|
619
|
}
|
674
|
}
|
620
|
- cooperationContractIds, _ := utils.SliceAtoi(batchOperateCooperationContractCommand.CooperationContractIds)
|
675
|
+
|
|
|
676
|
+ // 共创合约变更记录仓储初始化
|
|
|
677
|
+ var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
|
|
|
678
|
+ if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
|
|
|
679
|
+ "transactionContext": transactionContext,
|
|
|
680
|
+ }); err != nil {
|
|
|
681
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
682
|
+ } else {
|
|
|
683
|
+ cooperationContractChangeLogRepository = value
|
|
|
684
|
+ }
|
|
|
685
|
+
|
|
|
686
|
+ // 用户REST服务初始化
|
|
|
687
|
+ var userService service.UserService
|
|
|
688
|
+ if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
|
|
|
689
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
690
|
+ } else {
|
|
|
691
|
+ userService = value
|
|
|
692
|
+ }
|
|
|
693
|
+
|
|
|
694
|
+ // 获取操作人
|
|
|
695
|
+ var operator *domain.User
|
|
|
696
|
+ if data, err := userService.OperatorFrom(batchOperateCooperationContractCommand.CompanyId, batchOperateCooperationContractCommand.OrgId, batchOperateCooperationContractCommand.UserId); err != nil {
|
|
|
697
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
698
|
+ } else {
|
|
|
699
|
+ operator = data
|
|
|
700
|
+ }
|
|
|
701
|
+
|
|
|
702
|
+ cooperationContractIds, err := utils.SliceAtoi(batchOperateCooperationContractCommand.CooperationContractIds)
|
|
|
703
|
+ if err != nil {
|
|
|
704
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "转换共创合约ID列表错误")
|
|
|
705
|
+ }
|
621
|
if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
|
706
|
if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
|
622
|
"cooperationContractIds": cooperationContractIds,
|
707
|
"cooperationContractIds": cooperationContractIds,
|
623
|
}); err != nil {
|
708
|
}); err != nil {
|
|
@@ -631,6 +716,31 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
|
@@ -631,6 +716,31 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper |
631
|
if err != nil {
|
716
|
if err != nil {
|
632
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
717
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
633
|
}
|
718
|
}
|
|
|
719
|
+ for _, cooperationContractOperated := range cooperationContractsOperated {
|
|
|
720
|
+ // 新增共创合约变更记录
|
|
|
721
|
+ var operationType int32
|
|
|
722
|
+ if batchOperateCooperationContractCommand.Action == 1 {
|
|
|
723
|
+ operationType = domain.PAUSE
|
|
|
724
|
+ } else if batchOperateCooperationContractCommand.Action == 2 {
|
|
|
725
|
+ operationType = domain.RECOVER
|
|
|
726
|
+ }
|
|
|
727
|
+ newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
|
|
|
728
|
+ IncentivesRule: "",
|
|
|
729
|
+ IncentivesRuleDetail: "",
|
|
|
730
|
+ OperationType: operationType,
|
|
|
731
|
+ Undertakers: "",
|
|
|
732
|
+ CooperationContractNumber: cooperationContractOperated.CooperationContractNumber,
|
|
|
733
|
+ Company: cooperationContractOperated.Company,
|
|
|
734
|
+ Operator: operator,
|
|
|
735
|
+ CreatedAt: time.Now(),
|
|
|
736
|
+ }
|
|
|
737
|
+
|
|
|
738
|
+ // 保存共创合约变更记录
|
|
|
739
|
+ if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil {
|
|
|
740
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error())
|
|
|
741
|
+ }
|
|
|
742
|
+ }
|
|
|
743
|
+
|
634
|
if err := transactionContext.CommitTransaction(); err != nil {
|
744
|
if err := transactionContext.CommitTransaction(); err != nil {
|
635
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
745
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
636
|
}
|
746
|
}
|
|
@@ -705,12 +815,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -705,12 +815,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
705
|
if err := updateCooperationContractCommand.ValidateCommand(); err != nil {
|
815
|
if err := updateCooperationContractCommand.ValidateCommand(); err != nil {
|
706
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
816
|
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
|
707
|
}
|
817
|
}
|
708
|
- transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
709
|
- if err != nil {
|
|
|
710
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
818
|
+ transactionContext, err1 := factory.CreateTransactionContext(nil)
|
|
|
819
|
+ if err1 != nil {
|
|
|
820
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err1.Error())
|
711
|
}
|
821
|
}
|
712
|
- if err := transactionContext.StartTransaction(); err != nil {
|
|
|
713
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
822
|
+ if err2 := transactionContext.StartTransaction(); err2 != nil {
|
|
|
823
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
|
714
|
}
|
824
|
}
|
715
|
defer func() {
|
825
|
defer func() {
|
716
|
_ = transactionContext.RollbackTransaction()
|
826
|
_ = transactionContext.RollbackTransaction()
|
|
@@ -718,59 +828,76 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -718,59 +828,76 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
718
|
|
828
|
|
719
|
// 公司REST服务初始化
|
829
|
// 公司REST服务初始化
|
720
|
var companyService service.CompanyService
|
830
|
var companyService service.CompanyService
|
721
|
- if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
|
|
|
722
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
831
|
+ if value, err3 := factory.CreateCompanyService(map[string]interface{}{}); err3 != nil {
|
|
|
832
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
|
723
|
} else {
|
833
|
} else {
|
724
|
companyService = value
|
834
|
companyService = value
|
725
|
}
|
835
|
}
|
726
|
|
836
|
|
727
|
// 获取公司信息
|
837
|
// 获取公司信息
|
728
|
var company *domain.Company
|
838
|
var company *domain.Company
|
729
|
- if data, err := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err != nil {
|
|
|
730
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
839
|
+ if data, err4 := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err4 != nil {
|
|
|
840
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
|
731
|
} else {
|
841
|
} else {
|
732
|
company = data
|
842
|
company = data
|
733
|
}
|
843
|
}
|
734
|
|
844
|
|
735
|
// 组织机构REST服务初始化
|
845
|
// 组织机构REST服务初始化
|
736
|
var organizationService service.OrgService
|
846
|
var organizationService service.OrgService
|
737
|
- if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
|
|
|
738
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
847
|
+ if value, err5 := factory.CreateOrganizationService(map[string]interface{}{}); err5 != nil {
|
|
|
848
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err5.Error())
|
739
|
} else {
|
849
|
} else {
|
740
|
organizationService = value
|
850
|
organizationService = value
|
741
|
}
|
851
|
}
|
742
|
|
852
|
|
743
|
// 获取组织机构信息
|
853
|
// 获取组织机构信息
|
744
|
var organization *domain.Org
|
854
|
var organization *domain.Org
|
745
|
- if data, err := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err != nil {
|
|
|
746
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
855
|
+ if data, err6 := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err6 != nil {
|
|
|
856
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
|
747
|
} else {
|
857
|
} else {
|
748
|
organization = data
|
858
|
organization = data
|
749
|
}
|
859
|
}
|
750
|
|
860
|
|
751
|
- var cooperationContractRepository domain.CooperationContractRepository
|
|
|
752
|
- if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
861
|
+ // 共创合约变更记录仓储初始化
|
|
|
862
|
+ var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
|
|
|
863
|
+ if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
|
753
|
"transactionContext": transactionContext,
|
864
|
"transactionContext": transactionContext,
|
754
|
}); err != nil {
|
865
|
}); err != nil {
|
755
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
866
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
756
|
} else {
|
867
|
} else {
|
|
|
868
|
+ cooperationContractChangeLogRepository = value
|
|
|
869
|
+ }
|
|
|
870
|
+
|
|
|
871
|
+ // 共创合约仓储初始化
|
|
|
872
|
+ var cooperationContractRepository domain.CooperationContractRepository
|
|
|
873
|
+ if value, err7 := factory.CreateCooperationContractRepository(map[string]interface{}{
|
|
|
874
|
+ "transactionContext": transactionContext,
|
|
|
875
|
+ }); err7 != nil {
|
|
|
876
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err7.Error())
|
|
|
877
|
+ } else {
|
757
|
cooperationContractRepository = value
|
878
|
cooperationContractRepository = value
|
758
|
}
|
879
|
}
|
759
|
- cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": updateCooperationContractCommand.CooperationContractId})
|
|
|
760
|
- if err != nil {
|
|
|
761
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
880
|
+
|
|
|
881
|
+ // 获取待更新的共创合约
|
|
|
882
|
+ cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": updateCooperationContractCommand.CooperationContractId})
|
|
|
883
|
+ if err8 != nil {
|
|
|
884
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err8.Error())
|
762
|
}
|
885
|
}
|
763
|
if cooperationContract == nil {
|
886
|
if cooperationContract == nil {
|
764
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
|
887
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
|
765
|
}
|
888
|
}
|
|
|
889
|
+
|
|
|
890
|
+ cooperationContractFound := cooperationContract
|
|
|
891
|
+
|
766
|
// 更新合约基础信息
|
892
|
// 更新合约基础信息
|
767
|
- if err := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err != nil {
|
|
|
768
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
893
|
+ if err9 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err9 != nil {
|
|
|
894
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err9.Error())
|
769
|
}
|
895
|
}
|
|
|
896
|
+
|
770
|
// 用户REST服务初始化
|
897
|
// 用户REST服务初始化
|
771
|
var userService service.UserService
|
898
|
var userService service.UserService
|
772
|
- if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
|
|
|
773
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
899
|
+ if value, err10 := factory.CreateUserService(map[string]interface{}{}); err10 != nil {
|
|
|
900
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err10.Error())
|
774
|
} else {
|
901
|
} else {
|
775
|
userService = value
|
902
|
userService = value
|
776
|
}
|
903
|
}
|
|
@@ -778,12 +905,20 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -778,12 +905,20 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
778
|
// 获取发起人
|
905
|
// 获取发起人
|
779
|
var sponsor *domain.User
|
906
|
var sponsor *domain.User
|
780
|
sponsorUid, _ := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64)
|
907
|
sponsorUid, _ := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64)
|
781
|
- if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, sponsorUid); err != nil {
|
|
|
782
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
908
|
+ if data, err11 := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, sponsorUid); err11 != nil {
|
|
|
909
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err11.Error())
|
783
|
} else {
|
910
|
} else {
|
784
|
sponsor = data
|
911
|
sponsor = data
|
785
|
}
|
912
|
}
|
786
|
|
913
|
|
|
|
914
|
+ // 获取操作人
|
|
|
915
|
+ var operator *domain.User
|
|
|
916
|
+ if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, updateCooperationContractCommand.UserId); err != nil {
|
|
|
917
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
918
|
+ } else {
|
|
|
919
|
+ operator = data
|
|
|
920
|
+ }
|
|
|
921
|
+
|
787
|
// 更新发起人
|
922
|
// 更新发起人
|
788
|
cooperationContract.CooperationContractSponsor = sponsor
|
923
|
cooperationContract.CooperationContractSponsor = sponsor
|
789
|
|
924
|
|
|
@@ -792,8 +927,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -792,8 +927,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
792
|
for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople {
|
927
|
for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople {
|
793
|
var relevantDomain *domain.Relevant
|
928
|
var relevantDomain *domain.Relevant
|
794
|
relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64)
|
929
|
relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64)
|
795
|
- if data, err := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err != nil {
|
|
|
796
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
930
|
+ if data, err12 := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err12 != nil {
|
|
|
931
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err12.Error())
|
797
|
} else {
|
932
|
} else {
|
798
|
relevantDomain = data
|
933
|
relevantDomain = data
|
799
|
}
|
934
|
}
|
|
@@ -821,8 +956,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -821,8 +956,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
821
|
for _, undertaker := range updateCooperationContractCommand.Undertakers {
|
956
|
for _, undertaker := range updateCooperationContractCommand.Undertakers {
|
822
|
var undertakerDomain *domain.Undertaker
|
957
|
var undertakerDomain *domain.Undertaker
|
823
|
undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64)
|
958
|
undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64)
|
824
|
- if data, err := userService.UndertakerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, undertakerUid); err != nil {
|
|
|
825
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
959
|
+ if data, err13 := userService.UndertakerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, undertakerUid); err13 != nil {
|
|
|
960
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error())
|
826
|
} else {
|
961
|
} else {
|
827
|
undertakerDomain = data
|
962
|
undertakerDomain = data
|
828
|
}
|
963
|
}
|
|
@@ -831,8 +966,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -831,8 +966,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
831
|
var referrerDomain *domain.Referrer
|
966
|
var referrerDomain *domain.Referrer
|
832
|
referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
|
967
|
referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
|
833
|
if referrerUid > 0 {
|
968
|
if referrerUid > 0 {
|
834
|
- if data, err := userService.ReferrerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, referrerUid); err != nil {
|
|
|
835
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
969
|
+ if data, err14 := userService.ReferrerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, referrerUid); err14 != nil {
|
|
|
970
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err14.Error())
|
836
|
} else {
|
971
|
} else {
|
837
|
referrerDomain = data
|
972
|
referrerDomain = data
|
838
|
}
|
973
|
}
|
|
@@ -840,18 +975,21 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -840,18 +975,21 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
840
|
|
975
|
|
841
|
// 获取业务员
|
976
|
// 获取业务员
|
842
|
var salesmanDomain *domain.Salesman
|
977
|
var salesmanDomain *domain.Salesman
|
843
|
- salesmanUid, _ := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
|
978
|
+ salesmanUid, err22 := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
|
|
|
979
|
+ if err22 != nil {
|
|
|
980
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err22.Error())
|
|
|
981
|
+ }
|
844
|
if salesmanUid > 0 {
|
982
|
if salesmanUid > 0 {
|
845
|
- if data, err := userService.SalesmanFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, salesmanUid); err != nil {
|
|
|
846
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
983
|
+ if data, err15 := userService.SalesmanFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, salesmanUid); err15 != nil {
|
|
|
984
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err15.Error())
|
847
|
} else {
|
985
|
} else {
|
848
|
salesmanDomain = data
|
986
|
salesmanDomain = data
|
849
|
}
|
987
|
}
|
850
|
}
|
988
|
}
|
851
|
|
989
|
|
852
|
- undertakerId, err3 := strconv.ParseInt(undertaker.UndertakerId, 10, 64)
|
|
|
853
|
- if err3 != nil {
|
|
|
854
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
|
990
|
+ undertakerId, err16 := strconv.ParseInt(undertaker.UndertakerId, 10, 64)
|
|
|
991
|
+ if err16 != nil {
|
|
|
992
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error())
|
855
|
}
|
993
|
}
|
856
|
undertakers = append(undertakers, &domain.Undertaker{
|
994
|
undertakers = append(undertakers, &domain.Undertaker{
|
857
|
UndertakerId: undertakerId,
|
995
|
UndertakerId: undertakerId,
|
|
@@ -877,9 +1015,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -877,9 +1015,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
877
|
// 获取分红规则列表
|
1015
|
// 获取分红规则列表
|
878
|
var dividendsIncentivesRules []*domain.DividendsIncentivesRule
|
1016
|
var dividendsIncentivesRules []*domain.DividendsIncentivesRule
|
879
|
for _, dividendsIncentivesRule := range updateCooperationContractCommand.DividendsIncentivesRules {
|
1017
|
for _, dividendsIncentivesRule := range updateCooperationContractCommand.DividendsIncentivesRules {
|
880
|
- dividendsIncentivesRuleId, err2 := strconv.ParseInt(dividendsIncentivesRule.DividendsIncentivesRuleId, 10, 64)
|
|
|
881
|
- if err2 != nil {
|
|
|
882
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
|
1018
|
+ dividendsIncentivesRuleId, err17 := strconv.ParseInt(dividendsIncentivesRule.DividendsIncentivesRuleId, 10, 64)
|
|
|
1019
|
+ if err17 != nil {
|
|
|
1020
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err17.Error())
|
883
|
}
|
1021
|
}
|
884
|
dividendsIncentivesRules = append(dividendsIncentivesRules, &domain.DividendsIncentivesRule{
|
1022
|
dividendsIncentivesRules = append(dividendsIncentivesRules, &domain.DividendsIncentivesRule{
|
885
|
DividendsIncentivesRuleId: dividendsIncentivesRuleId,
|
1023
|
DividendsIncentivesRuleId: dividendsIncentivesRuleId,
|
|
@@ -903,9 +1041,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -903,9 +1041,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
903
|
// 获取金额激励规则列表
|
1041
|
// 获取金额激励规则列表
|
904
|
var moneyIncentivesRules []*domain.MoneyIncentivesRule
|
1042
|
var moneyIncentivesRules []*domain.MoneyIncentivesRule
|
905
|
for _, moneyIncentivesRule := range updateCooperationContractCommand.MoneyIncentivesRules {
|
1043
|
for _, moneyIncentivesRule := range updateCooperationContractCommand.MoneyIncentivesRules {
|
906
|
- moneyIncentivesRuleId, err4 := strconv.ParseInt(moneyIncentivesRule.MoneyIncentivesRuleId, 10, 64)
|
|
|
907
|
- if err4 != nil {
|
|
|
908
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
|
1044
|
+ moneyIncentivesRuleId, err18 := strconv.ParseInt(moneyIncentivesRule.MoneyIncentivesRuleId, 10, 64)
|
|
|
1045
|
+ if err18 != nil {
|
|
|
1046
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err18.Error())
|
909
|
}
|
1047
|
}
|
910
|
moneyIncentivesRules = append(moneyIncentivesRules, &domain.MoneyIncentivesRule{
|
1048
|
moneyIncentivesRules = append(moneyIncentivesRules, &domain.MoneyIncentivesRule{
|
911
|
MoneyIncentivesRuleId: moneyIncentivesRuleId,
|
1049
|
MoneyIncentivesRuleId: moneyIncentivesRuleId,
|
|
@@ -927,13 +1065,220 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -927,13 +1065,220 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
927
|
// 更新金额激励规则列表
|
1065
|
// 更新金额激励规则列表
|
928
|
cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
|
1066
|
cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
|
929
|
|
1067
|
|
930
|
- if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil {
|
|
|
931
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
1068
|
+ // 判断激励规则变更
|
|
|
1069
|
+ incentivesType := 0
|
|
|
1070
|
+ if len(dividendsIncentivesRules) > 0 {
|
|
|
1071
|
+ incentivesType = domain.TYPE_DIVIDNEDS_INCENTIVES
|
|
|
1072
|
+ } else if len(moneyIncentivesRules) > 0 {
|
|
|
1073
|
+ incentivesType = domain.TYPE_MONEY_INCENTIVES
|
|
|
1074
|
+ }
|
|
|
1075
|
+ cooperationContract.IncentivesType = int32(incentivesType)
|
|
|
1076
|
+
|
|
|
1077
|
+ // 保存共创合约变更
|
|
|
1078
|
+ if cooperationContractSaved, err19 := cooperationContractRepository.Save(cooperationContract); err19 != nil {
|
|
|
1079
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err19.Error())
|
932
|
} else {
|
1080
|
} else {
|
933
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
934
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
1081
|
+ // 保存共创合约变更记录
|
|
|
1082
|
+ // 原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
|
|
|
1083
|
+ var incentivesRuleChange string
|
|
|
1084
|
+ var incentivesRuleChangeDetail string
|
|
|
1085
|
+ if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 1.激励类型变更
|
|
|
1086
|
+ // 业绩分红-->金额激励
|
|
|
1087
|
+ incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
|
|
|
1088
|
+
|
|
|
1089
|
+ //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
|
|
|
1090
|
+ // 原业绩分红激励规则
|
|
|
1091
|
+ var dividendsIncentivesRuleOriginal string
|
|
|
1092
|
+ for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
|
|
|
1093
|
+ dividendsIncentivesRuleOriginal = dividendsIncentivesRuleOriginal + dividendsIncentivesRule.DividendsIncentivesStageCN +
|
|
|
1094
|
+ ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
|
|
|
1095
|
+ "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
|
|
|
1096
|
+ "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
|
|
|
1097
|
+ "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
|
|
|
1098
|
+ "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1099
|
+ }
|
|
|
1100
|
+ dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
|
|
|
1101
|
+
|
|
|
1102
|
+ // 变更后的金额激励规则
|
|
|
1103
|
+ var moneyIncentivesRuleChanged string
|
|
|
1104
|
+ for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
|
|
|
1105
|
+ moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
|
|
|
1106
|
+ ":" +
|
|
|
1107
|
+ "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
|
|
|
1108
|
+ "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
|
|
|
1109
|
+ "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1110
|
+ }
|
|
|
1111
|
+ moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleChanged + "】"
|
|
|
1112
|
+
|
|
|
1113
|
+ // 拼接规则变更
|
|
|
1114
|
+ incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleOriginalTmp
|
|
|
1115
|
+ } else if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES {
|
|
|
1116
|
+ // 金额激励-->业绩分红
|
|
|
1117
|
+ incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
|
|
|
1118
|
+ //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
|
|
|
1119
|
+
|
|
|
1120
|
+ // 原金额激励规则
|
|
|
1121
|
+ var moneyIncentivesRuleOriginal string
|
|
|
1122
|
+ for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
|
|
|
1123
|
+ moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
|
|
|
1124
|
+ ":" +
|
|
|
1125
|
+ "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
|
|
|
1126
|
+ "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
|
|
|
1127
|
+ "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1128
|
+ }
|
|
|
1129
|
+ moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
|
|
|
1130
|
+
|
|
|
1131
|
+ // 变更后的业绩分红激励规则
|
|
|
1132
|
+ var dividendsIncentivesRuleChanged string
|
|
|
1133
|
+ for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
|
|
|
1134
|
+ dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
|
|
|
1135
|
+ ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
|
|
|
1136
|
+ "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
|
|
|
1137
|
+ "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
|
|
|
1138
|
+ "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
|
|
|
1139
|
+ "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1140
|
+ }
|
|
|
1141
|
+ dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleChanged + "】"
|
|
|
1142
|
+
|
|
|
1143
|
+ // 拼接规则变更
|
|
|
1144
|
+ incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleOriginalTmp
|
|
|
1145
|
+ } else { // 2.激励规则变更
|
|
|
1146
|
+ if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红激励规则变更
|
|
|
1147
|
+ if !cooperationContract.DividendsIncentivesRuleSliceEqualBCE(cooperationContractFound.DividendsIncentivesRules, cooperationContractSaved.DividendsIncentivesRules) {
|
|
|
1148
|
+ // 业绩分红-->业绩分红
|
|
|
1149
|
+ incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
|
|
|
1150
|
+ //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
|
|
|
1151
|
+
|
|
|
1152
|
+ // 原业绩分红激励规则
|
|
|
1153
|
+ var dividendsIncentivesRuleOriginal string
|
|
|
1154
|
+ for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
|
|
|
1155
|
+ dividendsIncentivesRuleOriginal = dividendsIncentivesRuleOriginal + dividendsIncentivesRule.DividendsIncentivesStageCN +
|
|
|
1156
|
+ ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
|
|
|
1157
|
+ "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
|
|
|
1158
|
+ "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
|
|
|
1159
|
+ "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
|
|
|
1160
|
+ "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1161
|
+ }
|
|
|
1162
|
+ dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
|
|
|
1163
|
+
|
|
|
1164
|
+ // 变更后的业绩分红激励规则
|
|
|
1165
|
+ var dividendsIncentivesRuleChanged string
|
|
|
1166
|
+ for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
|
|
|
1167
|
+ dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
|
|
|
1168
|
+ ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
|
|
|
1169
|
+ "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
|
|
|
1170
|
+ "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
|
|
|
1171
|
+ "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
|
|
|
1172
|
+ "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1173
|
+ }
|
|
|
1174
|
+ dividendsIncentivesRuleChangedTmp := "【" + dividendsIncentivesRuleChanged + "】"
|
|
|
1175
|
+
|
|
|
1176
|
+ // 拼接规则变更
|
|
|
1177
|
+ incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp
|
935
|
}
|
1178
|
}
|
936
|
- return cooperationContract, nil
|
1179
|
+ } else if cooperationContractFound.IncentivesType == domain.MONEY_INCENTIVES { // 金额激励规则变更
|
|
|
1180
|
+ if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContractSaved.MoneyIncentivesRules) {
|
|
|
1181
|
+ incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
|
|
|
1182
|
+ //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
|
|
|
1183
|
+
|
|
|
1184
|
+ // 原金额激励规则
|
|
|
1185
|
+ var moneyIncentivesRuleOriginal string
|
|
|
1186
|
+ for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
|
|
|
1187
|
+ moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
|
|
|
1188
|
+ ":" +
|
|
|
1189
|
+ "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
|
|
|
1190
|
+ "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
|
|
|
1191
|
+ "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1192
|
+ }
|
|
|
1193
|
+ moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
|
|
|
1194
|
+
|
|
|
1195
|
+ // 变更后的激励规则
|
|
|
1196
|
+ var moneyIncentivesRuleChanged string
|
|
|
1197
|
+ for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
|
|
|
1198
|
+ moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
|
|
|
1199
|
+ ":" +
|
|
|
1200
|
+ "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
|
|
|
1201
|
+ "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
|
|
|
1202
|
+ "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
|
|
|
1203
|
+ }
|
|
|
1204
|
+ moneyIncentivesRuleChangedTmp := "【" + moneyIncentivesRuleChanged + "】"
|
|
|
1205
|
+
|
|
|
1206
|
+ // 拼接规则变更
|
|
|
1207
|
+ incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleChangedTmp
|
|
|
1208
|
+ }
|
|
|
1209
|
+ }
|
|
|
1210
|
+ }
|
|
|
1211
|
+
|
|
|
1212
|
+ // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
|
|
|
1213
|
+ var undertakerChange string
|
|
|
1214
|
+ if !cooperationContract.UndertakerSliceEqualBCE(cooperationContractFound.Undertakers, cooperationContractSaved.Undertakers) { // 3.承接人变更
|
|
|
1215
|
+ // 原承接人
|
|
|
1216
|
+ var undertakersOriginal string
|
|
|
1217
|
+ for i, undertaker := range cooperationContractFound.Undertakers {
|
|
|
1218
|
+ undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
|
|
|
1219
|
+ }
|
|
|
1220
|
+ undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
|
|
|
1221
|
+ // 变更承接人
|
|
|
1222
|
+ var undertakersChanged string
|
|
|
1223
|
+ for i, undertaker := range cooperationContractSaved.Undertakers {
|
|
|
1224
|
+ if undertaker.Referrer == nil {
|
|
|
1225
|
+ undertaker.Referrer = &domain.Referrer{
|
|
|
1226
|
+ UserId: 0,
|
|
|
1227
|
+ UserBaseId: 0,
|
|
|
1228
|
+ Roles: nil,
|
|
|
1229
|
+ Orgs: nil,
|
|
|
1230
|
+ Org: nil,
|
|
|
1231
|
+ Department: nil,
|
|
|
1232
|
+ Company: nil,
|
|
|
1233
|
+ UserInfo: nil,
|
|
|
1234
|
+ UserType: 0,
|
|
|
1235
|
+ UserName: "",
|
|
|
1236
|
+ UserPhone: "",
|
|
|
1237
|
+ }
|
|
|
1238
|
+ }
|
|
|
1239
|
+ if undertaker.Salesman == nil {
|
|
|
1240
|
+ undertaker.Salesman = &domain.Salesman{
|
|
|
1241
|
+ UserId: 0,
|
|
|
1242
|
+ UserBaseId: 0,
|
|
|
1243
|
+ Roles: nil,
|
|
|
1244
|
+ Orgs: nil,
|
|
|
1245
|
+ Org: nil,
|
|
|
1246
|
+ Department: nil,
|
|
|
1247
|
+ Company: nil,
|
|
|
1248
|
+ UserInfo: nil,
|
|
|
1249
|
+ UserType: 0,
|
|
|
1250
|
+ UserName: "",
|
|
|
1251
|
+ UserPhone: "",
|
|
|
1252
|
+ }
|
|
|
1253
|
+ }
|
|
|
1254
|
+ undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
|
|
|
1255
|
+ }
|
|
|
1256
|
+ undertakerChangeTemp2 := "【" + undertakersChanged + "】"
|
|
|
1257
|
+ // 拼接承接人变更记录
|
|
|
1258
|
+ undertakerChange = undertakerChangeTmp1 + " 变更为 " + undertakerChangeTemp2
|
|
|
1259
|
+ }
|
|
|
1260
|
+
|
|
|
1261
|
+ // 新增共创合约变更记录
|
|
|
1262
|
+ newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
|
|
|
1263
|
+ IncentivesRule: incentivesRuleChange,
|
|
|
1264
|
+ IncentivesRuleDetail: incentivesRuleChangeDetail,
|
|
|
1265
|
+ OperationType: domain.EDIT,
|
|
|
1266
|
+ Undertakers: undertakerChange,
|
|
|
1267
|
+ CooperationContractNumber: cooperationContractSaved.CooperationContractNumber,
|
|
|
1268
|
+ Company: company,
|
|
|
1269
|
+ Operator: operator,
|
|
|
1270
|
+ UpdatedAt: time.Time{},
|
|
|
1271
|
+ CreatedAt: time.Now(),
|
|
|
1272
|
+ }
|
|
|
1273
|
+
|
|
|
1274
|
+ // 保存共创合约变更记录
|
|
|
1275
|
+ if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil {
|
|
|
1276
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error())
|
|
|
1277
|
+ }
|
|
|
1278
|
+ if err21 := transactionContext.CommitTransaction(); err21 != nil {
|
|
|
1279
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err21.Error())
|
|
|
1280
|
+ }
|
|
|
1281
|
+ return cooperationContractSaved, nil
|
937
|
}
|
1282
|
}
|
938
|
}
|
1283
|
}
|
939
|
|
1284
|
|