...
|
...
|
@@ -609,6 +609,9 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
})
|
|
|
}
|
|
|
|
|
|
// 统计分红订单
|
|
|
var countDividendsOrders int32
|
|
|
|
|
|
// 获取订单产品
|
|
|
if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
|
|
|
"orderGoodIds": orderGoodIds,
|
...
|
...
|
@@ -634,9 +637,15 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
|
|
|
// 统计当前分红预算单数
|
|
|
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
for i, dividendsEstimateDetail := range dividendsEstimateDetails {
|
|
|
// 生成分红预算单号
|
|
|
dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber()
|
|
|
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), int64(i))
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -718,25 +727,16 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
"dividendsEstimates": dividendsEstimates,
|
|
|
})
|
|
|
|
|
|
// 创建成功的分红预算单
|
|
|
var dividendsEstimatesSavedSuccessfully []*domain.DividendsEstimate
|
|
|
// 创建失败的分红预算单
|
|
|
var dividendsEstimateSaveFailed []*domain.DividendsEstimate
|
|
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil {
|
|
|
dividendsEstimateSaveFailed = append(dividendsEstimateSaveFailed, dividendsEstimate)
|
|
|
if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else if dividendsEstimateSaved != nil {
|
|
|
dividendsEstimatesSavedSuccessfully = append(dividendsEstimatesSavedSuccessfully, dividendsEstimate)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
// TODO 分析成功和失败原因
|
|
|
|
|
|
return dividendsEstimatesSavedSuccessfully, nil
|
|
|
successfullyCount := len(dividendsEstimatesSaved)
|
|
|
return fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d订单分红预算失败,失败原因:%s", countDividendsOrders, successfullyCount, 0, ""), nil
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|