From d406177ca99441e4f7c3f96e503728b0fa80a0d6 Mon Sep 17 00:00:00 2001 From: xiaoCJ <406612557@qq.com> Date: Wed, 13 Dec 2023 17:32:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=80=80=E5=87=BA=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=E8=A1=A8=EF=BC=8C=E5=AE=8C=E6=88=90=E6=8A=95=E8=B5=84?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E9=A1=B5=E9=9D=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InvestmentReportController.java | 2 +- .../ProfitDistributionController.java | 12 +- .../InvestmentReportServiceImpl.java | 30 +- .../ProfitDistributionServiceImpl.java | 147 +++++- .../mappers/ProfitDistributionMapper.xml | 486 ++++++++++++++++++ 5 files changed, 648 insertions(+), 29 deletions(-) create mode 100644 src/main/resources/mappers/ProfitDistributionMapper.xml diff --git a/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java b/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java index 370067c..87ff50d 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java @@ -49,7 +49,7 @@ public class InvestmentReportController { BigDecimal investmentAmount = profitManagement.getInvestmentAmount(); // 投资金额 // 基金收益/投资金额=投资收益率 - BigDecimal bigDecimal = fundEarnings.divide(investmentAmount,2,RoundingMode.HALF_UP); + BigDecimal bigDecimal = fundEarnings.divide(investmentAmount, 2, RoundingMode.HALF_UP); map.put(profitManagement.getMarketTime(), bigDecimal);// todo 时间格式是年月日 } } diff --git a/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java b/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java index 5b6a60e..b77a582 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java @@ -25,12 +25,12 @@ public class ProfitDistributionController { private ProfitDistributionService profitDistributionService; - @AnonymousAccess - @PostMapping("/submit") - @ApiOperation("页面提交") - public void submit(@ApiParam("传id,flowID,用户输入8个框的内容(可用资金,自有资金和优先级LP必传)") ProfitDistribution profitDistribution) { - profitDistributionService.submit(profitDistribution); - } +// @AnonymousAccess +// @PostMapping("/submit") +// @ApiOperation("页面提交") +// public void submit(@ApiParam("传id(UUID),flowID,用户输入8个框的内容(可用资金,自有资金和优先级LP必传)") ProfitDistribution profitDistribution) { +// profitDistributionService.submit(profitDistribution); +// } @AnonymousAccess @GetMapping("/echo") diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java index c600ab3..037a98a 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/InvestmentReportServiceImpl.java @@ -1,5 +1,6 @@ package com.sztzjy.fund_investment.service.serviceImpl; +import cn.hutool.core.util.IdUtil; import com.sztzjy.fund_investment.config.Constant; import com.sztzjy.fund_investment.entity.TrainingReport; import com.sztzjy.fund_investment.entity.TrainingReportExample; @@ -29,7 +30,9 @@ public class InvestmentReportServiceImpl implements InvestmentReportService { TrainingReportMapper trainingReportMapper; - /**报告提交 + /** + * 报告提交 + * * @author xcj * @Date 2023/12/4 */ @@ -41,19 +44,20 @@ public class InvestmentReportServiceImpl implements InvestmentReportService { if (!fileExtension.equals(".pdf") && !fileExtension.equals(".doc") && !fileExtension.equals(".docx")) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "文件必须为word或pdf!"); } - List trainingReports = getTrainingReports(flowId); - + TrainingReportExample trainingReportExample = new TrainingReportExample(); + trainingReportExample.createCriteria().andFlowIdEqualTo(flowId).andStepEqualTo(Constant.TZBG); + List trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample); //只允许提交一次,判断是否只提交了心得没提交报告 if (!trainingReports.isEmpty()) { TrainingReport trainingReport = trainingReports.get(0); - if (StringUtils.isNotBlank(trainingReport.getReportName())) { + if (StringUtils.isNotBlank(trainingReport.getReportName()) && StringUtils.isNotBlank(trainingReport.getUrl())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "不允许重复提交!"); } else { trainingReport.setUrl(filePath); trainingReport.setReportName(fileName); trainingReport.setUploadtime(new Date()); trainingReport.setStep(Constant.TZBG); - trainingReportMapper.updateByPrimaryKey(trainingReport); + trainingReportMapper.updateByPrimaryKeySelective(trainingReport); return new ResultEntity<>(HttpStatus.OK, "报告上传成功!"); } } else { //没上传报告没提交心得的情况 @@ -91,17 +95,21 @@ public class InvestmentReportServiceImpl implements InvestmentReportService { if (StringUtils.isBlank(trainingReport.getId()) || StringUtils.isBlank(trainingReport.getFlowId()) || StringUtils.isBlank(trainingReport.getSchoolId())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "提交失败!缺少所需的ID!"); } - List trainingReports = getTrainingReports(trainingReport.getFlowId()); + TrainingReportExample trainingReportExample = new TrainingReportExample(); + trainingReportExample.createCriteria().andFlowIdEqualTo(trainingReport.getFlowId()).andStepEqualTo(Constant.TZBG); + List trainingReports = trainingReportMapper.selectByExampleWithBLOBs(trainingReportExample); if (!trainingReports.isEmpty()) { TrainingReport dataTrainingReport = trainingReports.get(0); - if (StringUtils.isNotBlank(dataTrainingReport.getExperience())){ + if (StringUtils.isNotBlank(dataTrainingReport.getExperience())) { return new ResultEntity<>(HttpStatus.BAD_REQUEST, "不允许重复提交!"); - }else { //提交了报告没提交心得 - trainingReport.setExperience(trainingReport.getExperience()); - trainingReport.setUploadtime(new Date()); - trainingReportMapper.updateByPrimaryKey(trainingReport); + } else { //提交了报告没提交心得 + dataTrainingReport.setExperience(trainingReport.getExperience()); + dataTrainingReport.setUploadtime(new Date()); + trainingReportMapper.updateByPrimaryKeyWithBLOBs(dataTrainingReport); } } else { //为空新增 + trainingReport.setUploadtime(new Date()); + trainingReport.setStep(Constant.TZBG); trainingReportMapper.insert(trainingReport); } return new ResultEntity<>(HttpStatus.OK, "提交成功!"); diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java index 3fca0bb..9994b2c 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java @@ -14,6 +14,7 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.List; /** * @Author xcj @@ -31,6 +32,111 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService private PerformanceScoreService performanceScoreService; + /* 收益分配计算提交 + * @author xcj + * @Date 2023/12/11 + */ +// @Override +// public void submit(ProfitDistribution profitDistribution) { +// //查看基金募集属于哪种情况 +// String flowId = profitDistribution.getFlowId(); +// Fundraising fundraising = fundraisingService.selectByFlowId(flowId); +// ExitTime exitTime = exitTimeMapper.selectByPrimaryKey(flowId); +// BigDecimal fundraisingAmount = fundraising.getFundraisingAmount(); //资金募集总金额 +// BigDecimal priorityLp = fundraising.getPriorityLp(); //优先级LP本金 +// BigDecimal subordinatedLp = fundraising.getSubordinatedLp();//劣后级LP本金 +// BigDecimal bankLoan = fundraising.getBankLoan(); //银行借款本金 +// BigDecimal exitFundEarnings = exitTime.getExitFundEarnings();//投资收益 +// BigDecimal userRoundOwnFunds = profitDistribution.getUserRoundOwnFunds();//用户/第一轮自有资金 +// BigDecimal userRoundPreferredLp = profitDistribution.getUserRoundPreferredLp(); //用户/第一轮优先级LP +// BigDecimal remainingOwnFunds = profitDistribution.getRemainingOwnFunds();//用户/第二轮自有资金 +// BigDecimal remainingEarningsPreferredLp = profitDistribution.getRemainingEarningsPreferredLp();//用户/第二轮优先级LP +// BigDecimal rightOwnFunds = fundraising.getOwnFunds();//正确/第一轮自有资金 +// BigDecimal rightFundraisingAmount = priorityLp.add(priorityLp.multiply(BigDecimal.valueOf(0.1))).setScale(2, RoundingMode.HALF_UP);//第一轮/优先级LP +// //1.归还自有资金的本金,归还优先级LP本金+本金*10% (两个值必填且都一样,提高优先级复用) +// profitDistribution.setRoundOwnFunds(rightOwnFunds); +// profitDistribution.setRoundPreferredLp(rightFundraisingAmount); +// Integer type = fundraising.getType(); +// //计算可用资金是否正确 +// BigDecimal rightAvailableFunds = fundraisingAmount.add(exitFundEarnings).setScale(2, RoundingMode.HALF_UP);//可用资金 +// BigDecimal residualIncome = rightAvailableFunds.subtract(rightOwnFunds).subtract(rightFundraisingAmount); //剩余分配(减去优先级LP和自有资金) +// if (profitDistribution.getUserAvailableFunds().compareTo(rightAvailableFunds) == 0) { +// performanceScoreService.calculateScoreByModule("profitDistributionAvailablefundsScore", 1, flowId); +// } +// if (type == 1) { //1:自有资金/优先级LP +// // 2.剩余收益分配比例为,自有资金25%,优先级LP75% +// BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 +// BigDecimal twoRightFundraisingAmount = residualIncome.subtract(twoRightOwnFunds); //剩余优先级LP +// profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); +// profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); +// profitDistributionMapper.insert(profitDistribution); +// //算分 共五分,可用资金1分,其他共4分,错一个不得分 +// if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && +// twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0) { +// performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId); +// } +// } else if (type == 2) { //2:自有资金/优先级LP/劣后级LP +// BigDecimal userRemainingEarningsSubordinatedLp = profitDistribution.getUserRemainingEarningsSubordinatedLp();//用户/剩余收益劣后级LP +// BigDecimal userRoundSubordinatedLp = profitDistribution.getUserRoundSubordinatedLp();//用户/第一轮劣后级LP +//// 第一轮归还劣后级LP本金 +// profitDistribution.setRoundSubordinatedLp(subordinatedLp); +// residualIncome = residualIncome.subtract(subordinatedLp); //剩余收益 +//// 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.35)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 +// BigDecimal twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP +// profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); +// profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); +// profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp); +// profitDistributionMapper.insert(profitDistribution); +// if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && +// twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 && +// userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) { +// performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId); +// } +// } else if (type == 3) { //3:自有资金/优先级LP/银行借款 +// BigDecimal userRoundBankLoan = profitDistribution.getUserRoundBankLoan(); //用户/银行借款 +// BigDecimal rightBankLoan = bankLoan.add(bankLoan.multiply(BigDecimal.valueOf(0.0475))).setScale(2, RoundingMode.HALF_UP); //银行借款/+利息4.75% +// profitDistribution.setRoundBankLoan(rightBankLoan); +// residualIncome = residualIncome.subtract(rightBankLoan); //剩余收益 +// // 2.剩余收益分配比例为,自有资金25%,优先级LP75% +// BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 +// BigDecimal twoRightFundraisingAmount = residualIncome.subtract(twoRightOwnFunds); //剩余优先级LP +// profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); +// profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); +// profitDistributionMapper.insert(profitDistribution); +// if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && +// twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 && +// rightBankLoan.compareTo(userRoundBankLoan) == 0) { +// performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId); +// } +// } else { //4:自有资金/优先级LP/劣后级LP/银行借款 +// BigDecimal userRemainingEarningsSubordinatedLp = profitDistribution.getUserRemainingEarningsSubordinatedLp();//用户/剩余收益劣后级LP +// BigDecimal userRoundSubordinatedLp = profitDistribution.getUserRoundSubordinatedLp();//用户/第一轮劣后级LP +// BigDecimal userRoundBankLoan = profitDistribution.getUserRoundBankLoan(); //用户/银行借款 +// // 第一轮归还劣后级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% +// 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 twoRightSubordinatedLp = residualIncome.subtract(twoRightOwnFunds).subtract(twoRightFundraisingAmount); //剩余劣后级LP +// profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); +// profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); +// profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp); +// profitDistributionMapper.insert(profitDistribution); +// if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && +// twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 && +// rightBankLoan.compareTo(userRoundBankLoan) == 0 && userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && +// userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) { +// performanceScoreService.calculateScoreByModule("profitDistributionScore", 4, flowId); +// } +// } +// } + + /* 收益分配计算提交 * @author xcj * @Date 2023/12/11 @@ -51,24 +157,43 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService BigDecimal remainingOwnFunds = profitDistribution.getRemainingOwnFunds();//用户/第二轮自有资金 BigDecimal remainingEarningsPreferredLp = profitDistribution.getRemainingEarningsPreferredLp();//用户/第二轮优先级LP BigDecimal rightOwnFunds = fundraising.getOwnFunds();//正确/第一轮自有资金 - BigDecimal rightFundraisingAmount = priorityLp.add(priorityLp.multiply(BigDecimal.valueOf(0.1))).setScale(2, RoundingMode.HALF_UP);//第一轮/优先级LP - //1.归还自有资金的本金,归还优先级LP本金+本金*10% (两个值必填且都一样,提高优先级复用) - profitDistribution.setRoundOwnFunds(rightOwnFunds); - profitDistribution.setRoundPreferredLp(rightFundraisingAmount); Integer type = fundraising.getType(); //计算可用资金是否正确 BigDecimal rightAvailableFunds = fundraisingAmount.add(exitFundEarnings).setScale(2, RoundingMode.HALF_UP);//可用资金 - BigDecimal residualIncome = rightAvailableFunds.subtract(rightOwnFunds).subtract(rightFundraisingAmount); //剩余分配(减去优先级LP和自有资金) + profitDistribution.setAvailableFunds(rightAvailableFunds); //设置可用资金 if (profitDistribution.getUserAvailableFunds().compareTo(rightAvailableFunds) == 0) { performanceScoreService.calculateScoreByModule("profitDistributionAvailablefundsScore", 1, flowId); } + BigDecimal rightFundraisingAmount = priorityLp.add(priorityLp.multiply(BigDecimal.valueOf(0.1))).setScale(2, RoundingMode.HALF_UP);//第一轮/优先级LP + BigDecimal subtract = rightAvailableFunds.subtract(rightFundraisingAmount); //可用资金 - 第一轮/优先级LP + BigDecimal residualIncome = rightAvailableFunds.subtract(rightOwnFunds).subtract(rightFundraisingAmount);//剩余分配金额(减去优先级LP和自有资金) 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 { + profitDistribution.setRoundPreferredLp(rightAvailableFunds);//可用资金都给优先级LP 其余都为0 + } + profitDistribution.setRoundOwnFunds(BigDecimal.ZERO); + profitDistributionMapper.insert(profitDistribution); + return; + } + if (subtract.compareTo(rightOwnFunds) <= 0&& subtract.compareTo(BigDecimal.ZERO) > 0) { //如果可用资金 - 优先级LP <= 需要分配的自有资金剩余金额全部给 自有资金,第二轮都为0 + profitDistribution.setRoundPreferredLp(rightFundraisingAmount); + profitDistribution.setRoundOwnFunds(subtract); + profitDistributionMapper.insert(profitDistribution); + return; + } + profitDistribution.setRoundOwnFunds(rightOwnFunds); + profitDistribution.setRoundPreferredLp(rightFundraisingAmount); // 2.剩余收益分配比例为,自有资金25%,优先级LP75% BigDecimal twoRightOwnFunds = residualIncome.multiply(BigDecimal.valueOf(0.25)).setScale(2, RoundingMode.HALF_UP);//剩余自有资金 BigDecimal twoRightFundraisingAmount = residualIncome.subtract(twoRightOwnFunds); //剩余优先级LP profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); - profitDistributionMapper.updateByPrimaryKey(profitDistribution); + profitDistributionMapper.insert(profitDistribution); //算分 共五分,可用资金1分,其他共4分,错一个不得分 if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0) { @@ -87,7 +212,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp); - profitDistributionMapper.updateByPrimaryKey(profitDistribution); + profitDistributionMapper.insert(profitDistribution); if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 && userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && userRemainingEarningsSubordinatedLp.compareTo(twoRightSubordinatedLp) == 0) { @@ -103,7 +228,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService BigDecimal twoRightFundraisingAmount = residualIncome.subtract(twoRightOwnFunds); //剩余优先级LP profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); - profitDistributionMapper.updateByPrimaryKey(profitDistribution); + profitDistributionMapper.insert(profitDistribution); if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0) { @@ -125,7 +250,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService profitDistribution.setRemainingOwnFunds(twoRightOwnFunds); profitDistribution.setRemainingEarningsPreferredLp(twoRightFundraisingAmount); profitDistribution.setRemainingEarningsSubordinatedLp(twoRightSubordinatedLp); - profitDistributionMapper.updateByPrimaryKey(profitDistribution); + profitDistributionMapper.insert(profitDistribution); if (rightOwnFunds.compareTo(userRoundOwnFunds) == 0 && rightFundraisingAmount.compareTo(userRoundPreferredLp) == 0 && twoRightOwnFunds.compareTo(remainingOwnFunds) == 0 && twoRightFundraisingAmount.compareTo(remainingEarningsPreferredLp) == 0 && rightBankLoan.compareTo(userRoundBankLoan) == 0 && userRoundSubordinatedLp.compareTo(subordinatedLp) == 0 && @@ -144,7 +269,7 @@ public class ProfitDistributionServiceImpl implements ProfitDistributionService public ProfitDistribution echo(String flowId) { ProfitDistributionExample profitDistributionExample = new ProfitDistributionExample(); profitDistributionExample.createCriteria().andFlowIdEqualTo(flowId); - profitDistributionMapper.selectByExample(profitDistributionExample); - return null; + List profitDistributions = profitDistributionMapper.selectByExample(profitDistributionExample); + return profitDistributions.get(0); } } diff --git a/src/main/resources/mappers/ProfitDistributionMapper.xml b/src/main/resources/mappers/ProfitDistributionMapper.xml new file mode 100644 index 0000000..59b8b62 --- /dev/null +++ b/src/main/resources/mappers/ProfitDistributionMapper.xml @@ -0,0 +1,486 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, flow_id, project_name, investment_amount, exit_stock_price, fund_earnings, available_funds, + round_own_funds, round_subordinated_lp, round_preferred_lp, round_bank_loan, remaining_own_funds, + remaining_earnings_subordinated_lp, remaining_earnings_preferred_lp, user_available_funds, + user_round_own_funds, user_round_subordinated_lp, user_round_preferred_lp, user_round_bank_loan, + user_remaining_own_funds, user_remaining_earnings_subordinated_lp, user_remaining_earnings_preferred_lp + + + + + delete from profit_distribution + where id = #{id,jdbcType=VARCHAR} + + + delete from profit_distribution + + + + + + insert into profit_distribution (id, flow_id, project_name, + investment_amount, exit_stock_price, fund_earnings, + available_funds, round_own_funds, round_subordinated_lp, + round_preferred_lp, round_bank_loan, remaining_own_funds, + remaining_earnings_subordinated_lp, remaining_earnings_preferred_lp, + user_available_funds, user_round_own_funds, + user_round_subordinated_lp, user_round_preferred_lp, + user_round_bank_loan, user_remaining_own_funds, + user_remaining_earnings_subordinated_lp, user_remaining_earnings_preferred_lp + ) + values (#{id,jdbcType=VARCHAR}, #{flowId,jdbcType=VARCHAR}, #{projectName,jdbcType=VARCHAR}, + #{investmentAmount,jdbcType=DECIMAL}, #{exitStockPrice,jdbcType=DECIMAL}, #{fundEarnings,jdbcType=DECIMAL}, + #{availableFunds,jdbcType=DECIMAL}, #{roundOwnFunds,jdbcType=DECIMAL}, #{roundSubordinatedLp,jdbcType=DECIMAL}, + #{roundPreferredLp,jdbcType=DECIMAL}, #{roundBankLoan,jdbcType=DECIMAL}, #{remainingOwnFunds,jdbcType=DECIMAL}, + #{remainingEarningsSubordinatedLp,jdbcType=DECIMAL}, #{remainingEarningsPreferredLp,jdbcType=DECIMAL}, + #{userAvailableFunds,jdbcType=DECIMAL}, #{userRoundOwnFunds,jdbcType=DECIMAL}, + #{userRoundSubordinatedLp,jdbcType=DECIMAL}, #{userRoundPreferredLp,jdbcType=DECIMAL}, + #{userRoundBankLoan,jdbcType=DECIMAL}, #{userRemainingOwnFunds,jdbcType=DECIMAL}, + #{userRemainingEarningsSubordinatedLp,jdbcType=DECIMAL}, #{userRemainingEarningsPreferredLp,jdbcType=DECIMAL} + ) + + + insert into profit_distribution + + + id, + + + flow_id, + + + project_name, + + + investment_amount, + + + exit_stock_price, + + + fund_earnings, + + + available_funds, + + + round_own_funds, + + + round_subordinated_lp, + + + round_preferred_lp, + + + round_bank_loan, + + + remaining_own_funds, + + + remaining_earnings_subordinated_lp, + + + remaining_earnings_preferred_lp, + + + user_available_funds, + + + user_round_own_funds, + + + user_round_subordinated_lp, + + + user_round_preferred_lp, + + + user_round_bank_loan, + + + user_remaining_own_funds, + + + user_remaining_earnings_subordinated_lp, + + + user_remaining_earnings_preferred_lp, + + + + + #{id,jdbcType=VARCHAR}, + + + #{flowId,jdbcType=VARCHAR}, + + + #{projectName,jdbcType=VARCHAR}, + + + #{investmentAmount,jdbcType=DECIMAL}, + + + #{exitStockPrice,jdbcType=DECIMAL}, + + + #{fundEarnings,jdbcType=DECIMAL}, + + + #{availableFunds,jdbcType=DECIMAL}, + + + #{roundOwnFunds,jdbcType=DECIMAL}, + + + #{roundSubordinatedLp,jdbcType=DECIMAL}, + + + #{roundPreferredLp,jdbcType=DECIMAL}, + + + #{roundBankLoan,jdbcType=DECIMAL}, + + + #{remainingOwnFunds,jdbcType=DECIMAL}, + + + #{remainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + + + #{remainingEarningsPreferredLp,jdbcType=DECIMAL}, + + + #{userAvailableFunds,jdbcType=DECIMAL}, + + + #{userRoundOwnFunds,jdbcType=DECIMAL}, + + + #{userRoundSubordinatedLp,jdbcType=DECIMAL}, + + + #{userRoundPreferredLp,jdbcType=DECIMAL}, + + + #{userRoundBankLoan,jdbcType=DECIMAL}, + + + #{userRemainingOwnFunds,jdbcType=DECIMAL}, + + + #{userRemainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + + + #{userRemainingEarningsPreferredLp,jdbcType=DECIMAL}, + + + + + + update profit_distribution + + + id = #{record.id,jdbcType=VARCHAR}, + + + flow_id = #{record.flowId,jdbcType=VARCHAR}, + + + project_name = #{record.projectName,jdbcType=VARCHAR}, + + + investment_amount = #{record.investmentAmount,jdbcType=DECIMAL}, + + + exit_stock_price = #{record.exitStockPrice,jdbcType=DECIMAL}, + + + fund_earnings = #{record.fundEarnings,jdbcType=DECIMAL}, + + + available_funds = #{record.availableFunds,jdbcType=DECIMAL}, + + + round_own_funds = #{record.roundOwnFunds,jdbcType=DECIMAL}, + + + round_subordinated_lp = #{record.roundSubordinatedLp,jdbcType=DECIMAL}, + + + round_preferred_lp = #{record.roundPreferredLp,jdbcType=DECIMAL}, + + + round_bank_loan = #{record.roundBankLoan,jdbcType=DECIMAL}, + + + remaining_own_funds = #{record.remainingOwnFunds,jdbcType=DECIMAL}, + + + remaining_earnings_subordinated_lp = #{record.remainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + + + remaining_earnings_preferred_lp = #{record.remainingEarningsPreferredLp,jdbcType=DECIMAL}, + + + user_available_funds = #{record.userAvailableFunds,jdbcType=DECIMAL}, + + + user_round_own_funds = #{record.userRoundOwnFunds,jdbcType=DECIMAL}, + + + user_round_subordinated_lp = #{record.userRoundSubordinatedLp,jdbcType=DECIMAL}, + + + user_round_preferred_lp = #{record.userRoundPreferredLp,jdbcType=DECIMAL}, + + + user_round_bank_loan = #{record.userRoundBankLoan,jdbcType=DECIMAL}, + + + user_remaining_own_funds = #{record.userRemainingOwnFunds,jdbcType=DECIMAL}, + + + user_remaining_earnings_subordinated_lp = #{record.userRemainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + + + user_remaining_earnings_preferred_lp = #{record.userRemainingEarningsPreferredLp,jdbcType=DECIMAL}, + + + + + + + + update profit_distribution + set id = #{record.id,jdbcType=VARCHAR}, + flow_id = #{record.flowId,jdbcType=VARCHAR}, + project_name = #{record.projectName,jdbcType=VARCHAR}, + investment_amount = #{record.investmentAmount,jdbcType=DECIMAL}, + exit_stock_price = #{record.exitStockPrice,jdbcType=DECIMAL}, + fund_earnings = #{record.fundEarnings,jdbcType=DECIMAL}, + available_funds = #{record.availableFunds,jdbcType=DECIMAL}, + round_own_funds = #{record.roundOwnFunds,jdbcType=DECIMAL}, + round_subordinated_lp = #{record.roundSubordinatedLp,jdbcType=DECIMAL}, + round_preferred_lp = #{record.roundPreferredLp,jdbcType=DECIMAL}, + round_bank_loan = #{record.roundBankLoan,jdbcType=DECIMAL}, + remaining_own_funds = #{record.remainingOwnFunds,jdbcType=DECIMAL}, + remaining_earnings_subordinated_lp = #{record.remainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + remaining_earnings_preferred_lp = #{record.remainingEarningsPreferredLp,jdbcType=DECIMAL}, + user_available_funds = #{record.userAvailableFunds,jdbcType=DECIMAL}, + user_round_own_funds = #{record.userRoundOwnFunds,jdbcType=DECIMAL}, + user_round_subordinated_lp = #{record.userRoundSubordinatedLp,jdbcType=DECIMAL}, + user_round_preferred_lp = #{record.userRoundPreferredLp,jdbcType=DECIMAL}, + user_round_bank_loan = #{record.userRoundBankLoan,jdbcType=DECIMAL}, + user_remaining_own_funds = #{record.userRemainingOwnFunds,jdbcType=DECIMAL}, + user_remaining_earnings_subordinated_lp = #{record.userRemainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + user_remaining_earnings_preferred_lp = #{record.userRemainingEarningsPreferredLp,jdbcType=DECIMAL} + + + + + + update profit_distribution + + + flow_id = #{flowId,jdbcType=VARCHAR}, + + + project_name = #{projectName,jdbcType=VARCHAR}, + + + investment_amount = #{investmentAmount,jdbcType=DECIMAL}, + + + exit_stock_price = #{exitStockPrice,jdbcType=DECIMAL}, + + + fund_earnings = #{fundEarnings,jdbcType=DECIMAL}, + + + available_funds = #{availableFunds,jdbcType=DECIMAL}, + + + round_own_funds = #{roundOwnFunds,jdbcType=DECIMAL}, + + + round_subordinated_lp = #{roundSubordinatedLp,jdbcType=DECIMAL}, + + + round_preferred_lp = #{roundPreferredLp,jdbcType=DECIMAL}, + + + round_bank_loan = #{roundBankLoan,jdbcType=DECIMAL}, + + + remaining_own_funds = #{remainingOwnFunds,jdbcType=DECIMAL}, + + + remaining_earnings_subordinated_lp = #{remainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + + + remaining_earnings_preferred_lp = #{remainingEarningsPreferredLp,jdbcType=DECIMAL}, + + + user_available_funds = #{userAvailableFunds,jdbcType=DECIMAL}, + + + user_round_own_funds = #{userRoundOwnFunds,jdbcType=DECIMAL}, + + + user_round_subordinated_lp = #{userRoundSubordinatedLp,jdbcType=DECIMAL}, + + + user_round_preferred_lp = #{userRoundPreferredLp,jdbcType=DECIMAL}, + + + user_round_bank_loan = #{userRoundBankLoan,jdbcType=DECIMAL}, + + + user_remaining_own_funds = #{userRemainingOwnFunds,jdbcType=DECIMAL}, + + + user_remaining_earnings_subordinated_lp = #{userRemainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + + + user_remaining_earnings_preferred_lp = #{userRemainingEarningsPreferredLp,jdbcType=DECIMAL}, + + + where id = #{id,jdbcType=VARCHAR} + + + update profit_distribution + set flow_id = #{flowId,jdbcType=VARCHAR}, + project_name = #{projectName,jdbcType=VARCHAR}, + investment_amount = #{investmentAmount,jdbcType=DECIMAL}, + exit_stock_price = #{exitStockPrice,jdbcType=DECIMAL}, + fund_earnings = #{fundEarnings,jdbcType=DECIMAL}, + available_funds = #{availableFunds,jdbcType=DECIMAL}, + round_own_funds = #{roundOwnFunds,jdbcType=DECIMAL}, + round_subordinated_lp = #{roundSubordinatedLp,jdbcType=DECIMAL}, + round_preferred_lp = #{roundPreferredLp,jdbcType=DECIMAL}, + round_bank_loan = #{roundBankLoan,jdbcType=DECIMAL}, + remaining_own_funds = #{remainingOwnFunds,jdbcType=DECIMAL}, + remaining_earnings_subordinated_lp = #{remainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + remaining_earnings_preferred_lp = #{remainingEarningsPreferredLp,jdbcType=DECIMAL}, + user_available_funds = #{userAvailableFunds,jdbcType=DECIMAL}, + user_round_own_funds = #{userRoundOwnFunds,jdbcType=DECIMAL}, + user_round_subordinated_lp = #{userRoundSubordinatedLp,jdbcType=DECIMAL}, + user_round_preferred_lp = #{userRoundPreferredLp,jdbcType=DECIMAL}, + user_round_bank_loan = #{userRoundBankLoan,jdbcType=DECIMAL}, + user_remaining_own_funds = #{userRemainingOwnFunds,jdbcType=DECIMAL}, + user_remaining_earnings_subordinated_lp = #{userRemainingEarningsSubordinatedLp,jdbcType=DECIMAL}, + user_remaining_earnings_preferred_lp = #{userRemainingEarningsPreferredLp,jdbcType=DECIMAL} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file