|
@@ -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,10 +1442,22 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
@@ -1431,10 +1442,22 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
1431
|
}
|
1442
|
}
|
1432
|
|
1443
|
|
1433
|
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
|
1444
|
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
|
1434
|
- if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
|
|
|
1435
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
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 {
|
|
|
1456
|
+ if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
|
|
|
1457
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1458
|
+ }
|
|
|
1459
|
+ moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
|
1436
|
}
|
1460
|
}
|
1437
|
- moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
|
|
|
1438
|
}
|
1461
|
}
|
1439
|
|
1462
|
|
1440
|
if err := transactionContext.CommitTransaction(); err != nil {
|
1463
|
if err := transactionContext.CommitTransaction(); err != nil {
|