利率测试
This commit is contained in:
parent
f1ce6706fb
commit
a26fc725c0
|
|
@ -111,6 +111,22 @@ public class BorrowerController extends BaseController {
|
||||||
return toAjax(tbBorrowerService.updateTbBorrower(tbBorrower));
|
return toAjax(tbBorrowerService.updateTbBorrower(tbBorrower));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/borrowerInserts")
|
||||||
|
public AjaxResult borrowerInserts(@RequestBody TbBorrower tbBorrower)
|
||||||
|
{
|
||||||
|
return toAjax(tbBorrowerService.borrowerInserts(tbBorrower));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/loans")
|
||||||
|
public AjaxResult loans(@RequestBody TbBorrower tbBorrower)
|
||||||
|
{
|
||||||
|
return tbBorrowerService.loans(tbBorrower);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.ruoyi.potenza.domain.vo.PeriodDetailVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
@ -64,7 +65,6 @@ public class BorrowerPeriodsController extends BaseController{
|
||||||
/**
|
/**
|
||||||
* 获取贷款周期详细信息
|
* 获取贷款周期详细信息
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("potenza:periods:query")
|
|
||||||
@GetMapping(value = "/{periodsById}")
|
@GetMapping(value = "/{periodsById}")
|
||||||
public AjaxResult getInfo(@PathVariable("periodsId") Long periodsId)
|
public AjaxResult getInfo(@PathVariable("periodsId") Long periodsId)
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +74,6 @@ public class BorrowerPeriodsController extends BaseController{
|
||||||
/**
|
/**
|
||||||
* 新增贷款周期
|
* 新增贷款周期
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("potenza:periods:add")
|
|
||||||
@Log(title = "贷款周期", businessType = BusinessType.INSERT)
|
@Log(title = "贷款周期", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("periodsInsert")
|
@PostMapping("periodsInsert")
|
||||||
public AjaxResult add(@RequestBody TbBorrowerPeriods tbBorrowerPeriods)
|
public AjaxResult add(@RequestBody TbBorrowerPeriods tbBorrowerPeriods)
|
||||||
|
|
@ -85,7 +84,6 @@ public class BorrowerPeriodsController extends BaseController{
|
||||||
/**
|
/**
|
||||||
* 修改贷款周期
|
* 修改贷款周期
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("potenza:periods:edit")
|
|
||||||
@Log(title = "贷款周期", businessType = BusinessType.UPDATE)
|
@Log(title = "贷款周期", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/periodsUpdate")
|
@PutMapping("/periodsUpdate")
|
||||||
public AjaxResult edit(@RequestBody TbBorrowerPeriods tbBorrowerPeriods)
|
public AjaxResult edit(@RequestBody TbBorrowerPeriods tbBorrowerPeriods)
|
||||||
|
|
@ -96,11 +94,18 @@ public class BorrowerPeriodsController extends BaseController{
|
||||||
/**
|
/**
|
||||||
* 删除贷款周期
|
* 删除贷款周期
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("potenza:periods:remove")
|
|
||||||
@Log(title = "贷款周期", businessType = BusinessType.DELETE)
|
@Log(title = "贷款周期", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{periodsIds}")
|
@DeleteMapping("/{periodsIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] periodsIds)
|
public AjaxResult remove(@PathVariable Long[] periodsIds)
|
||||||
{
|
{
|
||||||
return toAjax(tbBorrowerPeriodsService.deleteTbBorrowerPeriodsByPeriodsIds(periodsIds));
|
return toAjax(tbBorrowerPeriodsService.deleteTbBorrowerPeriodsByPeriodsIds(periodsIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Log(title = "周期详细", businessType = BusinessType.UPDATE)
|
||||||
|
@PostMapping("/detail")
|
||||||
|
public AjaxResult detail(@RequestBody PeriodDetailVo periodDetailVo)
|
||||||
|
{
|
||||||
|
return tbBorrowerPeriodsService.detail(periodDetailVo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ public class TbBorrowerPeriods implements Serializable {
|
||||||
*/
|
*/
|
||||||
private String updateBy;
|
private String updateBy;
|
||||||
|
|
||||||
|
private Double rateInterest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除状态0:存在,2:删除
|
* 删除状态0:存在,2:删除
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ruoyi.potenza.domain.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 木子
|
||||||
|
* @version 1.0
|
||||||
|
* @description: TODO
|
||||||
|
* @date 2023/1/15 20:39
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PeriodDetailVo implements Serializable {
|
||||||
|
private Double borrowerMoney;
|
||||||
|
|
||||||
|
private Integer wayId;
|
||||||
|
|
||||||
|
private Integer periodsId;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
package com.ruoyi.potenza.domain.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 木子
|
||||||
|
* @version 1.0
|
||||||
|
* @description: TODO
|
||||||
|
* @date 2023/1/15 19:26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TbBorrowerVo implements Serializable {
|
||||||
|
|
||||||
|
private Integer borrowerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户名称
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品ID
|
||||||
|
*/
|
||||||
|
private Integer productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认为最高可以借款金额
|
||||||
|
*/
|
||||||
|
private Double borrowerMoney;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 贷款周期ID
|
||||||
|
*/
|
||||||
|
private Integer periodsId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 贷款方式ID 0:等额本息 6000 1:等额本金 6000 1000 第一个月60000*利率 第二个月 5000*利率
|
||||||
|
*/
|
||||||
|
private Integer wayId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 借款用途
|
||||||
|
*/
|
||||||
|
private String borrowerPurpose;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1: 待审核 2:贷款成功 3:贷款失败
|
||||||
|
*/
|
||||||
|
private Integer borrowerState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 放款人
|
||||||
|
*/
|
||||||
|
private Integer loanerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新者
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除状态0:存在,2:删除
|
||||||
|
*/
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.ruoyi.potenza.service;
|
package com.ruoyi.potenza.service;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.potenza.domain.TbBorrowerPeriods;
|
import com.ruoyi.potenza.domain.TbBorrowerPeriods;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.ruoyi.potenza.domain.vo.PeriodDetailVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -58,4 +60,6 @@ public interface TbBorrowerPeriodsService extends IService<TbBorrowerPeriods> {
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteTbBorrowerPeriodsByPeriodsId(Long periodsId);
|
public int deleteTbBorrowerPeriodsByPeriodsId(Long periodsId);
|
||||||
|
|
||||||
|
AjaxResult detail(PeriodDetailVo periodDetailVo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,5 +51,7 @@ public interface TbBorrowerService extends IService<TbBorrower> {
|
||||||
public int updateTbBorrower(TbBorrower tbBorrower);
|
public int updateTbBorrower(TbBorrower tbBorrower);
|
||||||
|
|
||||||
|
|
||||||
|
int borrowerInserts(TbBorrower tbBorrower);
|
||||||
|
|
||||||
|
AjaxResult loans(TbBorrower tbBorrower);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,25 +2,31 @@ package com.ruoyi.potenza.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.potenza.domain.TbBorrowerPeriods;
|
import com.ruoyi.potenza.domain.TbBorrowerPeriods;
|
||||||
|
import com.ruoyi.potenza.domain.vo.PeriodDetailVo;
|
||||||
import com.ruoyi.potenza.service.TbBorrowerPeriodsService;
|
import com.ruoyi.potenza.service.TbBorrowerPeriodsService;
|
||||||
import com.ruoyi.potenza.mapper.TbBorrowerPeriodsMapper;
|
import com.ruoyi.potenza.mapper.TbBorrowerPeriodsMapper;
|
||||||
|
import com.ruoyi.potenza.utils.AverageCapitalPlusInterestUtils;
|
||||||
|
import com.ruoyi.potenza.utils.AverageCapitalUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 86155
|
* @author 86155
|
||||||
* @description 针对表【tb_borrower_periods(贷款周期表)】的数据库操作Service实现
|
* @description 针对表【tb_borrower_periods(贷款周期表)】的数据库操作Service实现
|
||||||
* @createDate 2023-01-13 15:56:37
|
* @createDate 2023-01-13 15:56:37
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class TbBorrowerPeriodsServiceImpl extends ServiceImpl<TbBorrowerPeriodsMapper, TbBorrowerPeriods>
|
public class TbBorrowerPeriodsServiceImpl extends ServiceImpl<TbBorrowerPeriodsMapper, TbBorrowerPeriods>
|
||||||
implements TbBorrowerPeriodsService{
|
implements TbBorrowerPeriodsService{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbBorrowerPeriodsMapper tbBorrowerPeriodsMapper;
|
private TbBorrowerPeriodsMapper tbBorrowerPeriodsMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询贷款周期
|
* 查询贷款周期
|
||||||
*
|
*
|
||||||
|
|
@ -95,6 +101,33 @@ public class TbBorrowerPeriodsServiceImpl extends ServiceImpl<TbBorrowerPeriodsM
|
||||||
return tbBorrowerPeriodsMapper.deleteTbBorrowerPeriodsByPeriodsId(periodsId);
|
return tbBorrowerPeriodsMapper.deleteTbBorrowerPeriodsByPeriodsId(periodsId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult detail(PeriodDetailVo periodDetailVo) {
|
||||||
|
|
||||||
|
//查询利率
|
||||||
|
Integer periodsId = periodDetailVo.getPeriodsId();
|
||||||
|
long periodsid = periodsId.longValue();
|
||||||
|
TbBorrowerPeriods tbBorrowerPeriods = tbBorrowerPeriodsMapper.selectTbBorrowerPeriodsByPeriodsId(periodsid);
|
||||||
|
if(tbBorrowerPeriods==null){
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
Integer wayId = periodDetailVo.getWayId();
|
||||||
|
//等额本息
|
||||||
|
if(wayId==0){
|
||||||
|
double principalInterestCount = AverageCapitalPlusInterestUtils.
|
||||||
|
getPrincipalInterestCount(periodDetailVo.getBorrowerMoney(),
|
||||||
|
tbBorrowerPeriods.getRateInterest()/100,
|
||||||
|
tbBorrowerPeriods.getPeriodsName());
|
||||||
|
return AjaxResult.success(principalInterestCount);
|
||||||
|
}
|
||||||
|
//等额本金
|
||||||
|
double principalInterestCount = AverageCapitalUtils.
|
||||||
|
getPrincipalInterestCount(periodDetailVo.getBorrowerMoney(),
|
||||||
|
tbBorrowerPeriods.getRateInterest()/100,
|
||||||
|
tbBorrowerPeriods.getPeriodsName());
|
||||||
|
return AjaxResult.success(principalInterestCount);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.potenza.service.impl;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.potenza.domain.TbBorrowerPlan;
|
import com.ruoyi.potenza.domain.TbBorrowerPlan;
|
||||||
|
import com.ruoyi.potenza.mapper.TbBorrowerPeriodsMapper;
|
||||||
import com.ruoyi.potenza.service.TbBorrowerPlanService;
|
import com.ruoyi.potenza.service.TbBorrowerPlanService;
|
||||||
import com.ruoyi.potenza.mapper.TbBorrowerPlanMapper;
|
import com.ruoyi.potenza.mapper.TbBorrowerPlanMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -18,6 +19,7 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class TbBorrowerPlanServiceImpl extends ServiceImpl<TbBorrowerPlanMapper, TbBorrowerPlan>
|
public class TbBorrowerPlanServiceImpl extends ServiceImpl<TbBorrowerPlanMapper, TbBorrowerPlan>
|
||||||
implements TbBorrowerPlanService{
|
implements TbBorrowerPlanService{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbBorrowerPlanMapper tbBorrowerPlanMapper;
|
private TbBorrowerPlanMapper tbBorrowerPlanMapper;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
package com.ruoyi.potenza.service.impl;
|
package com.ruoyi.potenza.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.potenza.domain.TbBorrower;
|
import com.ruoyi.potenza.domain.TbBorrower;
|
||||||
|
import com.ruoyi.potenza.domain.TbBorrowerPeriods;
|
||||||
import com.ruoyi.potenza.domain.vo.IdVo;
|
import com.ruoyi.potenza.domain.vo.IdVo;
|
||||||
|
import com.ruoyi.potenza.domain.vo.TbBorrowerVo;
|
||||||
|
import com.ruoyi.potenza.mapper.TbBorrowerPeriodsMapper;
|
||||||
import com.ruoyi.potenza.service.TbBorrowerService;
|
import com.ruoyi.potenza.service.TbBorrowerService;
|
||||||
import com.ruoyi.potenza.mapper.TbBorrowerMapper;
|
import com.ruoyi.potenza.mapper.TbBorrowerMapper;
|
||||||
|
import com.ruoyi.potenza.utils.AverageCapitalPlusInterestUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
@ -18,12 +25,16 @@ import java.util.List;
|
||||||
* @createDate 2023-01-13 15:56:37
|
* @createDate 2023-01-13 15:56:37
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class TbBorrowerServiceImpl extends ServiceImpl<TbBorrowerMapper, TbBorrower>
|
public class TbBorrowerServiceImpl extends ServiceImpl<TbBorrowerMapper, TbBorrower>
|
||||||
implements TbBorrowerService{
|
implements TbBorrowerService{
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbBorrowerMapper tbBorrowerMapper;
|
private TbBorrowerMapper tbBorrowerMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbBorrowerPeriodsMapper tbBorrowerPeriodsMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> pageList(TbBorrower tbBorrower) {
|
public List<?> pageList(TbBorrower tbBorrower) {
|
||||||
List<TbBorrower> list= tbBorrowerMapper.pageList();
|
List<TbBorrower> list= tbBorrowerMapper.pageList();
|
||||||
|
|
@ -36,14 +47,6 @@ public class TbBorrowerServiceImpl extends ServiceImpl<TbBorrowerMapper, TbBorro
|
||||||
return AjaxResult.success("删除成功");
|
return AjaxResult.success("删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询贷款
|
|
||||||
*
|
|
||||||
* @param borrowerId 贷款主键
|
|
||||||
* @return 贷款
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public TbBorrower selectTbBorrowerByBorrowerId(Long borrowerId)
|
public TbBorrower selectTbBorrowerByBorrowerId(Long borrowerId)
|
||||||
{
|
{
|
||||||
|
|
@ -88,7 +91,44 @@ public class TbBorrowerServiceImpl extends ServiceImpl<TbBorrowerMapper, TbBorro
|
||||||
return tbBorrowerMapper.updateTbBorrower(tbBorrower);
|
return tbBorrowerMapper.updateTbBorrower(tbBorrower);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int borrowerInserts(TbBorrower tbBorrower) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult loans(TbBorrower tbBorrower) {
|
||||||
|
|
||||||
|
//判断 用户 能否借款
|
||||||
|
|
||||||
|
|
||||||
|
//判断同一个人 只能借一个产品
|
||||||
|
LambdaQueryWrapper<TbBorrower> wrapper=new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(TbBorrower::getUserId,tbBorrower.getUserId());
|
||||||
|
wrapper.eq(TbBorrower::getProductId,tbBorrower.getProductId());
|
||||||
|
TbBorrower tbBorrower1 = tbBorrowerMapper.selectOne(wrapper);
|
||||||
|
if(tbBorrower1!=null){
|
||||||
|
return AjaxResult.error("请先还款");
|
||||||
|
}
|
||||||
|
Integer periodsId = tbBorrower.getPeriodsId();
|
||||||
|
long periodsid = periodsId.longValue();
|
||||||
|
//查询利率
|
||||||
|
TbBorrowerPeriods tbBorrowerPeriods = tbBorrowerPeriodsMapper.selectTbBorrowerPeriodsByPeriodsId(periodsid);
|
||||||
|
|
||||||
|
double perMonthPrincipalInterest = AverageCapitalPlusInterestUtils.
|
||||||
|
getPerMonthPrincipalInterest(tbBorrower.getBorrowerMoney(),
|
||||||
|
tbBorrowerPeriods.getRateInterest()/100,
|
||||||
|
tbBorrowerPeriods.getPeriodsName());
|
||||||
|
|
||||||
|
|
||||||
|
double principalInterestCount = AverageCapitalPlusInterestUtils.
|
||||||
|
getPrincipalInterestCount(tbBorrower.getBorrowerMoney(),
|
||||||
|
tbBorrowerPeriods.getRateInterest() / 100,
|
||||||
|
tbBorrowerPeriods.getPeriodsName());
|
||||||
|
|
||||||
|
log.info("---------"+principalInterestCount);
|
||||||
|
return AjaxResult.success("添加成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,141 @@
|
||||||
|
package com.ruoyi.potenza.utils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
* @description: TODO
|
||||||
|
* @author 木子
|
||||||
|
* @date 2023/1/15 19:17
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class AverageCapitalPlusInterestUtils {
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的每月偿还本金和利息
|
||||||
|
* <p>
|
||||||
|
* 公式:每月偿还本息=〔贷款本金×月利率×(1+月利率)^还款月数〕÷〔(1+月利率)^还款月数-1〕
|
||||||
|
*
|
||||||
|
* @param invest 总借款额(贷款本金)
|
||||||
|
* @param yearRate 年利率
|
||||||
|
* @param month 还款总月数
|
||||||
|
* @return 每月偿还本金和利息, 不四舍五入,直接截取小数点最后两位
|
||||||
|
*/
|
||||||
|
public static double getPerMonthPrincipalInterest(double invest, double yearRate, int totalmonth) {
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal monthIncome = new BigDecimal(invest)
|
||||||
|
.multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth)))
|
||||||
|
.divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);
|
||||||
|
return monthIncome.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的每月偿还利息
|
||||||
|
* <p>
|
||||||
|
* 公式:每月偿还利息=贷款本金×月利率×〔(1+月利率)^还款月数-(1+月利率)^(还款月序号-1)〕÷〔(1+月利率)^还款月数-1〕
|
||||||
|
*
|
||||||
|
* @param invest 总借款额(贷款本金)
|
||||||
|
* @param yearRate 年利率
|
||||||
|
* @param month 还款总月数
|
||||||
|
* @return 每月偿还利息
|
||||||
|
*/
|
||||||
|
public static Map<Integer, BigDecimal> getPerMonthInterest(double invest, double yearRate, int totalmonth) {
|
||||||
|
Map<Integer, BigDecimal> map = new HashMap<Integer, BigDecimal>();
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal monthInterest;
|
||||||
|
for (int i = 1; i < totalmonth + 1; i++) {
|
||||||
|
BigDecimal multiply = new BigDecimal(invest).multiply(new BigDecimal(monthRate));
|
||||||
|
BigDecimal sub = new BigDecimal(Math.pow(1 + monthRate, totalmonth)).subtract(new BigDecimal(Math.pow(1 + monthRate, i - 1)));
|
||||||
|
monthInterest = multiply.multiply(sub).divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 6, BigDecimal.ROUND_DOWN);
|
||||||
|
monthInterest = monthInterest.setScale(2, BigDecimal.ROUND_DOWN);
|
||||||
|
map.put(i, monthInterest);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的每月偿还本金
|
||||||
|
*
|
||||||
|
* @param invest 总借款额(贷款本金)
|
||||||
|
* @param yearRate 年利率
|
||||||
|
* @param month 还款总月数
|
||||||
|
* @return 每月偿还本金
|
||||||
|
*/
|
||||||
|
public static Map<Integer, BigDecimal> getPerMonthPrincipal(double invest, double yearRate, int totalmonth) {
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal monthIncome = new BigDecimal(invest)
|
||||||
|
.multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth)))
|
||||||
|
.divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);
|
||||||
|
Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, totalmonth);
|
||||||
|
Map<Integer, BigDecimal> mapPrincipal = new HashMap<Integer, BigDecimal>();
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, BigDecimal> entry : mapInterest.entrySet()) {
|
||||||
|
mapPrincipal.put(entry.getKey(), monthIncome.subtract(entry.getValue()));
|
||||||
|
}
|
||||||
|
return mapPrincipal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的总利息
|
||||||
|
*
|
||||||
|
* @param invest 总借款额(贷款本金)
|
||||||
|
* @param yearRate 年利率
|
||||||
|
* @param month 还款总月数
|
||||||
|
* @return 总利息
|
||||||
|
*/
|
||||||
|
public static double getInterestCount(double invest, double yearRate, int totalmonth) {
|
||||||
|
BigDecimal count = new BigDecimal(0);
|
||||||
|
Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, totalmonth);
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, BigDecimal> entry : mapInterest.entrySet()) {
|
||||||
|
count = count.add(entry.getValue());
|
||||||
|
}
|
||||||
|
return count.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应还本金总和
|
||||||
|
*
|
||||||
|
* @param invest 总借款额(贷款本金)
|
||||||
|
* @param yearRate 年利率
|
||||||
|
* @param month 还款总月数
|
||||||
|
* @return 应还本金总和
|
||||||
|
*/
|
||||||
|
public static double getPrincipalInterestCount(double invest, double yearRate, int totalmonth) {
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal perMonthInterest = new BigDecimal(invest)
|
||||||
|
.multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth)))
|
||||||
|
.divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);
|
||||||
|
BigDecimal count = perMonthInterest.multiply(new BigDecimal(totalmonth));
|
||||||
|
count = count.setScale(2, BigDecimal.ROUND_DOWN);
|
||||||
|
return count.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
double invest = 20000; // 本金
|
||||||
|
int month = 12;
|
||||||
|
double yearRate = 0.15; // 年利率
|
||||||
|
double perMonthPrincipalInterest = getPerMonthPrincipalInterest(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---每月还款本息:" + perMonthPrincipalInterest);
|
||||||
|
Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---每月还款利息:" + mapInterest);
|
||||||
|
Map<Integer, BigDecimal> mapPrincipal = getPerMonthPrincipal(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---每月还款本金:" + mapPrincipal);
|
||||||
|
double count = getInterestCount(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---总利息:" + count);
|
||||||
|
double principalInterestCount = getPrincipalInterestCount(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---应还本息总和:" + principalInterestCount);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,155 @@
|
||||||
|
package com.ruoyi.potenza.utils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
/**
|
||||||
|
* @author 木子
|
||||||
|
* @version 1.0
|
||||||
|
* @description: TODO
|
||||||
|
* @date 2023/1/15 20:49
|
||||||
|
*/
|
||||||
|
public class AverageCapitalUtils {
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的每月偿还本金和利息
|
||||||
|
*
|
||||||
|
* 公式:每月偿还本息=〔贷款本金×月利率×(1+月利率)^还款月数〕÷〔(1+月利率)^还款月数-1〕
|
||||||
|
*
|
||||||
|
* @param invest
|
||||||
|
* 总借款额(贷款本金)
|
||||||
|
* @param yearRate
|
||||||
|
* 年利率
|
||||||
|
* @param month
|
||||||
|
* 还款总月数
|
||||||
|
* @return 每月偿还本金和利息,不四舍五入,直接截取小数点最后两位
|
||||||
|
*/
|
||||||
|
public static BigDecimal getPerMonthPrincipalInterest(double invest, double yearRate, int totalmonth) {
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal monthIncome = new BigDecimal(invest)
|
||||||
|
.multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth)))
|
||||||
|
.divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_UP);
|
||||||
|
//return monthIncome.doubleValue();
|
||||||
|
return monthIncome;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的每月偿还利息
|
||||||
|
*
|
||||||
|
* 公式:每月偿还利息=贷款本金×月利率×〔(1+月利率)^还款月数-(1+月利率)^(还款月序号-1)〕÷〔(1+月利率)^还款月数-1〕
|
||||||
|
*
|
||||||
|
* @param invest
|
||||||
|
* 总借款额(贷款本金)
|
||||||
|
* @param yearRate
|
||||||
|
* 年利率
|
||||||
|
* @param month
|
||||||
|
* 还款总月数
|
||||||
|
* @return 每月偿还利息
|
||||||
|
*/
|
||||||
|
public static Map<Integer, BigDecimal> getPerMonthInterest(double invest, double yearRate, int totalmonth) {
|
||||||
|
Map<Integer, BigDecimal> map = new HashMap<Integer, BigDecimal>();
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal monthInterest;
|
||||||
|
for (int i = 1; i < totalmonth + 1; i++) {
|
||||||
|
BigDecimal multiply = new BigDecimal(invest).multiply(new BigDecimal(monthRate));
|
||||||
|
BigDecimal sub = new BigDecimal(Math.pow(1 + monthRate, totalmonth))
|
||||||
|
.subtract(new BigDecimal(Math.pow(1 + monthRate, i - 1)));
|
||||||
|
monthInterest = multiply.multiply(sub).divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2,
|
||||||
|
BigDecimal.ROUND_DOWN);
|
||||||
|
monthInterest = monthInterest.setScale(2, BigDecimal.ROUND_DOWN);
|
||||||
|
map.put(i, monthInterest);
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的每月偿还本金
|
||||||
|
*
|
||||||
|
* @param invest
|
||||||
|
* 总借款额(贷款本金)
|
||||||
|
* @param yearRate
|
||||||
|
* 年利率
|
||||||
|
* @param month
|
||||||
|
* 还款总月数
|
||||||
|
* @return 每月偿还本金
|
||||||
|
*/
|
||||||
|
public static Map<Integer, BigDecimal> getPerMonthPrincipal(double invest, double yearRate, int totalmonth) {
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal monthIncome = new BigDecimal(invest)
|
||||||
|
.multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth)))
|
||||||
|
.divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);
|
||||||
|
Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, totalmonth);
|
||||||
|
Map<Integer, BigDecimal> mapPrincipal = new HashMap<Integer, BigDecimal>();
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, BigDecimal> entry : mapInterest.entrySet()) {
|
||||||
|
mapPrincipal.put(entry.getKey(), monthIncome.subtract(entry.getValue()));
|
||||||
|
}
|
||||||
|
return mapPrincipal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等额本息计算获取还款方式为等额本息的总利息
|
||||||
|
*
|
||||||
|
* @param invest
|
||||||
|
* 总借款额(贷款本金)
|
||||||
|
* @param yearRate
|
||||||
|
* 年利率
|
||||||
|
* @param month
|
||||||
|
* 还款总月数
|
||||||
|
* @return 总利息
|
||||||
|
*/
|
||||||
|
public static double getInterestCount(double invest, double yearRate, int totalmonth) {
|
||||||
|
BigDecimal count = new BigDecimal(0);
|
||||||
|
Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, totalmonth);
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, BigDecimal> entry : mapInterest.entrySet()) {
|
||||||
|
count = count.add(entry.getValue());
|
||||||
|
}
|
||||||
|
return count.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应还本金总和
|
||||||
|
*
|
||||||
|
* @param invest
|
||||||
|
* 总借款额(贷款本金)
|
||||||
|
* @param yearRate
|
||||||
|
* 年利率
|
||||||
|
* @param month
|
||||||
|
* 还款总月数
|
||||||
|
* @return 应还本金总和
|
||||||
|
*/
|
||||||
|
public static double getPrincipalInterestCount(double invest, double yearRate, int totalmonth) {
|
||||||
|
double monthRate = yearRate / 12;
|
||||||
|
BigDecimal perMonthInterest = new BigDecimal(invest)
|
||||||
|
.multiply(new BigDecimal(monthRate * Math.pow(1 + monthRate, totalmonth)))
|
||||||
|
.divide(new BigDecimal(Math.pow(1 + monthRate, totalmonth) - 1), 2, BigDecimal.ROUND_DOWN);
|
||||||
|
BigDecimal count = perMonthInterest.multiply(new BigDecimal(totalmonth));
|
||||||
|
count = count.setScale(2, BigDecimal.ROUND_DOWN);
|
||||||
|
return count.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
double invest = 38988; // 本金
|
||||||
|
int month = 12;
|
||||||
|
double yearRate = 0.15; // 年利率
|
||||||
|
BigDecimal perMonthPrincipalInterest = getPerMonthPrincipalInterest(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---每月还款本息:" + perMonthPrincipalInterest);
|
||||||
|
System.out.println("等额本息---每月还款本息:" + getPerMonthPrincipalInterest(invest, yearRate, 3));
|
||||||
|
System.out.println("等额本息---每月还款本息:" + getPerMonthPrincipalInterest(invest, yearRate, 6));
|
||||||
|
System.out.println("等额本息---每月还款本息:" + getPerMonthPrincipalInterest(invest, yearRate, 9));
|
||||||
|
System.out.println("等额本息---每月还款本息:" + getPerMonthPrincipalInterest(invest, yearRate, 12));
|
||||||
|
System.out.println("等额本息---每月还款本息:" + getPerMonthPrincipalInterest(invest, yearRate, 15));
|
||||||
|
System.out.println("等额本息---每月还款本息:" + getPerMonthPrincipalInterest(invest, yearRate, 18));
|
||||||
|
/*Map<Integer, BigDecimal> mapInterest = getPerMonthInterest(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---每月还款利息:" + mapInterest);
|
||||||
|
Map<Integer, BigDecimal> mapPrincipal = getPerMonthPrincipal(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---每月还款本金:" + mapPrincipal);
|
||||||
|
double count = getInterestCount(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---总利息:" + count);
|
||||||
|
double principalInterestCount = getPrincipalInterestCount(invest, yearRate, month);
|
||||||
|
System.out.println("等额本息---应还本息总和:" + principalInterestCount);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
<resultMap type="com.ruoyi.potenza.domain.TbBorrowerPeriods" id="TbBorrowerPeriodsResult">
|
<resultMap type="com.ruoyi.potenza.domain.TbBorrowerPeriods" id="TbBorrowerPeriodsResult">
|
||||||
<result property="periodsId" column="periods_id" />
|
<result property="periodsId" column="periods_id" />
|
||||||
<result property="periodsName" column="periods_name" />
|
<result property="periodsName" column="periods_name" />
|
||||||
|
<result property="rateInterest" column="rate_interest" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
|
|
@ -15,7 +16,7 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectTbBorrowerPeriodsVo">
|
<sql id="selectTbBorrowerPeriodsVo">
|
||||||
select periods_id, periods_name, create_by, update_by, del_flag, create_time, update_time from tb_borrower_periods
|
select periods_id, periods_name,rate_interest, create_by, update_by, del_flag, create_time, update_time from tb_borrower_periods
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectTbBorrowerPeriodsList" parameterType="com.ruoyi.potenza.domain.TbBorrowerPeriods" resultMap="TbBorrowerPeriodsResult">
|
<select id="selectTbBorrowerPeriodsList" parameterType="com.ruoyi.potenza.domain.TbBorrowerPeriods" resultMap="TbBorrowerPeriodsResult">
|
||||||
|
|
@ -34,6 +35,7 @@
|
||||||
insert into tb_borrower_periods
|
insert into tb_borrower_periods
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="periodsName != null">periods_name,</if>
|
<if test="periodsName != null">periods_name,</if>
|
||||||
|
<if test="rateInterest != null">rate_interest,</if>
|
||||||
<if test="createBy != null">create_by,</if>
|
<if test="createBy != null">create_by,</if>
|
||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
<if test="delFlag != null">del_flag,</if>
|
<if test="delFlag != null">del_flag,</if>
|
||||||
|
|
@ -42,6 +44,7 @@
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="periodsName != null">#{periodsName},</if>
|
<if test="periodsName != null">#{periodsName},</if>
|
||||||
|
<if test="rateInterest != null">#{rateInterest},</if>
|
||||||
<if test="createBy != null">#{createBy},</if>
|
<if test="createBy != null">#{createBy},</if>
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
<if test="delFlag != null">#{delFlag},</if>
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
|
|
@ -54,6 +57,7 @@
|
||||||
update tb_borrower_periods
|
update tb_borrower_periods
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
<if test="periodsName != null">periods_name = #{periodsName},</if>
|
<if test="periodsName != null">periods_name = #{periodsName},</if>
|
||||||
|
<if test="rateInterest != null">rate_interest = #{rateInterest},</if>
|
||||||
<if test="createBy != null">create_by = #{createBy},</if>
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,15 @@ export function updateBorrower(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 添加贷款
|
||||||
|
export function insertBorrower(data) {
|
||||||
|
return request({
|
||||||
|
url: '/potenza/borrower/loans',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,3 +42,12 @@ export function delPeriods(periodsId) {
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function detail(data) {
|
||||||
|
return request({
|
||||||
|
url: '/potenza/periods/detail',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
<template>
|
||||||
|
<div class="from">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h1>贷款中心</h1>
|
||||||
|
|
||||||
|
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
|
||||||
|
<el-form-item label="借款金额" prop="borrowerMoney">
|
||||||
|
<el-input v-model="ruleForm.borrowerMoney"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="借款周期" prop="periodsId">
|
||||||
|
<el-select v-model="ruleForm.periodsId" placeholder="请选择">
|
||||||
|
<el-option v-for="item in periods" :key="item.periodsId" :label="item.periodsName"
|
||||||
|
:value="item.periodsId">
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="借款方式" prop="wayId">
|
||||||
|
<el-select v-model="ruleForm.wayId" placeholder="请选择方式">
|
||||||
|
<el-option label="等额本息" value=0></el-option>
|
||||||
|
<el-option label="等额本金" value=1></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<h4>总还款金额:{{ borrowerMoney }}</h4>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="借款用途" prop="borrowerPurpose">
|
||||||
|
<el-input v-model="ruleForm.borrowerPurpose"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submitForm(ruleForm)">借款</el-button>
|
||||||
|
<el-button>取消</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
import { listPeriods, insertBorrower } from "@/api/potenza/periods";
|
||||||
|
import { detail } from "@/api/potenza/periods";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
ruleForm: {
|
||||||
|
borrowerMoney: '',
|
||||||
|
periodsId: null,
|
||||||
|
borrowerPurpose: '',
|
||||||
|
wayId: null,
|
||||||
|
userName: '',
|
||||||
|
userId: null,
|
||||||
|
productId: null
|
||||||
|
|
||||||
|
},
|
||||||
|
periods: [],
|
||||||
|
timer: '',
|
||||||
|
borrowerMoney: '',
|
||||||
|
rules: {
|
||||||
|
borrowerMoney: [{ required: true, message: '请输入活动名称', trigger: 'blur' }],
|
||||||
|
periodsId: [{ required: true, message: '请输入借款周期', trigger: 'blur' }],
|
||||||
|
borrowerPurpose: [{ required: true, message: '请输入借款方式', trigger: 'blur' }],
|
||||||
|
wayId: [{ required: true, message: '请输入借款用途', trigger: 'blur' }],
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
submitForm(formName) {
|
||||||
|
this.$refs[formName].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
const username = this.$store.state.user.name;
|
||||||
|
this.ruleForm.userName = username
|
||||||
|
insertBorrower(this.ruleForm).then(respon => {
|
||||||
|
console.log(respon)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('error submit!!');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
listPeriods() {
|
||||||
|
listPeriods().then(response => {
|
||||||
|
console.log(response.rows)
|
||||||
|
this.periods = response.rows
|
||||||
|
});
|
||||||
|
},
|
||||||
|
valChange() {
|
||||||
|
if (this.ruleForm.borrowerMoney != '' && this.ruleForm.periodsId != null && this.ruleForm.wayId != null) {
|
||||||
|
let pram = {}
|
||||||
|
pram.borrowerMoney = this.ruleForm.borrowerMoney
|
||||||
|
pram.periodsId = this.ruleForm.periodsId
|
||||||
|
pram.wayId = this.ruleForm.wayId
|
||||||
|
console.log(pram)
|
||||||
|
detail(pram).then(respon => {
|
||||||
|
|
||||||
|
this.borrowerMoney = respon.data
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.listPeriods()
|
||||||
|
this.timer = setInterval(this.valChange, 2000);
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.from {
|
||||||
|
margin: auto;
|
||||||
|
width: 40%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in New Issue