|
|
@ -13,59 +13,74 @@ import com.cn.service.impl.PrepServiceImpl;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @ClassName: UpdatePrepServlet
|
|
|
|
* @ClassName: UpdatePrepServlet
|
|
|
|
* @Description: 会员 判断是改签还是付款,如果是付款的话实现付款业务,改签的话跳转到ChangePrepServlet
|
|
|
|
* @Description: 会员判断是改签还是付款,如果是付款的话实现付款业务,改签的话跳转到ChangePrepServlet
|
|
|
|
* @author: ljy
|
|
|
|
* @author: ljy
|
|
|
|
* @date: 2019年11月10日 下午8:24:24
|
|
|
|
* @date: 2019年11月10日 下午8:24:24
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class UpdatePrepServlet extends HttpServlet {
|
|
|
|
public class UpdatePrepServlet extends HttpServlet {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @see HttpServlet#HttpServlet()
|
|
|
|
* HttpServlet的构造函数。
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public UpdatePrepServlet() {
|
|
|
|
public UpdatePrepServlet() {
|
|
|
|
super();
|
|
|
|
super();
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
// 构造函数中的代码,通常不需要自定义操作,因为父类已经处理
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
|
|
|
* 处理GET请求的方法。
|
|
|
|
*/
|
|
|
|
* 当客户端发送GET请求到此Servlet时,这个方法会被调用。
|
|
|
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
* @param request HttpServletRequest对象,包含客户端请求信息。
|
|
|
|
Integer prepId = Integer.valueOf(request.getParameter("prepId"));
|
|
|
|
* @param response HttpServletResponse对象,用于发送响应到客户端。
|
|
|
|
Integer temp = Integer.valueOf(request.getParameter("temp"));
|
|
|
|
* @throws ServletException 可能抛出的Servlet异常。
|
|
|
|
|
|
|
|
* @throws IOException 可能抛出的IO异常。
|
|
|
|
PrepService prepService = new PrepServiceImpl();
|
|
|
|
*/
|
|
|
|
Prep prep = prepService.getById(prepId);
|
|
|
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
|
|
|
|
// 从请求中获取订单ID和临时变量temp参数,并转换为Integer类型
|
|
|
|
// 付款业务
|
|
|
|
Integer prepId = Integer.valueOf(request.getParameter("prepId"));
|
|
|
|
if(temp == 1) {
|
|
|
|
Integer temp = Integer.valueOf(request.getParameter("temp"));
|
|
|
|
prep.setWay(true);
|
|
|
|
|
|
|
|
int recordNumber = prepService.update(prep);
|
|
|
|
// 创建PrepService的实现类对象,用于访问订单相关的业务逻辑
|
|
|
|
if(recordNumber == 1) {
|
|
|
|
PrepService prepService = new PrepServiceImpl();
|
|
|
|
request.setAttribute("msg", "付款成功!");
|
|
|
|
// 根据订单ID获取订单对象
|
|
|
|
} else {
|
|
|
|
Prep prep = prepService.getById(prepId);
|
|
|
|
request.setAttribute("msg", "付款失败!");
|
|
|
|
|
|
|
|
}
|
|
|
|
// 如果temp参数为1,表示进行付款业务
|
|
|
|
request.getRequestDispatcher("MyPrepServlet").forward(request, response);
|
|
|
|
if(temp == 1) {
|
|
|
|
}
|
|
|
|
// 设置订单的付款状态为已付款
|
|
|
|
|
|
|
|
prep.setWay(true);
|
|
|
|
// 改签业务(先将prepId转发到ChangePrepServlet)
|
|
|
|
// 更新订单对象到数据库
|
|
|
|
if(temp == 2) {
|
|
|
|
int recordNumber = prepService.update(prep);
|
|
|
|
request.setAttribute("prepId", prepId);
|
|
|
|
// 根据更新结果设置消息,并转发到我的订单页面
|
|
|
|
request.getRequestDispatcher("ChangePrepServlet").forward(request, response);
|
|
|
|
if(recordNumber == 1) {
|
|
|
|
}
|
|
|
|
request.setAttribute("msg", "付款成功!");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
request.setAttribute("msg", "付款失败!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
request.getRequestDispatcher("MyPrepServlet").forward(request, response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果temp参数为2,表示进行改签业务,先将prepId转发到ChangePrepServlet
|
|
|
|
|
|
|
|
if(temp == 2) {
|
|
|
|
|
|
|
|
request.setAttribute("prepId", prepId);
|
|
|
|
|
|
|
|
request.getRequestDispatcher("ChangePrepServlet").forward(request, response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
|
|
|
* 处理POST请求的方法。
|
|
|
|
*/
|
|
|
|
* 当客户端发送POST请求时,这个方法会被调用。
|
|
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
* @param request HttpServletRequest对象,包含客户端请求信息。
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
* @param response HttpServletResponse对象,用于发送响应到客户端。
|
|
|
|
doGet(request, response);
|
|
|
|
* @throws ServletException 可能抛出的Servlet异常。
|
|
|
|
}
|
|
|
|
* @throws IOException 可能抛出的IO异常。
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
doGet(request, response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|