...
|
...
|
@@ -40,7 +40,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
return nil, err
|
|
|
} else {
|
|
|
dividendsReturnedOrderRepository = repo
|
|
|
|
|
|
}
|
|
|
|
|
|
// 订单产品仓储初始化
|
...
|
...
|
@@ -60,14 +59,45 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
var dividendsEstimatesCanceled []*domain.DividendsEstimate
|
|
|
var orderOrReturnOrderNums []string
|
|
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
if dividendsEstimate.DividendsType != 3 { // 非金额激励分红预算单处理
|
|
|
if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
|
|
|
// 自定义查询
|
|
|
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 countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsEstimate.Company.CompanyId,
|
|
|
"orgId": dividendsEstimate.Org.OrgId,
|
|
|
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
"offsetLimit": false,
|
|
|
}); err2 != nil {
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
|
|
|
return nil, err2
|
|
|
} else {
|
|
|
if countRelative > 0 {
|
...
|
...
|
@@ -84,15 +114,44 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
|
|
|
}
|
|
|
}
|
|
|
} else if dividendsEstimate.DividendsType == 3 {
|
|
|
} else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
|
|
|
// 自定义查询
|
|
|
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 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 {
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
|
|
|
return nil, err2
|
|
|
} else {
|
|
|
if countRelative > 0 {
|
...
|
...
|
@@ -110,18 +169,24 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
}
|
|
|
}
|
|
|
|
|
|
// 分红订单或分红退货单状态变更
|
|
|
// 分红订单
|
|
|
var orderNums []string
|
|
|
|
|
|
// 分红退货单
|
|
|
var returnedOrderNums []string
|
|
|
|
|
|
if len(orderOrReturnOrderNums) > 0 {
|
|
|
// 订单/退货单号数组去重
|
|
|
orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
|
|
|
|
|
|
// 分离订单和退货单
|
|
|
for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
|
|
|
if orderNullNum[:2] == "RE" { // 分红退后单
|
|
|
returnedOrderNums = append(returnedOrderNums, orderNullNum)
|
|
|
} else if orderNullNum[:2] == "SL" { // 分红订单
|
|
|
orderNums = append(orderNums, orderNullNum)
|
|
|
if len(orderNullNum) > 0 {
|
|
|
if orderNullNum[:2] == "RE" { // 分红退后单
|
|
|
returnedOrderNums = append(returnedOrderNums, orderNullNum)
|
|
|
} else if orderNullNum[:2] == "SL" { // 分红订单
|
|
|
orderNums = append(orderNums, orderNullNum)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|