|
@@ -649,16 +649,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -649,16 +649,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
649
|
cooperationContractRepository = value
|
649
|
cooperationContractRepository = value
|
650
|
}
|
650
|
}
|
651
|
|
651
|
|
652
|
- // 共创项目仓储初始化
|
|
|
653
|
- //var cooperationProjectRepository domain.CooperationProjectRepository
|
|
|
654
|
- //if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
|
|
|
655
|
- // "transactionContext": transactionContext,
|
|
|
656
|
- //}); err != nil {
|
|
|
657
|
- // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
658
|
- //} else {
|
|
|
659
|
- // cooperationProjectRepository = value
|
|
|
660
|
- //}
|
|
|
661
|
-
|
|
|
662
|
// 初始化确认业绩激励分红预算领域服务
|
652
|
// 初始化确认业绩激励分红预算领域服务
|
663
|
var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
|
653
|
var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
|
664
|
if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
|
654
|
if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
|
|
@@ -672,26 +662,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -672,26 +662,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
672
|
})
|
662
|
})
|
673
|
}
|
663
|
}
|
674
|
|
664
|
|
675
|
- // 查询共创项目
|
|
|
676
|
- //cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
|
|
|
677
|
- //if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
|
|
|
678
|
- // "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
|
|
679
|
- // "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
|
|
|
680
|
- // "offsetLimit": false,
|
|
|
681
|
- //}); err != nil {
|
|
|
682
|
- // return nil, err
|
|
|
683
|
- //} else {
|
|
|
684
|
- // if count > 0 {
|
|
|
685
|
- // for _, cooperationProjectFound := range cooperationProjectsFound {
|
|
|
686
|
- // cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound
|
|
|
687
|
- // }
|
|
|
688
|
- // }
|
|
|
689
|
- //}
|
|
|
690
|
- //
|
|
|
691
|
- //log.Logger.Info("查询共创项目", map[string]interface{}{
|
|
|
692
|
- // "cooperationProjectsMap": cooperationProjectsMap,
|
|
|
693
|
- //})
|
|
|
694
|
-
|
|
|
695
|
// 统计成功预算的分红订单
|
665
|
// 统计成功预算的分红订单
|
696
|
estimateSuccessfullyDividendsOrders := make(map[string]string)
|
666
|
estimateSuccessfullyDividendsOrders := make(map[string]string)
|
697
|
|
667
|
|
|
@@ -716,27 +686,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -716,27 +686,30 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
716
|
|
686
|
|
717
|
newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers)
|
687
|
newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers)
|
718
|
|
688
|
|
719
|
- // 查询共创合约
|
|
|
720
|
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
|
689
|
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
|
721
|
- if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
|
|
|
722
|
- "cooperationContractNumbers": newCooperationContractNumbers,
|
|
|
723
|
- "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
|
|
724
|
- "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
|
|
|
725
|
- "offsetLimit": false,
|
|
|
726
|
- }); err != nil {
|
|
|
727
|
- return nil, err
|
|
|
728
|
- } else {
|
|
|
729
|
- if count > 0 {
|
|
|
730
|
- for _, cooperationContractFound := range cooperationContractsFound {
|
|
|
731
|
- cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
|
690
|
+
|
|
|
691
|
+ // 查询共创合约
|
|
|
692
|
+ if len(newCooperationContractNumbers) > 0 {
|
|
|
693
|
+ if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
|
|
|
694
|
+ "cooperationContractNumbers": newCooperationContractNumbers,
|
|
|
695
|
+ "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
|
|
696
|
+ "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,
|
|
|
697
|
+ "offsetLimit": false,
|
|
|
698
|
+ }); err != nil {
|
|
|
699
|
+ return nil, err
|
|
|
700
|
+ } else {
|
|
|
701
|
+ if count > 0 {
|
|
|
702
|
+ for _, cooperationContractFound := range cooperationContractsFound {
|
|
|
703
|
+ cooperationContractsMap[cooperationContractFound.CooperationContractNumber] = cooperationContractFound
|
|
|
704
|
+ }
|
732
|
}
|
705
|
}
|
733
|
}
|
706
|
}
|
|
|
707
|
+ } else {
|
|
|
708
|
+ return map[string]interface{}{
|
|
|
709
|
+ "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
|
|
|
710
|
+ }, nil
|
734
|
}
|
711
|
}
|
735
|
|
712
|
|
736
|
- log.Logger.Info("查询共创合约", map[string]interface{}{
|
|
|
737
|
- "cooperationContractsMap": cooperationContractsMap,
|
|
|
738
|
- })
|
|
|
739
|
-
|
|
|
740
|
// 统计当前企业分红预算单数
|
713
|
// 统计当前企业分红预算单数
|
741
|
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
|
714
|
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
|
742
|
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
715
|
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
|
@@ -747,129 +720,241 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -747,129 +720,241 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
747
|
|
720
|
|
748
|
var countDividendsEstimate int64
|
721
|
var countDividendsEstimate int64
|
749
|
|
722
|
|
|
|
723
|
+ orderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
|
|
724
|
+ returnedOrderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
|
|
725
|
+
|
750
|
for _, orderGood := range orderGoods {
|
726
|
for _, orderGood := range orderGoods {
|
751
|
- log.Logger.Info("hello 1")
|
|
|
752
|
- dividendsEstimate := &domain.DividendsEstimate{}
|
|
|
753
|
- if orderGood.DividendsOrderNumber != "" { // 查询分红订单
|
|
|
754
|
- orderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
727
|
+ if orderGood.DividendsOrderNumber != "" {
|
755
|
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
|
728
|
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
|
756
|
- // 分红订单产品预算
|
|
|
757
|
- if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
|
758
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
759
|
- } else {
|
|
|
760
|
- for _, dividendsEstimateDetail := range dividendsEstimateDetails {
|
|
|
761
|
- log.Logger.Info("hello 2")
|
|
|
762
|
- if dividendsEstimateDetail.IsSuccessfully {
|
|
|
763
|
- // 生成分红预算单号
|
|
|
764
|
- dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
|
|
765
|
- if err != nil {
|
|
|
766
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
767
|
- }
|
729
|
+ } else if orderGood.DividendsReturnedOrderNumber != "" {
|
|
|
730
|
+ returnedOrderGoodsToConfirm = append(returnedOrderGoodsToConfirm, orderGood)
|
|
|
731
|
+ }
|
|
|
732
|
+ }
|
768
|
|
733
|
|
769
|
- // 记录成功的订单号
|
|
|
770
|
- estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
|
|
|
771
|
-
|
|
|
772
|
- // 统计分红预算单数目
|
|
|
773
|
- countDividendsEstimate = countDividendsEstimate + 1
|
|
|
774
|
-
|
|
|
775
|
- dividendsEstimate = &domain.DividendsEstimate{
|
|
|
776
|
- DividendsEstimateId: 0,
|
|
|
777
|
- DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
|
778
|
- DividendsAmount: dividendsEstimateDetail.DividendsAmount,
|
|
|
779
|
- DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
|
|
|
780
|
- DividendsEstimateTime: time.Now(),
|
|
|
781
|
- DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
|
|
|
782
|
- DividendsType: domain.ORDER_DIVIDENDS,
|
|
|
783
|
- DividendsTypeName: "订单分红",
|
|
|
784
|
- OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,
|
|
|
785
|
- CooperationContractNumber: orderGood.CooperationContractNumber,
|
|
|
786
|
- DividendsUser: dividendsEstimateDetail.DividendsUser,
|
|
|
787
|
- DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
|
|
|
788
|
- DividendsStage: dividendsEstimateDetail.DividendsStage,
|
|
|
789
|
- Org: organization,
|
|
|
790
|
- Company: company,
|
|
|
791
|
- Operator: operator,
|
|
|
792
|
- OperateTime: time.Time{},
|
|
|
793
|
- IsCanceled: false,
|
|
|
794
|
- CreatedAt: time.Now(),
|
|
|
795
|
- DeletedAt: time.Time{},
|
|
|
796
|
- UpdatedAt: time.Time{},
|
|
|
797
|
- OrderGoodId: orderGood.OrderGoodId,
|
|
|
798
|
- OrderGoodAmount: orderGood.OrderGoodAmount,
|
|
|
799
|
- PaymentStatus: int32(1),
|
|
|
800
|
- CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
|
|
|
801
|
- }
|
734
|
+ if len(orderGoodsToConfirm) > 0 { // 分红订单产品预算
|
|
|
735
|
+ if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
|
736
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
737
|
+ } else {
|
|
|
738
|
+ for _, dividendsEstimateDetail := range dividendsEstimateDetails {
|
|
|
739
|
+ if dividendsEstimateDetail.IsSuccessfully {
|
|
|
740
|
+ // 生成分红预算单号
|
|
|
741
|
+ dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
|
|
742
|
+ if err != nil {
|
|
|
743
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
744
|
+ }
|
802
|
|
745
|
|
803
|
- dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
|
|
|
804
|
- } else {
|
|
|
805
|
- // 记录失败的订单号和原因
|
|
|
806
|
- estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
|
746
|
+ // 记录成功的订单号
|
|
|
747
|
+ estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
|
|
|
748
|
+
|
|
|
749
|
+ // 统计分红预算单数目
|
|
|
750
|
+ countDividendsEstimate = countDividendsEstimate + 1
|
|
|
751
|
+
|
|
|
752
|
+ dividendsEstimate := &domain.DividendsEstimate{
|
|
|
753
|
+ DividendsEstimateId: 0,
|
|
|
754
|
+ DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
|
755
|
+ DividendsAmount: dividendsEstimateDetail.DividendsAmount,
|
|
|
756
|
+ DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
|
|
|
757
|
+ DividendsEstimateTime: time.Now(),
|
|
|
758
|
+ DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
|
|
|
759
|
+ DividendsType: domain.ORDER_DIVIDENDS,
|
|
|
760
|
+ DividendsTypeName: "订单分红",
|
|
|
761
|
+ OrderOrReturnedOrderNum: dividendsEstimateDetail.OrderOrReturnedOrderNumber,
|
|
|
762
|
+ CooperationContractNumber: dividendsEstimateDetail.CooperationContractNumber,
|
|
|
763
|
+ DividendsUser: dividendsEstimateDetail.DividendsUser,
|
|
|
764
|
+ DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
|
|
|
765
|
+ DividendsStage: dividendsEstimateDetail.DividendsStage,
|
|
|
766
|
+ Org: organization,
|
|
|
767
|
+ Company: company,
|
|
|
768
|
+ Operator: operator,
|
|
|
769
|
+ OperateTime: time.Time{},
|
|
|
770
|
+ IsCanceled: false,
|
|
|
771
|
+ CreatedAt: time.Now(),
|
|
|
772
|
+ DeletedAt: time.Time{},
|
|
|
773
|
+ UpdatedAt: time.Time{},
|
|
|
774
|
+ OrderGoodId: dividendsEstimateDetail.OrderGoodId,
|
|
|
775
|
+ OrderGoodAmount: dividendsEstimateDetail.OrderGoodAmount,
|
|
|
776
|
+ PaymentStatus: int32(1),
|
|
|
777
|
+ CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
|
807
|
}
|
778
|
}
|
|
|
779
|
+
|
|
|
780
|
+ dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
|
|
|
781
|
+ } else {
|
|
|
782
|
+ // 记录失败的订单号和原因
|
|
|
783
|
+ estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
|
808
|
}
|
784
|
}
|
809
|
}
|
785
|
}
|
810
|
- } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
|
|
|
811
|
- log.Logger.Info("hello 3")
|
|
|
812
|
- orderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
|
|
813
|
- orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
|
|
|
814
|
- // 分红退货单产品预算
|
|
|
815
|
- if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
|
816
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
817
|
- } else {
|
|
|
818
|
- for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
|
|
|
819
|
- if dividendsReturnedEstimateDetail.IsSuccessfully {
|
|
|
820
|
- // 生成分红预算单号
|
|
|
821
|
- dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
|
|
822
|
- if err != nil {
|
|
|
823
|
- return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
824
|
- }
|
|
|
825
|
-
|
|
|
826
|
- // 记录成功的退货单号
|
|
|
827
|
- estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
|
|
|
828
|
-
|
|
|
829
|
- // 统计生成的预算单数量
|
|
|
830
|
- countDividendsEstimate = countDividendsEstimate + 1
|
|
|
831
|
-
|
|
|
832
|
- dividendsEstimate = &domain.DividendsEstimate{
|
|
|
833
|
- DividendsEstimateId: 0,
|
|
|
834
|
- DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
|
835
|
- DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
|
|
|
836
|
- DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
|
|
|
837
|
- DividendsEstimateTime: time.Now(),
|
|
|
838
|
- DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
|
|
|
839
|
- DividendsType: domain.RETURN_WRITE_OFF,
|
|
|
840
|
- DividendsTypeName: "退货冲销",
|
|
|
841
|
- OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,
|
|
|
842
|
- CooperationContractNumber: orderGood.CooperationContractNumber,
|
|
|
843
|
- DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
|
|
|
844
|
- DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
|
|
|
845
|
- DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
|
|
|
846
|
- Org: organization,
|
|
|
847
|
- Company: company,
|
|
|
848
|
- Operator: operator,
|
|
|
849
|
- OperateTime: time.Time{},
|
|
|
850
|
- IsCanceled: false,
|
|
|
851
|
- CreatedAt: time.Now(),
|
|
|
852
|
- DeletedAt: time.Time{},
|
|
|
853
|
- UpdatedAt: time.Time{},
|
|
|
854
|
- OrderGoodId: orderGood.OrderGoodId,
|
|
|
855
|
- OrderGoodAmount: orderGood.OrderGoodAmount,
|
|
|
856
|
- PaymentStatus: int32(1),
|
|
|
857
|
- CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
|
|
|
858
|
- }
|
786
|
+ }
|
|
|
787
|
+ } else if len(returnedOrderGoodsToConfirm) > 0 { // 退货单产品预算
|
|
|
788
|
+ if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(returnedOrderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
|
789
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
790
|
+ } else {
|
|
|
791
|
+ for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
|
|
|
792
|
+ if dividendsReturnedEstimateDetail.IsSuccessfully {
|
|
|
793
|
+ // 生成分红预算单号
|
|
|
794
|
+ dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
|
|
795
|
+ if err != nil {
|
|
|
796
|
+ return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
797
|
+ }
|
859
|
|
798
|
|
860
|
- dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
|
|
|
861
|
- } else {
|
|
|
862
|
- // 记录失败的退货单号和原因
|
|
|
863
|
- estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
|
799
|
+ // 记录成功的退货单号
|
|
|
800
|
+ estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
|
|
|
801
|
+
|
|
|
802
|
+ // 统计生成的预算单数量
|
|
|
803
|
+ countDividendsEstimate = countDividendsEstimate + 1
|
|
|
804
|
+
|
|
|
805
|
+ dividendsEstimate := &domain.DividendsEstimate{
|
|
|
806
|
+ DividendsEstimateId: 0,
|
|
|
807
|
+ DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
|
808
|
+ DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
|
|
|
809
|
+ DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
|
|
|
810
|
+ DividendsEstimateTime: time.Now(),
|
|
|
811
|
+ DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
|
|
|
812
|
+ DividendsType: domain.RETURN_WRITE_OFF,
|
|
|
813
|
+ DividendsTypeName: "退货冲销",
|
|
|
814
|
+ OrderOrReturnedOrderNum: dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber,
|
|
|
815
|
+ CooperationContractNumber: dividendsReturnedEstimateDetail.CooperationContractNumber,
|
|
|
816
|
+ DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
|
|
|
817
|
+ DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
|
|
|
818
|
+ DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
|
|
|
819
|
+ Org: organization,
|
|
|
820
|
+ Company: company,
|
|
|
821
|
+ Operator: operator,
|
|
|
822
|
+ OperateTime: time.Time{},
|
|
|
823
|
+ IsCanceled: false,
|
|
|
824
|
+ CreatedAt: time.Now(),
|
|
|
825
|
+ DeletedAt: time.Time{},
|
|
|
826
|
+ UpdatedAt: time.Time{},
|
|
|
827
|
+ OrderGoodId: dividendsReturnedEstimateDetail.OrderGoodId,
|
|
|
828
|
+ OrderGoodAmount: dividendsReturnedEstimateDetail.OrderGoodAmount,
|
|
|
829
|
+ PaymentStatus: int32(1),
|
|
|
830
|
+ CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
|
864
|
}
|
831
|
}
|
|
|
832
|
+
|
|
|
833
|
+ dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
|
|
|
834
|
+ } else {
|
|
|
835
|
+ // 记录失败的退货单号和原因
|
|
|
836
|
+ estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
|
865
|
}
|
837
|
}
|
866
|
}
|
838
|
}
|
867
|
}
|
839
|
}
|
868
|
}
|
840
|
}
|
869
|
|
841
|
|
870
|
- log.Logger.Info("新增的分红预算单", map[string]interface{}{
|
|
|
871
|
- "dividendsEstimates": dividendsEstimates,
|
|
|
872
|
- })
|
842
|
+ //for _, orderGood := range orderGoods {
|
|
|
843
|
+ // dividendsEstimate := &domain.DividendsEstimate{}
|
|
|
844
|
+ // if orderGood.DividendsOrderNumber != "" { // 查询分红订单
|
|
|
845
|
+ // orderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
|
|
846
|
+ // orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
|
|
|
847
|
+ // // 分红订单产品预算
|
|
|
848
|
+ // if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
|
849
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
850
|
+ // } else {
|
|
|
851
|
+ // for _, dividendsEstimateDetail := range dividendsEstimateDetails {
|
|
|
852
|
+ // if dividendsEstimateDetail.IsSuccessfully {
|
|
|
853
|
+ // // 生成分红预算单号
|
|
|
854
|
+ // dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
|
|
855
|
+ // if err != nil {
|
|
|
856
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
857
|
+ // }
|
|
|
858
|
+ //
|
|
|
859
|
+ // // 记录成功的订单号
|
|
|
860
|
+ // estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
|
|
|
861
|
+ //
|
|
|
862
|
+ // // 统计分红预算单数目
|
|
|
863
|
+ // countDividendsEstimate = countDividendsEstimate + 1
|
|
|
864
|
+ //
|
|
|
865
|
+ // dividendsEstimate = &domain.DividendsEstimate{
|
|
|
866
|
+ // DividendsEstimateId: 0,
|
|
|
867
|
+ // DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
|
868
|
+ // DividendsAmount: dividendsEstimateDetail.DividendsAmount,
|
|
|
869
|
+ // DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
|
|
|
870
|
+ // DividendsEstimateTime: time.Now(),
|
|
|
871
|
+ // DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
|
|
|
872
|
+ // DividendsType: domain.ORDER_DIVIDENDS,
|
|
|
873
|
+ // DividendsTypeName: "订单分红",
|
|
|
874
|
+ // OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,
|
|
|
875
|
+ // CooperationContractNumber: orderGood.CooperationContractNumber,
|
|
|
876
|
+ // DividendsUser: dividendsEstimateDetail.DividendsUser,
|
|
|
877
|
+ // DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
|
|
|
878
|
+ // DividendsStage: dividendsEstimateDetail.DividendsStage,
|
|
|
879
|
+ // Org: organization,
|
|
|
880
|
+ // Company: company,
|
|
|
881
|
+ // Operator: operator,
|
|
|
882
|
+ // OperateTime: time.Time{},
|
|
|
883
|
+ // IsCanceled: false,
|
|
|
884
|
+ // CreatedAt: time.Now(),
|
|
|
885
|
+ // DeletedAt: time.Time{},
|
|
|
886
|
+ // UpdatedAt: time.Time{},
|
|
|
887
|
+ // OrderGoodId: orderGood.OrderGoodId,
|
|
|
888
|
+ // OrderGoodAmount: orderGood.OrderGoodAmount,
|
|
|
889
|
+ // PaymentStatus: int32(1),
|
|
|
890
|
+ // CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
|
|
|
891
|
+ // }
|
|
|
892
|
+ //
|
|
|
893
|
+ // dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
|
|
|
894
|
+ // } else {
|
|
|
895
|
+ // // 记录失败的订单号和原因
|
|
|
896
|
+ // estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
|
|
|
897
|
+ // }
|
|
|
898
|
+ // }
|
|
|
899
|
+ // }
|
|
|
900
|
+ // } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
|
|
|
901
|
+ // orderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
|
|
902
|
+ // orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
|
|
|
903
|
+ // // 分红退货单产品预算
|
|
|
904
|
+ // if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
|
905
|
+ // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
906
|
+ // } else {
|
|
|
907
|
+ // for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
|
|
|
908
|
+ // if dividendsReturnedEstimateDetail.IsSuccessfully {
|
|
|
909
|
+ // // 生成分红预算单号
|
|
|
910
|
+ // dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
|
|
911
|
+ // if err != nil {
|
|
|
912
|
+ // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
913
|
+ // }
|
|
|
914
|
+ //
|
|
|
915
|
+ // // 记录成功的退货单号
|
|
|
916
|
+ // estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
|
|
|
917
|
+ //
|
|
|
918
|
+ // // 统计生成的预算单数量
|
|
|
919
|
+ // countDividendsEstimate = countDividendsEstimate + 1
|
|
|
920
|
+ //
|
|
|
921
|
+ // dividendsEstimate = &domain.DividendsEstimate{
|
|
|
922
|
+ // DividendsEstimateId: 0,
|
|
|
923
|
+ // DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
|
924
|
+ // DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
|
|
|
925
|
+ // DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
|
|
|
926
|
+ // DividendsEstimateTime: time.Now(),
|
|
|
927
|
+ // DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
|
|
|
928
|
+ // DividendsType: domain.RETURN_WRITE_OFF,
|
|
|
929
|
+ // DividendsTypeName: "退货冲销",
|
|
|
930
|
+ // OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,
|
|
|
931
|
+ // CooperationContractNumber: orderGood.CooperationContractNumber,
|
|
|
932
|
+ // DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
|
|
|
933
|
+ // DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
|
|
|
934
|
+ // DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
|
|
|
935
|
+ // Org: organization,
|
|
|
936
|
+ // Company: company,
|
|
|
937
|
+ // Operator: operator,
|
|
|
938
|
+ // OperateTime: time.Time{},
|
|
|
939
|
+ // IsCanceled: false,
|
|
|
940
|
+ // CreatedAt: time.Now(),
|
|
|
941
|
+ // DeletedAt: time.Time{},
|
|
|
942
|
+ // UpdatedAt: time.Time{},
|
|
|
943
|
+ // OrderGoodId: orderGood.OrderGoodId,
|
|
|
944
|
+ // OrderGoodAmount: orderGood.OrderGoodAmount,
|
|
|
945
|
+ // PaymentStatus: int32(1),
|
|
|
946
|
+ // CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
|
|
|
947
|
+ // }
|
|
|
948
|
+ //
|
|
|
949
|
+ // dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
|
|
|
950
|
+ // } else {
|
|
|
951
|
+ // // 记录失败的退货单号和原因
|
|
|
952
|
+ // estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
|
|
|
953
|
+ // }
|
|
|
954
|
+ // }
|
|
|
955
|
+ // }
|
|
|
956
|
+ // }
|
|
|
957
|
+ //}
|
873
|
|
958
|
|
874
|
if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
|
959
|
if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
|
875
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
960
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
@@ -918,14 +1003,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -918,14 +1003,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
918
|
}
|
1003
|
}
|
919
|
}
|
1004
|
}
|
920
|
|
1005
|
|
921
|
- log.Logger.Info("分红订单", map[string]interface{}{
|
|
|
922
|
- "dividendsOrderNumbers": dividendsOrderNumbers,
|
|
|
923
|
- })
|
|
|
924
|
-
|
|
|
925
|
- log.Logger.Info("分红退货单", map[string]interface{}{
|
|
|
926
|
- "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,
|
|
|
927
|
- })
|
|
|
928
|
-
|
|
|
929
|
// 查找分红订单
|
1006
|
// 查找分红订单
|
930
|
if len(dividendsOrderNumbers) > 0 {
|
1007
|
if len(dividendsOrderNumbers) > 0 {
|
931
|
if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
|
1008
|
if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
|