...
|
...
|
@@ -68,6 +68,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive |
|
|
}
|
|
|
|
|
|
// 获取订单产品
|
|
|
listDividendsIncentivesEstimateQuery.OrderGoodDividendsStatus = int32(1)
|
|
|
if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(listDividendsIncentivesEstimateQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -77,8 +78,8 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive |
|
|
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
|
|
|
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
|
|
|
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
|
|
|
"companyId": orderGood.CompanyId,
|
|
|
"orgId": orderGood.OrgId,
|
|
|
"companyId": listDividendsIncentivesEstimateQuery.CompanyId,
|
|
|
"orgId": listDividendsIncentivesEstimateQuery.OrgId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -92,8 +93,8 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive |
|
|
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
|
|
|
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
|
|
|
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
|
|
|
"companyId": orderGood.CompanyId,
|
|
|
"orgId": orderGood.OrgId,
|
|
|
"companyId": listDividendsIncentivesEstimateQuery.CompanyId,
|
|
|
"orgId": listDividendsIncentivesEstimateQuery.OrgId,
|
|
|
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
|
|
|
})
|
|
|
if err != nil {
|
...
|
...
|
@@ -147,13 +148,11 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst |
|
|
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
// TODO 判断承接人是否已分红
|
|
|
|
|
|
// 数据传输对象
|
|
|
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
|
|
|
for _, cooperationContract := range cooperationContracts {
|
|
|
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
|
|
|
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
|
|
|
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, nil); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
|
...
|
...
|
@@ -749,8 +748,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
} else {
|
|
|
// 获取产品ID
|
|
|
orderGoodSavedIds := make([]int64, 0)
|
|
|
for _, dividendsEstimateSaved := range dividendsEstimatesSaved {
|
|
|
orderGoodSavedIds = append(orderGoodSavedIds, dividendsEstimateSaved.OrderGoodId)
|
|
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
orderGoodSavedIds = append(orderGoodSavedIds, dividendsEstimate.OrderGoodId)
|
|
|
}
|
|
|
|
|
|
// 获取订单产品
|
...
|
...
|
@@ -899,7 +898,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
|
}
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
"report": fmt.Sprintf("已完成%d笔单订单分红预算,生成%d笔单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
|
|
|
"report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
|
|
|
}, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -1283,39 +1282,45 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti |
|
|
}
|
|
|
|
|
|
// 获取订单产品
|
|
|
searchDividendsIncentivesEstimateQuery.OrderGoodDividendsStatus = int32(1) // 查询带分红的产品
|
|
|
if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(searchDividendsIncentivesEstimateQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
|
|
|
for _, orderGood := range orderGoods {
|
|
|
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
|
|
|
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
|
|
|
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
|
|
|
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
|
|
|
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
|
|
|
"companyId": orderGood.CompanyId,
|
|
|
"orgId": orderGood.OrgId,
|
|
|
"companyId": searchDividendsIncentivesEstimateQuery.CompanyId,
|
|
|
"orgId": searchDividendsIncentivesEstimateQuery.OrgId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
continue
|
|
|
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if dividendsOrder == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
|
|
|
continue
|
|
|
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
|
|
|
}
|
|
|
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
|
|
|
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
|
|
|
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
|
|
|
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
|
|
|
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
|
|
|
"companyId": orderGood.CompanyId,
|
|
|
"orgId": orderGood.OrgId,
|
|
|
"companyId": searchDividendsIncentivesEstimateQuery.CompanyId,
|
|
|
"orgId": searchDividendsIncentivesEstimateQuery.OrgId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
continue
|
|
|
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if dividendsReturnedOrder == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
|
|
|
continue
|
|
|
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
|
|
|
}
|
|
|
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -1348,6 +1353,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 共创合约仓储初始化
|
|
|
var cooperationContractRepository domain.CooperationContractRepository
|
|
|
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
...
|
...
|
@@ -1357,6 +1363,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
} else {
|
|
|
cooperationContractRepository = value
|
|
|
}
|
|
|
|
|
|
// TODO 阶段承接人列表
|
|
|
stageAndUndertaker := make([]*dto.StageAndUndertaker, 0)
|
|
|
|
|
|
// 查找共创合约
|
|
|
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
|
|
|
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
|
...
|
...
|
@@ -1364,8 +1374,13 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
} else {
|
|
|
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
|
|
|
for _, cooperationContract := range cooperationContracts {
|
|
|
// TODO 判断承接人是否已分红
|
|
|
//for _, undertaker := range cooperationContract.Undertakers {
|
|
|
//
|
|
|
//}
|
|
|
|
|
|
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
|
|
|
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
|
|
|
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
|
...
|
...
|
|