作者 陈志颖

fix:规则匹配

@@ -169,7 +169,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -169,7 +169,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
169 // 校验产品关联合约的激励规则是否匹配订单时间 169 // 校验产品关联合约的激励规则是否匹配订单时间
170 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { 170 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
171 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { 171 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
172 - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { 172 + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
  173 + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
173 ruleMatchedFlag = true 174 ruleMatchedFlag = true
174 break 175 break
175 } 176 }
@@ -754,7 +755,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -754,7 +755,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
754 // 校验产品关联合约的激励规则是否匹配订单时间 755 // 校验产品关联合约的激励规则是否匹配订单时间
755 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { 756 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
756 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { 757 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
757 - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { 758 + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
  759 + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
758 ruleMatchedFlag = true 760 ruleMatchedFlag = true
759 break 761 break
760 } 762 }
@@ -1205,7 +1207,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD @@ -1205,7 +1207,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
1205 // 校验产品关联合约的激励规则是否匹配订单时间 1207 // 校验产品关联合约的激励规则是否匹配订单时间
1206 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { 1208 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
1207 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { 1209 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
1208 - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { 1210 + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
  1211 + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
1209 ruleMatchedFlag = true 1212 ruleMatchedFlag = true
1210 break 1213 break
1211 } 1214 }
@@ -176,7 +176,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -176,7 +176,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
176 // 校验产品关联合约的激励规则是否匹配订单时间 176 // 校验产品关联合约的激励规则是否匹配订单时间
177 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { 177 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
178 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { 178 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
179 - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { 179 + if !(orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
  180 + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
180 ruleMatchedFlag = true 181 ruleMatchedFlag = true
181 break 182 break
182 } 183 }
@@ -795,6 +796,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -795,6 +796,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
795 orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则") 796 orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
796 } 797 }
797 } 798 }
  799 +
798 orderGoods = append(orderGoods, &domain.OrderGood{ 800 orderGoods = append(orderGoods, &domain.OrderGood{
799 OrderGoodId: 0, 801 OrderGoodId: 0,
800 OrderGoodAmount: orderGoodAmount, 802 OrderGoodAmount: orderGoodAmount,
@@ -1177,7 +1179,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide @@ -1177,7 +1179,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
1177 // 校验产品关联合约的激励规则是否匹配订单时间 1179 // 校验产品关联合约的激励规则是否匹配订单时间
1178 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil { 1180 if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
1179 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules { 1181 for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
1180 - if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) { 1182 + if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
  1183 + (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
1181 ruleMatchedFlag = true 1184 ruleMatchedFlag = true
1182 break 1185 break
1183 } 1186 }
@@ -172,7 +172,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -172,7 +172,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
172 // 匹配分红规则 172 // 匹配分红规则
173 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule 173 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
174 for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules { 174 for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
175 - if dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) && dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) { 175 + if (dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
  176 + (dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
176 dividendsIncentivesRuleMatched = dividendsIncentivesRule 177 dividendsIncentivesRuleMatched = dividendsIncentivesRule
177 break 178 break
178 } 179 }
@@ -302,7 +303,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -302,7 +303,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
302 // 匹配分红规则 303 // 匹配分红规则
303 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule 304 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
304 for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules { 305 for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
305 - if dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) && dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) { 306 + if (dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
  307 + (dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
306 dividendsIncentivesRuleMatched = dividendsIncentivesRule 308 dividendsIncentivesRuleMatched = dividendsIncentivesRule
307 break 309 break
308 } 310 }
@@ -43,7 +43,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -43,7 +43,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
43 43
44 // 判断金额激励阶段是否合法 44 // 判断金额激励阶段是否合法
45 currentTime := time.Now() 45 currentTime := time.Now()
46 - if moneyIncentivesRuleMatched.MoneyIncentivesStageStart.After(currentTime) { 46 + if currentTime.Before(moneyIncentivesRuleMatched.MoneyIncentivesStageStart) {
47 return nil, fmt.Errorf("还未到分红时间") 47 return nil, fmt.Errorf("还未到分红时间")
48 } 48 }
49 49