...
|
...
|
@@ -20,6 +20,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
|
|
|
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
|
|
|
var orderGoodRepository domain.OrderGoodRepository // 订单产品仓储
|
|
|
//var cooperationContactRepository domain.CooperationContractRepository // 合约仓储
|
|
|
|
|
|
// 分红预算单仓储初始化
|
|
|
if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {
|
...
|
...
|
@@ -49,6 +50,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
orderGoodRepository = repo
|
|
|
}
|
|
|
|
|
|
// 共创合约仓储初始化
|
|
|
//if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
|
|
|
// return nil, err
|
|
|
//} else {
|
|
|
// cooperationContactRepository = repo
|
|
|
//}
|
|
|
|
|
|
// 获取分红预算单
|
|
|
if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"dividendsEstimateIds": dividendsEstimateIds,
|
...
|
...
|
@@ -61,18 +69,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
for _, dividendsEstimate := range dividendsEstimates {
|
|
|
if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
|
|
|
// 自定义查询
|
|
|
queryOptions := make(map[string]interface{})
|
|
|
|
|
|
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},
|
|
|
}
|
|
|
|
|
|
//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{}{
|
...
|
...
|
@@ -107,7 +113,17 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
//}
|
|
|
|
|
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsEstimate.Company.CompanyId,
|
|
|
"orgId": dividendsEstimate.Org.OrgId,
|
|
|
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
"dividendsParticipateTypes": []int32{1, 2, 3},
|
|
|
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
"offsetLimit": false,
|
|
|
"dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
"dividendsTypes": []int32{1, 2},
|
|
|
"orderGoodId": dividendsEstimate.OrderGoodId,
|
|
|
}); err2 != nil {
|
|
|
return nil, err2
|
|
|
} else {
|
|
|
if countRelative > 0 {
|
...
|
...
|
@@ -125,19 +141,27 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
}
|
|
|
}
|
|
|
} else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
|
|
|
// 自定义查询
|
|
|
queryOptions := make(map[string]interface{})
|
|
|
|
|
|
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),
|
|
|
}
|
|
|
// 查询合约
|
|
|
//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{}{
|
...
|
...
|
@@ -172,7 +196,16 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
//}
|
|
|
|
|
|
// 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
|
|
|
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
"companyId": dividendsEstimate.Company.CompanyId,
|
|
|
"orgId": dividendsEstimate.Org.OrgId,
|
|
|
"cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
"cooperationContractUndertakerId": dividendsEstimate.CooperationContractUndertakerId,
|
|
|
"dividendsParticipateTypes": []int32{1, 2, 3},
|
|
|
"offsetLimit": false,
|
|
|
"dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
"dividendsType": int32(3),
|
|
|
}); err2 != nil {
|
|
|
return nil, err2
|
|
|
} else {
|
|
|
if countRelative > 0 {
|
...
|
...
|
@@ -180,9 +213,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst |
|
|
dividendsEstimatesRelative[i].IsCanceled = true
|
|
|
dividendsEstimatesRelative[i].Operator = operator
|
|
|
}
|
|
|
dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
|
|
|
if err3 != nil {
|
|
|
return nil, err3
|
|
|
dividendsEstimatesRelativeCanceled, err4 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
|
|
|
if err4 != nil {
|
|
|
return nil, err4
|
|
|
}
|
|
|
dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
|
|
|
}
|
...
|
...
|
|