|
...
|
...
|
@@ -491,10 +491,76 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti |
|
|
|
defer func() {
|
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
|
}()
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
// 分红订单仓储初始化
|
|
|
|
var dividendsOrderRepository domain.DividendsOrderRepository
|
|
|
|
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
}); err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
} else {
|
|
|
|
dividendsOrderRepository = value
|
|
|
|
}
|
|
|
|
// 分红退货单仓储初始化
|
|
|
|
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
|
|
|
|
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
}); err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
} else {
|
|
|
|
dividendsReturnedOrderRepository = value
|
|
|
|
}
|
|
|
|
|
|
|
|
// 订单产品仓储初始化
|
|
|
|
var orderGoodRepository domain.OrderGoodRepository
|
|
|
|
if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
}); err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
} else {
|
|
|
|
orderGoodRepository = value
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取订单产品
|
|
|
|
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 != "" { // 查询分红订单
|
|
|
|
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
|
|
|
|
if err != nil {
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
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 != "" { // 查询分红退货单
|
|
|
|
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
|
|
|
|
if err != nil {
|
|
|
|
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))
|
|
|
|
}
|
|
|
|
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())
|
|
|
|
}
|
|
|
|
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
return map[string]interface{}{
|
|
|
|
"total": count,
|
|
|
|
"list": dividendsIncentivesEstimateDtos,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SearchMoneyIncentivesEstimate 查询金额激励分红预算
|
|
...
|
...
|
@@ -512,10 +578,38 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
|
defer func() {
|
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
|
}()
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
// 共创合约仓储初始化
|
|
|
|
var cooperationContractRepository domain.CooperationContractRepository
|
|
|
|
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
|
|
|
|
"transactionContext": transactionContext,
|
|
|
|
}); err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
} else {
|
|
|
|
cooperationContractRepository = value
|
|
|
|
}
|
|
|
|
// 查找共创合约
|
|
|
|
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
|
|
|
|
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
} else {
|
|
|
|
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
|
|
|
|
for _, cooperationContract := range cooperationContracts {
|
|
|
|
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
|
|
|
|
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
|
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
|
|
|
|
}
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
|
}
|
|
|
|
return map[string]interface{}{
|
|
|
|
"grid": map[string]interface{}{
|
|
|
|
"total": count,
|
|
|
|
"list": moneyIncentivesEstimateDtos,
|
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateDividendsEstimate 更新分红预算单(预留)
|
...
|
...
|
|