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 b608f08..370067c 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/InvestmentReportController.java @@ -31,7 +31,7 @@ public class InvestmentReportController { @Autowired private ExitTimeMapper exitTimeMapper; @Autowired - ProfitManagementMapper profitManagementMapper; + private ProfitManagementMapper profitManagementMapper; @AnonymousAccess @GetMapping("getProjectPoolList") @@ -49,7 +49,7 @@ public class InvestmentReportController { BigDecimal investmentAmount = profitManagement.getInvestmentAmount(); // 投资金额 // 基金收益/投资金额=投资收益率 - BigDecimal bigDecimal = fundEarnings.divide(investmentAmount,6,RoundingMode.HALF_UP); + BigDecimal bigDecimal = fundEarnings.divide(investmentAmount,2,RoundingMode.HALF_UP); map.put(profitManagement.getMarketTime(), bigDecimal);// todo 时间格式是年月日 } } @@ -90,7 +90,7 @@ public class InvestmentReportController { @AnonymousAccess @PostMapping("uploadReport") @ApiOperation("上传报告") - public ResultEntity uploadReport(@RequestParam("file") @RequestPart(name = "file") MultipartFile file, + public ResultEntity uploadReport(@RequestPart(name = "file") MultipartFile file, @ApiParam("文件名称") @RequestParam String fileName, @RequestParam String flowId, @RequestParam String schoolId) { diff --git a/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java b/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java new file mode 100644 index 0000000..58f7fc3 --- /dev/null +++ b/src/main/java/com/sztzjy/fund_investment/controller/ProfitDistributionController.java @@ -0,0 +1,19 @@ +package com.sztzjy.fund_investment.controller; + +import com.sztzjy.fund_investment.service.ProfitDistributionService; +import io.swagger.annotations.Api; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Author xcj + * @Date 2023/12/6 + */ +@RestController +@RequestMapping("/stu/profitDistribution") +@Api(tags = "学生端--收益管理相关接口") +public class ProfitDistributionController { + @Autowired + private ProfitDistributionService profitDistributionService; +} diff --git a/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java b/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java index a219504..6c1638f 100644 --- a/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java +++ b/src/main/java/com/sztzjy/fund_investment/controller/ProfitManagementController.java @@ -1,6 +1,7 @@ package com.sztzjy.fund_investment.controller; import com.sztzjy.fund_investment.annotation.AnonymousAccess; +import com.sztzjy.fund_investment.entity.ExitTime; import com.sztzjy.fund_investment.entity.ProfitManagement; import com.sztzjy.fund_investment.service.ProfitManagementService; import com.sztzjy.fund_investment.util.ResultEntity; @@ -13,7 +14,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; import java.util.List; +import java.util.Random; /** * @Author xcj @@ -31,7 +34,7 @@ public class ProfitManagementController { * @author xcj * @Date 2023/11/23 */ - @ApiOperation("生成折线图/回显") + @ApiOperation("生成折线图/回显时间/价格/名称/时间方便排序是按日为单位的数字类型") @AnonymousAccess @GetMapping("/getLineChart") public ResultEntity> getLineChart(@RequestParam String flowId) { @@ -40,15 +43,38 @@ public class ProfitManagementController { } - @ApiOperation("退出时机弹窗") + @ApiOperation("退出时机弹窗/可用于回显") @AnonymousAccess - @GetMapping("/getExitTime") //todo 基金收益 / 投资金额 = 退出时收益率 - public ResultEntity getExitTime(@RequestParam String flowId) { - return null; + @GetMapping("/getExitTime") + public ResultEntity getExitTime(@RequestParam String flowId) { + return new ResultEntity(profitManagementService.getExitTime(flowId)); } - @ApiOperation("显示股票相关信息弹窗") + @ApiOperation("退出时机弹窗/随机获取股票价格") + @AnonymousAccess + @GetMapping("/getRandomPrice") + public ResultEntity getRandomPrice(@ApiParam("getLineChart返回的Id") @RequestParam String id) { + Random random = new Random(); + double randomValue = 0.01 + random.nextDouble() * 19.99; // 生成0到20之间的随机数(不包括0) + return new ResultEntity<>(randomValue); + } + + @ApiOperation("退出时机弹窗/判断市值和基金收益对错,计算错误则返回正确答案") + @AnonymousAccess + @GetMapping("/getExitTimeRightMarketValueAndFundEarnings") + public ResultEntity getExitTimeRightMarketValueAndFundEarnings(@RequestParam String flowId, + @ApiParam("退出时间") @RequestParam String exitTime, + @ApiParam("随机生成的价格") @RequestParam BigDecimal price, + @ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue, + @ApiParam("用户输入的基金收益") @RequestParam BigDecimal userFundEarnings) { + return profitManagementService.getExitTimeRightMarketValueAndFundEarnings(flowId, exitTime, price, userMarketValue, userFundEarnings); + } + + + + + @ApiOperation("显示股票相关信息弹窗/用户输入后后回显可用") @AnonymousAccess @GetMapping("/getStockInfo") public ResultEntity getStockInfo(@ApiParam("getLineChart返回的Id") @RequestParam String id) { @@ -56,13 +82,13 @@ public class ProfitManagementController { } - @ApiOperation("判断市值和基金收益对错") + @ApiOperation("判断市值和基金收益对错,计算错误则返回正确答案") @AnonymousAccess @GetMapping("/getRightMarketValueAndFundEarnings") public ResultEntity getStockInfo(@RequestParam @ApiParam("getLineChart返回的Id") String id, - @ApiParam("用户输入的市值") @RequestParam String userMarketValue, - @ApiParam("用户输入的基金收益") @RequestParam String userFundEarnings) { - profitManagementService.getRightMarketValueAndFundEarnings(id, userMarketValue, userFundEarnings); - return null; + @ApiParam("用户输入的市值") @RequestParam BigDecimal userMarketValue, + @ApiParam("用户输入的基金收益") @RequestParam BigDecimal userFundEarnings) { + return profitManagementService.getRightMarketValueAndFundEarnings(id, userMarketValue, userFundEarnings); } + } diff --git a/src/main/java/com/sztzjy/fund_investment/entity/ExitTime.java b/src/main/java/com/sztzjy/fund_investment/entity/ExitTime.java index d7635db..9663e43 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/ExitTime.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/ExitTime.java @@ -12,7 +12,7 @@ public class ExitTime { private String flowId; @ApiModelProperty("投资项目") - private String porjectName; + private String projectName; @ApiModelProperty("投资金额") private BigDecimal investmentAmount; @@ -41,6 +41,12 @@ public class ExitTime { @ApiModelProperty("退出股价") private BigDecimal exitStockPrice; + @ApiModelProperty("用户输入的市值") + private BigDecimal userMarketValue; + + @ApiModelProperty("用户输入的基金收益") + private BigDecimal userFundEarnings; + public String getFlowId() { return flowId; } @@ -49,12 +55,12 @@ public class ExitTime { this.flowId = flowId == null ? null : flowId.trim(); } - public String getPorjectName() { - return porjectName; + public String getProjectName() { + return projectName; } - public void setPorjectName(String porjectName) { - this.porjectName = porjectName == null ? null : porjectName.trim(); + public void setProjectName(String projectName) { + this.projectName = projectName == null ? null : projectName.trim(); } public BigDecimal getInvestmentAmount() { @@ -128,4 +134,20 @@ public class ExitTime { public void setExitStockPrice(BigDecimal exitStockPrice) { this.exitStockPrice = exitStockPrice; } + + public BigDecimal getUserMarketValue() { + return userMarketValue; + } + + public void setUserMarketValue(BigDecimal userMarketValue) { + this.userMarketValue = userMarketValue; + } + + public BigDecimal getUserFundEarnings() { + return userFundEarnings; + } + + public void setUserFundEarnings(BigDecimal userFundEarnings) { + this.userFundEarnings = userFundEarnings; + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/fund_investment/entity/ExitTimeExample.java b/src/main/java/com/sztzjy/fund_investment/entity/ExitTimeExample.java index 7f6432a..d479085 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/ExitTimeExample.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/ExitTimeExample.java @@ -175,73 +175,73 @@ public class ExitTimeExample { return (Criteria) this; } - public Criteria andPorjectNameIsNull() { - addCriterion("porject_name is null"); + public Criteria andProjectNameIsNull() { + addCriterion("project_name is null"); return (Criteria) this; } - public Criteria andPorjectNameIsNotNull() { - addCriterion("porject_name is not null"); + public Criteria andProjectNameIsNotNull() { + addCriterion("project_name is not null"); return (Criteria) this; } - public Criteria andPorjectNameEqualTo(String value) { - addCriterion("porject_name =", value, "porjectName"); + public Criteria andProjectNameEqualTo(String value) { + addCriterion("project_name =", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameNotEqualTo(String value) { - addCriterion("porject_name <>", value, "porjectName"); + public Criteria andProjectNameNotEqualTo(String value) { + addCriterion("project_name <>", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameGreaterThan(String value) { - addCriterion("porject_name >", value, "porjectName"); + public Criteria andProjectNameGreaterThan(String value) { + addCriterion("project_name >", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameGreaterThanOrEqualTo(String value) { - addCriterion("porject_name >=", value, "porjectName"); + public Criteria andProjectNameGreaterThanOrEqualTo(String value) { + addCriterion("project_name >=", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameLessThan(String value) { - addCriterion("porject_name <", value, "porjectName"); + public Criteria andProjectNameLessThan(String value) { + addCriterion("project_name <", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameLessThanOrEqualTo(String value) { - addCriterion("porject_name <=", value, "porjectName"); + public Criteria andProjectNameLessThanOrEqualTo(String value) { + addCriterion("project_name <=", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameLike(String value) { - addCriterion("porject_name like", value, "porjectName"); + public Criteria andProjectNameLike(String value) { + addCriterion("project_name like", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameNotLike(String value) { - addCriterion("porject_name not like", value, "porjectName"); + public Criteria andProjectNameNotLike(String value) { + addCriterion("project_name not like", value, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameIn(List values) { - addCriterion("porject_name in", values, "porjectName"); + public Criteria andProjectNameIn(List values) { + addCriterion("project_name in", values, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameNotIn(List values) { - addCriterion("porject_name not in", values, "porjectName"); + public Criteria andProjectNameNotIn(List values) { + addCriterion("project_name not in", values, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameBetween(String value1, String value2) { - addCriterion("porject_name between", value1, value2, "porjectName"); + public Criteria andProjectNameBetween(String value1, String value2) { + addCriterion("project_name between", value1, value2, "projectName"); return (Criteria) this; } - public Criteria andPorjectNameNotBetween(String value1, String value2) { - addCriterion("porject_name not between", value1, value2, "porjectName"); + public Criteria andProjectNameNotBetween(String value1, String value2) { + addCriterion("project_name not between", value1, value2, "projectName"); return (Criteria) this; } @@ -794,6 +794,126 @@ public class ExitTimeExample { addCriterion("exit_stock_price not between", value1, value2, "exitStockPrice"); return (Criteria) this; } + + public Criteria andUserMarketValueIsNull() { + addCriterion("user_market_value is null"); + return (Criteria) this; + } + + public Criteria andUserMarketValueIsNotNull() { + addCriterion("user_market_value is not null"); + return (Criteria) this; + } + + public Criteria andUserMarketValueEqualTo(BigDecimal value) { + addCriterion("user_market_value =", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueNotEqualTo(BigDecimal value) { + addCriterion("user_market_value <>", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueGreaterThan(BigDecimal value) { + addCriterion("user_market_value >", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("user_market_value >=", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueLessThan(BigDecimal value) { + addCriterion("user_market_value <", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueLessThanOrEqualTo(BigDecimal value) { + addCriterion("user_market_value <=", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueIn(List values) { + addCriterion("user_market_value in", values, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueNotIn(List values) { + addCriterion("user_market_value not in", values, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_market_value between", value1, value2, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_market_value not between", value1, value2, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsIsNull() { + addCriterion("user_fund_earnings is null"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsIsNotNull() { + addCriterion("user_fund_earnings is not null"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings =", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsNotEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings <>", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsGreaterThan(BigDecimal value) { + addCriterion("user_fund_earnings >", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings >=", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsLessThan(BigDecimal value) { + addCriterion("user_fund_earnings <", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsLessThanOrEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings <=", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsIn(List values) { + addCriterion("user_fund_earnings in", values, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsNotIn(List values) { + addCriterion("user_fund_earnings not in", values, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_fund_earnings between", value1, value2, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_fund_earnings not between", value1, value2, "userFundEarnings"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/fund_investment/entity/ProfitDistribution.java b/src/main/java/com/sztzjy/fund_investment/entity/ProfitDistribution.java index eb1da2d..fa97a0b 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/ProfitDistribution.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/ProfitDistribution.java @@ -4,7 +4,7 @@ import java.math.BigDecimal; import io.swagger.annotations.ApiModelProperty; /** - * + * 收益分配表 * @author xcj * profit_distribution */ diff --git a/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagement.java b/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagement.java index a754cd9..f795606 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagement.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagement.java @@ -15,6 +15,9 @@ public class ProfitManagement { @ApiModelProperty("流程ID") private String flowId; + @ApiModelProperty("项目名称") + private String projectName; + @ApiModelProperty("投资金额") private BigDecimal investmentAmount; @@ -39,6 +42,12 @@ public class ProfitManagement { @ApiModelProperty("基金收益") private BigDecimal fundEarnings; + @ApiModelProperty("用户输入的市值") + private BigDecimal userMarketValue; + + @ApiModelProperty("用户输入的基金收益") + private BigDecimal userFundEarnings; + public String getId() { return id; } @@ -55,6 +64,14 @@ public class ProfitManagement { this.flowId = flowId == null ? null : flowId.trim(); } + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName == null ? null : projectName.trim(); + } + public BigDecimal getInvestmentAmount() { return investmentAmount; } @@ -118,4 +135,20 @@ public class ProfitManagement { public void setFundEarnings(BigDecimal fundEarnings) { this.fundEarnings = fundEarnings; } + + public BigDecimal getUserMarketValue() { + return userMarketValue; + } + + public void setUserMarketValue(BigDecimal userMarketValue) { + this.userMarketValue = userMarketValue; + } + + public BigDecimal getUserFundEarnings() { + return userFundEarnings; + } + + public void setUserFundEarnings(BigDecimal userFundEarnings) { + this.userFundEarnings = userFundEarnings; + } } \ No newline at end of file diff --git a/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagementExample.java b/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagementExample.java index bd142c8..5761908 100644 --- a/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagementExample.java +++ b/src/main/java/com/sztzjy/fund_investment/entity/ProfitManagementExample.java @@ -245,6 +245,76 @@ public class ProfitManagementExample { return (Criteria) this; } + public Criteria andProjectNameIsNull() { + addCriterion("project_name is null"); + return (Criteria) this; + } + + public Criteria andProjectNameIsNotNull() { + addCriterion("project_name is not null"); + return (Criteria) this; + } + + public Criteria andProjectNameEqualTo(String value) { + addCriterion("project_name =", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameNotEqualTo(String value) { + addCriterion("project_name <>", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameGreaterThan(String value) { + addCriterion("project_name >", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameGreaterThanOrEqualTo(String value) { + addCriterion("project_name >=", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameLessThan(String value) { + addCriterion("project_name <", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameLessThanOrEqualTo(String value) { + addCriterion("project_name <=", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameLike(String value) { + addCriterion("project_name like", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameNotLike(String value) { + addCriterion("project_name not like", value, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameIn(List values) { + addCriterion("project_name in", values, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameNotIn(List values) { + addCriterion("project_name not in", values, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameBetween(String value1, String value2) { + addCriterion("project_name between", value1, value2, "projectName"); + return (Criteria) this; + } + + public Criteria andProjectNameNotBetween(String value1, String value2) { + addCriterion("project_name not between", value1, value2, "projectName"); + return (Criteria) this; + } + public Criteria andInvestmentAmountIsNull() { addCriterion("investment_amount is null"); return (Criteria) this; @@ -724,6 +794,126 @@ public class ProfitManagementExample { addCriterion("fund_earnings not between", value1, value2, "fundEarnings"); return (Criteria) this; } + + public Criteria andUserMarketValueIsNull() { + addCriterion("user_market_value is null"); + return (Criteria) this; + } + + public Criteria andUserMarketValueIsNotNull() { + addCriterion("user_market_value is not null"); + return (Criteria) this; + } + + public Criteria andUserMarketValueEqualTo(BigDecimal value) { + addCriterion("user_market_value =", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueNotEqualTo(BigDecimal value) { + addCriterion("user_market_value <>", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueGreaterThan(BigDecimal value) { + addCriterion("user_market_value >", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("user_market_value >=", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueLessThan(BigDecimal value) { + addCriterion("user_market_value <", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueLessThanOrEqualTo(BigDecimal value) { + addCriterion("user_market_value <=", value, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueIn(List values) { + addCriterion("user_market_value in", values, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueNotIn(List values) { + addCriterion("user_market_value not in", values, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_market_value between", value1, value2, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserMarketValueNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_market_value not between", value1, value2, "userMarketValue"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsIsNull() { + addCriterion("user_fund_earnings is null"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsIsNotNull() { + addCriterion("user_fund_earnings is not null"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings =", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsNotEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings <>", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsGreaterThan(BigDecimal value) { + addCriterion("user_fund_earnings >", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsGreaterThanOrEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings >=", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsLessThan(BigDecimal value) { + addCriterion("user_fund_earnings <", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsLessThanOrEqualTo(BigDecimal value) { + addCriterion("user_fund_earnings <=", value, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsIn(List values) { + addCriterion("user_fund_earnings in", values, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsNotIn(List values) { + addCriterion("user_fund_earnings not in", values, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_fund_earnings between", value1, value2, "userFundEarnings"); + return (Criteria) this; + } + + public Criteria andUserFundEarningsNotBetween(BigDecimal value1, BigDecimal value2) { + addCriterion("user_fund_earnings not between", value1, value2, "userFundEarnings"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/src/main/java/com/sztzjy/fund_investment/service/ProfitDistributionService.java b/src/main/java/com/sztzjy/fund_investment/service/ProfitDistributionService.java new file mode 100644 index 0000000..f92edbc --- /dev/null +++ b/src/main/java/com/sztzjy/fund_investment/service/ProfitDistributionService.java @@ -0,0 +1,8 @@ +package com.sztzjy.fund_investment.service; + +/** + * @Author xcj + * @Date 2023/12/6 + */ +public interface ProfitDistributionService { +} diff --git a/src/main/java/com/sztzjy/fund_investment/service/ProfitManagementService.java b/src/main/java/com/sztzjy/fund_investment/service/ProfitManagementService.java index 4a0df70..c1c6dea 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/ProfitManagementService.java +++ b/src/main/java/com/sztzjy/fund_investment/service/ProfitManagementService.java @@ -1,7 +1,10 @@ package com.sztzjy.fund_investment.service; +import com.sztzjy.fund_investment.entity.ExitTime; import com.sztzjy.fund_investment.entity.ProfitManagement; +import com.sztzjy.fund_investment.util.ResultEntity; +import java.math.BigDecimal; import java.util.List; /** @@ -13,5 +16,9 @@ public interface ProfitManagementService { ProfitManagement getStockInfo(String id); - void getRightMarketValueAndFundEarnings(String id, String userMarketValue, String userFundEarnings); + ResultEntity getRightMarketValueAndFundEarnings(String id, BigDecimal userMarketValue, BigDecimal userFundEarnings); + + ExitTime getExitTime(String flowId); + + ResultEntity getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price, BigDecimal userMarketValue, BigDecimal userFundEarnings); } 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 new file mode 100644 index 0000000..246f90a --- /dev/null +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitDistributionServiceImpl.java @@ -0,0 +1,12 @@ +package com.sztzjy.fund_investment.service.serviceImpl; + +import com.sztzjy.fund_investment.service.ProfitDistributionService; +import org.springframework.stereotype.Service; + +/** + * @Author xcj + * @Date 2023/12/6 + */ +@Service +public class ProfitDistributionServiceImpl implements ProfitDistributionService { +} diff --git a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java index cbff34b..159f8bb 100644 --- a/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java +++ b/src/main/java/com/sztzjy/fund_investment/service/serviceImpl/ProfitManagementServiceImpl.java @@ -1,19 +1,20 @@ 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.ExitTime; import com.sztzjy.fund_investment.entity.ProfitManagement; import com.sztzjy.fund_investment.entity.ProfitManagementExample; +import com.sztzjy.fund_investment.mapper.ExitTimeMapper; import com.sztzjy.fund_investment.mapper.ProfitManagementMapper; +import com.sztzjy.fund_investment.service.PerformanceScoreService; import com.sztzjy.fund_investment.service.ProfitManagementService; +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; import java.math.RoundingMode; -import java.util.ArrayList; import java.util.List; -import java.util.Random; /** * @Author xcj @@ -23,38 +24,16 @@ import java.util.Random; public class ProfitManagementServiceImpl implements ProfitManagementService { @Autowired private ProfitManagementMapper profitManagementMapper; + @Autowired + private PerformanceScoreService performanceScoreService; + @Autowired + private ExitTimeMapper exitTimeMapper; - /* + /* 折线图 * @author xcj - * @Date 2023/11/23 + * @Date 2023/12/6 */ -// @Override -// public List getLineChart(String flowId) { -// ProfitManagementExample profitManagementExample = new ProfitManagementExample(); -// profitManagementExample.createCriteria().andFlowIdEqualTo(flowId); -// profitManagementExample.setOrderByClause("market_time ASC"); -// List profitManagementList = profitManagementMapper.selectByExample(profitManagementExample); -// if (!profitManagementList.isEmpty()) { -// return profitManagementList; -// } -// int date[] = {Constant.ONEDAY, Constant.FIVEDAY, Constant.TWENTYDAY, Constant.ONEMONTH, Constant.THREEMONTHS, Constant.SIXMONTHS}; -// List list = new ArrayList<>(); -// for (int i = 0; i < date.length; i++) { -// ProfitManagement profitManagement = new ProfitManagement(); -// profitManagement.setId(IdUtil.simpleUUID()); -// profitManagement.setFlowId(flowId); -// profitManagement.setMarketTime(date[i]); -// Random random = new Random(); -// double randomValue = 0.01 + random.nextDouble() * 19.99; // 生成0到20之间的随机数(不包括0) -// BigDecimal stockPrice = BigDecimal.valueOf(randomValue).setScale(2, RoundingMode.HALF_UP); // 保留两位小数 -// profitManagement.setStockPrice(stockPrice); -// profitManagementMapper.insert(profitManagement); -// list.add(profitManagement); -// } -// return list; -// } - @Override public List getLineChart(String flowId) { ProfitManagementExample profitManagementExample = new ProfitManagementExample(); @@ -71,18 +50,98 @@ public class ProfitManagementServiceImpl implements ProfitManagementService { } - + /** + * 计算市值和收益并算分 + * + * @author xcj + * @Date 2023/12/6 + */ @Override - public void getRightMarketValueAndFundEarnings(String id, String userMarketValue, String userFundEarnings) { + public ResultEntity getRightMarketValueAndFundEarnings(String id, BigDecimal userMarketValue, BigDecimal userFundEarnings) { ProfitManagement profitManagement = profitManagementMapper.selectByPrimaryKey(id); //公司市值=股票价格*总股本 - BigDecimal marketValue = profitManagement.getStockPrice().multiply(profitManagement.getTotalEquity()).setScale(6, RoundingMode.HALF_UP); + BigDecimal marketValue = profitManagement.getStockPrice().multiply(profitManagement.getTotalEquity()).setScale(2, RoundingMode.HALF_UP); profitManagement.setMarketValue(marketValue); + profitManagement.setUserMarketValue(userMarketValue); //基金收益=持股数量*股票价格-投资金额 - BigDecimal fundEarnings = profitManagement.getShareCount().multiply(profitManagement.getStockPrice()).subtract(profitManagement.getInvestmentAmount()).setScale(6, RoundingMode.HALF_UP); + BigDecimal fundEarnings = profitManagement.getShareCount().multiply(profitManagement.getStockPrice()).subtract(profitManagement.getInvestmentAmount()).setScale(2, RoundingMode.HALF_UP); profitManagement.setFundEarnings(fundEarnings); -// if (new BigDecimal(userMarketValue).compareTo(fundEarnings)=0){ -// BigDecimal. -// } + profitManagement.setUserFundEarnings(userFundEarnings); + + profitManagementMapper.updateByPrimaryKey(profitManagement); + if (!(userMarketValue.compareTo(marketValue) == 0)) { + return new ResultEntity(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue); + } else { + performanceScoreService.calculateScoreByModule("profitManagementMarketValueScore", 2, profitManagement.getFlowId()); + } + if (!(userFundEarnings.compareTo(fundEarnings) == 0)) { + return new ResultEntity(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings); + } else { + performanceScoreService.calculateScoreByModule("profitManagementFundScore", 2, profitManagement.getFlowId()); + } + return null; + } + + + /* 展示退出时机弹窗 + * @author xcj + * @Date 2023/12/6 + */ + @Override + public ExitTime getExitTime(String flowId) { + ExitTime dataExitTime = exitTimeMapper.selectByPrimaryKey(flowId); + if (dataExitTime != null) { + return dataExitTime; + } else { + ExitTime exitTime = new ExitTime(); + List profitManagementList = getLineChart(flowId); + ProfitManagement profitManagement = profitManagementList.get(0); + exitTime.setFlowId(flowId); + exitTime.setProjectName(profitManagement.getProjectName()); + exitTime.setInvestmentAmount(profitManagement.getInvestmentAmount()); + exitTime.setShareRatio(profitManagement.getShareRatio()); + exitTime.setTotalEquity(profitManagement.getTotalEquity()); + exitTime.setShareCount(profitManagement.getShareCount()); + exitTimeMapper.insert(exitTime); + return exitTime; + } + } + + + /* 计算退出时基金收益和市值,并与学生填写的比较 + * @author xcj + * @Date 2023/12/6 + */ + @Override + public ResultEntity getExitTimeRightMarketValueAndFundEarnings(String flowId, String exitTime, BigDecimal price, + BigDecimal userMarketValue, BigDecimal userFundEarnings) { + ExitTime exitTimeEntity = exitTimeMapper.selectByPrimaryKey(flowId); + exitTimeEntity.setExitTiming(exitTime); + exitTimeEntity.setExitStockPrice(price); + exitTimeEntity.setUserMarketValue(userMarketValue); + exitTimeEntity.setUserFundEarnings(userFundEarnings); + //公司市值=股票价格*总股本 + BigDecimal marketValue = exitTimeEntity.getExitStockPrice().multiply(exitTimeEntity.getTotalEquity()).setScale(2, RoundingMode.HALF_UP); + exitTimeEntity.setExitMarketValue(marketValue); + exitTimeEntity.setUserMarketValue(userMarketValue); + //基金收益=持股数量*股票价格-投资金额 + BigDecimal fundEarnings = exitTimeEntity.getShareCount().multiply(exitTimeEntity.getExitStockPrice()).subtract(exitTimeEntity.getInvestmentAmount()).setScale(2, RoundingMode.HALF_UP); + exitTimeEntity.setUserFundEarnings(userFundEarnings); + exitTimeEntity.setExitFundEarnings(fundEarnings); + // 退出时收益率 = 基金收益 / 投资金额 + BigDecimal exitYield = exitTimeEntity.getExitFundEarnings().divide(exitTimeEntity.getInvestmentAmount(), 2, RoundingMode.HALF_UP); + exitTimeEntity.setExitYield(exitYield); + exitTimeMapper.updateByPrimaryKey(exitTimeEntity); + if (!(userMarketValue.compareTo(marketValue) == 0)) { + return new ResultEntity(HttpStatus.BAD_REQUEST, "市值计算错误!", marketValue); + } else { + performanceScoreService.calculateScoreByModule("profitManagementFundExitScore", 3, flowId); + } + if (!(userFundEarnings.compareTo(fundEarnings) == 0)) { + return new ResultEntity(HttpStatus.BAD_REQUEST, "收益计算错误!", fundEarnings); + } else { + performanceScoreService.calculateScoreByModule("profitManagementMarketValueExitScore", 3, flowId); + } + return null; } } diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml index 949468c..46a3ba6 100644 --- a/src/main/resources/generatorConfig.xml +++ b/src/main/resources/generatorConfig.xml @@ -3,9 +3,9 @@ "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> - - - + + + @@ -16,44 +16,47 @@ - - + + - + - - + + - + - - + + - - - - - - - - - - - + + + + + + + + + +
+ - - - - - + + + + + diff --git a/src/main/resources/mappers/ProfitManagementMapper.xml b/src/main/resources/mappers/ProfitManagementMapper.xml index 416c986..840b6f7 100644 --- a/src/main/resources/mappers/ProfitManagementMapper.xml +++ b/src/main/resources/mappers/ProfitManagementMapper.xml @@ -4,6 +4,7 @@ + @@ -12,6 +13,8 @@ + + @@ -72,8 +75,8 @@ - id, flow_id, investment_amount, share_ratio, total_equity, share_count, market_time, - stock_price, market_value, fund_earnings + id, flow_id, project_name, investment_amount, share_ratio, total_equity, share_count, + market_time, stock_price, market_value, fund_earnings, user_market_value, user_fund_earnings @@ -197,6 +220,9 @@ flow_id = #{record.flowId,jdbcType=VARCHAR}, + + project_name = #{record.projectName,jdbcType=VARCHAR}, + investment_amount = #{record.investmentAmount,jdbcType=DECIMAL}, @@ -221,6 +247,12 @@ fund_earnings = #{record.fundEarnings,jdbcType=DECIMAL}, + + user_market_value = #{record.userMarketValue,jdbcType=DECIMAL}, + + + user_fund_earnings = #{record.userFundEarnings,jdbcType=DECIMAL}, + @@ -230,6 +262,7 @@ update profit_management set id = #{record.id,jdbcType=VARCHAR}, flow_id = #{record.flowId,jdbcType=VARCHAR}, + project_name = #{record.projectName,jdbcType=VARCHAR}, investment_amount = #{record.investmentAmount,jdbcType=DECIMAL}, share_ratio = #{record.shareRatio,jdbcType=DECIMAL}, total_equity = #{record.totalEquity,jdbcType=DECIMAL}, @@ -237,7 +270,9 @@ market_time = #{record.marketTime,jdbcType=INTEGER}, stock_price = #{record.stockPrice,jdbcType=DECIMAL}, market_value = #{record.marketValue,jdbcType=DECIMAL}, - fund_earnings = #{record.fundEarnings,jdbcType=DECIMAL} + fund_earnings = #{record.fundEarnings,jdbcType=DECIMAL}, + user_market_value = #{record.userMarketValue,jdbcType=DECIMAL}, + user_fund_earnings = #{record.userFundEarnings,jdbcType=DECIMAL} @@ -248,6 +283,9 @@ flow_id = #{flowId,jdbcType=VARCHAR}, + + project_name = #{projectName,jdbcType=VARCHAR}, + investment_amount = #{investmentAmount,jdbcType=DECIMAL}, @@ -272,12 +310,19 @@ fund_earnings = #{fundEarnings,jdbcType=DECIMAL}, + + user_market_value = #{userMarketValue,jdbcType=DECIMAL}, + + + user_fund_earnings = #{userFundEarnings,jdbcType=DECIMAL}, + where id = #{id,jdbcType=VARCHAR} update profit_management set flow_id = #{flowId,jdbcType=VARCHAR}, + project_name = #{projectName,jdbcType=VARCHAR}, investment_amount = #{investmentAmount,jdbcType=DECIMAL}, share_ratio = #{shareRatio,jdbcType=DECIMAL}, total_equity = #{totalEquity,jdbcType=DECIMAL}, @@ -285,7 +330,9 @@ market_time = #{marketTime,jdbcType=INTEGER}, stock_price = #{stockPrice,jdbcType=DECIMAL}, market_value = #{marketValue,jdbcType=DECIMAL}, - fund_earnings = #{fundEarnings,jdbcType=DECIMAL} + fund_earnings = #{fundEarnings,jdbcType=DECIMAL}, + user_market_value = #{userMarketValue,jdbcType=DECIMAL}, + user_fund_earnings = #{userFundEarnings,jdbcType=DECIMAL} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file