作者 陈志颖

fix:金额激励分红预算

... ... @@ -800,6 +800,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
// 分离分红订单和退货单
dividendsOrderNumbers := make([]string, 0)
dividendsReturnedOrderNumbers := make([]string, 0)
if len(estimateSuccessfullyDividendsOrders) > 0 {
for k, _ := range estimateSuccessfullyDividendsOrders {
if k[:2] == "RE" { // 分红退货单
dividendsReturnedOrderNumbers = append(dividendsReturnedOrderNumbers, k)
... ... @@ -807,6 +808,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
dividendsOrderNumbers = append(dividendsOrderNumbers, k)
}
}
}
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
... ... @@ -819,6 +821,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
// 查找分红订单
if len(dividendsOrderNumbers) > 0 {
if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
"dividendsOrderNumbers": dividendsOrderNumbers,
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
... ... @@ -848,6 +851,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
}
}
// 分红退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
... ... @@ -860,6 +864,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
// 查找分红退货单
if len(dividendsReturnedOrderNumbers) > 0 {
if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
... ... @@ -889,6 +894,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
}
}
// 完成第二阶段事务提交
if err := newTransactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -63,7 +63,8 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
if undertakerEstimated {
return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红")
} else {
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage))).Div(decimal.NewFromFloat(100))).Float64()
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).
Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
... ...