作者 陈志颖

refactor:优化分红预算

... ... @@ -689,6 +689,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
log.Logger.Info("查询共创合约", map[string]interface{}{
"cooperationContractsMap": cooperationContractsMap,
})
// 查询共创项目
cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
... ... @@ -705,6 +709,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
log.Logger.Info("查询共创项目", map[string]interface{}{
"cooperationProjectsMap": cooperationProjectsMap,
})
// 统计成功预算的分红订单
estimateSuccessfullyDividendsOrders := make(map[string]string)
... ...
... ... @@ -8,7 +8,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
)
type ConfirmDividendsIncentivesEstimateService struct {
... ... @@ -85,12 +84,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
// 确认业绩分红预算
var dividendsEstimateDetails []*service.DividendsEstimateDetail
go func() {
for _, orderGood := range orderGoods {
log.Logger.Info("业绩分红预算产品", map[string]interface{}{
"orderGood": orderGood,
})
if orderGood.CooperationContractNumber == "" {
var orderNumber string
if orderGood.DividendsOrderNumber != "" {
... ... @@ -462,6 +456,18 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
}
// 计算分红
if len(cooperationContract.Undertakers) <= 0 {
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
IsSuccessfully: false,
Reason: "合约承接人不存在",
})
continue
} else {
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红退货预算信息详情
if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
... ... @@ -551,7 +557,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
}
}
}()
}
return dividendsEstimateDetails, nil
}
... ...