作者 陈志颖

fix:规则匹配

... ... @@ -169,7 +169,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
(orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
ruleMatchedFlag = true
break
}
... ... @@ -754,7 +755,8 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
(orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
ruleMatchedFlag = true
break
}
... ... @@ -1205,7 +1207,8 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
(orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
ruleMatchedFlag = true
break
}
... ...
... ... @@ -176,7 +176,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
if !(orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
(orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
ruleMatchedFlag = true
break
}
... ... @@ -795,6 +796,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
}
}
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: 0,
OrderGoodAmount: orderGoodAmount,
... ... @@ -1177,7 +1179,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
if !((orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) &&
(orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd))) {
ruleMatchedFlag = true
break
}
... ...
... ... @@ -172,7 +172,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
// 匹配分红规则
var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
if dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) && dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) {
if (dividendsOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
(dividendsOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
dividendsIncentivesRuleMatched = dividendsIncentivesRule
break
}
... ... @@ -302,7 +303,8 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
// 匹配分红规则
var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
if dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) && dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) {
if (dividendsReturnedOrder.OrderTime.After(dividendsIncentivesRule.DividendsIncentivesStageStart) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageStart)) &&
(dividendsReturnedOrder.OrderTime.Before(dividendsIncentivesRule.DividendsIncentivesStageEnd) || dividendsReturnedOrder.OrderTime.Equal(dividendsIncentivesRule.DividendsIncentivesStageEnd)) {
dividendsIncentivesRuleMatched = dividendsIncentivesRule
break
}
... ...
... ... @@ -43,7 +43,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
// 判断金额激励阶段是否合法
currentTime := time.Now()
if moneyIncentivesRuleMatched.MoneyIncentivesStageStart.After(currentTime) {
if currentTime.Before(moneyIncentivesRuleMatched.MoneyIncentivesStageStart) {
return nil, fmt.Errorf("还未到分红时间")
}
... ...