新增报告保存接口,修改收益分配优先级LP分配率,空指针bug,退出时计算接口

master
xiaoCJ 1 year ago
parent 9169429ce8
commit 33f6a49318

@ -14,6 +14,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -72,6 +73,13 @@ public class InvestmentReportController {
return investmentReportService.commitExperience(trainingReport); return investmentReportService.commitExperience(trainingReport);
} }
@AnonymousAccess
@PostMapping("saveExperience")
@ApiOperation("保存心得")
public ResultEntity<HttpStatus> saveExperience(@ApiParam("用户填写的心得") @RequestParam String text, @RequestParam String flowId, @RequestParam String schoolId) {
return investmentReportService.saveExperience(text,flowId,schoolId);
}
@AnonymousAccess @AnonymousAccess
@GetMapping("getExperience") @GetMapping("getExperience")
@ApiOperation("心得回显") @ApiOperation("心得回显")
@ -81,10 +89,12 @@ public class InvestmentReportController {
return null; return null;
} }
TrainingReport trainingReport = trainingReports.get(0); TrainingReport trainingReport = trainingReports.get(0);
if (StringUtils.isBlank(trainingReport.getExperience())) { if (!StringUtils.isBlank(trainingReport.getExperience())) {
return null; return new ResultEntity<>(trainingReport.getExperience());
} if (!StringUtils.isBlank(trainingReport.getVersion())) {
return new ResultEntity<>(trainingReport.getVersion());
} }
return new ResultEntity<>(trainingReport.getExperience()); return null;
} }
@AnonymousAccess @AnonymousAccess

@ -67,7 +67,7 @@ public class ProfitManagementController {
@ApiOperation("退出时机弹窗/判断市值和基金收益对错,计算错误则返回正确答案") @ApiOperation("退出时机弹窗/判断市值和基金收益对错,计算错误则返回正确答案")
@AnonymousAccess @AnonymousAccess
@GetMapping("/getExitTimeRightMarketValueAndFundEarnings") @GetMapping("/getExitTimeRightMarketValueAndFundEarnings")
public ResultEntity<HttpStatus> getExitTimeRightMarketValueAndFundEarnings(@RequestParam String flowId, public ResultEntity getExitTimeRightMarketValueAndFundEarnings(@RequestParam String flowId,
@ApiParam("退出时间") @RequestParam String exitTime, @ApiParam("退出时间") @RequestParam String exitTime,
@ApiParam("随机生成的价格") @RequestParam BigDecimal price, @ApiParam("随机生成的价格") @RequestParam BigDecimal price,
@ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue, @ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue,

@ -2,6 +2,7 @@ package com.sztzjy.fund_investment.service;
import com.sztzjy.fund_investment.entity.TrainingReport; import com.sztzjy.fund_investment.entity.TrainingReport;
import com.sztzjy.fund_investment.util.ResultEntity; import com.sztzjy.fund_investment.util.ResultEntity;
import org.springframework.http.HttpStatus;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
@ -16,4 +17,6 @@ public interface InvestmentReportService {
List<TrainingReport> getTrainingReports(String flowId); List<TrainingReport> getTrainingReports(String flowId);
ResultEntity<String> commitExperience(TrainingReport trainingReport); ResultEntity<String> commitExperience(TrainingReport trainingReport);
ResultEntity<HttpStatus> saveExperience(String text, String flowId, String schoolId);
} }

@ -106,7 +106,7 @@ public class InvestmentReportServiceImpl implements InvestmentReportService {
if (StringUtils.isBlank(trainingReport.getExperience())) { if (StringUtils.isBlank(trainingReport.getExperience())) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请先填写心得再提交!"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请先填写心得再提交!");
} }
if (StringUtils.isBlank(trainingReport.getId()) || StringUtils.isBlank(trainingReport.getFlowId()) || StringUtils.isBlank(trainingReport.getSchoolId())) { if (StringUtils.isBlank(trainingReport.getFlowId()) || StringUtils.isBlank(trainingReport.getSchoolId())) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败缺少所需的ID"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败缺少所需的ID");
} }
TrainingReportExample trainingReportExample = new TrainingReportExample(); TrainingReportExample trainingReportExample = new TrainingReportExample();
@ -122,10 +122,44 @@ public class InvestmentReportServiceImpl implements InvestmentReportService {
trainingReportMapper.updateByPrimaryKeyWithBLOBs(dataTrainingReport); trainingReportMapper.updateByPrimaryKeyWithBLOBs(dataTrainingReport);
} }
} else { //为空新增 } else { //为空新增
trainingReport.setId(IdUtil.simpleUUID());
trainingReport.setUploadtime(new Date()); trainingReport.setUploadtime(new Date());
trainingReport.setStep(Constant.TZBG); trainingReport.setStep(Constant.TZBG);
trainingReportMapper.insert(trainingReport); trainingReportMapper.insert(trainingReport);
} }
return new ResultEntity<>(HttpStatus.OK, "提交成功!"); return new ResultEntity<>(HttpStatus.OK, "提交成功!");
} }
/*
* @author xcj
* @Date 2024/1/31
*/
@Override
public ResultEntity<HttpStatus> saveExperience(String text,String flowId,String schoolId) {
TrainingReportExample trainingReportExample = new TrainingReportExample();
trainingReportExample.createCriteria().andFlowIdEqualTo(flowId).andStepEqualTo(Constant.TZBG);
List<TrainingReport> trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample);
//为空代表没有提交或保存过,新增一条
if (trainingReports.isEmpty()){
TrainingReport trainingReport = new TrainingReport();
trainingReport.setFlowId(flowId);
trainingReport.setId(IdUtil.simpleUUID());
trainingReport.setSchoolId(schoolId);
trainingReport.setUploadtime(new Date());
trainingReport.setStep(Constant.TZBG);
trainingReport.setVersion(text); //新增保存功能,使用版本字段,没有再添加字段
trainingReportMapper.insert(trainingReport);
return new ResultEntity<>(HttpStatus.OK,"保存成功!");
}else {
TrainingReport trainingReport = trainingReports.get(0);
if (trainingReport.getExperience()!=null){
return new ResultEntity<>(HttpStatus.BAD_REQUEST,"提交过不允许再保存!");
}
trainingReport.setVersion(text);
trainingReportMapper.updateByPrimaryKeyWithBLOBs(trainingReport);
return new ResultEntity<>(HttpStatus.OK,"保存成功!");
}
}
} }

@ -149,10 +149,10 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
if (profitDistribution.getUserAvailableFunds() == null) { if (profitDistribution.getUserAvailableFunds() == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入可用资金!"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请输入可用资金!");
} }
ProfitDistributionExample example =new ProfitDistributionExample(); ProfitDistributionExample example = new ProfitDistributionExample();
example.createCriteria().andFlowIdEqualTo(profitDistribution.getFlowId()); example.createCriteria().andFlowIdEqualTo(profitDistribution.getFlowId());
List<ProfitDistribution> profitDistributions = profitDistributionMapper.selectByExample(example); List<ProfitDistribution> profitDistributions = profitDistributionMapper.selectByExample(example);
if (!profitDistributions.isEmpty()){ if (!profitDistributions.isEmpty()) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请勿重复提交!"); return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请勿重复提交!");
} }
//校验优先级LP和自有资金 //校验优先级LP和自有资金
@ -295,16 +295,24 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
residualIncome = residualIncome.subtract(subordinatedLp); //剩余收益 residualIncome = residualIncome.subtract(subordinatedLp); //剩余收益
// 2.剩余收益分配比例为自有资金25%优先级LP 30%劣后级LP 45% // 2.剩余收益分配比例为自有资金25%优先级LP 30%劣后级LP 45%
BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金
BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.35)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.3)).setScale(2, RoundingMode.HALF_UP);//剩余优先级
BigDecimal twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP BigDecimal twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP
profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingOwnFunds(twoRightOwnFunds);
profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount);
profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp); profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp);
profitDistributionMapper.insert(profitDistribution); profitDistributionMapper.insert(profitDistribution);
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && if (rightOwnFunds != null && userRoundOwnFunds != null &&
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 && userRoundPreferredLp != null &&
userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) { userRoundSubordinatedLp != null && subordinatedLp != null &&
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId); userRemainingEarningsSubordinatedLp != null) {
if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 &&
rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 &&
twoRightOwnFunds.compareTo(userRemainingOwnFunds) == 0 &&
twoRightFundraisingAmount.compareTo(userRemainingEarningsPreferredLp) == 0 &&
userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 &&
userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) {
performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId);
}
} }
PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId); PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId);
performanceScore.setProfitDistributionTime(new Date()); performanceScore.setProfitDistributionTime(new Date());
@ -469,7 +477,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
residualIncome = residualIncome.subtract(subordinatedLp).subtract(rightBankLoan); //剩余收益 residualIncome = residualIncome.subtract(subordinatedLp).subtract(rightBankLoan); //剩余收益
//2.剩余收益分配比例为自有资金25%优先级LP 30%劣后级LP 45% //2.剩余收益分配比例为自有资金25%优先级LP 30%劣后级LP 45%
BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金
BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.35)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 BigDecimal twoRightFundraisingAmount = residualIncome.multiply(BigDecimal.valueOf(0.3)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金
BigDecimal twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP BigDecimal twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP
profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingOwnFunds(twoRightOwnFunds);
profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount);
@ -498,7 +506,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService
ProfitDistributionExample profitDistributionExample = new ProfitDistributionExample(); ProfitDistributionExample profitDistributionExample = new ProfitDistributionExample();
profitDistributionExample.createCriteria().andFlowIdEqualTo(flowId); profitDistributionExample.createCriteria().andFlowIdEqualTo(flowId);
List<ProfitDistribution> profitDistributions = profitDistributionMapper.selectByExample(profitDistributionExample); List<ProfitDistribution> profitDistributions = profitDistributionMapper.selectByExample(profitDistributionExample);
if (profitDistributions.isEmpty()){ if (profitDistributions.isEmpty()) {
return null; return null;
} }
return profitDistributions.get(0); return profitDistributions.get(0);

@ -104,7 +104,7 @@ public class ProfitManagementServiceImpl implements ProfitManagementService {
@Override @Override
public ResultEntity getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price, public ResultEntity getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price,
BigDecimal userMarketValue, BigDecimal userFundEarnings) { BigDecimal userMarketValue, BigDecimal userFundEarnings) {
ExitTime exitTimeEntity =new ExitTime(); ExitTime exitTimeEntity = new ExitTime();
List<ProfitManagement> profitManagementList = getLineChart(flowId); List<ProfitManagement> profitManagementList = getLineChart(flowId);
if (profitManagementList.isEmpty()) { if (profitManagementList.isEmpty()) {
return null; return null;
@ -134,14 +134,10 @@ public class ProfitManagementServiceImpl implements ProfitManagementService {
PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId); PerformanceScore performanceScore = performanceScoreService.getByFlowId(flowId);
performanceScore.setProfitManagementTime(new Date()); performanceScore.setProfitManagementTime(new Date());
performanceScoreMapper.updateByPrimaryKey(performanceScore); performanceScoreMapper.updateByPrimaryKey(performanceScore);
if (!(userMarketValue.compareTo(marketValue) == 0)) { if (userMarketValue.compareTo(marketValue) == 0) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue);
} else {
performanceScoreService.calculateScoreByModule("profitManagementFundExitScore", 3, flowId); performanceScoreService.calculateScoreByModule("profitManagementFundExitScore", 3, flowId);
} }
if (!(userFundEarnings.compareTo(fundEarnings) == 0)) { if (userFundEarnings.compareTo(fundEarnings) == 0) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings);
} else {
performanceScoreService.calculateScoreByModule("profitManagementMarketValueExitScore", 3, flowId); performanceScoreService.calculateScoreByModule("profitManagementMarketValueExitScore", 3, flowId);
} }
return null; return null;

Loading…
Cancel
Save