|
@@ -355,11 +355,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs |
|
@@ -355,11 +355,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs |
355
|
|
355
|
|
356
|
// 校验是否能够取消
|
356
|
// 校验是否能够取消
|
357
|
if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红/退货冲销
|
357
|
if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红/退货冲销
|
358
|
- if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
359
|
- "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
360
|
- "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
361
|
- "orgId": dividendsEstimate.Org.OrgId,
|
|
|
362
|
- }); err2 != nil {
|
358
|
+ // 自定义查询
|
|
|
359
|
+ queryOptions := make(map[string]interface{})
|
|
|
360
|
+
|
|
|
361
|
+ //参与分红类型,1承接人,2推荐人,3关联业务员
|
|
|
362
|
+ if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
|
|
|
363
|
+ queryOptions = map[string]interface{}{
|
|
|
364
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
365
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
366
|
+ "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
367
|
+ "dividendsParticipateTypes": []int32{2, 3},
|
|
|
368
|
+ "offsetLimit": false,
|
|
|
369
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
370
|
+ "dividendsTypes": []int32{1, 2},
|
|
|
371
|
+ }
|
|
|
372
|
+ } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
|
|
|
373
|
+ queryOptions = map[string]interface{}{
|
|
|
374
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
375
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
376
|
+ "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
377
|
+ "dividendsParticipateTypes": []int32{1, 3},
|
|
|
378
|
+ "offsetLimit": false,
|
|
|
379
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
380
|
+ "dividendsTypes": []int32{1, 2},
|
|
|
381
|
+ }
|
|
|
382
|
+ } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
|
|
|
383
|
+ queryOptions = map[string]interface{}{
|
|
|
384
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
385
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
386
|
+ "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
|
|
|
387
|
+ "dividendsParticipateTypes": []int32{1, 2},
|
|
|
388
|
+ "offsetLimit": false,
|
|
|
389
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
390
|
+ "dividendsTypes": []int32{1, 2},
|
|
|
391
|
+ }
|
|
|
392
|
+ }
|
|
|
393
|
+
|
|
|
394
|
+ if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
|
363
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
|
395
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
|
364
|
} else {
|
396
|
} else {
|
365
|
if countRelativeDividendsEstimates > 0 {
|
397
|
if countRelativeDividendsEstimates > 0 {
|
|
@@ -371,11 +403,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs |
|
@@ -371,11 +403,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs |
371
|
}
|
403
|
}
|
372
|
}
|
404
|
}
|
373
|
} else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红
|
405
|
} else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红
|
374
|
- if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{
|
|
|
375
|
- "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
376
|
- "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
377
|
- "orgId": dividendsEstimate.Org.OrgId,
|
|
|
378
|
- }); err3 != nil {
|
406
|
+ // 自定义查询
|
|
|
407
|
+ queryOptions := make(map[string]interface{})
|
|
|
408
|
+
|
|
|
409
|
+ //参与分红类型,1承接人,2推荐人,3关联业务员
|
|
|
410
|
+ if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
|
|
|
411
|
+ queryOptions = map[string]interface{}{
|
|
|
412
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
413
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
414
|
+ "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
415
|
+ "dividendsParticipateTypes": []int32{2, 3},
|
|
|
416
|
+ "offsetLimit": false,
|
|
|
417
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
418
|
+ "dividendsType": int32(3),
|
|
|
419
|
+ }
|
|
|
420
|
+ } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
|
|
|
421
|
+ queryOptions = map[string]interface{}{
|
|
|
422
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
423
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
424
|
+ "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
425
|
+ "dividendsParticipateTypes": []int32{1, 3},
|
|
|
426
|
+ "offsetLimit": false,
|
|
|
427
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
428
|
+ "dividendsType": int32(3),
|
|
|
429
|
+ }
|
|
|
430
|
+ } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
|
|
|
431
|
+ queryOptions = map[string]interface{}{
|
|
|
432
|
+ "companyId": dividendsEstimate.Company.CompanyId,
|
|
|
433
|
+ "orgId": dividendsEstimate.Org.OrgId,
|
|
|
434
|
+ "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
|
|
|
435
|
+ "dividendsParticipateTypes": []int32{1, 2},
|
|
|
436
|
+ "offsetLimit": false,
|
|
|
437
|
+ "dividendsStage": dividendsEstimate.DividendsStage,
|
|
|
438
|
+ "dividendsType": int32(3),
|
|
|
439
|
+ }
|
|
|
440
|
+ }
|
|
|
441
|
+
|
|
|
442
|
+ if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(queryOptions); err3 != nil {
|
379
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
|
443
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
|
380
|
} else {
|
444
|
} else {
|
381
|
if countRelativeDividendsEstimates > 0 {
|
445
|
if countRelativeDividendsEstimates > 0 {
|
|
@@ -388,6 +452,7 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs |
|
@@ -388,6 +452,7 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs |
388
|
}
|
452
|
}
|
389
|
}
|
453
|
}
|
390
|
}
|
454
|
}
|
|
|
455
|
+
|
391
|
// 批量取消分红预算单
|
456
|
// 批量取消分红预算单
|
392
|
if dividendsEstimatesCanceled, errCancel := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); errCancel != nil {
|
457
|
if dividendsEstimatesCanceled, errCancel := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); errCancel != nil {
|
393
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errCancel.Error())
|
458
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errCancel.Error())
|
|
@@ -651,6 +716,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -651,6 +716,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
651
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
716
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
652
|
} else {
|
717
|
} else {
|
653
|
dividendsEstimates := make([]*domain.DividendsEstimate, 0)
|
718
|
dividendsEstimates := make([]*domain.DividendsEstimate, 0)
|
|
|
719
|
+
|
654
|
// 统计当前企业分红预算单数
|
720
|
// 统计当前企业分红预算单数
|
655
|
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
|
721
|
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
|
656
|
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
722
|
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
|
|
@@ -658,6 +724,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
|
@@ -658,6 +724,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent |
658
|
if err != nil {
|
724
|
if err != nil {
|
659
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
725
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
660
|
}
|
726
|
}
|
|
|
727
|
+
|
661
|
var countDividendsEstimate int64
|
728
|
var countDividendsEstimate int64
|
662
|
for _, orderGood := range orderGoods {
|
729
|
for _, orderGood := range orderGoods {
|
663
|
dividendsEstimate := &domain.DividendsEstimate{}
|
730
|
dividendsEstimate := &domain.DividendsEstimate{}
|