Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/allied-crea…
…tion-cooperation into test
正在显示
9 个修改的文件
包含
106 行增加
和
17 行删除
@@ -281,8 +281,22 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -281,8 +281,22 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
281 | cooperationApplicationRepository = value | 281 | cooperationApplicationRepository = value |
282 | } | 282 | } |
283 | 283 | ||
284 | + var getCooperationProjectQuerySpecific *query.GetCooperationProjectQuery | ||
285 | + if getCooperationProjectQuery.CooperationProjectId != 0 { // 根据ID查询 | ||
286 | + getCooperationProjectQuerySpecific = &query.GetCooperationProjectQuery{ | ||
287 | + CooperationProjectId: getCooperationProjectQuery.CooperationProjectId, | ||
288 | + CooperationProjectNumber: "", | ||
289 | + CompanyId: 0, | ||
290 | + OrgId: 0, | ||
291 | + UserId: 0, | ||
292 | + UserBaseId: 0, | ||
293 | + } | ||
294 | + } else if getCooperationProjectQuery.CooperationProjectNumber != "" { // 根据编号查询 | ||
295 | + getCooperationProjectQuerySpecific = getCooperationProjectQuery | ||
296 | + } | ||
297 | + | ||
284 | // 获取共创项目 | 298 | // 获取共创项目 |
285 | - cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery)) | 299 | + cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuerySpecific)) |
286 | if err != nil { | 300 | if err != nil { |
287 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 301 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
288 | } | 302 | } |
@@ -306,8 +320,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -306,8 +320,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
306 | gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ | 320 | gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ |
307 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, | 321 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, |
308 | "user": true, | 322 | "user": true, |
309 | - "companyId": getCooperationProjectQuery.CompanyId, | ||
310 | - "orgId": getCooperationProjectQuery.OrgId, | 323 | + "companyId": cooperationProject.Company.CompanyId, |
324 | + "orgId": cooperationProject.Org.OrgId, | ||
311 | }) | 325 | }) |
312 | if err != nil { | 326 | if err != nil { |
313 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 327 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -320,8 +334,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -320,8 +334,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
320 | gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ | 334 | gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ |
321 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, | 335 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, |
322 | "partner": true, | 336 | "partner": true, |
323 | - "companyId": getCooperationProjectQuery.CompanyId, | ||
324 | - "orgId": getCooperationProjectQuery.OrgId, | 337 | + "companyId": cooperationProject.Company.CompanyId, |
338 | + "orgId": cooperationProject.Org.OrgId, | ||
325 | }) | 339 | }) |
326 | if err != nil { | 340 | if err != nil { |
327 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 341 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -337,6 +351,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -337,6 +351,7 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
337 | 351 | ||
338 | // 返回所有员工类型的申请通过人 | 352 | // 返回所有员工类型的申请通过人 |
339 | applicants := make([]*domain.User, 0) | 353 | applicants := make([]*domain.User, 0) |
354 | + | ||
340 | // 获取当前项目的所有申请 | 355 | // 获取当前项目的所有申请 |
341 | if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{ | 356 | if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{ |
342 | "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber, | 357 | "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber, |
@@ -157,6 +157,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | @@ -157,6 +157,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred | ||
157 | OrderGoodAmount: dividendsEstimate.OrderGoodAmount, | 157 | OrderGoodAmount: dividendsEstimate.OrderGoodAmount, |
158 | CooperationContractNumber: dividendsEstimate.CooperationContractNumber, | 158 | CooperationContractNumber: dividendsEstimate.CooperationContractNumber, |
159 | }) | 159 | }) |
160 | + | ||
160 | settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount | 161 | settlementAmount = settlementAmount + dividendsEstimate.DividendsAmount |
161 | 162 | ||
162 | goodAmountCount = goodAmountCount + dividendsEstimate.OrderGoodAmount | 163 | goodAmountCount = goodAmountCount + dividendsEstimate.OrderGoodAmount |
@@ -30,6 +30,10 @@ type SearchMoneyIncentivesEstimateQuery struct { | @@ -30,6 +30,10 @@ type SearchMoneyIncentivesEstimateQuery struct { | ||
30 | PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` | 30 | PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` |
31 | // 激励方式 | 31 | // 激励方式 |
32 | IncentivesType int32 `cname:"激励方式" json:"incentivesType,omitempty"` | 32 | IncentivesType int32 `cname:"激励方式" json:"incentivesType,omitempty"` |
33 | + // 合约状态,1正常,2暂停 | ||
34 | + Status int32 `cname:"合约状态" json:"status,omitempty"` | ||
35 | + // 查询限制 | ||
36 | + OffsetLimit bool `json:"offsetLimit,omitempty"` | ||
33 | } | 37 | } |
34 | 38 | ||
35 | func (searchMoneyIncentivesEstimateQuery *SearchMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) { | 39 | func (searchMoneyIncentivesEstimateQuery *SearchMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) { |
@@ -1380,6 +1380,8 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1380,6 +1380,8 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
1380 | 1380 | ||
1381 | // 查找共创合约 | 1381 | // 查找共创合约 |
1382 | searchMoneyIncentivesEstimateQuery.IncentivesType = 2 | 1382 | searchMoneyIncentivesEstimateQuery.IncentivesType = 2 |
1383 | + searchMoneyIncentivesEstimateQuery.Status = 1 | ||
1384 | + searchMoneyIncentivesEstimateQuery.OffsetLimit = false | ||
1383 | if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil { | 1385 | if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil { |
1384 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1386 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1385 | } else { | 1387 | } else { |
@@ -1387,15 +1389,19 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1387,15 +1389,19 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
1387 | for _, cooperationContract := range cooperationContracts { | 1389 | for _, cooperationContract := range cooperationContracts { |
1388 | // 阶段承接人map | 1390 | // 阶段承接人map |
1389 | stageUndertakerMap := make(map[int32][]*domain.Undertaker) | 1391 | stageUndertakerMap := make(map[int32][]*domain.Undertaker) |
1392 | + | ||
1390 | // 阶段承接人列表 | 1393 | // 阶段承接人列表 |
1391 | stageAndUndertaker := make([]*dto.StageAndUndertaker, 0) | 1394 | stageAndUndertaker := make([]*dto.StageAndUndertaker, 0) |
1395 | + | ||
1392 | // 初始化阶段承接人map | 1396 | // 初始化阶段承接人map |
1393 | for _, rule := range cooperationContract.MoneyIncentivesRules { | 1397 | for _, rule := range cooperationContract.MoneyIncentivesRules { |
1394 | stageUndertakerMap[rule.MoneyIncentivesStage] = make([]*domain.Undertaker, 0) | 1398 | stageUndertakerMap[rule.MoneyIncentivesStage] = make([]*domain.Undertaker, 0) |
1395 | } | 1399 | } |
1400 | + | ||
1396 | log.Logger.Info("阶段承接人map初始化", map[string]interface{}{ | 1401 | log.Logger.Info("阶段承接人map初始化", map[string]interface{}{ |
1397 | "stageUndertakerMap": stageUndertakerMap, | 1402 | "stageUndertakerMap": stageUndertakerMap, |
1398 | }) | 1403 | }) |
1404 | + | ||
1399 | // 获取承接人 | 1405 | // 获取承接人 |
1400 | for _, undertaker := range cooperationContract.Undertakers { | 1406 | for _, undertaker := range cooperationContract.Undertakers { |
1401 | // 查询承接人分红预算单 | 1407 | // 查询承接人分红预算单 |
@@ -1404,6 +1410,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1404,6 +1410,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
1404 | "companyId": cooperationContract.Company.CompanyId, | 1410 | "companyId": cooperationContract.Company.CompanyId, |
1405 | "orgId": cooperationContract.Org.OrgId, | 1411 | "orgId": cooperationContract.Org.OrgId, |
1406 | "dividendsUserId": undertaker.UserId, | 1412 | "dividendsUserId": undertaker.UserId, |
1413 | + "offsetLimit": false, | ||
1407 | }); err != nil { | 1414 | }); err != nil { |
1408 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1415 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1409 | } else { | 1416 | } else { |
@@ -1413,16 +1420,20 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1413,16 +1420,20 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
1413 | stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker) | 1420 | stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker) |
1414 | } | 1421 | } |
1415 | } | 1422 | } |
1423 | + break | ||
1416 | } else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励 | 1424 | } else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励 |
1417 | for i, _ := range stageUndertakerMap { | 1425 | for i, _ := range stageUndertakerMap { |
1418 | stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) | 1426 | stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) |
1419 | } | 1427 | } |
1428 | + break | ||
1420 | } | 1429 | } |
1421 | } | 1430 | } |
1422 | } | 1431 | } |
1432 | + | ||
1423 | log.Logger.Info("阶段承接人map", map[string]interface{}{ | 1433 | log.Logger.Info("阶段承接人map", map[string]interface{}{ |
1424 | "stageUndertakerMap": stageUndertakerMap, | 1434 | "stageUndertakerMap": stageUndertakerMap, |
1425 | }) | 1435 | }) |
1436 | + | ||
1426 | for k, v := range stageUndertakerMap { | 1437 | for k, v := range stageUndertakerMap { |
1427 | stageAndUndertaker = append(stageAndUndertaker, &dto.StageAndUndertaker{ | 1438 | stageAndUndertaker = append(stageAndUndertaker, &dto.StageAndUndertaker{ |
1428 | Stage: k, | 1439 | Stage: k, |
@@ -1431,11 +1442,23 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1431,11 +1442,23 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
1431 | } | 1442 | } |
1432 | 1443 | ||
1433 | moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{} | 1444 | moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{} |
1445 | + | ||
1446 | + // 判断当前合约的承接人是否全部分红 | ||
1447 | + allEstimate := true | ||
1448 | + for i, _ := range stageUndertakerMap { | ||
1449 | + if len(stageUndertakerMap[i]) > 0 { | ||
1450 | + allEstimate = false | ||
1451 | + break | ||
1452 | + } | ||
1453 | + } | ||
1454 | + | ||
1455 | + if !allEstimate { | ||
1434 | if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil { | 1456 | if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil { |
1435 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1457 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1436 | } | 1458 | } |
1437 | moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto) | 1459 | moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto) |
1438 | } | 1460 | } |
1461 | + } | ||
1439 | 1462 | ||
1440 | if err := transactionContext.CommitTransaction(); err != nil { | 1463 | if err := transactionContext.CommitTransaction(); err != nil { |
1441 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1464 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -1122,8 +1122,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | @@ -1122,8 +1122,16 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide | ||
1122 | } | 1122 | } |
1123 | orderTime := utils.TransformTimestampToTime(orderTimeInt) | 1123 | orderTime := utils.TransformTimestampToTime(orderTimeInt) |
1124 | 1124 | ||
1125 | + // 退货单ID类型转换 | ||
1126 | + dividendsReturnedOrderId, err := strconv.ParseInt(updateDividendsReturnedOrderCommand.DividendsReturnedOrderId, 10, 64) | ||
1127 | + if err != nil { | ||
1128 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单ID类型错误") | ||
1129 | + } | ||
1130 | + | ||
1125 | // 获取分红退货单 | 1131 | // 获取分红退货单 |
1126 | - dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderId": updateDividendsReturnedOrderCommand.DividendsReturnedOrderId}) | 1132 | + dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{ |
1133 | + "dividendsReturnedOrderId": dividendsReturnedOrderId, | ||
1134 | + }) | ||
1127 | if err != nil { | 1135 | if err != nil { |
1128 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1136 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1129 | } | 1137 | } |
@@ -9,7 +9,7 @@ import ( | @@ -9,7 +9,7 @@ import ( | ||
9 | 9 | ||
10 | type DividendsEstimateDetail struct { | 10 | type DividendsEstimateDetail struct { |
11 | DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户) | 11 | DividendsUser *domain.User `json:"dividendsUser"` // 共创参与(分红用户) |
12 | - DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 | 12 | + DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 1承接人,2推荐人,3关联业务员 |
13 | DividendsStage int32 `json:"dividendsStage"` // 分红阶段 | 13 | DividendsStage int32 `json:"dividendsStage"` // 分红阶段 |
14 | DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 | 14 | DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 |
15 | OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号 | 15 | OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号 |
@@ -60,11 +60,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -60,11 +60,13 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
60 | var dividendsEstimatesCanceled []*domain.DividendsEstimate | 60 | var dividendsEstimatesCanceled []*domain.DividendsEstimate |
61 | var orderOrReturnOrderNums []string | 61 | var orderOrReturnOrderNums []string |
62 | for _, dividendsEstimate := range dividendsEstimates { | 62 | for _, dividendsEstimate := range dividendsEstimates { |
63 | + if dividendsEstimate.DividendsType != 3 { // 非金额激励分红预算单处理 | ||
63 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | 64 | // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 |
64 | if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ | 65 | if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ |
65 | "companyId": dividendsEstimate.Company.CompanyId, | 66 | "companyId": dividendsEstimate.Company.CompanyId, |
66 | "orgId": dividendsEstimate.Org.OrgId, | 67 | "orgId": dividendsEstimate.Org.OrgId, |
67 | "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, | 68 | "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, |
69 | + "offsetLimit": false, | ||
68 | }); err2 != nil { | 70 | }); err2 != nil { |
69 | return nil, err2 | 71 | return nil, err2 |
70 | } else { | 72 | } else { |
@@ -82,12 +84,37 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -82,12 +84,37 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
82 | dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) | 84 | dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) |
83 | } | 85 | } |
84 | } | 86 | } |
87 | + } else if dividendsEstimate.DividendsType == 3 { | ||
88 | + // 根据当前分红预算单的分红订单号或退货单号获取相关的分红预算单 | ||
89 | + if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ | ||
90 | + "companyId": dividendsEstimate.Company.CompanyId, | ||
91 | + "orgId": dividendsEstimate.Org.OrgId, | ||
92 | + "cooperationContractNumber": dividendsEstimate.CooperationContractNumber, | ||
93 | + "dividendsType": int32(3), | ||
94 | + "offsetLimit": false, | ||
95 | + }); err2 != nil { | ||
96 | + return nil, err2 | ||
97 | + } else { | ||
98 | + if countRelative > 0 { | ||
99 | + for i, _ := range dividendsEstimatesRelative { | ||
100 | + dividendsEstimatesRelative[i].IsCanceled = true | ||
101 | + dividendsEstimatesRelative[i].Operator = operator | ||
102 | + } | ||
103 | + dividendsEstimatesRelativeCanceled, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimatesRelative) | ||
104 | + if err3 != nil { | ||
105 | + return nil, err3 | ||
106 | + } | ||
107 | + dividendsEstimatesCanceled = append(dividendsEstimatesCanceled, dividendsEstimatesRelativeCanceled...) | ||
108 | + } | ||
109 | + } | ||
110 | + } | ||
85 | } | 111 | } |
86 | 112 | ||
87 | // 分红订单或分红退货单状态变更 | 113 | // 分红订单或分红退货单状态变更 |
88 | var orderNums []string | 114 | var orderNums []string |
89 | var returnedOrderNums []string | 115 | var returnedOrderNums []string |
90 | 116 | ||
117 | + if len(orderOrReturnOrderNums) > 0 { | ||
91 | // 订单/退货单号数组去重 | 118 | // 订单/退货单号数组去重 |
92 | orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums) | 119 | orderOrReturnOrderNumsWithoutDup := utils.RemoveDuplication(orderOrReturnOrderNums) |
93 | for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup { | 120 | for _, orderNullNum := range orderOrReturnOrderNumsWithoutDup { |
@@ -98,7 +125,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -98,7 +125,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
98 | } | 125 | } |
99 | } | 126 | } |
100 | 127 | ||
101 | - // 获取分红订单 | 128 | + // 获取分红订单并更新分红订单产品的状态 |
129 | + if len(orderNums) > 0 { | ||
102 | if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{ | 130 | if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{ |
103 | "companyId": dividendsEstimates[0].Company.CompanyId, | 131 | "companyId": dividendsEstimates[0].Company.CompanyId, |
104 | "orgId": dividendsEstimates[0].Org.OrgId, | 132 | "orgId": dividendsEstimates[0].Org.OrgId, |
@@ -120,6 +148,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -120,6 +148,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
120 | ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber) | 148 | ordersNumbers = append(ordersNumbers, order.DividendsOrderNumber) |
121 | } | 149 | } |
122 | // 获取分红订单产品并更新产品状态 | 150 | // 获取分红订单产品并更新产品状态 |
151 | + if len(ordersNumbers) > 0 { | ||
123 | if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{ | 152 | if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{ |
124 | "orderNumbers": ordersNumbers, | 153 | "orderNumbers": ordersNumbers, |
125 | "companyId": dividendsEstimates[0].Company.CompanyId, | 154 | "companyId": dividendsEstimates[0].Company.CompanyId, |
@@ -138,8 +167,11 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -138,8 +167,11 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
138 | } | 167 | } |
139 | } | 168 | } |
140 | } | 169 | } |
170 | + } | ||
171 | + } | ||
141 | 172 | ||
142 | - // 获取分红退货单 | 173 | + // 获取分红退货单并更新订单产品的状态 |
174 | + if len(returnedOrderNums) > 0 { | ||
143 | if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{ | 175 | if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{ |
144 | "companyId": dividendsEstimates[0].Company.CompanyId, | 176 | "companyId": dividendsEstimates[0].Company.CompanyId, |
145 | "orgId": dividendsEstimates[0].Org.OrgId, | 177 | "orgId": dividendsEstimates[0].Org.OrgId, |
@@ -161,6 +193,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -161,6 +193,7 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
161 | returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber) | 193 | returnedOrdersNumbers = append(returnedOrdersNumbers, returnedOrder.DividendsReturnedOrderNumber) |
162 | } | 194 | } |
163 | // 获取退货单产品并更新产品状态 | 195 | // 获取退货单产品并更新产品状态 |
196 | + if len(returnedOrdersNumbers) > 0 { | ||
164 | if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{ | 197 | if countOrderGood, orderGoodsFound, err := orderGoodRepository.Find(map[string]interface{}{ |
165 | "returnedOrderNumbers": returnedOrdersNumbers, | 198 | "returnedOrderNumbers": returnedOrdersNumbers, |
166 | "companyId": dividendsEstimates[0].Company.CompanyId, | 199 | "companyId": dividendsEstimates[0].Company.CompanyId, |
@@ -179,7 +212,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | @@ -179,7 +212,9 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst | ||
179 | } | 212 | } |
180 | } | 213 | } |
181 | } | 214 | } |
182 | - | 215 | + } |
216 | + } | ||
217 | + } | ||
183 | return dividendsEstimatesCanceled, nil | 218 | return dividendsEstimatesCanceled, nil |
184 | } | 219 | } |
185 | } | 220 | } |
@@ -44,7 +44,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -44,7 +44,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
44 | 44 | ||
45 | // 判断金额激励阶段是否合法 | 45 | // 判断金额激励阶段是否合法 |
46 | currentTime := time.Now() | 46 | currentTime := time.Now() |
47 | - if currentTime.Before(moneyIncentivesRuleMatched.MoneyIncentivesStageStart) { | 47 | + if currentTime.Before(moneyIncentivesRuleMatched.MoneyIncentivesTime) { |
48 | return nil, fmt.Errorf("还未到分红时间") | 48 | return nil, fmt.Errorf("还未到分红时间") |
49 | } | 49 | } |
50 | 50 | ||
@@ -61,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -61,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
61 | return nil, err | 61 | return nil, err |
62 | } | 62 | } |
63 | if undertakerEstimated { | 63 | if undertakerEstimated { |
64 | - return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红") | 64 | + return nil, fmt.Errorf("承接人 " + undertaker.UserName + " 已分红") |
65 | } else { | 65 | } else { |
66 | undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64() | 66 | undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Float64() |
67 | //Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64() | 67 | //Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage)).Div(decimal.NewFromFloat(100)))).Float64() |
@@ -80,7 +80,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -80,7 +80,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
80 | Status: undertaker.Status, | 80 | Status: undertaker.Status, |
81 | Company: undertaker.Company, | 81 | Company: undertaker.Company, |
82 | }, | 82 | }, |
83 | - DividendsParticipateType: domain.MONEY_INCENTIVES, | 83 | + DividendsParticipateType: 1, |
84 | DividendsStage: stage, | 84 | DividendsStage: stage, |
85 | DividendsAmount: undertakerDividendsAmount, | 85 | DividendsAmount: undertakerDividendsAmount, |
86 | }) | 86 | }) |
@@ -114,7 +114,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -114,7 +114,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
114 | UserPhone: undertaker.Salesman.UserPhone, | 114 | UserPhone: undertaker.Salesman.UserPhone, |
115 | Company: undertaker.Salesman.Company, | 115 | Company: undertaker.Salesman.Company, |
116 | }, | 116 | }, |
117 | - DividendsParticipateType: domain.MONEY_INCENTIVES, | 117 | + DividendsParticipateType: 3, |
118 | DividendsStage: stage, | 118 | DividendsStage: stage, |
119 | DividendsAmount: undertakerDividendsAmount, | 119 | DividendsAmount: undertakerDividendsAmount, |
120 | }) | 120 | }) |
@@ -122,7 +122,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -122,7 +122,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
122 | 122 | ||
123 | } | 123 | } |
124 | 124 | ||
125 | - // 判断关联业务员在当前阶段是否已经分红 | 125 | + // 判断推荐人在当前阶段是否已经分红 |
126 | if undertaker.Referrer != nil { | 126 | if undertaker.Referrer != nil { |
127 | referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ | 127 | referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ |
128 | "undertakerUid": undertaker.Referrer.UserId, | 128 | "undertakerUid": undertaker.Referrer.UserId, |
@@ -133,7 +133,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -133,7 +133,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
133 | return nil, err | 133 | return nil, err |
134 | } | 134 | } |
135 | if referrerEstimated { | 135 | if referrerEstimated { |
136 | - return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红") | 136 | + return nil, fmt.Errorf("推荐人 " + undertaker.Referrer.UserName + " 已分红") |
137 | } else { | 137 | } else { |
138 | undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64() | 138 | undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64() |
139 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ | 139 | dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ |
@@ -150,7 +150,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | @@ -150,7 +150,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do | ||
150 | UserPhone: undertaker.Referrer.UserPhone, | 150 | UserPhone: undertaker.Referrer.UserPhone, |
151 | Company: undertaker.Referrer.Company, | 151 | Company: undertaker.Referrer.Company, |
152 | }, | 152 | }, |
153 | - DividendsParticipateType: domain.MONEY_INCENTIVES, | 153 | + DividendsParticipateType: 2, |
154 | DividendsStage: stage, | 154 | DividendsStage: stage, |
155 | DividendsAmount: undertakerDividendsAmount, | 155 | DividendsAmount: undertakerDividendsAmount, |
156 | }) | 156 | }) |
@@ -308,6 +308,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | @@ -308,6 +308,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | ||
308 | if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 { | 308 | if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 { |
309 | query.Where("cooperation_contract_number in (?)", pg.In(v)) | 309 | query.Where("cooperation_contract_number in (?)", pg.In(v)) |
310 | } | 310 | } |
311 | + if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { | ||
312 | + query.Where("cooperation_contract_number = ?", cooperationContractNumber) | ||
313 | + } | ||
311 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { | 314 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { |
312 | query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId) | 315 | query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId) |
313 | } | 316 | } |
-
请 注册 或 登录 后发表评论