package com.crazy.finance.controller;
import com.crazy.finance.bean.*;
import com.crazy.finance.dao.FlowOfFundsDao;
import com.crazy.finance.service.BankCardService;
import com.crazy.finance.service.InfoService;
import com.crazy.finance.service.LoanService;
import com.crazy.finance.utils.JsonUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Controller
public class LoanController {
@Autowired
private LoanService loanService;
@Autowired
private InfoService infoService;
@Autowired
private BankCardService bankCardService;
@Autowired(required = false)
private FlowOfFundsDao flowOfFundsDao;
/**
* 审核通过
*
* @param id
* @return
*/
@PutMapping("/loan/passApplyStatus/{id}")
@ResponseBody
public JsonUtils passApplyStatus(@PathVariable("id") Integer id, HttpSession session) {
Admin admin = (Admin) session.getAttribute("loginAdmin");
Loan loan = loanService.selectLoanById(id);
loan.setAdminId(admin.getId());
loan.setApplyStatus(2);
loanService.updateLoan(loan);
BankCard bankCard = bankCardService.selectDefaultBankCardByUserId(loan.getUserId());
BigDecimal balance = bankCard.getBalance();
BigDecimal amount = loan.getAmount();
bankCard.setBalance(balance.add(amount));
bankCardService.updateBankCardBalance(bankCard.getId(),bankCard.getBalance());
FlowOfFunds flowOfFunds = new FlowOfFunds(loan.getUserId(), amount, 2, "网贷", new Date(), "");
flowOfFundsDao.insertFlowOfFundsDao(flowOfFunds);
Info info = new Info();
info.setSendid(admin.getId());
info.setReceiveid(loan.getUserId());
info.setCreatetime(new Date());
info.setTitle("网贷审核通过");
info.setInfodesc("用户" + loan.getUser().getUsername() + "的" + loan.getAmount() + "元网贷申请审核通过!审核人为:" + admin.getUsername());
info.setStatus(0);
infoService.insertInfo(info);
return JsonUtils.success();
}
/**
* 审核不通过
*
* @param id
* @return
*/
@PutMapping("/loan/notPassApplyStatus/{id}")
@ResponseBody
public JsonUtils notPassApplyStatus(@PathVariable("id") Integer id, HttpSession session) {
Admin admin = (Admin) session.getAttribute("loginAdmin");
Loan loan = loanService.selectLoanById(id);
loan.setAdminId(admin.getId());
loan.setApplyStatus(1);
loanService.updateLoan(loan);
Info info = new Info();
info.setSendid(admin.getId());
info.setReceiveid(loan.getUser().getId());
info.setCreatetime(new Date());
info.setTitle("网贷审核未通过");
info.setInfodesc("用户" + loan.getUser().getUsername() + "的" + loan.getAmount() + "元网贷申请审核未通过!审核人为:" + admin.getUsername());
info.setStatus(0);
infoService.insertInfo(info);
return JsonUtils.success();
}
/**
* 提醒还款
*
* @param id
* @param session
* @return
*/
@PutMapping("/loan/remindPay/{id}")
@ResponseBody
public JsonUtils remindPay(@PathVariable("id") Integer id, HttpSession session) {
Admin admin = (Admin) session.getAttribute("loginAdmin");
Loan loan = loanService.selectLoanById(id);
Info info = new Info();
info.setSendid(admin.getId());
info.setReceiveid(loan.getUser().getId());
info.setCreatetime(new Date());
info.setTitle("还款通知");
info.setInfodesc("用户" + loan.getUser().getUsername() + "申请的" + loan.getAmount() + "元网贷该还款了!该提醒发送人为:" + admin.getUsername());
info.setStatus(0);
infoService.insertInfo(info);
return JsonUtils.success();
}
/**
* 跳转到网贷审核(管理员)
*
* @param pageNum
* @param pageSize
* @param model
* @return
*/
@GetMapping("/admin/loan/toLoanexam.html")
public String toLoanexam(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model) {
PageHelper.startPage(pageNum, pageSize);
List<Loan> list = loanService.selectAllLoanByApplyStatusAsc();
PageInfo<Loan> pageInfo = new PageInfo(list);
model.addAttribute("loanPageInfo", pageInfo);
model.addAttribute("loanList", list);
model.addAttribute("activeUrl1", "loanActive");
model.addAttribute("activeUrl2", "loanexamActive");
model.addAttribute("pageTopBarInfo", "网贷审核界面");
return "admin/loan/loanexam";
}
/**
* 跳转到网贷信息界面(管理员)
*
* @param pageNum
* @param pageSize
* @param model
* @return
*/
@GetMapping("/admin/loan/toLoaninfo.html")
public String toLoaninfo(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model) {
PageHelper.startPage(pageNum, pageSize);
List<Loan> list = loanService.selectAllExamedLoan();
PageInfo<Loan> pageInfo = new PageInfo(list);
model.addAttribute("loanPageInfo", pageInfo);
model.addAttribute("loanList", list);
model.addAttribute("activeUrl1", "loanActive");
model.addAttribute("activeUrl2", "loaninfoActive");
model.addAttribute("pageTopBarInfo", "网贷信息界面");
return "admin/loan/loaninfo";
}
/**
* 借贷还款
*
* @param id
* @param session
* @return
*/
@ResponseBody
@PutMapping("/user/repayment/{id}")
public JsonUtils repayment(@PathVariable("id") Integer id,
HttpSession session) {
User loginUser = (User) session.getAttribute("loginUser");
try {
loanService.updateLoanById(id, loginUser.getId());
return JsonUtils.success();
} catch (Exception e) {
e.printStackTrace();
return JsonUtils.fail();
}
}
/**
* 我的借贷界面
*
* @param pageNum
* @param pageSize
* @param model
* @param session
* @return
*/
@RequestMapping("/user/personal/toMyLoan.html")
public String toMyLoan(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
Model model, HttpSession session) {
User loginUser = (User) session.getAttribute("loginUser");
PageHelper.startPage(pageNum, pageSize);
List<Loan> list = loanService.selectLoanByUserId(loginUser.getId());
PageInfo<Loan> pageInfo = new PageInfo(list);
model.addAttribute("myLoansPageInfo", pageInfo);
model.addAttribute("loansList", list);
model.addAttribute("pageTopBarInfo", "我的借贷界面");
model.addAttribute("activeUrl1", "personalActive");
model.addAttribute("activeUrl2", "myLoanActive");
return "user/personal/myloan";
}
/**
* 添加借贷
*
* @param amount
* @param rate
* @param term
* @param session
* @return
*/
@ResponseBody
@PostMapping("/user/applyLoan")
public JsonUtils addLoan(@RequestParam("amount") BigDecimal amount,
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
主要功能: 基于springboot理财系统 工具用到idea、navicat、mysql,maven。 一个功能完善的个人理财管理系统,有管理员和普通用户两种角色模块,各个角色具有不同的功能 管理具有用户信息管理,理财产品管理,网贷管理,权限管理等功能,普通用户具有个人贷款,投资理财等管理。 用户:个人理财管理:零钱理财,工资理财,期限理财,基金理财,银行推荐 金融工具:资金记录往来,网贷申请
资源推荐
资源详情
资源评论























收起资源包目录





































































































共 610 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论


渡清欢689
- 粉丝: 2
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- zibbs开源php轻论坛,Bootstrap论坛-PHP资源
- Javascript-JavaScript资源
- ERD-ONLINE-SQL资源
- Friday-毕业设计资源
- 蓝桥杯单片机真题代码-蓝桥杯资源
- asmeg-汇编语言资源
- northstar-Java资源
- DrissionPage-Python资源
- zkClient4Swift-Swift资源
- matlab-Matlab资源
- zzrobot_ws-机器人开发资源
- acp-Kotlin资源
- vectorize-mcp-server-AI人工智能资源
- litemall-移动应用开发资源
- STC51-单片机开发资源
- vue-vben-admin-Typescript资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
