客车网上售票系统(8)
一、今日完成任务
改签
二、页面展示:
三、核心源码:
//改签 @RequestMapping("/change/{oid}") public String change(@PathVariable("oid")int oid,HttpServletRequest request){ CarTrainOrder selectFkOrder = carSerivce.selectFkOrder(oid); request.setAttribute("car", selectFkOrder); return "../change.jsp"; } //改签查票 @RequestMapping(value="/changeSearch",produces={"application/json;charset=utf-8"}) @ResponseBody public String changeSearch(Carinfo car,HttpServletRequest request){ //获取当前时间 /*Calendar now=Calendar.getInstance(); String now_hour=now.get(Calendar.HOUR_OF_DAY)+""; String now_minute=now.get(Calendar.MINUTE)+""; car.setStart_time(now_hour+":"+now_minute);*/ List<CarTrain> list = carSerivce.findByProperty2(car); System.out.println(list.size()); return JSONArray.fromObject(list).toString(); } //点击改签查询列车信息 @RequestMapping("/changeYd/{cid}/{oid}") public String changeYd(@PathVariable("cid")int cid,@PathVariable("oid")int oid,HttpServletRequest request){ Orderinfo order = carSerivce.findOrderByOid(oid); CarTrain car = carSerivce.findByCid(cid); request.setAttribute("order", order); request.setAttribute("car", car); return "../../changeYdOrder.jsp"; } //改签提交订单 修改列车信息 @RequestMapping(value="/updateOrder",produces={"application/json;charset=utf-8"}) @ResponseBody public String updateOrder(Orderinfo order,HttpServletRequest request){ //获取订单提交时间 Date date=new Date(); SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd"); String d = format.format(date); order.setOdate(d); order.setState("3");//已改签 //通过id查询订单 Orderinfo beforeOrder = carSerivce.findOrderByOid(order.getOid()); //原来的座位数要加一 carSerivce.addSeatnum(beforeOrder.getCid()); carSerivce.updateChangeOrder(order); int i=carSerivce.updateSnum(order.getCid()); //待确认订单 return i+""; }
dao
//查询付款订单 @Select("select c.*,t.tnum,o.oid,o.ucard,o.urealname,o.oprice,o.seatnum,o.state,o.odate from traininfo t inner join carinfo c on c.tid=t.tid inner join orderinfo o on c.cid=o.cid where o.oid=#{oid}") public CarTrainOrder selectFkOrder(int oid); //查看全部已付款订单 @Select("select c.*,t.tnum,o.oid,o.ucard,o.urealname,o.oprice,o.seatnum,o.state,o.odate from traininfo t inner join carinfo c on c.tid=t.tid inner join orderinfo o on c.cid=o.cid where o.uid=#{uid}") public List<CarTrainOrder> selectAllFkOrder(int uid); @Select("select c.*,t.tnum,o.oid,o.ucard,o.urealname,o.oprice,o.seatnum,o.state,o.odate from traininfo t inner join carinfo c on c.tid=t.tid inner join orderinfo o on c.cid=o.cid where o.uid=#{uid} and o.odate=#{odate}") public List<CarTrainOrder> selectAllSearchOrder(@Param("uid")int uid,@Param("odate")String odate);
三、遇到的问题:
1)业务逻辑容易出错,考虑不全,一直在重复去改
四、解决的方法:
1)改
五、项目燃尽图更新: