作者 陈志颖

fix:金额激励分红预算

@@ -800,6 +800,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -800,6 +800,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
800 // 分离分红订单和退货单 800 // 分离分红订单和退货单
801 dividendsOrderNumbers := make([]string, 0) 801 dividendsOrderNumbers := make([]string, 0)
802 dividendsReturnedOrderNumbers := make([]string, 0) 802 dividendsReturnedOrderNumbers := make([]string, 0)
  803 + if len(estimateSuccessfullyDividendsOrders) > 0 {
803 for k, _ := range estimateSuccessfullyDividendsOrders { 804 for k, _ := range estimateSuccessfullyDividendsOrders {
804 if k[:2] == "RE" { // 分红退货单 805 if k[:2] == "RE" { // 分红退货单
805 dividendsReturnedOrderNumbers = append(dividendsReturnedOrderNumbers, k) 806 dividendsReturnedOrderNumbers = append(dividendsReturnedOrderNumbers, k)
@@ -807,6 +808,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -807,6 +808,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
807 dividendsOrderNumbers = append(dividendsOrderNumbers, k) 808 dividendsOrderNumbers = append(dividendsOrderNumbers, k)
808 } 809 }
809 } 810 }
  811 + }
810 812
811 // 分红订单仓储初始化 813 // 分红订单仓储初始化
812 var dividendsOrderRepository domain.DividendsOrderRepository 814 var dividendsOrderRepository domain.DividendsOrderRepository
@@ -819,6 +821,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -819,6 +821,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
819 } 821 }
820 822
821 // 查找分红订单 823 // 查找分红订单
  824 + if len(dividendsOrderNumbers) > 0 {
822 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{ 825 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
823 "dividendsOrderNumbers": dividendsOrderNumbers, 826 "dividendsOrderNumbers": dividendsOrderNumbers,
824 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, 827 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
@@ -848,6 +851,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -848,6 +851,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
848 } 851 }
849 } 852 }
850 } 853 }
  854 + }
851 855
852 // 分红退货单仓储初始化 856 // 分红退货单仓储初始化
853 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository 857 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
@@ -860,6 +864,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -860,6 +864,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
860 } 864 }
861 865
862 // 查找分红退货单 866 // 查找分红退货单
  867 + if len(dividendsReturnedOrderNumbers) > 0 {
863 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ 868 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
864 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers, 869 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,
865 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, 870 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
@@ -889,6 +894,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -889,6 +894,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
889 } 894 }
890 } 895 }
891 } 896 }
  897 + }
892 898
893 // 完成第二阶段事务提交 899 // 完成第二阶段事务提交
894 if err := newTransactionContext.CommitTransaction(); err != nil { 900 if err := newTransactionContext.CommitTransaction(); err != nil {
@@ -63,7 +63,8 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -63,7 +63,8 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
63 if undertakerEstimated { 63 if undertakerEstimated {
64 return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红") 64 return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红")
65 } else { 65 } else {
66 - undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage))).Div(decimal.NewFromFloat(100))).Float64() 66 + undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).
  67 + Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64()
67 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 68 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
68 DividendsUser: &domain.User{ 69 DividendsUser: &domain.User{
69 UserId: undertaker.UserId, 70 UserId: undertaker.UserId,