作者 陈志颖

fix:确定金额激励分红预算校验

@@ -356,43 +356,54 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -356,43 +356,54 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
356 356
357 // 校验是否能够取消 357 // 校验是否能够取消
358 if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红/退货冲销 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,  
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{}{  
375 - "companyId": dividendsEstimate.Company.CompanyId,  
376 - "orgId": dividendsEstimate.Org.OrgId,  
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 359
395 - if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(queryOptions); err2 != nil { 360 + //// 自定义查询
  361 + //queryOptions := make(map[string]interface{})
  362 + //
  363 + ////参与分红类型,1承接人,2推荐人,3关联业务员
  364 + //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
  365 + // queryOptions = map[string]interface{}{
  366 + // "companyId": dividendsEstimate.Company.CompanyId,
  367 + // "orgId": dividendsEstimate.Org.OrgId,
  368 + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  369 + // "dividendsParticipateTypes": []int32{2, 3},
  370 + // "offsetLimit": false,
  371 + // "dividendsStage": dividendsEstimate.DividendsStage,
  372 + // "dividendsTypes": []int32{1, 2},
  373 + // }
  374 + //} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
  375 + // queryOptions = map[string]interface{}{
  376 + // "companyId": dividendsEstimate.Company.CompanyId,
  377 + // "orgId": dividendsEstimate.Org.OrgId,
  378 + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  379 + // "dividendsParticipateTypes": []int32{1, 3},
  380 + // "offsetLimit": false,
  381 + // "dividendsStage": dividendsEstimate.DividendsStage,
  382 + // "dividendsTypes": []int32{1, 2},
  383 + // }
  384 + //} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
  385 + // queryOptions = map[string]interface{}{
  386 + // "companyId": dividendsEstimate.Company.CompanyId,
  387 + // "orgId": dividendsEstimate.Org.OrgId,
  388 + // "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  389 + // "dividendsParticipateTypes": []int32{1, 2},
  390 + // "offsetLimit": false,
  391 + // "dividendsStage": dividendsEstimate.DividendsStage,
  392 + // "dividendsTypes": []int32{1, 2},
  393 + // }
  394 + //}
  395 +
  396 + if countRelativeDividendsEstimates, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
  397 + "companyId": dividendsEstimate.Company.CompanyId,
  398 + "orgId": dividendsEstimate.Org.OrgId,
  399 + "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
  400 + "dividendsParticipateTypes": []int32{1, 2, 3},
  401 + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  402 + "offsetLimit": false,
  403 + "dividendsStage": dividendsEstimate.DividendsStage,
  404 + "dividendsTypes": []int32{1, 2},
  405 + "orderGoodId": dividendsEstimate.OrderGoodId,
  406 + }); err2 != nil {
396 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) 407 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
397 } else { 408 } else {
398 if countRelativeDividendsEstimates > 0 { 409 if countRelativeDividendsEstimates > 0 {
@@ -404,43 +415,53 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -404,43 +415,53 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
404 } 415 }
405 } 416 }
406 } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红 417 } else if dividendsEstimate.DividendsType == domain.MONEY_INCENTIVES { // 金额激励分红
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,  
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{}{  
423 - "companyId": dividendsEstimate.Company.CompanyId,  
424 - "orgId": dividendsEstimate.Org.OrgId,  
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 418
443 - if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(queryOptions); err3 != nil { 419 + //// 自定义查询
  420 + //queryOptions := make(map[string]interface{})
  421 + //
  422 + ////参与分红类型,1承接人,2推荐人,3关联业务员
  423 + //if dividendsEstimate.DividendsParticipateType == 1 { // 当前取消的是承接人的分红预算单
  424 + // queryOptions = map[string]interface{}{
  425 + // "companyId": dividendsEstimate.Company.CompanyId,
  426 + // "orgId": dividendsEstimate.Org.OrgId,
  427 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  428 + // "dividendsParticipateTypes": []int32{2, 3},
  429 + // "offsetLimit": false,
  430 + // "dividendsStage": dividendsEstimate.DividendsStage,
  431 + // "dividendsType": int32(3),
  432 + // }
  433 + //} else if dividendsEstimate.DividendsParticipateType == 2 { // 当前取消的是推荐人的分红预算单
  434 + // queryOptions = map[string]interface{}{
  435 + // "companyId": dividendsEstimate.Company.CompanyId,
  436 + // "orgId": dividendsEstimate.Org.OrgId,
  437 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  438 + // "dividendsParticipateTypes": []int32{1, 3},
  439 + // "offsetLimit": false,
  440 + // "dividendsStage": dividendsEstimate.DividendsStage,
  441 + // "dividendsType": int32(3),
  442 + // }
  443 + //} else if dividendsEstimate.DividendsParticipateType == 3 { // 当前取消的是关联业务员的分红预算单
  444 + // queryOptions = map[string]interface{}{
  445 + // "companyId": dividendsEstimate.Company.CompanyId,
  446 + // "orgId": dividendsEstimate.Org.OrgId,
  447 + // "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  448 + // "dividendsParticipateTypes": []int32{1, 2},
  449 + // "offsetLimit": false,
  450 + // "dividendsStage": dividendsEstimate.DividendsStage,
  451 + // "dividendsType": int32(3),
  452 + // }
  453 + //}
  454 +
  455 + if countRelativeDividendsEstimates, dividendsEstimatesRelative, err3 := dividendsEstimateRepository.Find(map[string]interface{}{
  456 + "companyId": dividendsEstimate.Company.CompanyId,
  457 + "orgId": dividendsEstimate.Org.OrgId,
  458 + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber,
  459 + "cooperationContractUndertakerId": dividendsEstimate.CooperationContractUndertakerId,
  460 + "dividendsParticipateTypes": []int32{1, 2, 3},
  461 + "offsetLimit": false,
  462 + "dividendsStage": dividendsEstimate.DividendsStage,
  463 + "dividendsType": int32(3),
  464 + }); err3 != nil {
444 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) 465 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
445 } else { 466 } else {
446 if countRelativeDividendsEstimates > 0 { 467 if countRelativeDividendsEstimates > 0 {
@@ -1393,7 +1414,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti @@ -1393,7 +1414,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
1393 } 1414 }
1394 1415
1395 // 获取订单产品 1416 // 获取订单产品
1396 - searchDividendsIncentivesEstimateQuery.OrderGoodDividendsStatus = int32(1) // 查询分红的产品 1417 + searchDividendsIncentivesEstimateQuery.OrderGoodDividendsStatus = int32(1) // 查询分红的产品
1397 if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(searchDividendsIncentivesEstimateQuery)); err != nil { 1418 if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(searchDividendsIncentivesEstimateQuery)); err != nil {
1398 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1419 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1399 } else { 1420 } else {
@@ -76,6 +76,18 @@ func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface @@ -76,6 +76,18 @@ func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface
76 if undertakerUid, ok := queryOptions["undertakerUid"]; ok && undertakerUid.(int64) != 0 { 76 if undertakerUid, ok := queryOptions["undertakerUid"]; ok && undertakerUid.(int64) != 0 {
77 query = query.Where(`dividends_estimate.dividends_user @> '{"userId":"?"}'`, undertakerUid) 77 query = query.Where(`dividends_estimate.dividends_user @> '{"userId":"?"}'`, undertakerUid)
78 } 78 }
  79 + if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
  80 + query = query.Where("cooperation_contract_number = ?", cooperationContractNumber.(string))
  81 + }
  82 + if cooperationContractUndertakerId, ok := queryOptions["cooperationContractUndertakerId"]; ok && cooperationContractUndertakerId.(int64) != 0 {
  83 + query = query.Where("cooperation_contract_undertaker_id = ?", cooperationContractUndertakerId)
  84 + }
  85 + if dividendsParticipateType, ok := queryOptions["dividendsParticipateType"]; ok && dividendsParticipateType.(int32) != 0 {
  86 + query = query.Where("dividends_participate_type = ?", dividendsParticipateType)
  87 + }
  88 + if dividendsStage, ok := queryOptions["dividendsStage"]; ok && dividendsStage.(int32) != 0 {
  89 + query = query.Where("dividends_stage = ?", dividendsStage)
  90 + }
79 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { 91 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
80 query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId) 92 query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
81 } 93 }
@@ -66,6 +66,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -66,6 +66,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
66 if count > 0 { 66 if count > 0 {
67 var dividendsEstimatesCanceled []*domain.DividendsEstimate 67 var dividendsEstimatesCanceled []*domain.DividendsEstimate
68 var orderOrReturnOrderNums []string 68 var orderOrReturnOrderNums []string
  69 + var orderGoodIds []int64
69 for _, dividendsEstimate := range dividendsEstimates { 70 for _, dividendsEstimate := range dividendsEstimates {
70 if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销 71 if dividendsEstimate.DividendsType == 1 || dividendsEstimate.DividendsType == 2 { // 1.订单分红 2.退货冲销
71 // 自定义查询 72 // 自定义查询
@@ -132,6 +133,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -132,6 +133,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
132 dividendsEstimatesRelative[i].Operator = operator 133 dividendsEstimatesRelative[i].Operator = operator
133 // 获取相关订单/退货单号 134 // 获取相关订单/退货单号
134 orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum) 135 orderOrReturnOrderNums = append(orderOrReturnOrderNums, dividendsEstimatesRelative[i].OrderOrReturnedOrderNum)
  136 + orderGoodIds = append(orderGoodIds, dividendsEstimatesRelative[i].OrderGoodId)
135 } 137 }
136 dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) 138 dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative)
137 if err3 != nil { 139 if err3 != nil {
@@ -229,7 +231,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -229,7 +231,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
229 // 分红退货单 231 // 分红退货单
230 var returnedOrderNums []string 232 var returnedOrderNums []string
231 233
232 - if len(orderOrReturnOrderNums) > 0 { 234 + if len(orderOrReturnOrderNums) > 0 { // 业绩分红
233 // 订单/退货单号数组去重 235 // 订单/退货单号数组去重
234 orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums) 236 orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums)
235 237
@@ -254,22 +256,31 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -254,22 +256,31 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
254 return nil, err4 256 return nil, err4
255 } else { 257 } else {
256 if countDividendsOrder > 0 { 258 if countDividendsOrder > 0 {
257 - for i, _ := range orders {  
258 - orders[i].DividendStatus = 1 259 + for i, order := range orders {
  260 + if len(order.Goods) == len(orderGoodIds) { // 1.全部产品取消分红预算
  261 + orders[i].DividendStatus = 1
  262 + } else if len(order.Goods) > len(orderGoodIds) { // 3.部分产品被取消分红预算
  263 + orders[i].DividendStatus = 3
  264 + }
  265 + orders[i].DividendStatus = order.DividendStatus
259 } 266 }
  267 +
260 // 保存订单状态 268 // 保存订单状态
261 if _, err6 := dividendsOrderRepository.UpdateMany(orders); err6 != nil { 269 if _, err6 := dividendsOrderRepository.UpdateMany(orders); err6 != nil {
262 return nil, err6 270 return nil, err6
263 } 271 }
  272 +
264 // 获取订单编号 273 // 获取订单编号
265 ordersNumbers := make([]string, 0) 274 ordersNumbers := make([]string, 0)
266 for _, order := range orders { 275 for _, order := range orders {
267 ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber) 276 ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber)
268 } 277 }
  278 +
269 // 获取分红订单产品并更新产品状态 279 // 获取分红订单产品并更新产品状态
270 if len(ordersNumbers) > 0 { 280 if len(ordersNumbers) > 0 {
271 if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{ 281 if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
272 - "orderNumbers": ordersNumbers, 282 + //"orderNumbers": ordersNumbers,
  283 + "orderGoodIds": orderGoodIds,
273 "companyId": dividendsEstimates[0].Company.CompanyId, 284 "companyId": dividendsEstimates[0].Company.CompanyId,
274 "orgId": dividendsEstimates[0].Org.OrgId, 285 "orgId": dividendsEstimates[0].Org.OrgId,
275 }); err != nil { 286 }); err != nil {
@@ -299,24 +310,33 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -299,24 +310,33 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
299 return nil, err5 310 return nil, err5
300 } else { 311 } else {
301 if countDividendsReturnedOrder > 0 { 312 if countDividendsReturnedOrder > 0 {
302 - for i, _ := range returnedOrders {  
303 - returnedOrders[i].DividendStatus = 1 313 + for i, returnedOrder := range returnedOrders {
  314 + if len(returnedOrder.Goods) == len(orderGoodIds) { // 1.全部产品取消分红预算
  315 + returnedOrders[i].DividendStatus = 1
  316 + } else if len(returnedOrder.Goods) > len(orderGoodIds) { // 3.部分产品被取消分红预算
  317 + returnedOrders[i].DividendStatus = 3
  318 + }
  319 + returnedOrders[i].DividendStatus = returnedOrder.DividendStatus
304 } 320 }
  321 +
305 // 保存退货单状态 322 // 保存退货单状态
306 if _, err7 := dividendsReturnedOrderRepository.UpdateMany(returnedOrders); err7 != nil { 323 if _, err7 := dividendsReturnedOrderRepository.UpdateMany(returnedOrders); err7 != nil {
307 return nil, err7 324 return nil, err7
308 } 325 }
  326 +
309 // 获取订单编号 327 // 获取订单编号
310 returnedOrdersNumbers := make([]string, 0) 328 returnedOrdersNumbers := make([]string, 0)
311 for _, returnedOrder := range returnedOrders { 329 for _, returnedOrder := range returnedOrders {
312 returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber) 330 returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber)
313 } 331 }
  332 +
314 // 获取退货单产品并更新产品状态 333 // 获取退货单产品并更新产品状态
315 if len(returnedOrdersNumbers) > 0 { 334 if len(returnedOrdersNumbers) > 0 {
316 if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{ 335 if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{
317 - "returnedOrderNumbers": returnedOrdersNumbers,  
318 - "companyId": dividendsEstimates[0].Company.CompanyId,  
319 - "orgId": dividendsEstimates[0].Org.OrgId, 336 + //"returnedOrderNumbers": returnedOrdersNumbers,
  337 + "orderGoodIds": orderGoodIds,
  338 + "companyId": dividendsEstimates[0].Company.CompanyId,
  339 + "orgId": dividendsEstimates[0].Org.OrgId,
320 }); err != nil { 340 }); err != nil {
321 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 341 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
322 } else { 342 } else {
@@ -53,9 +53,13 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -53,9 +53,13 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
53 if utils.IsContain64(undertakerUIDs, undertaker.UndertakerId) { 53 if utils.IsContain64(undertakerUIDs, undertaker.UndertakerId) {
54 // 判断承接人在当前阶段是否已经分红 54 // 判断承接人在当前阶段是否已经分红
55 undertakerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ 55 undertakerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
56 - "undertakerUid": undertaker.UserId,  
57 - "companyId": contract.Company.CompanyId,  
58 - "orgId": contract.Org.OrgId, 56 + "cooperationContractUndertakerId": undertaker.UndertakerId,
  57 + "dividendsParticipateType": int32(1), // 承接人类型
  58 + "cooperationContractNumber": contract.CooperationContractNumber,
  59 + "dividendsStage": moneyIncentivesRuleMatched.MoneyIncentivesStage,
  60 + "undertakerUid": undertaker.UserId,
  61 + "companyId": contract.Company.CompanyId,
  62 + "orgId": contract.Org.OrgId,
59 }) 63 })
60 if err != nil { 64 if err != nil {
61 return nil, err 65 return nil, err
@@ -89,9 +93,13 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -89,9 +93,13 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
89 // 判断业务员在当前阶段是否已经分红 93 // 判断业务员在当前阶段是否已经分红
90 if undertaker.Salesman != nil { 94 if undertaker.Salesman != nil {
91 salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ 95 salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
92 - "undertakerUid": undertaker.Salesman.UserId,  
93 - "companyId": contract.Company.CompanyId,  
94 - "orgId": contract.Org.OrgId, 96 + "cooperationContractUndertakerId": undertaker.UndertakerId,
  97 + "dividendsParticipateType": int32(3), // 承接人类型
  98 + "cooperationContractNumber": contract.CooperationContractNumber,
  99 + "dividendsStage": moneyIncentivesRuleMatched.MoneyIncentivesStage,
  100 + "undertakerUid": undertaker.Salesman.UserId,
  101 + "companyId": contract.Company.CompanyId,
  102 + "orgId": contract.Org.OrgId,
95 }) 103 })
96 if err != nil { 104 if err != nil {
97 return nil, err 105 return nil, err
@@ -126,9 +134,13 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -126,9 +134,13 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
126 // 判断推荐人在当前阶段是否已经分红 134 // 判断推荐人在当前阶段是否已经分红
127 if undertaker.Referrer != nil { 135 if undertaker.Referrer != nil {
128 referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ 136 referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
129 - "undertakerUid": undertaker.Referrer.UserId,  
130 - "companyId": contract.Company.CompanyId,  
131 - "orgId": contract.Org.OrgId, 137 + "cooperationContractUndertakerId": undertaker.UndertakerId,
  138 + "dividendsParticipateType": int32(2), // 承接人类型
  139 + "cooperationContractNumber": contract.CooperationContractNumber,
  140 + "dividendsStage": moneyIncentivesRuleMatched.MoneyIncentivesStage,
  141 + "undertakerUid": undertaker.Referrer.UserId,
  142 + "companyId": contract.Company.CompanyId,
  143 + "orgId": contract.Org.OrgId,
132 }) 144 })
133 if err != nil { 145 if err != nil {
134 return nil, err 146 return nil, err