zoukankan      html  css  js  c++  java
  • 充值-controller

    package com.zhenshan.controller;

    import java.util.List;

    import org.apache.dubbo.config.annotation.Reference;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestParam;

    import com.github.pagehelper.PageInfo;
    import com.zhenshan.entity.BorrowCar;
    import com.zhenshan.entity.Condition;
    import com.zhenshan.service.BorrowCarService;

    @Controller
    public class BorrowCarController {
    @Reference
    BorrowCarService borrowCarService;
    //列表 分页
    @RequestMapping("findAll")
    public String findAll(Model model,Condition con,@RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "5") Integer pageSize) {
    System.err.println(con);
    PageInfo<BorrowCar> info = borrowCarService.findAll(con, pageNum, pageSize);
    List<BorrowCar> list = info.getList();
    for (BorrowCar borrowCar : list) {
    System.err.println(borrowCar);
    }
    model.addAttribute("info", info);
    model.addAttribute("con", con);
    return "list";
    }
    //去充值
    @RequestMapping("toChong")
    public String toChong() {

    return "chong";
    }
    //充值
    @RequestMapping("chong")
    public String chong(BorrowCar borrowCar) {
    List<BorrowCar> list= borrowCarService.list();
    for (BorrowCar b : list) {
    //判断 是否是同一用户
    if (b.getUserName().equals(borrowCar.getUserName())) {
    int i=borrowCarService.jia(borrowCar);
    return "redirect:findAll";
    }
    }
    int i=borrowCarService.add(borrowCar);
    return "redirect:findAll";
    }
    //去借车
    @RequestMapping("toChe")
    public String toChe(Integer bid,Model model) {
    System.err.println(bid);
    BorrowCar borrowCar =borrowCarService.toChe(bid);
    model.addAttribute("borrowCar", borrowCar);
    return "che";
    }
    //借车
    @RequestMapping("che")
    public String che(BorrowCar borrowCar,Model model) {

    BorrowCar b =borrowCarService.toChe(borrowCar.getBid());
    //判断借车花费的金额是否大于总的充值金额
    if(b.getBoorowCarAmount()>b.getTotalAmount()) {
    model.addAttribute("shuo", "您的余额不足请充值!!");
    return "toChong";
    }else {
    //钱数+1 次数+1
    int i=borrowCarService.updateAmount(borrowCar);
    int j=borrowCarService.updateNumber(borrowCar);
    }

    return "redirect:findAll";
    }


    }

  • 相关阅读:
    SQL 分组 行变列的一个例子
    用JS如何獲得DropDownList所選Text和Value?
    用了.net2.0,再用1.1的问题。1.1里修改.cs文件不重新编译,.dll不重新生成。
    ASP.NET中上传文件
    获得用户控件的值!
    在没有vs2005环境里部署Crystal Reports 10水晶报表
    onkeypress,onkeydown,onkeyup区别
    2012湖南大学第八届程序设计竞赛 Incredible[公式]
    POJ3624 Charm Bracelet[01背包问题入门]
    HDOJ1257 最少拦截系统[DP入门]
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12971286.html
Copyright © 2011-2022 走看看