作者 陈志颖

fix:修复退货单产品新增错误

... ... @@ -356,43 +356,6 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
// 校验是否能够取消
if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红/退货冲销
//// 自定义查询
//queryOptions := make(map[string]interface{})
//
////参与分红类型,1承接人,2推荐人,3关联业务员
//if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
// "dividendsParticipateTypes": []int32{2, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsTypes": []int32{1, 2},
// }
//} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
// "dividendsParticipateTypes": []int32{1, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsTypes": []int32{1, 2},
// }
//} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
// "dividendsParticipateTypes": []int32{1, 2},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsTypes": []int32{1, 2},
// }
//}
if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
... ... @@ -415,43 +378,6 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
}
}
} else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红
//// 自定义查询
//queryOptions := make(map[string]interface{})
//
////参与分红类型,1承接人,2推荐人,3关联业务员
//if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
// "dividendsParticipateTypes": []int32{2, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsType": int32(3),
// }
//} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
// "dividendsParticipateTypes": []int32{1, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsType": int32(3),
// }
//} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
// "dividendsParticipateTypes": []int32{1, 2},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsType": int32(3),
// }
//}
if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
... ...
... ... @@ -1281,7 +1281,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
orderGoodFound := &domain.OrderGood{}
// 获取产品
if orderGood.OrderGoodId != "" {
if orderGoodId != 0 {
orderGoodFetched, err4 := orderGoodRepository.FindOne(map[string]interface{}{
"orderGoodId": orderGoodId,
})
... ...
... ... @@ -69,50 +69,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
var orderGoodIds []int64
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
// 自定义查询
//queryOptions := map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
// "dividendsParticipateTypes": []int32{1, 2, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsTypes": []int32{1, 2},
//}
//参与分红类型,1承接人,2推荐人,3关联业务员
//if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
// "dividendsParticipateTypes": []int32{1, 2, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsTypes": []int32{1, 2},
// }
//} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
// "dividendsParticipateTypes": []int32{1, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsTypes": []int32{1, 2},
// }
//} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
// "dividendsParticipateTypes": []int32{1, 2},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsTypes": []int32{1, 2},
// }
//}
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
... ... @@ -143,60 +99,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
}
}
} else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
// 查询合约
//cooperationContract, err3 := cooperationContactRepository.FindOne(map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
//})
//if err3 != nil {
// return nil, err3
//}
// 自定义查询
//queryOptions := map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
// "dividendsParticipateTypes": []int32{1, 2, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsType": int32(3),
//}
//参与分红类型,1承接人,2推荐人,3关联业务员
//if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
// "dividendsParticipateTypes": []int32{2, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsType": int32(3),
// }
//} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
// "dividendsParticipateTypes": []int32{1, 3},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsType": int32(3),
// }
//} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
// queryOptions = map[string]interface{}{
// "companyId": dividendsEstimate.Company.CompanyId,
// "orgId": dividendsEstimate.Org.OrgId,
// "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
// "dividendsParticipateTypes": []int32{1, 2},
// "offsetLimit": false,
// "dividendsStage": dividendsEstimate.DividendsStage,
// "dividendsType": int32(3),
// }
//}
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
... ... @@ -288,7 +190,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
// 获取分红订单产品并更新产品状态
if len(ordersNumbers) > 0 {
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
//"orderNumbers": ordersNumbers,
"orderGoodIds": orderGoodIds,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
... ... @@ -318,11 +219,21 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
}); err5 != nil {
return nil, err5
} else {
// orderGoodIds去重
newReturnedOrderGoodIds := utils.RemoveDuplicationInt64(orderGoodIds)
if countDividendsReturnedOrder > 0 {
for i, returnedOrder := range returnedOrders {
if len(returnedOrder.Goods) == len(orderGoodIds) { // 1.全部产品取消分红预算
goods := make([]*domain.OrderGood, 0)
for _, good := range returnedOrder.Goods {
if good.OrderGoodDividendsStatus == 2 {
goods = append(goods, good)
}
}
if len(goods) == len(newReturnedOrderGoodIds) { // 1.已分红的产品数量等于取消的产品数量,退货单分红状态变更为未分红
returnedOrders[i].DividendStatus = 1
} else if len(returnedOrder.Goods) > len(orderGoodIds) { // 3.部分产品被取消分红预算
} else if len(goods) > len(newReturnedOrderGoodIds) { // 3.已分红的产品数量大于被取消分红的产品数量,退货单分红状态变更为部分分红
returnedOrders[i].DividendStatus = 3
}
returnedOrders[i].DividendStatus = returnedOrder.DividendStatus
... ... @@ -342,7 +253,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
// 获取退货单产品并更新产品状态
if len(returnedOrdersNumbers) > 0 {
if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
//"returnedOrderNumbers": returnedOrdersNumbers,
"orderGoodIds": orderGoodIds,
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
... ...