package com.example.meal_ordering_system.controller;
import com.example.meal_ordering_system.entity.*;
import com.example.meal_ordering_system.service.MenusService;
import com.example.meal_ordering_system.service.OrdersService;
import com.example.meal_ordering_system.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* (Orders)表控制层
*
* @author makejava
* @since 2021-02-04 12:51:20
*/
@Controller
@RequestMapping("orders")
public class OrdersController {
/**
* 服务对象
*/
@Autowired
@Qualifier("ordersService")
private OrdersService ordersService;
@Autowired
@Qualifier("menusService")
private MenusService menusService;
@Autowired
@Qualifier("usersService")
private UsersService usersService;
//获取全部订单信息
@RequestMapping("ordergetall")
public String ordergetall( HttpServletRequest request) {
//传给前端
Pages page1=null;
//总页面
Integer totalCount=null;
//当前页面
String currentpages="1";
//获取上一页还是下一页标识
String s="";
//数据库操作页面
String pagess="1";
//前端页面总数
Integer allpage=null;
//如果不为空则获取currentpage
if(request.getParameter("currentpage")!=null){
currentpages=request.getParameter("currentpage");
totalCount= ordersService.pageCount();
allpage=totalCount/5;
if(totalCount%5!=0){
allpage++;
}
if(Integer.parseInt(currentpages)<=0){
currentpages="1";
}
if(Integer.parseInt(currentpages)>allpage){
currentpages=""+allpage;
}
//设置pagess的值
if(request.getParameter("s")!=null){
s=request.getParameter("s");
if(s.equals("up")){
pagess=""+(Integer.parseInt(currentpages)-4);
}else if(s.equals("down")){
pagess=""+((Integer.parseInt(currentpages)-1)*5-1);
}else if (s.equals("first")){
pagess="0";
}else if(s.equals("last")){
pagess=""+(totalCount-(totalCount%5)-1);
}else {
System.out.println("错误");
}
}
page1=new Pages(currentpages,allpage);
request.setAttribute("pages",page1);
}else{
totalCount= ordersService.pageCount();
allpage=totalCount/5;
if(ordersService.pageCount()%5!=0){
allpage++;
}
page1=new Pages("1", allpage);
request.setAttribute("pages",page1);
}
//判断操作数据库页面是否突破限制
if(Integer.parseInt(pagess)<=0){
pagess="0";
}
if(Integer.parseInt(pagess)>totalCount){
pagess=""+(totalCount-(totalCount%5)-1);
}
List<Orders> list= ordersService.pageList(Integer.parseInt(pagess),5);
request.setAttribute("list",list);
System.out.println("pagess="+pagess);
System.out.println("currentpages="+currentpages);
return "/admin/order";
}
//确认打印订单 确认则将deliverys设置为一否则删除
@RequestMapping("OrderComfirm")
public String OrderComfirm( HttpServletRequest request){
int id=Integer.parseInt(request.getParameter("id"));
String reqtype=request.getParameter("reqtype");
if(reqtype.equals("delivery")){
ordersService.updatedeliveryById(id);
}else if(reqtype.equals("del")){
ordersService.deleteById(id);
}else{
System.out.println("错误");
}
return "redirect:/orders/ordergetall";
}
@RequestMapping("order_search")
public String order_search( HttpServletRequest request) {
return "/admin/order_search";
}
@RequestMapping("ordergetallbydelivery")
public String ordergetallbydelivery(HttpServletRequest request){
String delivery=request.getParameter("delivery");
Integer d=Integer.parseInt(delivery);
HttpSession session=request.getSession();
Users user = (Users) session.getAttribute("user_session");
Integer uid = usersService.queryByname(user.getName());
List<Orders> list=ordersService.pageListByDeliveryAndUid(d,uid);
session.setAttribute("ordersearch", list);
return "/qiantai/order";
}
@RequestMapping("orderGetAllByUid")
public String orderGetAllByUid(HttpServletRequest request){
HttpSession session=request.getSession();
Users user = (Users) session.getAttribute("user_session");
Integer uid = usersService.queryByname(user.getName());
List<Orders> list=ordersService.pageListByUid(uid);
session.setAttribute("ordersearch", list);
return "/qiantai/order";
}
@RequestMapping(value="order_qiantai",method = RequestMethod.POST)
public String order_qiantai( HttpServletRequest request) throws UnsupportedEncodingException {
List<Orders> list=null;
HttpSession session=request.getSession();
request.setCharacterEncoding("utf-8");
Integer id=null;
String menuname=null;
String day1=null;
if(request.getParameter("menuname")!=null&&(!request.getParameter("menuname").equals(""))){
menuname=request.getParameter("menuname");
Users user = (Users) session.getAttribute("user_session");
Integer uid = usersService.queryByname(user.getName());
/* list=ordersService.pageListByMenue(menuname);*/
list=ordersService.pageListByMenuAndUid(menuname,uid);
}else if(request.getParameter("date")!=null&&(!request.getParameter("date").equals(""))){
day1=request.getParameter("date");
Integer a=Integer.parseInt(day1.substring(9,10));
String aa=""+(a+1);
StringBuilder day=new StringBuilder(day1);
day.replace(9,10,aa);
String day2=day.toString();
list=ordersService.pageListByDate(day1,day2);
}else {
System.out.println("未提交");
}
session.setAttribute("ordersearch", list);
System.out.println(id);
System.out.println(menuname);
System.out.println(day1);
return "/qiantai/order";
}
@RequestMapping(value="order_searchs",method = RequestMethod.POST)
public String order_searchs( HttpServletRequest request) throws UnsupportedEncodingException {
List<Orders> list=null;
HttpSession session=request.getSession();
request.setCharacterEncoding("utf-8");
Integer id=null;
String menuname=null;
String day1=null;
if(request.getParameter("userid")!=null&&(!request.getParameter("userid").equals(""))){
id=Integer.parseInt(request.getParameter("userid"));
list=ordersService.pageListByID(id);
}else if(request.getParameter("menuname")!=null&&(!request.getParameter("menuname").equals(""))){
menuname=request.getParameter("menuname");
list=ordersService.pageListByMenu(menuname);
}else if(request.getParameter("date")!=null&&(!request.getParameter("date").equals("")))
lonzgzhouzhou
- 粉丝: 824
- 资源: 31
最新资源
- 基于Javaweb实现的校园疫情防控管理系统全部资料+详细文档+高分项目.zip
- 基于Java的校园超市购物系统全部资料+详细文档+高分项目.zip
- 基于node.js和微信jssdk的校园轻应用全部资料+详细文档+高分项目.zip
- 基于node.js与vue.js的校园考试系统全部资料+详细文档+高分项目.zip
- 基于PHP框架写的一个校园失物招领平台全部资料+详细文档+高分项目.zip
- 基于php的校园失物招领平台(自动寻找匹配度高的招领启事)全部资料+详细文档+高分项目.zip
- 基于RAG的校园LLM全部资料+详细文档+高分项目.zip
- 基于SpringBoot、SSM框架,Mysql等技术支持的智慧校园管理系统全部资料+详细文档+高分项目.zip
- 基于Spring、SpringMVC、Mybatis的校园二手交易平台全部资料+详细文档+高分项目.zip
- 基于SpringBoot+Mybatis+Thymeleaf的校园二手交易平台全部资料+详细文档+高分项目.zip
- 基于SpringMVC+spring+Mybatis的校园o2o电商项目的后台和管理平台全部资料+详细文档+高分项目.zip
- 基于SpringCloud Alibaba 微服务的前后端分离项目实现一个校园范围内的微博,是一个社交网站,让你的朋友圈扩大到你所在的整个校园范围内全部资料+详细文档+高分项目.zip
- allwinner全志-V3S-LINUX-QT-4G-WIFI实现4G路由器WIFI热点上网功能.rar
- 基于springboot的简单校园商城系统涵盖JavaEE基本知识点全部资料+详细文档+高分项目.zip
- 基于SSM(Sping+Spring MVC+MyBatis)框架的校园宽带业务管理系统全部资料+详细文档+高分项目.zip
- 基于SSH(struts2+spring+herbinate)的校园二手网站开发全部资料+详细文档+高分项目.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈