编写收益分配页面,修改算分公共方法

master
xiaoCJ 1 year ago
parent 85183fabc8
commit 9412996231

@ -49,6 +49,7 @@ public class FoundProjectController {
@GetMapping("getBP")
@ApiOperation("BP按钮")
@AnonymousAccess
public ResponseEntity<FileSystemResource> getFundraising(@ApiParam("bp路径") @RequestParam String bp_path) {
String PDFPath = filePath + bp_path;
File videoFile = new File(PDFPath);
@ -87,6 +88,7 @@ public class FoundProjectController {
@GetMapping("getProjectApproval")
@ApiOperation("立项回显")
@AnonymousAccess
public ResultEntity getProjectApproval(@ApiParam("流程ID") @RequestParam String flowId){
FoundProject foundProject=foundProjectService.selectByFlowId(flowId);
foundProject.setFinancialDueDiligence(null);

@ -1,17 +1,16 @@
package com.sztzjy.fund_investment.controller;
import com.sztzjy.fund_investment.annotation.AnonymousAccess;
import com.sztzjy.fund_investment.entity.Fundraising;
import com.sztzjy.fund_investment.entity.ProfitDistribution;
import com.sztzjy.fund_investment.service.ISysFundraisingService;
import com.sztzjy.fund_investment.service.ProfitDistributionService;
import com.sztzjy.fund_investment.util.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
* @Author xcj
@ -23,14 +22,15 @@ import org.springframework.web.bind.annotation.RestController;
public class ProfitDistributionController {
@Autowired
private ProfitDistributionService profitDistributionService;
@Autowired
ISysFundraisingService fundraisingService;
// @AnonymousAccess
// @PostMapping("/submit")
// @ApiOperation("页面提交")
// public void submit(@ApiParam("传id(UUID),flowID,用户输入8个框的内容(可用资金,自有资金和优先级LP必传)") ProfitDistribution profitDistribution) {
// profitDistributionService.submit(profitDistribution);
// }
@AnonymousAccess
@PostMapping("/submit")
@ApiOperation("页面提交")
public ResultEntity submit(@ApiParam("传id(UUID),flowID,用户输入8个框的内容(可用资金,自有资金和优先级LP必传)") ProfitDistribution profitDistribution) {
return profitDistributionService.submit(profitDistribution);
}
@AnonymousAccess
@GetMapping("/echo")
@ -38,4 +38,13 @@ public class ProfitDistributionController {
public ResultEntity<ProfitDistribution> echo(@ApiParam("流程ID") String flowId) {
return new ResultEntity<ProfitDistribution>(profitDistributionService.echo(flowId));
}
@AnonymousAccess
@PostMapping("/getType")
@ApiOperation("返回基金募集的类型")
public Integer submit(@RequestParam String flowId) {
return fundraisingService.selectByFlowId(flowId).getType();
}
}

@ -157,38 +157,38 @@ public class TopicController {
performanceScore.setPracticalCognitionTime(new Date());
//防止后面算分有问题在第一个步骤初始化成0
performanceScore.setKnowledgeAssessmentScore(BigDecimal.ZERO);
performanceScore.setFundraisingScore(BigDecimal.ZERO);
performanceScore.setProjectSearchScore(BigDecimal.ZERO);
performanceScore.setProjectSearchReportScore(BigDecimal.ZERO);
performanceScore.setProjectDueDiligenceScore(BigDecimal.ZERO);
performanceScore.setProjectValuationEstimationRiskScore(BigDecimal.ZERO);
performanceScore.setProjectDueDiligenceBusinessReportScore(BigDecimal.ZERO);
performanceScore.setProjectDueDiligenceFinanceReportScore(BigDecimal.ZERO);
performanceScore.setProjectValuationRelativeScore(BigDecimal.ZERO);
performanceScore.setProjectValuationScore(BigDecimal.ZERO);
performanceScore.setProjectValuationAbsoluteScore(BigDecimal.ZERO);
performanceScore.setProjectUseValuationAbsoluteScore(BigDecimal.ZERO);
performanceScore.setProjectUseValuationRelativeScore(BigDecimal.ZERO);
performanceScore.setInvestmentSigningVlauationReportScore(BigDecimal.ZERO);
performanceScore.setInvestmentSigningDiligenceReportScore(BigDecimal.ZERO);
performanceScore.setInvestmentSigningInvestScore(BigDecimal.ZERO);
performanceScore.setInvestmentSigningScore(BigDecimal.ZERO);
performanceScore.setIpoFlowScore(BigDecimal.ZERO);
performanceScore.setIpoListedConditionScore(BigDecimal.ZERO);
performanceScore.setIpoListedSectorScore(BigDecimal.ZERO);
performanceScore.setNewPricingIssuanceScore(BigDecimal.ZERO);
performanceScore.setPricingIssuanceConfirmScore(BigDecimal.ZERO);
performanceScore.setInitPricingIssuanceScore(BigDecimal.ZERO);
performanceScore.setPricingIssuanceEnteringScore(BigDecimal.ZERO);
performanceScore.setProfitManagementMarketValueScore(BigDecimal.ZERO);
performanceScore.setProfitManagementFundScore(BigDecimal.ZERO);
performanceScore.setProfitManagementFundExitScore(BigDecimal.ZERO);
performanceScore.setProfitManagementMarketValueExitScore(BigDecimal.ZERO);
performanceScore.setProfitDistributionScore(BigDecimal.ZERO);
performanceScore.setInvestmentReportScore(BigDecimal.ZERO);
performanceScore.setExperienceScore(BigDecimal.ZERO);
performanceScore.setTotalScore(BigDecimal.ZERO);
// performanceScore.setKnowledgeAssessmentScore(BigDecimal.ZERO);
// performanceScore.setFundraisingScore(BigDecimal.ZERO);
// performanceScore.setProjectSearchScore(BigDecimal.ZERO);
// performanceScore.setProjectSearchReportScore(BigDecimal.ZERO);
// performanceScore.setProjectDueDiligenceScore(BigDecimal.ZERO);
// performanceScore.setProjectValuationEstimationRiskScore(BigDecimal.ZERO);
// performanceScore.setProjectDueDiligenceBusinessReportScore(BigDecimal.ZERO);
// performanceScore.setProjectDueDiligenceFinanceReportScore(BigDecimal.ZERO);
// performanceScore.setProjectValuationRelativeScore(BigDecimal.ZERO);
// performanceScore.setProjectValuationScore(BigDecimal.ZERO);
// performanceScore.setProjectValuationAbsoluteScore(BigDecimal.ZERO);
// performanceScore.setProjectUseValuationAbsoluteScore(BigDecimal.ZERO);
// performanceScore.setProjectUseValuationRelativeScore(BigDecimal.ZERO);
// performanceScore.setInvestmentSigningVlauationReportScore(BigDecimal.ZERO);
// performanceScore.setInvestmentSigningDiligenceReportScore(BigDecimal.ZERO);
// performanceScore.setInvestmentSigningInvestScore(BigDecimal.ZERO);
// performanceScore.setInvestmentSigningScore(BigDecimal.ZERO);
// performanceScore.setIpoFlowScore(BigDecimal.ZERO);
// performanceScore.setIpoListedConditionScore(BigDecimal.ZERO);
// performanceScore.setIpoListedSectorScore(BigDecimal.ZERO);
// performanceScore.setNewPricingIssuanceScore(BigDecimal.ZERO);
// performanceScore.setPricingIssuanceConfirmScore(BigDecimal.ZERO);
// performanceScore.setInitPricingIssuanceScore(BigDecimal.ZERO);
// performanceScore.setPricingIssuanceEnteringScore(BigDecimal.ZERO);
// performanceScore.setProfitManagementMarketValueScore(BigDecimal.ZERO);
// performanceScore.setProfitManagementFundScore(BigDecimal.ZERO);
// performanceScore.setProfitManagementFundExitScore(BigDecimal.ZERO);
// performanceScore.setProfitManagementMarketValueExitScore(BigDecimal.ZERO);
// performanceScore.setProfitDistributionScore(BigDecimal.ZERO);
// performanceScore.setInvestmentReportScore(BigDecimal.ZERO);
// performanceScore.setExperienceScore(BigDecimal.ZERO);
// performanceScore.setTotalScore(BigDecimal.ZERO);
performanceScoreMapper.insert(performanceScore);
}

@ -8,7 +8,7 @@ import com.sztzjy.fund_investment.util.ResultEntity;
* @Date 2023/12/6
*/
public interface ProfitDistributionService {
void submit(ProfitDistribution profitDistribution);
ResultEntity submit(ProfitDistribution profitDistribution);
ProfitDistribution echo(String flowId);
}

@ -28,9 +28,11 @@ public class PerformanceScoreServiceImpl implements PerformanceScoreService {
public void calculateScoreByModule(String methodName, Integer score, String flowId) {
PerformanceScore performanceScore = getByFlowId(flowId);
BigDecimal scoreOld =(BigDecimal) performanceScore.get(methodName);
performanceScore.set(methodName, BigDecimal.valueOf(score));
performanceScore.setTotalScore(performanceScore.getTotalScore().add(BigDecimal.valueOf(score).subtract(scoreOld)));
performanceScoreMapper.updateByPrimaryKey(performanceScore);
if (scoreOld==null){
performanceScore.set(methodName, BigDecimal.valueOf(score));
performanceScore.setTotalScore(performanceScore.getTotalScore().add(BigDecimal.valueOf(score)));
performanceScoreMapper.updateByPrimaryKey(performanceScore);
}
}
@Override

@ -9,7 +9,9 @@ import com.sztzjy.fund_investment.mapper.ProfitDistributionMapper;
import com.sztzjy.fund_investment.service.ISysFundraisingService;
import com.sztzjy.fund_investment.service.PerformanceScoreService;
import com.sztzjy.fund_investment.service.ProfitDistributionService;
import com.sztzjy.fund_investment.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@ -140,13 +142,27 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
/*
* @author xcj
* @Date 2023/12/11
* + LP+*10% LP
*/
@Override
public void submit(ProfitDistribution profitDistribution) {
public ResultEntity submit(ProfitDistribution profitDistribution) {
//校验可用资金
if (profitDistribution.getUserAvailableFunds() == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入可用资金!");
}
//校验优先级LP和自有资金
if (profitDistribution.getUserRemainingOwnFunds() == null || profitDistribution.getUserRoundOwnFunds() == null ||
profitDistribution.getUserRoundPreferredLp() == null || profitDistribution.getUserRemainingEarningsPreferredLp() == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入分配金额!");
}
//查看基金募集属于哪种情况
String flowId = profitDistribution.getFlowId();
Fundraising fundraising = fundraisingService.selectByFlowId(flowId);
ExitTime exitTime = exitTimeMapper.selectByPrimaryKey(flowId);
profitDistribution.setProjectName(exitTime.getProjectName());
profitDistribution.setInvestmentAmount(exitTime.getInvestmentAmount());
profitDistribution.setExitStockPrice(exitTime.getExitStockPrice());
profitDistribution.setFundEarnings(exitTime.getExitFundEarnings());
BigDecimal fundraisingAmount = fundraising.getFundraisingAmount(); //资金募集总金额
BigDecimal priorityLp = fundraising.getPriorityLp(); //优先级LP本金
BigDecimal subordinatedLp = fundraising.getSubordinatedLp();//劣后级LP本金
@ -154,8 +170,8 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
BigDecimal exitFundEarnings = exitTime.getExitFundEarnings();//投资收益
BigDecimal userRoundOwnFunds = profitDistribution.getUserRoundOwnFunds();//用户/第一轮自有资金
BigDecimal userRoundPreferredLp = profitDistribution.getUserRoundPreferredLp(); //用户/第一轮优先级LP
BigDecimal remainingOwnFunds = profitDistribution.getRemainingOwnFunds();//用户/第二轮自有资金
BigDecimal remainingEarningsPreferredLp = profitDistribution.getRemainingEarningsPreferredLp();//用户/第二轮优先级LP
BigDecimal userRemainingOwnFunds = profitDistribution.getRemainingOwnFunds();//用户/第二轮自有资金
BigDecimal userRemainingEarningsPreferredLp = profitDistribution.getRemainingEarningsPreferredLp();//用户/第二轮优先级LP
BigDecimal rightOwnFunds = fundraising.getOwnFunds();//正确/第一轮自有资金
Integer type = fundraising.getType();
//计算可用资金是否正确
@ -170,21 +186,31 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
if (type == 1) { //1:自有资金/优先级LP
profitDistribution.setRemainingOwnFunds(BigDecimal.ZERO);
profitDistribution.setRemainingEarningsPreferredLp(BigDecimal.ZERO);
if (exitFundEarnings.compareTo(BigDecimal.ZERO) <= 0) { //盈利<0 亏损状态
if (rightAvailableFunds.compareTo(BigDecimal.ZERO)<=0){
profitDistribution.setRoundPreferredLp(BigDecimal.ZERO);//可用资金都给优先级LP 其余都为0
}else {
if (exitFundEarnings.compareTo(BigDecimal.ZERO) <= 0 || subtract.compareTo(BigDecimal.ZERO) < 0) { //盈利<0 亏损状态
if (rightAvailableFunds.compareTo(BigDecimal.ZERO) <= 0) {
profitDistribution.setRoundPreferredLp(BigDecimal.ZERO);//可用资金>0的情况
} else {
profitDistribution.setRoundPreferredLp(rightAvailableFunds);//可用资金都给优先级LP 其余都为0
}
profitDistribution.setRoundOwnFunds(BigDecimal.ZERO);
profitDistributionMapper.insert(profitDistribution);
return;
//算分
if (BigDecimal.ZERO.compareTo(userRoundOwnFunds) == 0 && rightAvailableFunds.compareTo(userRoundPreferredLp) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
if (subtract.compareTo(rightOwnFunds) <= 0&& subtract.compareTo(BigDecimal.ZERO) > 0) { //如果可用资金 - 优先级LP <= 需要分配的自有资金剩余金额全部给 自有资金第二轮都为0
if (subtract.compareTo(rightOwnFunds) <= 0 && subtract.compareTo(BigDecimal.ZERO) >= 0) { //如果可用资金 - 优先级LP <= 需要分配的自有资金剩余金额全部给 自有资金第二轮都为0
profitDistribution.setRoundPreferredLp(rightFundraisingAmount);
profitDistribution.setRoundOwnFunds(subtract);
profitDistributionMapper.insert(profitDistribution);
return;
//判断算分
if (subtract.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
profitDistribution.setRoundOwnFunds(rightOwnFunds);
profitDistribution.setRoundPreferredLp(rightFundraisingAmount);
@ -196,14 +222,67 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
profitDistributionMapper.insert(profitDistribution);
//算分 共五分可用资金1分其他共4分错一个不得分
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0) {
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
} else if (type == 2) { //2:自有资金/优先级LP/劣后级LP
if (profitDistribution.getUserRemainingEarningsSubordinatedLp() == null || profitDistribution.getUserRoundSubordinatedLp() == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请填写劣后级LP分配金额");
}
profitDistribution.setRemainingOwnFunds(BigDecimal.ZERO);
profitDistribution.setRemainingEarningsPreferredLp(BigDecimal.ZERO);
profitDistribution.setRemainingEarningsSubordinatedLp(BigDecimal.ZERO);
profitDistribution.setRoundSubordinatedLp(BigDecimal.ZERO);
profitDistribution.setRoundOwnFunds(BigDecimal.ZERO);
BigDecimal userRemainingEarningsSubordinatedLp = profitDistribution.getUserRemainingEarningsSubordinatedLp();//用户/剩余收益劣后级LP
BigDecimal userRoundSubordinatedLp = profitDistribution.getUserRoundSubordinatedLp();//用户/第一轮劣后级LP
if (exitFundEarnings.compareTo(BigDecimal.ZERO) <= 0 || subtract.compareTo(BigDecimal.ZERO) < 0) { //盈利<=0 亏损状态
if (rightAvailableFunds.compareTo(BigDecimal.ZERO) <= 0) {
rightAvailableFunds = BigDecimal.ZERO;
profitDistribution.setRoundPreferredLp(rightAvailableFunds);//可用资金>0的情况
} else {
profitDistribution.setRoundPreferredLp(rightAvailableFunds);//可用资金都给优先级LP 其余都为0
}
profitDistributionMapper.insert(profitDistribution);
//算分
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) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
profitDistribution.setRoundPreferredLp(rightFundraisingAmount); //下面的情况优先级LP都足够
//需要分配的劣后级LP金额 >= 剩余金额 >=0将剩余的都给劣后级LP第二轮都为0
if (subtract.compareTo(subordinatedLp) <= 0 && subtract.compareTo(BigDecimal.ZERO) >= 0) {
profitDistribution.setRoundSubordinatedLp(subtract);
profitDistributionMapper.insert(profitDistribution);
//判断算分
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) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
//分配完优劣LP后剩余的钱
BigDecimal subtractSubordinatedLp = subtract.subtract(subordinatedLp); //可用资金 - 第一轮/优先级LP - 第一轮劣后优先级LP
if (subtractSubordinatedLp.compareTo(BigDecimal.ZERO) >= 0 && subtractSubordinatedLp.compareTo(rightOwnFunds) <= 0) {
profitDistribution.setRoundSubordinatedLp(subordinatedLp);
profitDistribution.setRoundOwnFunds(subtractSubordinatedLp);
profitDistributionMapper.insert(profitDistribution);
//判断算分
if (subtractSubordinatedLp.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0 &&
subordinatedLp.compareTo(userRoundSubordinatedLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
// 第一轮归还劣后级LP本金
profitDistribution.setRoundSubordinatedLp(subordinatedLp);
profitDistribution.setRoundOwnFunds(rightOwnFunds);
residualIncome = residualIncome.subtract(subordinatedLp); //剩余收益
// 2.剩余收益分配比例为自有资金25%优先级LP 30%劣后级LP 45%
BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金
@ -214,14 +293,67 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp);
profitDistributionMapper.insert(profitDistribution);
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 &&
userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
} else if (type == 3) { //3:自有资金/优先级LP/银行借款
BigDecimal userRoundBankLoan = profitDistribution.getUserRoundBankLoan(); //用户/银行借款
} else if (type == 3) { //3:银行借款/自有资金/优先级LP
if (profitDistribution.getUserRoundBankLoan() == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请填写银行借款分配金额!");
}
BigDecimal rightBankLoan = bankLoan.add(bankLoan.multiply(BigDecimal.valueOf(0.0475))).setScale(2, RoundingMode.HALF_UP); //银行借款/+利息4.75%
profitDistribution.setRoundBankLoan(rightBankLoan);
profitDistribution.setRemainingOwnFunds(BigDecimal.ZERO);
profitDistribution.setRemainingEarningsPreferredLp(BigDecimal.ZERO);
profitDistribution.setRoundOwnFunds(BigDecimal.ZERO);
profitDistribution.setRoundPreferredLp(BigDecimal.ZERO);
BigDecimal userRoundBankLoan = profitDistribution.getUserRoundBankLoan(); //用户/银行借款
BigDecimal subtractBankLoan = rightAvailableFunds.subtract(rightBankLoan); //可用资金 - 银行利息
if (exitFundEarnings.compareTo(BigDecimal.ZERO) <= 0 || subtractBankLoan.compareTo(BigDecimal.ZERO) < 0) { //盈利<0 亏损状态或者盈利少的状态
if (rightAvailableFunds.compareTo(BigDecimal.ZERO) <= 0) {
rightAvailableFunds = BigDecimal.ZERO;
profitDistribution.setRoundBankLoan(rightAvailableFunds);//可用资金>0的情况
} else {
profitDistribution.setRoundBankLoan(rightAvailableFunds);//可用资金都给银行贷款 其余都为0
}
profitDistributionMapper.insert(profitDistribution);
//算分
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) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
profitDistribution.setRoundBankLoan(rightBankLoan); //下面的情况优先级银行贷款都足够
//需要分配的优先级LP金额 >= 剩余金额 >=0将剩余的都给优先级LP第二轮都为0
if (subtractBankLoan.compareTo(rightFundraisingAmount) <= 0 && subtractBankLoan.compareTo(BigDecimal.ZERO) >= 0) {
profitDistribution.setRoundPreferredLp(subtractBankLoan);
profitDistributionMapper.insert(profitDistribution);
//判断算分
if (BigDecimal.ZERO.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
subtractBankLoan.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
//分配完优先级LP后剩余的钱给自有资金
BigDecimal subtractRoundOwnFunds = subtract.subtract(rightBankLoan); //可用资金 - 第一轮/优先级LP - 银行利息
if (subtractRoundOwnFunds.compareTo(BigDecimal.ZERO) >= 0 && subtractRoundOwnFunds.compareTo(rightOwnFunds) <= 0) {
profitDistribution.setRoundOwnFunds(subtractRoundOwnFunds);
profitDistribution.setRoundPreferredLp(rightFundraisingAmount);
profitDistributionMapper.insert(profitDistribution);
//判断算分
if (subtractRoundOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
profitDistribution.setRoundPreferredLp(rightFundraisingAmount);
profitDistribution.setRoundOwnFunds(rightOwnFunds);
residualIncome = residualIncome.subtract(rightBankLoan); //剩余收益
// 2.剩余收益分配比例为自有资金25%优先级LP75%
BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金
@ -230,17 +362,92 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount);
profitDistributionMapper.insert(profitDistribution);
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 &&
rightBankLoan.compareTo(userRoundBankLoan) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
} else { //4:自有资金/优先级LP/劣后级LP/银行借款
} else { //4:银行借款/优先级LP/劣后级LP/自有资金
if (profitDistribution.getUserRemainingEarningsSubordinatedLp() == null || profitDistribution.getUserRoundSubordinatedLp() == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请填写劣后级LP分配金额");
}
if (profitDistribution.getUserRoundBankLoan() == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请填写银行借款分配金额!");
}
BigDecimal rightBankLoan = bankLoan.add(bankLoan.multiply(BigDecimal.valueOf(0.0475))).setScale(2, RoundingMode.HALF_UP); //银行借款/+利息4.75%
profitDistribution.setRemainingOwnFunds(BigDecimal.ZERO);
profitDistribution.setRemainingEarningsPreferredLp(BigDecimal.ZERO);
profitDistribution.setRemainingEarningsSubordinatedLp(BigDecimal.ZERO);
profitDistribution.setRoundPreferredLp(BigDecimal.ZERO);
profitDistribution.setRoundOwnFunds(BigDecimal.ZERO);
BigDecimal userRoundBankLoan = profitDistribution.getUserRoundBankLoan(); //用户/银行借款
BigDecimal subtractBankLoan = rightAvailableFunds.subtract(rightBankLoan); //可用资金 - 银行利息
BigDecimal userRemainingEarningsSubordinatedLp = profitDistribution.getUserRemainingEarningsSubordinatedLp();//用户/剩余收益劣后级LP
BigDecimal userRoundSubordinatedLp = profitDistribution.getUserRoundSubordinatedLp();//用户/第一轮劣后级LP
BigDecimal userRoundBankLoan = profitDistribution.getUserRoundBankLoan(); //用户/银行借款
if (exitFundEarnings.compareTo(BigDecimal.ZERO) <= 0 || subtractBankLoan.compareTo(BigDecimal.ZERO) < 0) { //盈利<0 亏损状态或者盈利少的状态
if (rightAvailableFunds.compareTo(BigDecimal.ZERO) <= 0) {
rightAvailableFunds = BigDecimal.ZERO;
profitDistribution.setRoundBankLoan(rightAvailableFunds);//可用资金>0的情况
} else {
profitDistribution.setRoundBankLoan(rightAvailableFunds);//可用资金都给银行贷款 其余都为0
}
profitDistributionMapper.insert(profitDistribution);
//算分
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 && BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0 &&
BigDecimal.ZERO.compareTo(userRoundSubordinatedLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
profitDistribution.setRoundBankLoan(rightBankLoan); //下面的情况优先级银行贷款都足够
//需要分配的优先级LP金额 >= 剩余金额 >=0将剩余的都给优先级LP第二轮都为0
if (subtractBankLoan.compareTo(rightFundraisingAmount) <= 0 && subtractBankLoan.compareTo(BigDecimal.ZERO) >= 0) {
profitDistribution.setRoundPreferredLp(subtractBankLoan);
profitDistributionMapper.insert(profitDistribution);
//判断算分
if (BigDecimal.ZERO.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
subtractBankLoan.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRoundSubordinatedLp) == 0
&& BigDecimal.ZERO.compareTo(userRemainingEarningsSubordinatedLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
//分配完优先级LP后剩余的钱给劣后级LP
BigDecimal subtractSubordinatedLp = subtract.subtract(rightBankLoan); //可用资金 - 第一轮/优先级LP - 银行利息
profitDistribution.setRoundPreferredLp(rightFundraisingAmount);
if (subtractSubordinatedLp.compareTo(BigDecimal.ZERO) >= 0 && subtractSubordinatedLp.compareTo(subordinatedLp) <= 0) {
profitDistribution.setRoundSubordinatedLp(subtractSubordinatedLp);
profitDistributionMapper.insert(profitDistribution);
//判断算分
if (subtractSubordinatedLp.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
//分配完优先级LP 和 劣后级LP 剩下的给自有资金
BigDecimal subtractRoundOwnFunds = subtract.subtract(rightBankLoan).subtract(subordinatedLp); //可用资金 - 第一轮/优先级LP - 银行利息
if (subtractRoundOwnFunds.compareTo(BigDecimal.ZERO) >= 0 && subtractRoundOwnFunds.compareTo(rightOwnFunds) <= 0) {
profitDistribution.setRoundSubordinatedLp(subordinatedLp);
profitDistribution.setRoundOwnFunds(subtractRoundOwnFunds);
profitDistributionMapper.insert(profitDistribution);
//判断算分
if (subtractRoundOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 &&
subordinatedLp.compareTo(userRoundSubordinatedLp) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingOwnFunds) == 0 && subordinatedLp.compareTo(userRoundSubordinatedLp) == 0 &&
BigDecimal.ZERO.compareTo(userRemainingEarningsPreferredLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
return new ResultEntity<>(HttpStatus.OK, "分配完成!");
}
// 第一轮归还劣后级LP本金和银行利息
profitDistribution.setRoundSubordinatedLp(subordinatedLp);
BigDecimal rightBankLoan = bankLoan.add(bankLoan.multiply(BigDecimal.valueOf(0.0475))); //银行借款/+利息4.75%
profitDistribution.setRoundBankLoan(rightBankLoan);
residualIncome = residualIncome.subtract(subordinatedLp).subtract(rightBankLoan); //剩余收益
//2.剩余收益分配比例为自有资金25%优先级LP 30%劣后级LP 45%
@ -252,12 +459,13 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp);
profitDistributionMapper.insert(profitDistribution);
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 &&
rightBankLoan.compareTo(userRoundBankLoan) == 0 && userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 &&
userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
}
return null;
}

Loading…
Cancel
Save