作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
@@ -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,
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
7 "github.com/linmadan/egglib-go/utils/tool_funs" 7 "github.com/linmadan/egglib-go/utils/tool_funs"
  8 + "github.com/shopspring/decimal"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/dto" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/dto"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
@@ -354,12 +355,44 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -354,12 +355,44 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
354 } 355 }
355 356
356 // 校验是否能够取消 357 // 校验是否能够取消
357 - if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销  
358 - if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ 358 + if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红/退货冲销
  359 + // 自定义查询
  360 + queryOptions := make(map[string]interface{})
  361 +
  362 + //参与分红类型,1承接人,2推荐人,3关联业务员
  363 + if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
  364 + queryOptions = map[string]interface{}{
  365 + "companyId": dividendsEstimate.Company.CompanyId,
  366 + "orgId": dividendsEstimate.Org.OrgId,
359 "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, 367 "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  368 + "dividendsParticipateTypes": []int32{2, 3},
  369 + "offsetLimit": false,
  370 + "dividendsStage": dividendsEstimate.DividendsStage,
  371 + "dividendsTypes": []int32{1, 2},
  372 + }
  373 + } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
  374 + queryOptions = map[string]interface{}{
360 "companyId": dividendsEstimate.Company.CompanyId, 375 "companyId": dividendsEstimate.Company.CompanyId,
361 "orgId": dividendsEstimate.Org.OrgId, 376 "orgId": dividendsEstimate.Org.OrgId,
362 - }); err2 != nil { 377 + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  378 + "dividendsParticipateTypes": []int32{1, 3},
  379 + "offsetLimit": false,
  380 + "dividendsStage": dividendsEstimate.DividendsStage,
  381 + "dividendsTypes": []int32{1, 2},
  382 + }
  383 + } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
  384 + queryOptions = map[string]interface{}{
  385 + "companyId": dividendsEstimate.Company.CompanyId,
  386 + "orgId": dividendsEstimate.Org.OrgId,
  387 + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  388 + "dividendsParticipateTypes": []int32{1, 2},
  389 + "offsetLimit": false,
  390 + "dividendsStage": dividendsEstimate.DividendsStage,
  391 + "dividendsTypes": []int32{1, 2},
  392 + }
  393 + }
  394 +
  395 + if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
363 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) 396 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
364 } else { 397 } else {
365 if countRelativeDividendsEstimates > 0 { 398 if countRelativeDividendsEstimates > 0 {
@@ -371,11 +404,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -371,11 +404,43 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
371 } 404 }
372 } 405 }
373 } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红 406 } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红
374 - if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{ 407 + // 自定义查询
  408 + queryOptions := make(map[string]interface{})
  409 +
  410 + //参与分红类型,1承接人,2推荐人,3关联业务员
  411 + if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
  412 + queryOptions = map[string]interface{}{
  413 + "companyId": dividendsEstimate.Company.CompanyId,
  414 + "orgId": dividendsEstimate.Org.OrgId,
375 "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, 415 "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  416 + "dividendsParticipateTypes": []int32{2, 3},
  417 + "offsetLimit": false,
  418 + "dividendsStage": dividendsEstimate.DividendsStage,
  419 + "dividendsType": int32(3),
  420 + }
  421 + } else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
  422 + queryOptions = map[string]interface{}{
376 "companyId": dividendsEstimate.Company.CompanyId, 423 "companyId": dividendsEstimate.Company.CompanyId,
377 "orgId": dividendsEstimate.Org.OrgId, 424 "orgId": dividendsEstimate.Org.OrgId,
378 - }); err3 != nil { 425 + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  426 + "dividendsParticipateTypes": []int32{1, 3},
  427 + "offsetLimit": false,
  428 + "dividendsStage": dividendsEstimate.DividendsStage,
  429 + "dividendsType": int32(3),
  430 + }
  431 + } else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
  432 + queryOptions = map[string]interface{}{
  433 + "companyId": dividendsEstimate.Company.CompanyId,
  434 + "orgId": dividendsEstimate.Org.OrgId,
  435 + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  436 + "dividendsParticipateTypes": []int32{1, 2},
  437 + "offsetLimit": false,
  438 + "dividendsStage": dividendsEstimate.DividendsStage,
  439 + "dividendsType": int32(3),
  440 + }
  441 + }
  442 +
  443 + if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(queryOptions); err3 != nil {
379 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) 444 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
380 } else { 445 } else {
381 if countRelativeDividendsEstimates > 0 { 446 if countRelativeDividendsEstimates > 0 {
@@ -388,12 +453,13 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -388,12 +453,13 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
388 } 453 }
389 } 454 }
390 } 455 }
  456 +
391 // 批量取消分红预算单 457 // 批量取消分红预算单
392 - if dividendsEstimatesCanceled, err := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); err != nil {  
393 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 458 + if dividendsEstimatesCanceled, errCancel := cancelDividendsEstimateService.CancelEstimate(dividendsEstimateIds, operator); errCancel != nil {
  459 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, errCancel.Error())
394 } else { 460 } else {
395 - if err := transactionContext.CommitTransaction(); err != nil {  
396 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 461 + if errTx := transactionContext.CommitTransaction(); errTx != nil {
  462 + return nil, application.ThrowError(application.TRANSACTION_ERROR, errTx.Error())
397 } 463 }
398 return dividendsEstimatesCanceled, nil 464 return dividendsEstimatesCanceled, nil
399 } 465 }
@@ -651,6 +717,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -651,6 +717,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
651 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 717 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
652 } else { 718 } else {
653 dividendsEstimates := make([]*domain.DividendsEstimate, 0) 719 dividendsEstimates := make([]*domain.DividendsEstimate, 0)
  720 +
654 // 统计当前企业分红预算单数 721 // 统计当前企业分红预算单数
655 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{ 722 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
656 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, 723 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
@@ -658,6 +725,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -658,6 +725,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
658 if err != nil { 725 if err != nil {
659 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 726 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
660 } 727 }
  728 +
661 var countDividendsEstimate int64 729 var countDividendsEstimate int64
662 for _, orderGood := range orderGoods { 730 for _, orderGood := range orderGoods {
663 dividendsEstimate := &domain.DividendsEstimate{} 731 dividendsEstimate := &domain.DividendsEstimate{}
@@ -1076,10 +1144,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives @@ -1076,10 +1144,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
1076 // 统计生成的预算单数目 1144 // 统计生成的预算单数目
1077 countDividendsEstimate = countDividendsEstimate + 1 1145 countDividendsEstimate = countDividendsEstimate + 1
1078 1146
  1147 + // 分红金额精度处理
  1148 + dividendsAmount, _ := decimal.NewFromFloatWithExponent(dividendsEstimateDetail.DividendsAmount, -2).Float64()
  1149 +
1079 dividendsEstimate := &domain.DividendsEstimate{ 1150 dividendsEstimate := &domain.DividendsEstimate{
1080 DividendsEstimateId: 0, 1151 DividendsEstimateId: 0,
1081 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 1152 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
1082 - DividendsAmount: dividendsEstimateDetail.DividendsAmount, 1153 + DividendsAmount: dividendsAmount,
1083 DividendsEstimateOrderNumber: dividendsEstimateOrderNumber, 1154 DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,
1084 DividendsEstimateTime: time.Now(), 1155 DividendsEstimateTime: time.Now(),
1085 DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType, 1156 DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
@@ -106,6 +106,9 @@ func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error @@ -106,6 +106,9 @@ func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error
106 if customerName, ok := data["customerName"]; ok { 106 if customerName, ok := data["customerName"]; ok {
107 dividendsOrder.CustomerName = customerName.(string) 107 dividendsOrder.CustomerName = customerName.(string)
108 } 108 }
  109 + if remarks, ok := data["remarks"]; ok {
  110 + dividendsOrder.Remarks = remarks.(string)
  111 + }
109 dividendsOrder.UpdatedAt = time.Now() 112 dividendsOrder.UpdatedAt = time.Now()
110 return nil 113 return nil
111 } 114 }
@@ -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,55 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -60,14 +59,55 @@ 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 + queryOptions = map[string]interface{}{
66 "companyId": dividendsEstimate.Company.CompanyId, 67 "companyId": dividendsEstimate.Company.CompanyId,
67 "orgId": dividendsEstimate.Org.OrgId, 68 "orgId": dividendsEstimate.Org.OrgId,
68 "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, 69 "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  70 + "dividendsParticipateTypes": []int32{1, 2, 3},
69 "offsetLimit": false, 71 "offsetLimit": false,
70 - }); err2 != nil { 72 + "dividendsStage": dividendsEstimate.DividendsStage,
  73 + "dividendsTypes": []int32{1, 2},
  74 + }
  75 +
  76 + //参与分红类型,1承接人,2推荐人,3关联业务员
  77 + //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
  78 + // queryOptions = map[string]interface{}{
  79 + // "companyId": dividendsEstimate.Company.CompanyId,
  80 + // "orgId": dividendsEstimate.Org.OrgId,
  81 + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  82 + // "dividendsParticipateTypes": []int32{1, 2, 3},
  83 + // "offsetLimit": false,
  84 + // "dividendsStage": dividendsEstimate.DividendsStage,
  85 + // "dividendsTypes": []int32{1, 2},
  86 + // }
  87 + //} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
  88 + // queryOptions = map[string]interface{}{
  89 + // "companyId": dividendsEstimate.Company.CompanyId,
  90 + // "orgId": dividendsEstimate.Org.OrgId,
  91 + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  92 + // "dividendsParticipateTypes": []int32{1, 3},
  93 + // "offsetLimit": false,
  94 + // "dividendsStage": dividendsEstimate.DividendsStage,
  95 + // "dividendsTypes": []int32{1, 2},
  96 + // }
  97 + //} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
  98 + // queryOptions = map[string]interface{}{
  99 + // "companyId": dividendsEstimate.Company.CompanyId,
  100 + // "orgId": dividendsEstimate.Org.OrgId,
  101 + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  102 + // "dividendsParticipateTypes": []int32{1, 2},
  103 + // "offsetLimit": false,
  104 + // "dividendsStage": dividendsEstimate.DividendsStage,
  105 + // "dividendsTypes": []int32{1, 2},
  106 + // }
  107 + //}
  108 +
  109 + // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
  110 + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
71 return nil, err2 111 return nil, err2
72 } else { 112 } else {
73 if countRelative > 0 { 113 if countRelative > 0 {
@@ -84,15 +124,55 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -84,15 +124,55 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
84 dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) 124 dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...)
85 } 125 }
86 } 126 }
87 - } else if dividendsEstimate.DividendsType == 3 {  
88 - // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单  
89 - if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ 127 + } else if dividendsEstimate.DividendsType == 3 { // 3.金额激励
  128 + // 自定义查询
  129 + queryOptions := make(map[string]interface{})
  130 +
  131 + queryOptions = map[string]interface{}{
90 "companyId": dividendsEstimate.Company.CompanyId, 132 "companyId": dividendsEstimate.Company.CompanyId,
91 "orgId": dividendsEstimate.Org.OrgId, 133 "orgId": dividendsEstimate.Org.OrgId,
92 "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, 134 "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
93 - "dividendsType": int32(3), 135 + "dividendsParticipateTypes": []int32{1, 2, 3},
94 "offsetLimit": false, 136 "offsetLimit": false,
95 - }); err2 != nil { 137 + "dividendsStage": dividendsEstimate.DividendsStage,
  138 + "dividendsType": int32(3),
  139 + }
  140 +
  141 + //参与分红类型,1承接人,2推荐人,3关联业务员
  142 + //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
  143 + // queryOptions = map[string]interface{}{
  144 + // "companyId": dividendsEstimate.Company.CompanyId,
  145 + // "orgId": dividendsEstimate.Org.OrgId,
  146 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  147 + // "dividendsParticipateTypes": []int32{2, 3},
  148 + // "offsetLimit": false,
  149 + // "dividendsStage": dividendsEstimate.DividendsStage,
  150 + // "dividendsType": int32(3),
  151 + // }
  152 + //} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
  153 + // queryOptions = map[string]interface{}{
  154 + // "companyId": dividendsEstimate.Company.CompanyId,
  155 + // "orgId": dividendsEstimate.Org.OrgId,
  156 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  157 + // "dividendsParticipateTypes": []int32{1, 3},
  158 + // "offsetLimit": false,
  159 + // "dividendsStage": dividendsEstimate.DividendsStage,
  160 + // "dividendsType": int32(3),
  161 + // }
  162 + //} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
  163 + // queryOptions = map[string]interface{}{
  164 + // "companyId": dividendsEstimate.Company.CompanyId,
  165 + // "orgId": dividendsEstimate.Org.OrgId,
  166 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  167 + // "dividendsParticipateTypes": []int32{1, 2},
  168 + // "offsetLimit": false,
  169 + // "dividendsStage": dividendsEstimate.DividendsStage,
  170 + // "dividendsType": int32(3),
  171 + // }
  172 + //}
  173 +
  174 + // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单
  175 + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil {
96 return nil, err2 176 return nil, err2
97 } else { 177 } else {
98 if countRelative > 0 { 178 if countRelative > 0 {
@@ -110,20 +190,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -110,20 +190,26 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
110 } 190 }
111 } 191 }
112 192
113 - // 分红订单或分红退货单状态变更 193 + // 分红订单
114 var orderNums []string 194 var orderNums []string
  195 +
  196 + // 分红退货单
115 var returnedOrderNums []string 197 var returnedOrderNums []string
116 198
117 if len(orderOrReturnOrderNums) > 0 { 199 if len(orderOrReturnOrderNums) > 0 {
118 // 订单/退货单号数组去重 200 // 订单/退货单号数组去重
119 orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums) 201 orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
  202 +
  203 + // 分离订单和退货单
120 for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup { 204 for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup {
  205 + if len(orderNullNum) > 0 {
121 if orderNullNum[:2] == "RE" { // 分红退后单 206 if orderNullNum[:2] == "RE" { // 分红退后单
122 returnedOrderNums = append(returnedOrderNums, orderNullNum) 207 returnedOrderNums = append(returnedOrderNums, orderNullNum)
123 } else if orderNullNum[:2] == "SL" { // 分红订单 208 } else if orderNullNum[:2] == "SL" { // 分红订单
124 orderNums = append(orderNums, orderNullNum) 209 orderNums = append(orderNums, orderNullNum)
125 } 210 }
126 } 211 }
  212 + }
127 213
128 // 获取分红订单并更新分红订单产品的状态 214 // 获取分红订单并更新分红订单产品的状态
129 if len(orderNums) > 0 { 215 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 != "" {
@@ -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,6 +328,12 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte @@ -325,6 +328,12 @@ 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 }