• (免费分享)基于springboot财务管理系统


    开发工具IDEA,数据库mysql5.7

    源码获取:关注文末gongzhonghao,输入006领取下载链接

     

     

     

     

     

     

     

    1. package com.bjpowernode.finance.controller;
    2. import com.bjpowernode.finance.common.Msg;
    3. import com.bjpowernode.finance.entity.FlowOfFunds;
    4. import com.bjpowernode.finance.entity.FundProduct;
    5. import com.bjpowernode.finance.entity.UserFundProduct;
    6. import com.bjpowernode.finance.service.FlowOfFundsService;
    7. import com.bjpowernode.finance.service.FundProductService;
    8. import com.bjpowernode.finance.service.UserFundProductService;
    9. import com.github.pagehelper.PageHelper;
    10. import com.github.pagehelper.PageInfo;
    11. import org.springframework.beans.factory.annotation.Autowired;
    12. import org.springframework.stereotype.Controller;
    13. import org.springframework.ui.Model;
    14. import org.springframework.web.bind.annotation.*;
    15. import javax.servlet.http.HttpSession;
    16. import java.util.Date;
    17. import java.util.List;
    18. @Controller
    19. public class FundProductController {
    20. @Autowired
    21. FundProductService fundProductService;
    22. @Autowired
    23. UserFundProductService userFundProductService;
    24. @Autowired
    25. FlowOfFundsService flowOfFundsService;
    26. /**
    27. * 跳转到基金理财界面
    28. * @param model
    29. * @return
    30. */
    31. @RequestMapping("/user/finance/toFundProduct.html")
    32. public String toFundProduct(Model model){
    33. List list = fundProductService.selectAllFundProduct();
    34. model.addAttribute("fundProductList",list);
    35. model.addAttribute("pageTopBarInfo","基金理财界面");
    36. model.addAttribute("activeUrl1","financeActive");
    37. model.addAttribute("activeUrl2","fundProductActive");
    38. return "/user/finance/fundproduct";
    39. }
    40. /**
    41. * 购买基金理财产品
    42. * @param fundProductId
    43. * @param userId
    44. * @return
    45. */
    46. @PostMapping("/user/buyFundProduct")
    47. @ResponseBody
    48. public Msg buyFundProduct(@RequestParam("fundProductId")Integer fundProductId,
    49. @RequestParam("userId") Integer userId ){
    50. UserFundProduct ufp = new UserFundProduct();
    51. ufp.setUserid(userId);
    52. ufp.setFundid(fundProductId);
    53. ufp.setStarttime(new Date());
    54. FundProduct fp = fundProductService.selectFundProductById(fundProductId);
    55. ufp.setAveryield(fp.getMonthlygrowth());
    56. ufp.setProfit(fp.getLeastmoney().multiply(fp.getMonthlygrowth()));
    57. ufp.setStatus(1);
    58. Integer result = userFundProductService.insertUserFundProduct(ufp);
    59. if (result==1){
    60. FlowOfFunds fof = new FlowOfFunds();
    61. fof.setUserid(userId);
    62. fof.setFlowmoney(fp.getLeastmoney());
    63. fof.setType(1);
    64. fof.setSource(fp.getFunddesc());
    65. fof.setCreatetime(new Date());
    66. fof.setFunddesc("无");
    67. flowOfFundsService.insertFlowOfFunds(fof);
    68. return Msg.success();
    69. }else {
    70. return Msg.fail();
    71. }
    72. }
    73. /**
    74. * 跳转到基金理财管理界面(管理员)
    75. * @param pageNum
    76. * @param pageSize
    77. * @param model
    78. * @param session
    79. * @return
    80. */
    81. @GetMapping("/admin/finance/toFundProduct.html")
    82. public String toFundProduct(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
    83. @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
    84. Model model, HttpSession session) {
    85. PageHelper.startPage(pageNum, pageSize);
    86. List list = fundProductService.selectAllFundProduct();
    87. PageInfo pageInfo = new PageInfo(list, 5);
    88. model.addAttribute("finacnePageInfo",pageInfo);
    89. model.addAttribute("financeList",list);
    90. model.addAttribute("activeUrl1", "financeActive");
    91. model.addAttribute("activeUrl2", "fundproductActive");
    92. model.addAttribute("pageTopBarInfo", "基金理财管理界面");
    93. return "/admin/finance/fundproduct";
    94. }
    95. /**
    96. * 新增基金理财产品
    97. *
    98. * @return
    99. */
    100. @PostMapping("/admin/addFundProduct")
    101. @ResponseBody
    102. public Msg addFundProduct(FundProduct fundProduct){
    103. Integer result = fundProductService.insertFundProduct(fundProduct);
    104. if (result==1){
    105. return Msg.success();
    106. }
    107. return Msg.fail();
    108. }
    109. /**
    110. * 更新时回显信息
    111. * @param id
    112. * @return
    113. */
    114. @GetMapping("/admin/getFundProductInfoById/{id}")
    115. @ResponseBody
    116. public Msg getFundProductInfoById(@PathVariable("id") Integer id){
    117. FundProduct fundProduct = fundProductService.selectFundProductById(id);
    118. //System.out.println(fundProduct.getFunddesc());
    119. return Msg.success().add("fundProduct",fundProduct);
    120. }
    121. /**
    122. * 更新
    123. * @param id
    124. *
    125. * @return
    126. */
    127. @PutMapping("/admin/updateFundProduct/{id}")
    128. @ResponseBody
    129. public Msg updateFundProduct(@PathVariable("id") Integer id,FundProduct fundProduct){
    130. fundProduct.setId(id);
    131. Integer result = fundProductService.updateFundProduct(fundProduct);
    132. if (result==1){
    133. return Msg.success();
    134. }
    135. return Msg.fail();
    136. }
    137. /**
    138. * 删除
    139. * @param id
    140. * @return
    141. */
    142. @DeleteMapping("/admin/deleteFundProductById/{id}")
    143. @ResponseBody
    144. public Msg deleteFundProductById(@PathVariable("id") Integer id){
    145. Integer result = fundProductService.deleteFundProductById(id);
    146. if (result==1){
    147. return Msg.success();
    148. }
    149. return Msg.fail();
    150. }
    151. }
    package com.bjpowernode.finance.controller;
    
    import com.bjpowernode.finance.common.Msg;
    import com.bjpowernode.finance.entity.Admin;
    import com.bjpowernode.finance.entity.Info;
    import com.bjpowernode.finance.entity.Loan;
    import com.bjpowernode.finance.entity.User;
    import com.bjpowernode.finance.service.InfoService;
    import com.bjpowernode.finance.service.LoanService;
    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
        LoanService loanService;
        @Autowired
        InfoService infoService;
    
        /**
         * 跳转到网贷申请界面
         *
         * @param model
         * @return
         */
        @RequestMapping("/user/tools/toApplyLoan.html")
        public String toApplyLoan(Model model) {
    
            model.addAttribute("pageTopBarInfo", "网贷申请界面");
            model.addAttribute("activeUrl1", "toolsActive");
            model.addAttribute("activeUrl2", "applyLoanActive");
            return "/user/tools/applyloan";
        }
    
        /**
         * 跳转到我的借贷界面
         *
         * @param model
         * @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 list = loanService.selectLoanByLoanId(loginUser.getId());
            PageInfo pageInfo = new PageInfo(list, 5);
            model.addAttribute("myLoansPageInfo", pageInfo);
            model.addAttribute("loansList", list);
    
            model.addAttribute("pageTopBarInfo", "我的借贷界面");
            model.addAttribute("activeUrl1", "personalActive");
            model.addAttribute("activeUrl2", "myLoanActive");
            return "/user/personal/myloan";
        }
    
        /**
         * 新增网贷申请
         *
         * @param amout
         * @param term
         * @param rate
         * @param session
         * @return
         */
        @PostMapping("/user/applyLoan")
        @ResponseBody
        public Msg applyLoan(@RequestParam("amout") BigDecimal amout,
                             @RequestParam("term") Integer term,
                             @RequestParam("rate") BigDecimal rate, HttpSession session) {
            User loginUser = (User) session.getAttribute("loginUser");
    
            Loan loan = new Loan();
            loan.setLoanid(loginUser.getId());
            loan.setLoantime(new Date());
            loan.setAmount(amout);
            loan.setTerm(term);
            loan.setRate(rate);
            loan.setApplystatus(0);
            loan.setLoanstatus(0);
            Integer result = loanService.insertLoan(loan);
            if (result == 1) {
                return Msg.success();
            }
            return Msg.fail();
        }
    
        /**
         * 还款
         *
         * @param id
         * @return
         */
        @PutMapping("/user/repayment/{id}")
        @ResponseBody
        public Msg repayment(@PathVariable("id") Integer id) {
            Loan loan = loanService.selectLoanById(id);
            loan.setLoanstatus(2);
            Integer result = loanService.updateLoan(loan);
            if (result == 1) {
                return Msg.success();
            }
            return Msg.fail();
        }
    
        /**
         * 跳转到网贷审核(管理员)
         *
         * @param pageNum
         * @param pageSize
         * @param model
         * @param session
         * @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, HttpSession session) {
            // 引入PageHelper插件,在查询之前调用startPage方法,传入页码以及每页大小
            PageHelper.startPage(pageNum, pageSize);
            List list = loanService.selectAllLoanByApplyStatusAsc();
            // 使用PageInfo包装查询后的结果,并交给页面处理
            // PageInfo封装了详细的分页信息,包括我们查询出来的数据,还可以传入连续显示的页数(5)
            PageInfo pageInfo = new PageInfo(list, 5);
            model.addAttribute("loanPageInfo", pageInfo);
            model.addAttribute("loanList", list);
    
            model.addAttribute("activeUrl1", "loanActive");
            model.addAttribute("activeUrl2", "loanexamActive");
            model.addAttribute("pageTopBarInfo", "网贷审核界面");
            return "admin/loan/loanexam";
        }
    
        /**
         * 审核通过
         *
         * @param id
         * @return
         */
        @PutMapping("/loan/passApplyStatus/{id}")
        @ResponseBody
        public Msg passApplyStatus(@PathVariable("id") Integer id, HttpSession session) {
            Admin admin = (Admin) session.getAttribute("loginAdmin");
            Loan loan = loanService.selectLoanById(id);
            loan.setExamineid(admin.getId());
            loan.setApplystatus(2);
            Integer result = loanService.updateLoan(loan);
            if (result == 1) {
                Info info = new Info();
                info.setSendid(admin.getId());
                info.setReceiveid(loan.getLoanid());
                info.setCreatetime(new Date());
                info.setTitle("网贷审核通过");
                info.setInfodesc("用户" + loan.getUser().getUsername() + "的" + loan.getAmount() + "元网贷申请审核通过!审核人为:" + admin.getUsername());
                info.setStatus(0);
                infoService.insertInfo(info);
                return Msg.success();
            }
            return Msg.fail();
        }
    
        /**
         * 审核不通过
         *
         * @param id
         * @return
         */
        @PutMapping("/loan/notPassApplyStatus/{id}")
        @ResponseBody
        public Msg notPassApplyStatus(@PathVariable("id") Integer id, HttpSession session) {
            Admin admin = (Admin) session.getAttribute("loginAdmin");
            Loan loan = loanService.selectLoanById(id);
            loan.setExamineid(admin.getId());
            loan.setApplystatus(1);
            Integer result = loanService.updateLoan(loan);
            if (result == 1) {
                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 Msg.success();
            }
            return Msg.fail();
        }
    
        /**
         * 跳转到网贷信息界面(管理员)
         *
         * @param pageNum
         * @param pageSize
         * @param model
         * @param session
         * @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, HttpSession session) {
            // 引入PageHelper插件,在查询之前调用startPage方法,传入页码以及每页大小
            PageHelper.startPage(pageNum, pageSize);
            List list = loanService.selectAllExamedLoan();
            // 使用PageInfo包装查询后的结果,并交给页面处理
            // PageInfo封装了详细的分页信息,包括我们查询出来的数据,还可以传入连续显示的页数(5)
            PageInfo pageInfo = new PageInfo(list, 5);
            model.addAttribute("loanPageInfo", pageInfo);
            model.addAttribute("loanList", list);
    
            model.addAttribute("activeUrl1", "loanActive");
            model.addAttribute("activeUrl2", "loaninfoActive");
            model.addAttribute("pageTopBarInfo", "网贷信息界面");
            return "admin/loan/loaninfo";
        }
    
        @PutMapping("/loan/remindPay/{id}")
        @ResponseBody
        public Msg 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);
            Integer result = infoService.insertInfo(info);
            if (result == 1) {
                return Msg.success();
            }
            return Msg.fail();
        }
    }
    
  • 相关阅读:
    SpringCloud学习笔记 - 服务调用、负载均衡组件 - ribbon
    主题聚类模型
    腾讯云 BI 数据分析与可视化的快速入门指南
    SpringBoot自动配置及自定义starter
    Get请求 与 Post请求的区别
    【OpenDDS开发指南V3.20】第四章:条件和监听
    计算机毕业设计选题推荐-课程教学平台-Java/Python项目实战
    ChatGPT,AIGC 助力人力资源管理对身份证号处理
    Session-based Recommendation with Graph Neural Networks论文阅读笔记
    华为数通方向HCIP-DataCom H12-831题库(多选题:81-100)
  • 原文地址:https://blog.csdn.net/qq_35334787/article/details/127812545