|
@@ -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,8 +686,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -716,8 +686,10 @@ 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)
|
|
|
|
690
|
+
|
|
|
|
691
|
+ // 查询共创合约
|
|
|
|
692
|
+ if len(newCooperationContractNumbers) > 0 {
|
|
721
|
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
|
693
|
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
|
|
722
|
"cooperationContractNumbers": newCooperationContractNumbers,
|
694
|
"cooperationContractNumbers": newCooperationContractNumbers,
|
|
723
|
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
695
|
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
|
@@ -732,10 +704,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -732,10 +704,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
732
|
}
|
704
|
}
|
|
733
|
}
|
705
|
}
|
|
734
|
}
|
706
|
}
|
|
735
|
-
|
|
|
|
736
|
- log.Logger.Info("查询共创合约", map[string]interface{}{
|
|
|
|
737
|
- "cooperationContractsMap": cooperationContractsMap,
|
|
|
|
738
|
- })
|
707
|
+ } else {
|
|
|
|
708
|
+ return map[string]interface{}{
|
|
|
|
709
|
+ "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
|
|
|
|
710
|
+ }, nil
|
|
|
|
711
|
+ }
|
|
739
|
|
712
|
|
|
740
|
// 统计当前企业分红预算单数
|
713
|
// 统计当前企业分红预算单数
|
|
741
|
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
|
714
|
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
|
|
@@ -747,18 +720,22 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -747,18 +720,22 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
747
|
|
720
|
|
|
748
|
var countDividendsEstimate int64
|
721
|
var countDividendsEstimate int64
|
|
749
|
|
722
|
|
|
750
|
- for _, orderGood := range orderGoods {
|
|
|
|
751
|
- log.Logger.Info("hello 1")
|
|
|
|
752
|
- dividendsEstimate := &domain.DividendsEstimate{}
|
|
|
|
753
|
- if orderGood.DividendsOrderNumber != "" { // 查询分红订单
|
|
|
|
754
|
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
723
|
orderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
|
|
|
724
|
+ returnedOrderGoodsToConfirm := make([]*domain.OrderGood, 0)
|
|
|
|
725
|
+
|
|
|
|
726
|
+ for _, orderGood := range orderGoods {
|
|
|
|
727
|
+ if orderGood.DividendsOrderNumber != "" {
|
|
755
|
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
|
728
|
orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
|
|
756
|
- // 分红订单产品预算
|
729
|
+ } else if orderGood.DividendsReturnedOrderNumber != "" {
|
|
|
|
730
|
+ returnedOrderGoodsToConfirm = append(returnedOrderGoodsToConfirm, orderGood)
|
|
|
|
731
|
+ }
|
|
|
|
732
|
+ }
|
|
|
|
733
|
+
|
|
|
|
734
|
+ if len(orderGoodsToConfirm) > 0 { // 分红订单产品预算
|
|
757
|
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
735
|
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
758
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
736
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
759
|
} else {
|
737
|
} else {
|
|
760
|
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
|
738
|
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
|
|
761
|
- log.Logger.Info("hello 2")
|
|
|
|
762
|
if dividendsEstimateDetail.IsSuccessfully {
|
739
|
if dividendsEstimateDetail.IsSuccessfully {
|
|
763
|
// 生成分红预算单号
|
740
|
// 生成分红预算单号
|
|
764
|
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
741
|
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
|
|
@@ -772,7 +749,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -772,7 +749,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
772
|
// 统计分红预算单数目
|
749
|
// 统计分红预算单数目
|
|
773
|
countDividendsEstimate = countDividendsEstimate + 1
|
750
|
countDividendsEstimate = countDividendsEstimate + 1
|
|
774
|
|
751
|
|
|
775
|
- dividendsEstimate = &domain.DividendsEstimate{
|
752
|
+ dividendsEstimate := &domain.DividendsEstimate{
|
|
776
|
DividendsEstimateId: 0,
|
753
|
DividendsEstimateId: 0,
|
|
777
|
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
754
|
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
778
|
DividendsAmount: dividendsEstimateDetail.DividendsAmount,
|
755
|
DividendsAmount: dividendsEstimateDetail.DividendsAmount,
|
|
@@ -781,8 +758,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -781,8 +758,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
781
|
DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
|
758
|
DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
|
|
782
|
DividendsType: domain.ORDER_DIVIDENDS,
|
759
|
DividendsType: domain.ORDER_DIVIDENDS,
|
|
783
|
DividendsTypeName: "订单分红",
|
760
|
DividendsTypeName: "订单分红",
|
|
784
|
- OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,
|
|
|
|
785
|
- CooperationContractNumber: orderGood.CooperationContractNumber,
|
761
|
+ OrderOrReturnedOrderNum: dividendsEstimateDetail.OrderOrReturnedOrderNumber,
|
|
|
|
762
|
+ CooperationContractNumber: dividendsEstimateDetail.CooperationContractNumber,
|
|
786
|
DividendsUser: dividendsEstimateDetail.DividendsUser,
|
763
|
DividendsUser: dividendsEstimateDetail.DividendsUser,
|
|
787
|
DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
|
764
|
DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
|
|
788
|
DividendsStage: dividendsEstimateDetail.DividendsStage,
|
765
|
DividendsStage: dividendsEstimateDetail.DividendsStage,
|
|
@@ -794,8 +771,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -794,8 +771,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
794
|
CreatedAt: time.Now(),
|
771
|
CreatedAt: time.Now(),
|
|
795
|
DeletedAt: time.Time{},
|
772
|
DeletedAt: time.Time{},
|
|
796
|
UpdatedAt: time.Time{},
|
773
|
UpdatedAt: time.Time{},
|
|
797
|
- OrderGoodId: orderGood.OrderGoodId,
|
|
|
|
798
|
- OrderGoodAmount: orderGood.OrderGoodAmount,
|
774
|
+ OrderGoodId: dividendsEstimateDetail.OrderGoodId,
|
|
|
|
775
|
+ OrderGoodAmount: dividendsEstimateDetail.OrderGoodAmount,
|
|
799
|
PaymentStatus: int32(1),
|
776
|
PaymentStatus: int32(1),
|
|
800
|
CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
|
777
|
CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
|
|
801
|
}
|
778
|
}
|
|
@@ -807,12 +784,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -807,12 +784,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
807
|
}
|
784
|
}
|
|
808
|
}
|
785
|
}
|
|
809
|
}
|
786
|
}
|
|
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 {
|
787
|
+ } else if len(returnedOrderGoodsToConfirm) > 0 { // 退货单产品预算
|
|
|
|
788
|
+ if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(returnedOrderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
|
|
816
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
789
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
817
|
} else {
|
790
|
} else {
|
|
818
|
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
|
791
|
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
|
|
@@ -829,7 +802,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -829,7 +802,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
829
|
// 统计生成的预算单数量
|
802
|
// 统计生成的预算单数量
|
|
830
|
countDividendsEstimate = countDividendsEstimate + 1
|
803
|
countDividendsEstimate = countDividendsEstimate + 1
|
|
831
|
|
804
|
|
|
832
|
- dividendsEstimate = &domain.DividendsEstimate{
|
805
|
+ dividendsEstimate := &domain.DividendsEstimate{
|
|
833
|
DividendsEstimateId: 0,
|
806
|
DividendsEstimateId: 0,
|
|
834
|
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
807
|
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
|
|
835
|
DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
|
808
|
DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
|
|
@@ -838,8 +811,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -838,8 +811,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
838
|
DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
|
811
|
DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
|
|
839
|
DividendsType: domain.RETURN_WRITE_OFF,
|
812
|
DividendsType: domain.RETURN_WRITE_OFF,
|
|
840
|
DividendsTypeName: "退货冲销",
|
813
|
DividendsTypeName: "退货冲销",
|
|
841
|
- OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,
|
|
|
|
842
|
- CooperationContractNumber: orderGood.CooperationContractNumber,
|
814
|
+ OrderOrReturnedOrderNum: dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber,
|
|
|
|
815
|
+ CooperationContractNumber: dividendsReturnedEstimateDetail.CooperationContractNumber,
|
|
843
|
DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
|
816
|
DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
|
|
844
|
DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
|
817
|
DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
|
|
845
|
DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
|
818
|
DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
|
|
@@ -851,8 +824,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -851,8 +824,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
851
|
CreatedAt: time.Now(),
|
824
|
CreatedAt: time.Now(),
|
|
852
|
DeletedAt: time.Time{},
|
825
|
DeletedAt: time.Time{},
|
|
853
|
UpdatedAt: time.Time{},
|
826
|
UpdatedAt: time.Time{},
|
|
854
|
- OrderGoodId: orderGood.OrderGoodId,
|
|
|
|
855
|
- OrderGoodAmount: orderGood.OrderGoodAmount,
|
827
|
+ OrderGoodId: dividendsReturnedEstimateDetail.OrderGoodId,
|
|
|
|
828
|
+ OrderGoodAmount: dividendsReturnedEstimateDetail.OrderGoodAmount,
|
|
856
|
PaymentStatus: int32(1),
|
829
|
PaymentStatus: int32(1),
|
|
857
|
CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
|
830
|
CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
|
|
858
|
}
|
831
|
}
|
|
@@ -865,11 +838,123 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -865,11 +838,123 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
865
|
}
|
838
|
}
|
|
866
|
}
|
839
|
}
|
|
867
|
}
|
840
|
}
|
|
868
|
- }
|
|
|
|
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{}{
|