新增退出时机表,完成投资报告页面接口

master
xiaoCJ 1 year ago
parent a66950f786
commit 258a3d8468

@ -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<String> uploadReport(@RequestParam("file") @RequestPart(name = "file") MultipartFile file,
public ResultEntity<String> uploadReport(@RequestPart(name = "file") MultipartFile file,
@ApiParam("文件名称") @RequestParam String fileName,
@RequestParam String flowId,
@RequestParam String schoolId) {

@ -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;
}

@ -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<List<ProfitManagement>> getLineChart(@RequestParam String flowId) {
@ -40,15 +43,38 @@ public class ProfitManagementController {
}
@ApiOperation("退出时机弹窗")
@ApiOperation("退出时机弹窗/可用于回显")
@AnonymousAccess
@GetMapping("/getExitTime") //todo 基金收益 / 投资金额 = 退出时收益率
public ResultEntity<String> getExitTime(@RequestParam String flowId) {
return null;
@GetMapping("/getExitTime")
public ResultEntity<ExitTime> getExitTime(@RequestParam String flowId) {
return new ResultEntity<ExitTime>(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<ProfitManagement> 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);
}
}

@ -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;
}
}

@ -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<String> values) {
addCriterion("porject_name in", values, "porjectName");
public Criteria andProjectNameIn(List<String> values) {
addCriterion("project_name in", values, "projectName");
return (Criteria) this;
}
public Criteria andPorjectNameNotIn(List<String> values) {
addCriterion("porject_name not in", values, "porjectName");
public Criteria andProjectNameNotIn(List<String> 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<BigDecimal> values) {
addCriterion("user_market_value in", values, "userMarketValue");
return (Criteria) this;
}
public Criteria andUserMarketValueNotIn(List<BigDecimal> 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<BigDecimal> values) {
addCriterion("user_fund_earnings in", values, "userFundEarnings");
return (Criteria) this;
}
public Criteria andUserFundEarningsNotIn(List<BigDecimal> 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 {

@ -4,7 +4,7 @@ import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
/**
*
*
* @author xcj
* profit_distribution
*/

@ -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;
}
}

@ -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<String> values) {
addCriterion("project_name in", values, "projectName");
return (Criteria) this;
}
public Criteria andProjectNameNotIn(List<String> 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<BigDecimal> values) {
addCriterion("user_market_value in", values, "userMarketValue");
return (Criteria) this;
}
public Criteria andUserMarketValueNotIn(List<BigDecimal> 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<BigDecimal> values) {
addCriterion("user_fund_earnings in", values, "userFundEarnings");
return (Criteria) this;
}
public Criteria andUserFundEarningsNotIn(List<BigDecimal> 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 {

@ -0,0 +1,8 @@
package com.sztzjy.fund_investment.service;
/**
* @Author xcj
* @Date 2023/12/6
*/
public interface ProfitDistributionService {
}

@ -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);
}

@ -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 {
}

@ -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<ProfitManagement> getLineChart(String flowId) {
// ProfitManagementExample profitManagementExample = new ProfitManagementExample();
// profitManagementExample.createCriteria().andFlowIdEqualTo(flowId);
// profitManagementExample.setOrderByClause("market_time ASC");
// List<ProfitManagement> profitManagementList = profitManagementMapper.selectByExample(profitManagementExample);
// if (!profitManagementList.isEmpty()) {
// return profitManagementList;
// }
// int date[] = {Constant.ONEDAY, Constant.FIVEDAY, Constant.TWENTYDAY, Constant.ONEMONTH, Constant.THREEMONTHS, Constant.SIXMONTHS};
// List<ProfitManagement> 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<ProfitManagement> 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<ProfitManagement> 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;
}
}

@ -3,9 +3,9 @@
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- <commentGenerator>-->
<!-- <property name="suppressAllComments" value="true"/>-->
<!-- </commentGenerator>-->
<!-- <commentGenerator>-->
<!-- <property name="suppressAllComments" value="true"/>-->
<!-- </commentGenerator>-->
<!-- type值为自定义的MyCommentGenerator-->
<commentGenerator type="com.sztzjy.fund_investment.util.MyCommentGenerator">
<!-- 是否去除自动生成的注释 true false:否 -->
@ -16,44 +16,47 @@
</commentGenerator>
<!-- 配置数据库连接信息 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://118.31.7.2:3306/fund_investment" userId="root" password="sztzjy2017">
<property name="useInformationSchema" value="true"/> <!--useInformationSchema 实体类上添加数据表的注释 -->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://118.31.7.2:3306/fund_investment" userId="root"
password="sztzjy2017">
<property name="useInformationSchema" value="true"/> <!--useInformationSchema 实体类上添加数据表的注释 -->
</jdbcConnection>
<!-- 配置实体类的位置 -->
<!-- 配置实体类的位置 -->
<javaModelGenerator targetPackage="com.sztzjy.fund_investment.entity" targetProject="src/main/java">
<!-- 生成的Java模型是否支持序列化 -->
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 配置Mapper XML文件的位置-->
<sqlMapGenerator targetPackage="mappers" targetProject="src/main/resources">
<property name="enableSubPackages" value="true" />
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 配置Mapper接口的位置 -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.sztzjy.fund_investment.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
<javaClientGenerator type="XMLMAPPER" targetPackage="com.sztzjy.fund_investment.mapper"
targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<!-- 需要生成的表 -->
<!-- <table tableName="allotment_object" domainObjectName="AllotmentObject" />-->
<!-- <table tableName="flow" domainObjectName="Flow" />-->
<!-- <table tableName="fundraising" domainObjectName="Fundraising" />-->
<!-- <table tableName="inquiry_participation" domainObjectName="InquiryParticipation" />-->
<!-- <table tableName="issuance_info" domainObjectName="IssuanceInfo" />-->
<!-- <table tableName="issuance_parameter_input" domainObjectName="IssuanceParameterInput" />-->
<!-- <table tableName="performance_score" domainObjectName="PerformanceScore" />-->
<!-- <table tableName="tea_class_score" domainObjectName="TeaClassScore" />-->
<!-- <table tableName="profit_distribution" domainObjectName="ProfitDistribution" />-->
<table tableName="profit_management" domainObjectName="ProfitManagement" />
<!-- <table tableName="exit_time" domainObjectName="ExitTime" />-->
<!-- <table tableName="allotment_object" domainObjectName="AllotmentObject" />-->
<!-- <table tableName="flow" domainObjectName="Flow" />-->
<!-- <table tableName="fundraising" domainObjectName="Fundraising" />-->
<!-- <table tableName="inquiry_participation" domainObjectName="InquiryParticipation" />-->
<!-- <table tableName="issuance_info" domainObjectName="IssuanceInfo" />-->
<!-- <table tableName="issuance_parameter_input" domainObjectName="IssuanceParameterInput" />-->
<!-- <table tableName="performance_score" domainObjectName="PerformanceScore" />-->
<!-- <table tableName="tea_class_score" domainObjectName="TeaClassScore" />-->
<!-- <table tableName="profit_distribution" domainObjectName="ProfitDistribution" />-->
<table tableName="profit_management" domainObjectName="ProfitManagement"/>
<!-- <table tableName="exit_time" domainObjectName="ExitTime"/>-->
<!-- <table tableName="question_answer" domainObjectName="QuestionAnswer" />-->
<!-- <table tableName="sys_topics" domainObjectName="Topics" />-->
<!-- <table tableName="topic_record" domainObjectName="TopicRecord" />-->
<!-- <table tableName="found_project" domainObjectName="FoundProject" />-->
<!-- <table tableName="training_report" domainObjectName="TrainingReport" />-->
<!-- <table tableName="user_table" domainObjectName="UserTable" />-->
<!-- <table tableName="sys_topics" domainObjectName="Topics" />-->
<!-- <table tableName="topic_record" domainObjectName="TopicRecord" />-->
<!-- <table tableName="found_project" domainObjectName="FoundProject" />-->
<!-- <table tableName="training_report" domainObjectName="TrainingReport" />-->
<!-- <table tableName="user_table" domainObjectName="UserTable" />-->
</context>

@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="com.sztzjy.fund_investment.entity.ProfitManagement">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="flow_id" jdbcType="VARCHAR" property="flowId" />
<result column="project_name" jdbcType="VARCHAR" property="projectName" />
<result column="investment_amount" jdbcType="DECIMAL" property="investmentAmount" />
<result column="share_ratio" jdbcType="DECIMAL" property="shareRatio" />
<result column="total_equity" jdbcType="DECIMAL" property="totalEquity" />
@ -12,6 +13,8 @@
<result column="stock_price" jdbcType="DECIMAL" property="stockPrice" />
<result column="market_value" jdbcType="DECIMAL" property="marketValue" />
<result column="fund_earnings" jdbcType="DECIMAL" property="fundEarnings" />
<result column="user_market_value" jdbcType="DECIMAL" property="userMarketValue" />
<result column="user_fund_earnings" jdbcType="DECIMAL" property="userFundEarnings" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -72,8 +75,8 @@
</where>
</sql>
<sql id="Base_Column_List">
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
</sql>
<select id="selectByExample" parameterType="com.sztzjy.fund_investment.entity.ProfitManagementExample" resultMap="BaseResultMap">
select
@ -106,14 +109,16 @@
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.fund_investment.entity.ProfitManagement">
insert into profit_management (id, flow_id, investment_amount,
share_ratio, total_equity, share_count,
market_time, stock_price, market_value,
fund_earnings)
values (#{id,jdbcType=VARCHAR}, #{flowId,jdbcType=VARCHAR}, #{investmentAmount,jdbcType=DECIMAL},
#{shareRatio,jdbcType=DECIMAL}, #{totalEquity,jdbcType=DECIMAL}, #{shareCount,jdbcType=DECIMAL},
#{marketTime,jdbcType=INTEGER}, #{stockPrice,jdbcType=DECIMAL}, #{marketValue,jdbcType=DECIMAL},
#{fundEarnings,jdbcType=DECIMAL})
insert into profit_management (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)
values (#{id,jdbcType=VARCHAR}, #{flowId,jdbcType=VARCHAR}, #{projectName,jdbcType=VARCHAR},
#{investmentAmount,jdbcType=DECIMAL}, #{shareRatio,jdbcType=DECIMAL}, #{totalEquity,jdbcType=DECIMAL},
#{shareCount,jdbcType=DECIMAL}, #{marketTime,jdbcType=INTEGER}, #{stockPrice,jdbcType=DECIMAL},
#{marketValue,jdbcType=DECIMAL}, #{fundEarnings,jdbcType=DECIMAL}, #{userMarketValue,jdbcType=DECIMAL},
#{userFundEarnings,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.fund_investment.entity.ProfitManagement">
insert into profit_management
@ -124,6 +129,9 @@
<if test="flowId != null">
flow_id,
</if>
<if test="projectName != null">
project_name,
</if>
<if test="investmentAmount != null">
investment_amount,
</if>
@ -148,6 +156,12 @@
<if test="fundEarnings != null">
fund_earnings,
</if>
<if test="userMarketValue != null">
user_market_value,
</if>
<if test="userFundEarnings != null">
user_fund_earnings,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -156,6 +170,9 @@
<if test="flowId != null">
#{flowId,jdbcType=VARCHAR},
</if>
<if test="projectName != null">
#{projectName,jdbcType=VARCHAR},
</if>
<if test="investmentAmount != null">
#{investmentAmount,jdbcType=DECIMAL},
</if>
@ -180,6 +197,12 @@
<if test="fundEarnings != null">
#{fundEarnings,jdbcType=DECIMAL},
</if>
<if test="userMarketValue != null">
#{userMarketValue,jdbcType=DECIMAL},
</if>
<if test="userFundEarnings != null">
#{userFundEarnings,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.fund_investment.entity.ProfitManagementExample" resultType="java.lang.Long">
@ -197,6 +220,9 @@
<if test="record.flowId != null">
flow_id = #{record.flowId,jdbcType=VARCHAR},
</if>
<if test="record.projectName != null">
project_name = #{record.projectName,jdbcType=VARCHAR},
</if>
<if test="record.investmentAmount != null">
investment_amount = #{record.investmentAmount,jdbcType=DECIMAL},
</if>
@ -221,6 +247,12 @@
<if test="record.fundEarnings != null">
fund_earnings = #{record.fundEarnings,jdbcType=DECIMAL},
</if>
<if test="record.userMarketValue != null">
user_market_value = #{record.userMarketValue,jdbcType=DECIMAL},
</if>
<if test="record.userFundEarnings != null">
user_fund_earnings = #{record.userFundEarnings,jdbcType=DECIMAL},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -248,6 +283,9 @@
<if test="flowId != null">
flow_id = #{flowId,jdbcType=VARCHAR},
</if>
<if test="projectName != null">
project_name = #{projectName,jdbcType=VARCHAR},
</if>
<if test="investmentAmount != null">
investment_amount = #{investmentAmount,jdbcType=DECIMAL},
</if>
@ -272,12 +310,19 @@
<if test="fundEarnings != null">
fund_earnings = #{fundEarnings,jdbcType=DECIMAL},
</if>
<if test="userMarketValue != null">
user_market_value = #{userMarketValue,jdbcType=DECIMAL},
</if>
<if test="userFundEarnings != null">
user_fund_earnings = #{userFundEarnings,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.fund_investment.entity.ProfitManagement">
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}
</update>
</mapper>
Loading…
Cancel
Save