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,
渡清欢689
- 粉丝: 2
- 资源: 2
最新资源
- Spring学习笔记mysbproject20241227
- GC9005 是一颗专门针对图形显示场景定义的多功能 MPU 集成自研专利高性能3D 图形加速引擎,最高支持 2048x2048 分辨率的高清显示 具有高清视频解码和音频编解码等多媒体功能处理
- 面向物联网机器视觉的目标跟踪方法设计与实现-LW.zip
- 2900区县的相邻矩阵.xlsx
- 料箱输送线程序,有合流和分拣, 精华部分是WCS和PLC的Socket接口和分拣控制程序 提供设备布局图和电气图纸以及博途V16程序 程序源自欧企,无加密,外企程序还是比较美观的,程序仅供学习参考
- 价值8000的H5聊天系统即时通讯,风车IM聊天APP、聊天、交友、客服系统源码
- 足球检测45-YOLO(v5至v9)、COCO、CreateML、TFRecord数据集合集.rar
- 西门子S7-1200 PID温度控制程序,PID参数经过预调节和精确调节之后得出,程序采用博图V15高级版编写,适合用于不带冷却功能的模具加热生产工艺上,项目上运用已稳定工作多时,带详细注释,可进行
- 使用python批量获取纸质发票信息转为excel
- 电动汽车电池管理系统(BMS)的STM32实现及其设计
- 地级市-产业升级、产业结构高级化(2000-2021年).zip
- 基于神经网络的自适应PID控制器 通过将RBF(BP)神经网络和PID控制器相结合,建立了神经网络PID控制器,采用传递函数进行系统建模,通过自动调整PID参数,实现了对方波信号的跟踪 程序有注释
- knn 1.12.0压缩包
- 一个非常优秀的项目源码范例,C#+Visionpro9.0,三相机定位,PLC, 逻辑及代码都非常好,使用过的项目,是学习及项目参考的极佳范例 注:主界面未放出来
- 数字经济对产业结构升级和创业增长的影响(2011-2021年).zip
- YOLO目标检测标注的垃圾识别数据集
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈