作者 陈志颖

fix:取消金额激励分红预算

... ... @@ -84,6 +84,25 @@ 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 {
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
if err3 != nil {
return nil, err3
}
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
}
}
}
}
... ... @@ -102,7 +121,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
}
}
// 获取分红订单
// 获取分红订单并更新分红订单产品的状态
if len(orderNums) > 0 {
if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
... ... @@ -147,7 +166,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
}
}
// 获取分红退货单
// 获取分红退货单并更新订单产品的状态
if len(returnedOrderNums) > 0 {
if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
... ...
... ... @@ -308,6 +308,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
}
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number = ?", cooperationContractNumber)
}
if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 {
query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId)
}
... ...