|
|
|
@ -203,9 +203,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
//算分
|
|
|
|
|
if (BigDecimal.ZERO.compareTo(userRoundOwnFunds) == 0 && rightAvailableFunds.compareTo(userRoundPreferredLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
if (subtract.compareTo(rightOwnFunds) <= 0 && subtract.compareTo(BigDecimal.ZERO) >= 0) { //如果可用资金 - 优先级LP <= 需要分配的自有资金剩余金额全部给 自有资金,第二轮都为0
|
|
|
|
@ -215,9 +215,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
//判断算分
|
|
|
|
|
if (subtract.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
profitDistribution.setRoundOwnFunds(rightOwnFunds);
|
|
|
|
@ -231,10 +231,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
//算分 共五分,可用资金1分,其他共4分,错一个不得分
|
|
|
|
|
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
|
|
|
|
|
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreMapper.updateByPrimaryKey(performanceScore);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
} else if (type == 2) { //2:自有资金/优先级LP/劣后级LP
|
|
|
|
|
if (profitDistribution.getUserRemainingEarningsSubordinatedLp() == null || profitDistribution.getUserRoundSubordinatedLp() == null) {
|
|
|
|
@ -260,9 +259,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
if (BigDecimal.ZERO.compareTo(userRoundOwnFunds) == 0 && rightAvailableFunds.compareTo(userRoundPreferredLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRoundSubordinatedLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
profitDistribution.setRoundPreferredLp(rightFundraisingAmount); //下面的情况优先级LP都足够
|
|
|
|
@ -274,9 +273,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0 &&
|
|
|
|
|
subtract.compareTo(userRoundSubordinatedLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
//分配完优劣LP后剩余的钱
|
|
|
|
@ -290,8 +289,8 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0 &&
|
|
|
|
|
subordinatedLp.compareTo(userRoundSubordinatedLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0) {
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
// 第一轮归还劣后级LP本金
|
|
|
|
@ -316,11 +315,10 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 &&
|
|
|
|
|
userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 &&
|
|
|
|
|
userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreMapper.updateByPrimaryKey(performanceScore);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
} else if (type == 3) { //3:银行借款/自有资金/优先级LP
|
|
|
|
|
if (profitDistribution.getUserRoundBankLoan() == null) {
|
|
|
|
@ -346,9 +344,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
if (BigDecimal.ZERO.compareTo(userRoundOwnFunds) == 0 && rightAvailableFunds.compareTo(userRoundBankLoan) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
profitDistribution.setRoundBankLoan(rightBankLoan); //下面的情况优先级银行贷款都足够
|
|
|
|
@ -360,9 +358,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
if (BigDecimal.ZERO.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
|
|
|
|
|
subtractBankLoan.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
//分配完优先级LP后剩余的钱给自有资金
|
|
|
|
@ -375,9 +373,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
if (subtractRoundOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
|
|
|
|
|
rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
profitDistribution.setRoundPreferredLp(rightFundraisingAmount);
|
|
|
|
@ -392,10 +390,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
|
|
|
|
|
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 &&
|
|
|
|
|
rightBankLoan.compareTo(userRoundBankLoan) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreMapper.updateByPrimaryKey(performanceScore);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
} else { //4:银行借款/优先级LP/劣后级LP/自有资金
|
|
|
|
|
if (profitDistribution.getUserRemainingEarningsSubordinatedLp() == null || profitDistribution.getUserRoundSubordinatedLp() == null) {
|
|
|
|
@ -428,9 +425,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRoundSubordinatedLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
profitDistribution.setRoundBankLoan(rightBankLoan); //下面的情况优先级银行贷款都足够
|
|
|
|
@ -443,9 +440,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
subtractBankLoan.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRoundSubordinatedLp) == 0
|
|
|
|
|
&& BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
//分配完优先级LP后剩余的钱给劣后级LP
|
|
|
|
@ -458,9 +455,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
if (subtractSubordinatedLp.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
|
|
|
|
|
rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -475,16 +472,17 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
subordinatedLp.compareTo(userRoundSubordinatedLp) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && subordinatedLp.compareTo(userRoundSubordinatedLp) == 0 &&
|
|
|
|
|
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 第一轮归还劣后级LP本金和银行利息
|
|
|
|
|
profitDistribution.setRoundSubordinatedLp(subordinatedLp);
|
|
|
|
|
profitDistribution.setRoundOwnFunds(rightOwnFunds);
|
|
|
|
|
profitDistribution.setRoundBankLoan(rightBankLoan);
|
|
|
|
|
residualIncome = residualIncome.subtract(subordinatedLp).subtract(rightBankLoan); //剩余收益
|
|
|
|
|
residualIncome = residualIncome.subtract(subordinatedLp).subtract(rightBankLoan).subtract(rightOwnFunds); //剩余收益
|
|
|
|
|
//2.剩余收益分配比例为,自有资金25%,优先级LP 30%,劣后级LP 45%
|
|
|
|
|
BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金
|
|
|
|
|
BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.3)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金
|
|
|
|
@ -497,10 +495,9 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
|
|
|
|
|
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 &&
|
|
|
|
|
rightBankLoan.compareTo(userRoundBankLoan) == 0 && userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 &&
|
|
|
|
|
userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) {
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
|
|
|
|
|
}
|
|
|
|
|
performanceScore.setProfitDistributionTime(new Date());
|
|
|
|
|
performanceScoreMapper.updateByPrimaryKey(performanceScore);
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|