作者 陈志颖

test:测试预算分红

... ... @@ -699,6 +699,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
// 统计预算失败的分红订单
estimateFailedDividendsOrders := make(map[string]string)
initRepo := time.Since(start)
log.Logger.Info("初始化耗时", map[string]interface{}{
"初始化耗时": initRepo,
})
startFindOrderGood := time.Now() // 获取当前时间
// 获取订单产品
if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
"orderGoodIds": orderGoodIds,
... ... @@ -706,6 +713,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
findOrderGood := time.Since(startFindOrderGood)
log.Logger.Info("查询预算产品耗时", map[string]interface{}{
"初始化耗时": findOrderGood,
})
dividendsEstimates := make([]*domain.DividendsEstimate, 0)
var cooperationContractNumbers []string
... ... @@ -715,6 +728,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber)
}
startFindContracts := time.Now()
// 查询共创合约
cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
... ... @@ -732,6 +747,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
endFindContracts := time.Since(startFindContracts)
log.Logger.Info("查询合约耗时", map[string]interface{}{
"查询合约耗时": endFindContracts,
})
log.Logger.Info("查询共创合约", map[string]interface{}{
"cooperationContractsMap": cooperationContractsMap,
})
... ... @@ -746,6 +766,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
var countDividendsEstimate int64
startConfirm := time.Now()
for _, orderGood := range orderGoods {
dividendsEstimate := &domain.DividendsEstimate{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
... ... @@ -863,10 +885,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
}
}
endConfirm := time.Since(startConfirm)
log.Logger.Info("预算耗时", map[string]interface{}{
"预算耗时": endConfirm,
})
log.Logger.Info("新增的分红预算单", map[string]interface{}{
"dividendsEstimates": dividendsEstimates,
})
startSave := time.Now()
if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -1031,6 +1060,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
elapsed := time.Since(start)
fmt.Println("该函数执行完成耗时:", elapsed)
endSave := time.Since(startSave)
log.Logger.Info("保存预算单耗时", map[string]interface{}{
"保存预算单耗时": endSave,
})
return map[string]interface{}{
"report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
}, nil
... ...