public ActionForward reseat( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { // TODO Auto-generated method stub if (request.getSession().getAttribute("loginUser") != null) { String oid = request.getParameter("oid"); List list = ordetailService.getByOid(Integer.valueOf(oid)); odetail = (Odetail) list.get(0); request.setAttribute("mtt", odetail.getTimetable()); return mapping.findForward("goStep2"); } else { return mapping.findForward("goLogin"); } }
public ActionForward submitSeat( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { // get user Users user = (Users) request.getSession().getAttribute("loginUser"); // get timetable String tid = request.getParameter("tid"); Timetable timetable = (Timetable) timeTableService.findById(Timetable.class, Integer.valueOf(tid)); // get tickets count SeatForm seatForm = (SeatForm) form; if (seatForm.getNums().length == 2) { if (seatForm.getNums()[0] == seatForm.getNums()[1]) { if (seatForm.getRows()[0] == seatForm.getRows()[1]) { ocount = 1; } } else { ocount = 2; } } else { ocount = seatForm.getNums().length; } // save orders order = new Orders(); order.setUsers(user); order.setOdate(new java.util.Date()); order.setOstate("no-pay"); order = orderService.getSaveOrderID(order); // submit to database // seatService.save(seat); odetail = new Odetail(); seat = new Seat(); if (ocount == 1) { seat.setSerow(seatForm.getRows()[0]); seat.setSenum(seatForm.getNums()[0]); seat.setHall(timetable.getHall()); seatService.save(seat); odetail.setSeat(seat); odetail.setOcount(ocount); odetail.setOmoney(timetable.getTticketPrice() * ocount); odetail.setOrders(order); odetail.setTimetable(timetable); ordetailService.save(odetail); } else if (ocount == 2) { if (seatForm.getRows().length == 1) { seat.setSerow(seatForm.getRows()[0]); seat.setSenum(seatForm.getNums()[0]); seat.setHall(timetable.getHall()); seatService.save(seat); odetail.setSeat(seat); odetail.setOcount(ocount); odetail.setOmoney(timetable.getTticketPrice() * ocount); odetail.setOrders(order); odetail.setTimetable(timetable); ordetailService.save(odetail); seat = new Seat(); odetail = new Odetail(); seat.setSerow(seatForm.getRows()[0]); seat.setSenum(seatForm.getNums()[1]); seat.setHall(timetable.getHall()); seatService.save(seat); odetail.setSeat(seat); odetail.setOcount(ocount); odetail.setOmoney(timetable.getTticketPrice() * ocount); odetail.setOrders(order); odetail.setTimetable(timetable); ordetailService.save(odetail); } else { seat.setSerow(seatForm.getRows()[0]); seat.setSenum(seatForm.getNums()[0]); seat.setHall(timetable.getHall()); seatService.save(seat); odetail.setSeat(seat); odetail.setOcount(ocount); odetail.setOmoney(timetable.getTticketPrice() * ocount); odetail.setOrders(order); odetail.setTimetable(timetable); ordetailService.save(odetail); seat = new Seat(); odetail = new Odetail(); seat.setSerow(seatForm.getRows()[1]); seat.setSenum(seatForm.getNums()[1]); seat.setHall(timetable.getHall()); seatService.save(seat); odetail.setSeat(seat); odetail.setOcount(ocount); odetail.setOmoney(timetable.getTticketPrice() * ocount); odetail.setOrders(order); odetail.setTimetable(timetable); ordetailService.save(odetail); } } List list = ordetailService.getOrders(order.getOid()); if (list.size() == 2) { request.setAttribute("mtt", list.get(0)); request.setAttribute("seats", list.get(1)); } else { request.setAttribute("mtt", list.get(0)); } return mapping.findForward("goStep3"); }