...
|
...
|
@@ -60,11 +60,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
var dividendsEstimatesCanceled []*domain.DividendsEstimate
|
|
|
var orderOrReturnOrderNums []string
|
|
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
if dividendsEstimate.DividendsType != 3 { // 非金额激励分红预算单处理
|
|
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsEstimate.Company.CompanyId,
|
|
|
"orgId": dividendsEstimate.Org.OrgId,
|
|
|
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
"offsetLimit": false,
|
|
|
}); err2 != nil {
|
|
|
return nil, err2
|
|
|
} else {
|
...
|
...
|
@@ -82,12 +84,37 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
|
|
|
}
|
|
|
}
|
|
|
} else if dividendsEstimate.DividendsType == 3 {
|
|
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsEstimate.Company.CompanyId,
|
|
|
"orgId": dividendsEstimate.Org.OrgId,
|
|
|
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
"dividendsType": int32(3),
|
|
|
"offsetLimit": false,
|
|
|
}); err2 != nil {
|
|
|
return nil, err2
|
|
|
} else {
|
|
|
if countRelative > 0 {
|
|
|
for i, _ := range dividendsEstimatesRelative {
|
|
|
dividendsEstimatesRelative[i].IsCanceled = true
|
|
|
dividendsEstimatesRelative[i].Operator = operator
|
|
|
}
|
|
|
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
|
|
|
if err3 != nil {
|
|
|
return nil, err3
|
|
|
}
|
|
|
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 分红订单或分红退货单状态变更
|
|
|
var orderNums []string
|
|
|
var returnedOrderNums []string
|
|
|
|
|
|
if len(orderOrReturnOrderNums) > 0 {
|
|
|
// 订单/退货单号数组去重
|
|
|
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
|
|
|
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
|
...
|
...
|
@@ -98,7 +125,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取分红订单
|
|
|
// 获取分红订单并更新分红订单产品的状态
|
|
|
if len(orderNums) > 0 {
|
|
|
if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
|
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
...
|
...
|
@@ -120,6 +148,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber)
|
|
|
}
|
|
|
// 获取分红订单产品并更新产品状态
|
|
|
if len(ordersNumbers) > 0 {
|
|
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
|
|
"orderNumbers": ordersNumbers,
|
|
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
...
|
...
|
@@ -138,8 +167,11 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取分红退货单
|
|
|
// 获取分红退货单并更新订单产品的状态
|
|
|
if len(returnedOrderNums) > 0 {
|
|
|
if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
|
|
"orgId": dividendsEstimates[0].Org.OrgId,
|
...
|
...
|
@@ -161,6 +193,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber)
|
|
|
}
|
|
|
// 获取退货单产品并更新产品状态
|
|
|
if len(returnedOrdersNumbers) > 0 {
|
|
|
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
|
|
|
"returnedOrderNumbers": returnedOrdersNumbers,
|
|
|
"companyId": dividendsEstimates[0].Company.CompanyId,
|
...
|
...
|
@@ -179,7 +212,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return dividendsEstimatesCanceled, nil
|
|
|
}
|
|
|
}
|
...
|
...
|
|