合并分支 'dev' 到 'test'
Dev 查看合并请求 !41
正在显示
8 个修改的文件
包含
179 行增加
和
22 行删除
| @@ -1095,6 +1095,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1095,6 +1095,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
| 1095 | UndertakerId: undertakerId, | 1095 | UndertakerId: undertakerId, |
| 1096 | UserId: undertakerDomain.UserId, | 1096 | UserId: undertakerDomain.UserId, |
| 1097 | CooperationContractNumber: cooperationContract.CooperationContractNumber, | 1097 | CooperationContractNumber: cooperationContract.CooperationContractNumber, |
| 1098 | + CooperationContractId: cooperationContract.CooperationContractId, | ||
| 1098 | UserBaseId: undertakerDomain.UserBaseId, | 1099 | UserBaseId: undertakerDomain.UserBaseId, |
| 1099 | Org: undertakerDomain.Org, | 1100 | Org: undertakerDomain.Org, |
| 1100 | Orgs: undertakerDomain.Orgs, | 1101 | Orgs: undertakerDomain.Orgs, |
| @@ -354,12 +354,44 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | @@ -354,12 +354,44 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | ||
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | // 校验是否能够取消 | 356 | // 校验是否能够取消 |
| 357 | - if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销 | ||
| 358 | - if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ | 357 | + if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红/退货冲销 |
| 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, | ||
| 359 | "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | 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{}{ | ||
| 360 | "companyId": dividendsEstimate.Company.CompanyId, | 374 | "companyId": dividendsEstimate.Company.CompanyId, |
| 361 | "orgId": dividendsEstimate.Org.OrgId, | 375 | "orgId": dividendsEstimate.Org.OrgId, |
| 362 | - }); err2 != nil { | 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{}{ | 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, | ||
| 375 | "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | 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{}{ | ||
| 376 | "companyId": dividendsEstimate.Company.CompanyId, | 422 | "companyId": dividendsEstimate.Company.CompanyId, |
| 377 | "orgId": dividendsEstimate.Org.OrgId, | 423 | "orgId": dividendsEstimate.Org.OrgId, |
| 378 | - }); err3 != nil { | 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,12 +452,13 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | @@ -388,12 +452,13 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs | ||
| 388 | } | 452 | } |
| 389 | } | 453 | } |
| 390 | } | 454 | } |
| 455 | + | ||
| 391 | // 批量取消分红预算单 | 456 | // 批量取消分红预算单 |
| 392 | - if dividendsEstimatesCanceled, err := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); err != nil { | ||
| 393 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 457 | + if dividendsEstimatesCanceled, errCancel := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); errCancel != nil { |
| 458 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errCancel.Error()) | ||
| 394 | } else { | 459 | } else { |
| 395 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
| 396 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 460 | + if errTx := transactionContext.CommitTransaction(); errTx != nil { |
| 461 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, errTx.Error()) | ||
| 397 | } | 462 | } |
| 398 | return dividendsEstimatesCanceled, nil | 463 | return dividendsEstimatesCanceled, nil |
| 399 | } | 464 | } |
| @@ -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{} |
| @@ -706,6 +773,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -706,6 +773,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 706 | UpdatedAt: time.Time{}, | 773 | UpdatedAt: time.Time{}, |
| 707 | OrderGoodId: orderGood.OrderGoodId, | 774 | OrderGoodId: orderGood.OrderGoodId, |
| 708 | OrderGoodAmount: orderGood.OrderGoodAmount, | 775 | OrderGoodAmount: orderGood.OrderGoodAmount, |
| 776 | + PaymentStatus: int32(1), | ||
| 709 | } | 777 | } |
| 710 | 778 | ||
| 711 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 779 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
| @@ -759,6 +827,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | @@ -759,6 +827,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent | ||
| 759 | UpdatedAt: time.Time{}, | 827 | UpdatedAt: time.Time{}, |
| 760 | OrderGoodId: orderGood.OrderGoodId, | 828 | OrderGoodId: orderGood.OrderGoodId, |
| 761 | OrderGoodAmount: orderGood.OrderGoodAmount, | 829 | OrderGoodAmount: orderGood.OrderGoodAmount, |
| 830 | + PaymentStatus: int32(1), | ||
| 762 | } | 831 | } |
| 763 | 832 | ||
| 764 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 833 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
| @@ -1095,6 +1164,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | @@ -1095,6 +1164,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives | ||
| 1095 | CreatedAt: time.Now(), | 1164 | CreatedAt: time.Now(), |
| 1096 | DeletedAt: time.Time{}, | 1165 | DeletedAt: time.Time{}, |
| 1097 | UpdatedAt: time.Time{}, | 1166 | UpdatedAt: time.Time{}, |
| 1167 | + PaymentStatus: int32(1), | ||
| 1098 | } | 1168 | } |
| 1099 | 1169 | ||
| 1100 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) | 1170 | dividendsEstimates = append(dividendsEstimates, dividendsEstimate) |
| @@ -40,7 +40,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -40,7 +40,6 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 40 | return nil, err | 40 | return nil, err |
| 41 | } else { | 41 | } else { |
| 42 | dividendsReturnedOrderRepository = repo | 42 | dividendsReturnedOrderRepository = repo |
| 43 | - | ||
| 44 | } | 43 | } |
| 45 | 44 | ||
| 46 | // 订单产品仓储初始化 | 45 | // 订单产品仓储初始化 |
| @@ -60,14 +59,45 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -60,14 +59,45 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 60 | var dividendsEstimatesCanceled []*domain.DividendsEstimate | 59 | var dividendsEstimatesCanceled []*domain.DividendsEstimate |
| 61 | var orderOrReturnOrderNums []string | 60 | var orderOrReturnOrderNums []string |
| 62 | for _, dividendsEstimate := range dividendsEstimates { | 61 | for _, dividendsEstimate := range dividendsEstimates { |
| 63 | - if dividendsEstimate.DividendsType != 3 { // 非金额激励分红预算单处理 | ||
| 64 | - // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | ||
| 65 | - if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ | 62 | + if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 |
| 63 | + // 自定义查询 | ||
| 64 | + queryOptions := make(map[string]interface{}) | ||
| 65 | + | ||
| 66 | + //参与分红类型,1承接人,2推荐人,3关联业务员 | ||
| 67 | + if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 | ||
| 68 | + queryOptions = map[string]interface{}{ | ||
| 69 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
| 70 | + "orgId": dividendsEstimate.Org.OrgId, | ||
| 71 | + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | ||
| 72 | + "dividendsParticipateTypes": []int32{2, 3}, | ||
| 73 | + "offsetLimit": false, | ||
| 74 | + "dividendsStage": dividendsEstimate.DividendsStage, | ||
| 75 | + "dividendsTypes": []int32{1, 2}, | ||
| 76 | + } | ||
| 77 | + } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单 | ||
| 78 | + queryOptions = map[string]interface{}{ | ||
| 66 | "companyId": dividendsEstimate.Company.CompanyId, | 79 | "companyId": dividendsEstimate.Company.CompanyId, |
| 67 | "orgId": dividendsEstimate.Org.OrgId, | 80 | "orgId": dividendsEstimate.Org.OrgId, |
| 68 | "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | 81 | "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, |
| 82 | + "dividendsParticipateTypes": []int32{1, 3}, | ||
| 69 | "offsetLimit": false, | 83 | "offsetLimit": false, |
| 70 | - }); err2 != nil { | 84 | + "dividendsStage": dividendsEstimate.DividendsStage, |
| 85 | + "dividendsTypes": []int32{1, 2}, | ||
| 86 | + } | ||
| 87 | + } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单 | ||
| 88 | + queryOptions = map[string]interface{}{ | ||
| 89 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
| 90 | + "orgId": dividendsEstimate.Org.OrgId, | ||
| 91 | + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | ||
| 92 | + "dividendsParticipateTypes": []int32{1, 2}, | ||
| 93 | + "offsetLimit": false, | ||
| 94 | + "dividendsStage": dividendsEstimate.DividendsStage, | ||
| 95 | + "dividendsTypes": []int32{1, 2}, | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | ||
| 100 | + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil { | ||
| 71 | return nil, err2 | 101 | return nil, err2 |
| 72 | } else { | 102 | } else { |
| 73 | if countRelative > 0 { | 103 | if countRelative > 0 { |
| @@ -84,15 +114,45 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -84,15 +114,45 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 84 | dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) | 114 | dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) |
| 85 | } | 115 | } |
| 86 | } | 116 | } |
| 87 | - } else if dividendsEstimate.DividendsType == 3 { | ||
| 88 | - // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | ||
| 89 | - if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ | 117 | + } else if dividendsEstimate.DividendsType == 3 { // 3.金额激励 |
| 118 | + // 自定义查询 | ||
| 119 | + queryOptions := make(map[string]interface{}) | ||
| 120 | + | ||
| 121 | + //参与分红类型,1承接人,2推荐人,3关联业务员 | ||
| 122 | + if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单 | ||
| 123 | + queryOptions = map[string]interface{}{ | ||
| 90 | "companyId": dividendsEstimate.Company.CompanyId, | 124 | "companyId": dividendsEstimate.Company.CompanyId, |
| 91 | "orgId": dividendsEstimate.Org.OrgId, | 125 | "orgId": dividendsEstimate.Org.OrgId, |
| 92 | "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | 126 | "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, |
| 127 | + "dividendsParticipateTypes": []int32{2, 3}, | ||
| 128 | + "offsetLimit": false, | ||
| 129 | + "dividendsStage": dividendsEstimate.DividendsStage, | ||
| 93 | "dividendsType": int32(3), | 130 | "dividendsType": int32(3), |
| 131 | + } | ||
| 132 | + } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单 | ||
| 133 | + queryOptions = map[string]interface{}{ | ||
| 134 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
| 135 | + "orgId": dividendsEstimate.Org.OrgId, | ||
| 136 | + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
| 137 | + "dividendsParticipateTypes": []int32{1, 3}, | ||
| 94 | "offsetLimit": false, | 138 | "offsetLimit": false, |
| 95 | - }); err2 != nil { | 139 | + "dividendsStage": dividendsEstimate.DividendsStage, |
| 140 | + "dividendsType": int32(3), | ||
| 141 | + } | ||
| 142 | + } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单 | ||
| 143 | + queryOptions = map[string]interface{}{ | ||
| 144 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
| 145 | + "orgId": dividendsEstimate.Org.OrgId, | ||
| 146 | + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
| 147 | + "dividendsParticipateTypes": []int32{1, 2}, | ||
| 148 | + "offsetLimit": false, | ||
| 149 | + "dividendsStage": dividendsEstimate.DividendsStage, | ||
| 150 | + "dividendsType": int32(3), | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | ||
| 155 | + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil { | ||
| 96 | return nil, err2 | 156 | return nil, err2 |
| 97 | } else { | 157 | } else { |
| 98 | if countRelative > 0 { | 158 | if countRelative > 0 { |
| @@ -110,20 +170,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -110,20 +170,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
| 110 | } | 170 | } |
| 111 | } | 171 | } |
| 112 | 172 | ||
| 113 | - // 分红订单或分红退货单状态变更 | 173 | + // 分红订单 |
| 114 | var orderNums []string | 174 | var orderNums []string |
| 175 | + | ||
| 176 | + // 分红退货单 | ||
| 115 | var returnedOrderNums []string | 177 | var returnedOrderNums []string |
| 116 | 178 | ||
| 117 | if len(orderOrReturnOrderNums) > 0 { | 179 | if len(orderOrReturnOrderNums) > 0 { |
| 118 | // 订单/退货单号数组去重 | 180 | // 订单/退货单号数组去重 |
| 119 | orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums) | 181 | orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums) |
| 182 | + | ||
| 183 | + // 分离订单和退货单 | ||
| 120 | for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup { | 184 | for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup { |
| 185 | + if len(orderNullNum) > 0 { | ||
| 121 | if orderNullNum[:2] == "RE" { // 分红退后单 | 186 | if orderNullNum[:2] == "RE" { // 分红退后单 |
| 122 | returnedOrderNums = append(returnedOrderNums, orderNullNum) | 187 | returnedOrderNums = append(returnedOrderNums, orderNullNum) |
| 123 | } else if orderNullNum[:2] == "SL" { // 分红订单 | 188 | } else if orderNullNum[:2] == "SL" { // 分红订单 |
| 124 | orderNums = append(orderNums, orderNullNum) | 189 | orderNums = append(orderNums, orderNullNum) |
| 125 | } | 190 | } |
| 126 | } | 191 | } |
| 192 | + } | ||
| 127 | 193 | ||
| 128 | // 获取分红订单并更新分红订单产品的状态 | 194 | // 获取分红订单并更新分红订单产品的状态 |
| 129 | if len(orderNums) > 0 { | 195 | if len(orderNums) > 0 { |
| @@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | 9 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" |
| 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" | 10 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" |
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
| 11 | ) | 12 | ) |
| 12 | 13 | ||
| 13 | type ConfirmDividendsIncentivesEstimateService struct { | 14 | type ConfirmDividendsIncentivesEstimateService struct { |
| @@ -53,6 +54,10 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -53,6 +54,10 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
| 53 | // 确认业绩分红预算 | 54 | // 确认业绩分红预算 |
| 54 | var dividendsEstimateDetails []*service.DividendsEstimateDetail | 55 | var dividendsEstimateDetails []*service.DividendsEstimateDetail |
| 55 | for _, orderGood := range orderGoods { | 56 | for _, orderGood := range orderGoods { |
| 57 | + log.Logger.Info("业绩分红预算产品", map[string]interface{}{ | ||
| 58 | + "orderGood": orderGood, | ||
| 59 | + }) | ||
| 60 | + | ||
| 56 | // 获取合约 | 61 | // 获取合约 |
| 57 | cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{ | 62 | cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{ |
| 58 | "cooperationContractNumber": orderGood.CooperationContractNumber, | 63 | "cooperationContractNumber": orderGood.CooperationContractNumber, |
| @@ -95,6 +100,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | @@ -95,6 +100,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo | ||
| 95 | }) | 100 | }) |
| 96 | continue | 101 | continue |
| 97 | } else { | 102 | } else { |
| 103 | + log.Logger.Info("产品相关的合约", map[string]interface{}{ | ||
| 104 | + "cooperationContract": cooperationContract, | ||
| 105 | + }) | ||
| 98 | if cooperationContract.Status == 2 { | 106 | if cooperationContract.Status == 2 { |
| 99 | var orderNumber string | 107 | var orderNumber string |
| 100 | if orderGood.DividendsOrderNumber != "" { | 108 | if orderGood.DividendsOrderNumber != "" { |
| @@ -178,7 +178,7 @@ func (ptr *CooperationStatisticsService) getCompanyContracts(orgId, userId int64 | @@ -178,7 +178,7 @@ func (ptr *CooperationStatisticsService) getCompanyContracts(orgId, userId int64 | ||
| 178 | 178 | ||
| 179 | //getRelevantContracts 获取相关人的合约 | 179 | //getRelevantContracts 获取相关人的合约 |
| 180 | func (ptr *CooperationStatisticsService) getRelevantContracts(queryOptions map[string]interface{}) ([]string, error) { | 180 | func (ptr *CooperationStatisticsService) getRelevantContracts(queryOptions map[string]interface{}) ([]string, error) { |
| 181 | - undertakerRepository, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext) | 181 | + undertakerRepository, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext) |
| 182 | _, undertakers, err := undertakerRepository.Find(queryOptions) | 182 | _, undertakers, err := undertakerRepository.Find(queryOptions) |
| 183 | var numbers []string | 183 | var numbers []string |
| 184 | for i := range undertakers { | 184 | for i := range undertakers { |
| @@ -30,7 +30,7 @@ type CooperationContractChangeLog struct { | @@ -30,7 +30,7 @@ type CooperationContractChangeLog struct { | ||
| 30 | // 更新时间 | 30 | // 更新时间 |
| 31 | UpdatedAt time.Time `comment:"更新时间"` | 31 | UpdatedAt time.Time `comment:"更新时间"` |
| 32 | // 删除时间 | 32 | // 删除时间 |
| 33 | - DeletedAt time.Time `comment:"删除时间"` | 33 | + DeletedAt time.Time `comment:"删除时间" pg:",soft_delete"` |
| 34 | // 创建时间 | 34 | // 创建时间 |
| 35 | CreatedAt time.Time `comment:"创建时间"` | 35 | CreatedAt time.Time `comment:"创建时间"` |
| 36 | } | 36 | } |
| @@ -1146,7 +1146,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | @@ -1146,7 +1146,7 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in | ||
| 1146 | if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { | 1146 | if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { |
| 1147 | query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber)) | 1147 | query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber)) |
| 1148 | } | 1148 | } |
| 1149 | - if cooperationContractName, ok := queryOptions["cooperationContactName"]; ok && cooperationContractName != "" { | 1149 | + if cooperationContractName, ok := queryOptions["cooperationContractName"]; ok && cooperationContractName != "" { |
| 1150 | query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName)) | 1150 | query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName)) |
| 1151 | } | 1151 | } |
| 1152 | if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" { | 1152 | if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" { |
| @@ -307,6 +307,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | @@ -307,6 +307,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | ||
| 307 | if dividendsType, ok := queryOptions["dividendsType"]; ok && dividendsType.(int32) != 0 { | 307 | if dividendsType, ok := queryOptions["dividendsType"]; ok && dividendsType.(int32) != 0 { |
| 308 | query.Where("dividends_type = ?", dividendsType) | 308 | query.Where("dividends_type = ?", dividendsType) |
| 309 | } | 309 | } |
| 310 | + if dividendsTypes, ok := queryOptions["dividendsTypes"]; ok && len(dividendsTypes.([]int32)) > 0 { | ||
| 311 | + query.Where("dividends_type in (?)", pg.In(dividendsTypes.([]int32))) | ||
| 312 | + } | ||
| 310 | if dividendsEstimateOrderNumber, ok := queryOptions["dividendsEstimateOrderNumber"]; ok && dividendsEstimateOrderNumber != "" { | 313 | if dividendsEstimateOrderNumber, ok := queryOptions["dividendsEstimateOrderNumber"]; ok && dividendsEstimateOrderNumber != "" { |
| 311 | query.Where("dividends_estimate_order_number ilike ?", fmt.Sprintf("%%%s%%", dividendsEstimateOrderNumber)) | 314 | query.Where("dividends_estimate_order_number ilike ?", fmt.Sprintf("%%%s%%", dividendsEstimateOrderNumber)) |
| 312 | } | 315 | } |
| @@ -325,12 +328,21 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | @@ -325,12 +328,21 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | ||
| 325 | if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 { | 328 | if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 { |
| 326 | query.Where("dividends_participate_type = ?", dividendsParticipateType) | 329 | query.Where("dividends_participate_type = ?", dividendsParticipateType) |
| 327 | } | 330 | } |
| 331 | + if dividendsParticipateTypes, ok := queryOptions["dividendsParticipateTypes"]; ok && len(dividendsParticipateTypes.([]int32)) > 0 { | ||
| 332 | + query.Where("dividends_participate_type in (?)", pg.In(dividendsParticipateTypes.([]int32))) | ||
| 333 | + } | ||
| 334 | + if dividendsStage, ok := queryOptions["dividendsStage"]; ok && dividendsStage.(int32) > 0 { | ||
| 335 | + query.Where("dividends_stage = ?", dividendsStage) | ||
| 336 | + } | ||
| 328 | if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { | 337 | if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { |
| 329 | query.Where("cooperation_contract_number = ?", cooperationContractNumber) | 338 | query.Where("cooperation_contract_number = ?", cooperationContractNumber) |
| 330 | } | 339 | } |
| 331 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { | 340 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { |
| 332 | query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId) | 341 | query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId) |
| 333 | } | 342 | } |
| 343 | + if userBaseId, ok := queryOptions["userBaseId"]; ok && userBaseId.(int64) != 0 { | ||
| 344 | + query.Where(`dividends_user @> '{"userBaseId":"?"}'`, userBaseId) | ||
| 345 | + } | ||
| 334 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | 346 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { |
| 335 | query.Where("company->>'companyId' = '?'", companyId) | 347 | query.Where("company->>'companyId' = '?'", companyId) |
| 336 | } | 348 | } |
-
请 注册 或 登录 后发表评论