基于javaweb+mysql的ssm餐厅点餐收银管理系统(java+ssm+jsp+bootstrap+mysql+redis)

基于javaweb+mysql的ssm餐厅点餐收银管理系统(java+ssm+jsp+bootstrap+mysql+redis)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb的SSM餐厅点餐收银管理系统(java+ssm+jsp+bootstrap+mysql+redis)

项目介绍

用于餐厅的收银管理系统,包含了四个模块 1.桌位模块 桌位模块主要是用于管理桌位的模块,包括点菜到结账的流程 将桌位人数设置为0可以滞空当前桌位

2.账单模块 账单模块记录了每一天的帐单汇总,同时提供了年月日账单的统计,在日账单内可以查看当日的所有消费详情,还提供了按日期或日期区间搜索账单的功能

3.日常维护模块 提供了桌位菜单用户供应商的配置功能,也就是增删改查

添加菜品时,添加酒水类时,可以选择进货内的酒水,这样的话在结账后若客人点了该酒水,会将销售信息记录在酒水库存内的销售信息里

4.酒水库存模块 查看添加酒水的进销存信息

管理员角色包含以下功能:

登录,查看桌位,开桌,点菜,结账,查看账单,添加菜品,查看菜品,桌位维护,添加桌位,添加账号,查看账号,添加供应商,进货信息管理,添加进货信息等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否; 7.Redis数据库;

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+Bootstrap+jQuery

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中applicationcontext-mybatis.xml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/login.html 登录 管理员账号/密码:admin/adminadmin
    }

    @RequestMapping("/showUserList.do")
    public ModelAndView showUserList(ModelAndView modelAndView, Pager pager){
        pager.setPageSize(PagerTools.deskBillPagerSize);
        pager.setTotalCount(userService.getTotalCount(pager));
        pager.count();
        pager.setList(userService.showUserList(pager));
        modelAndView.addObject("pager",pager);
        modelAndView.setViewName("/daily/user/userList");
        return modelAndView;
    }
    @RequestMapping("/delUserById.do")
    @ResponseBody
    public Object delUserById(User user){
        return JSON.toJSONString(userService.delUserById(user));
    }
    @RequestMapping("/updateUser.do")
    @ResponseBody
    public Object updateUser(User user){
        return JSON.toJSONString(userService.updateUser(user));
    }
    @RequestMapping("/loadUserInfoById.do")
    public ModelAndView loadUserInfoById(ModelAndView modelAndView,Pager pager){
        pager.setPageSize(1);
        pager.setTotalCount(userService.getTotalCount(pager));
        pager.count();
        modelAndView.addObject("user",userService.showUserList(pager).get(0));
        modelAndView.setViewName("/daily/user/updateUser");
        return modelAndView;
    }

    @ResponseBody
    @RequestMapping("/userIsExist.do")
    public Object userIsExist(User user){
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println(user.getIdentity()+user.getUserCode()+user.getPhone());
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~");
        int phoneFlag=-1;
        int identityFlag=-1;
        int userCodeFlag=-1;
		return "login";
	}
	
	//处理登录
	@RequestMapping(value="login.html",method=RequestMethod.POST)
	public String doLogin(User user,HttpSession session,Model model){
		User logUser=userService.login(user);
		if(logUser!=null){
			session.setAttribute("user", logUser);
			return "redirect:desklist.html?show=desk";
		}else{
			model.addAttribute("error", "账号和密码不匹配");
			return "login";
		}	
	}
	
	//处理注销
	@RequestMapping(value="/logout.html")
	public String logout(HttpSession session){
		session.invalidate();
		return "redirect:login.html";
	}
}

/**
 * 日志增强
 */
public class AdviceLog {
    private static final Logger log=Logger.getLogger(AdviceLog.class);
    @ResponseBody
    public Object delDrinkBill(@RequestParam(required = false) String id) {
        providerService.delDrinkSellBill(id);
        return JSON.toJSONString(providerService.delDrinkBill(id));
    }

    //del删除销售信息
    @RequestMapping("/delDrinkSellBill.do")
    @ResponseBody
    public Object delDrinkSellBill(@RequestParam(required = false) String id) {
        return JSON.toJSONString(providerService.delDrinkSellBill(id));
    }

    //更新进货信息
    @RequestMapping("/updateDrinkBill.do")
    @ResponseBody
    public Object delDrinkBill(Drinkbill drinkbill) {
        drinkbill.setIsPay(2);
        return JSON.toJSONString(providerService.updateDrinkBill(drinkbill));
    }

    //添加进货信息
    @RequestMapping("/addDrinkBill.do")
    @ResponseBody
    public Object addDrinkBill(Drinkbill drinkbill, DrinkSellBill drinkSellBill) {
        String drinkBillCode = BillCodeUtil.getBillCode();
        drinkbill.setDrinbillCode(drinkBillCode);
        int addDrinkBillFlag = providerService.addDrinkBill(drinkbill);
        drinkSellBill.setDrinkbillId(drinkbill.getId());
        drinkSellBill.setDrinkBillCode(drinkBillCode);
        int addDrinkSellBillFlag = providerService.addDrinkSellBill(drinkSellBill);
        return "{\"addDrinkBillFlag\":\"" + addDrinkBillFlag + "\",\"addDrinkSellBillFlag\":\"" + addDrinkSellBillFlag + "\"}";
    }

    //加载销售信息
    @RequestMapping("/loadDrinkSellBill.do")
    @ResponseBody
    public ModelAndView loadDrinkSellBill(ModelAndView modelAndView, DrinkBillPager pager) {
        int totalCount = providerService.getDrinkSellBillCount(pager);
        if (totalCount != 0) {
            pager.setTotalCount(totalCount);
        } else {
            pager.setTotalCount(1);
        }
        pager.setPageSize(PagerTools.drinkBillPagerSize);
        pager.count();
        pager.setList(providerService.getDrinkSellBill(pager));
        modelAndView.addObject("pager", pager);
        modelAndView.setViewName("/drink/sellList");
    @ResponseBody
    @RequestMapping("/dishNameIsExist.do")
    public Object dishNameIsExist(@RequestParam(required = false) String dishName) {
        boolean existFlag = false;
        if (dishName != "" && dishName != null) {
            existFlag = dishService.isExist(dishName);
        }
        if (existFlag) {
            return JSON.toJSONString("0");//存在该菜品
        }
        return JSON.toJSONString("1");//不存在该菜品
    }

    //加载菜品列表
    @ResponseBody
    @RequestMapping("/dishList.do")
    public ModelAndView dishList(Pager pager, ModelAndView modelAndView,
                                 @RequestParam(required = false) String dishName) {
        if (dishName == null || "".equals(dishName)) {//如果没有输入查询名字则当作opr=allDish
            pager.setOpr("allDish");
        }
        modelAndView.setViewName("/daily/dish/dishList");
        Dishes dishes = Dishes.getDishes();
        pager.setPageSize(PagerTools.delDishListPagerSize);
        if (dishes.getAllDishCount() == 0) {
            if(redisUtil.getList("allDishes")==null){
                redisUtil.addList("allDishes",dishService.getDish());
            }
            dishes.setAllDish(redisUtil.getList("allDishes"));
        }
        pager.setTotalCount(dishes.getAllDishCount());
        if ("serchDish".equals(pager.getOpr())) {//优先查询
            pager.setPageSize(dishes.getAllDishCount());//搜索时把所有菜品全部查出
            System.out.println("~~~~~~~~~~~~~~~~~~~~~~" + dishName);
        }
        pager.count();
        List<Dish> list = dishes.getAllDish(pager);
        if ("serchDish".equals(pager.getOpr())) {//优先查询
            List<Dish> serchList = new ArrayList<Dish>();
            if (dishName != null && !"".equals(dishName)) {
                System.out.println("~~~~~~~~查找相同菜品的数据~~~~~~~~~~");
                for (Dish dish : list) {
                    if(dish.getDishName().contains(dishName)){
                        System.out.println("~~~~~~~~~~~找到与"+dishName+"相似的菜品~~~~~~~~~~~");
                        serchList.add(dish);
                    }
                }
        return JSON.toJSONString(userService.delUserById(user));
    }
    @RequestMapping("/updateUser.do")
    @ResponseBody
    public Object updateUser(User user){
        return JSON.toJSONString(userService.updateUser(user));
    }
    @RequestMapping("/loadUserInfoById.do")
    public ModelAndView loadUserInfoById(ModelAndView modelAndView,Pager pager){
        pager.setPageSize(1);
        pager.setTotalCount(userService.getTotalCount(pager));
        pager.count();
        modelAndView.addObject("user",userService.showUserList(pager).get(0));
        modelAndView.setViewName("/daily/user/updateUser");
        return modelAndView;
    }

    @ResponseBody
    @RequestMapping("/userIsExist.do")
    public Object userIsExist(User user){
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println(user.getIdentity()+user.getUserCode()+user.getPhone());
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~");
        int phoneFlag=-1;
        int identityFlag=-1;
        int userCodeFlag=-1;
        if(user.getUserCode()!=null && !user.getUserCode().equals("")){
            userCodeFlag=userService.userIsExist(user);
        }
        if(user.getIdentity()!=null && !"".equals(user.getIdentity())){
            identityFlag=userService.userIsExist(user);
        }
        if(user.getPhone()!=null && !"".equals(user.getPhone())){
            phoneFlag=userService.userIsExist(user);
        }
        return "{\"userCodeFlag\":\""+userCodeFlag+"\",\"phoneFlag\":\""+phoneFlag+"\",\"identityFlag\":\""+identityFlag+"\"}";
    }
}

		boolean data=deskService.updateDesk(desk);
		return JSON.toJSONString(data?"1":"0");
	}

}

@Controller
public class DeskBillController {
	@Autowired
	private DeskBillService deskBillService;
	@Resource(name="redisUtil")
	private RedisUtil redisUtil;
	@Autowired
	private DeskService deskService;
	
	
	// ajax结账
	@RequestMapping("/pay.do")
	@ResponseBody
	public Object pay(Deskbill deskBill) {
		deskBill.setBillCode(BillCodeUtil.getBillCode());// 设置账单编号为当前毫秒数
		deskBillService.addDeskBill(deskBill);//添加账单

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping("/addUser.do")
    public Object addUser(User user){
        return JSON.toJSONString(userService.addUser(user));
    }

    @RequestMapping("/showUserList.do")
    public ModelAndView showUserList(ModelAndView modelAndView, Pager pager){
        pager.setPageSize(PagerTools.deskBillPagerSize);
        pager.setTotalCount(userService.getTotalCount(pager));
        pager.count();
        pager.setList(userService.showUserList(pager));
        modelAndView.addObject("pager",pager);
        modelAndView.setViewName("/daily/user/userList");
        return modelAndView;
    }
    @RequestMapping("/delUserById.do")
    @ResponseBody
    public Object delUserById(User user){
        return JSON.toJSONString(userService.delUserById(user));
    }
    @RequestMapping("/updateUser.do")
    @ResponseBody
    public Object updateUser(User user){
        return JSON.toJSONString(userService.updateUser(user));
    }
    @RequestMapping("/loadUserInfoById.do")
    public ModelAndView loadUserInfoById(ModelAndView modelAndView,Pager pager){
        pager.setPageSize(1);
        pager.setTotalCount(userService.getTotalCount(pager));
        pager.count();
        modelAndView.addObject("user",userService.showUserList(pager).get(0));
        modelAndView.setViewName("/daily/user/updateUser");
        return modelAndView;
    }
            String oldFileName = file.getOriginalFilename();//获取原文件名
            System.out.println("原文件名:" + oldFileName);
            String newFileName = BillCodeUtil.getBillCode() + "_"+oldFileName;//新文件名
            String prefix = FilenameUtils.getExtension(oldFileName);//获取文件后缀,对后缀进行判断,过滤不符合条件的文件
            System.out.println("~~~文件类型:" + prefix + "~~~");
            System.out.println("~~~文件大小:" + file.getSize() + "~~~");
            if ("jpg".equals(prefix) || "JPG".equals(prefix)) {
                System.out.println("~~~文件类型验证通过~~~");
                if (file.getSize() < PagerTools.maxFileSize) {
                    System.out.println("~~~~~~~~~文件大小验证通过~~~~~~~~~~~");
                    try {
                        file.transferTo(new File(path + File.separator +newFileName));
                        System.out.println("上传成功");
                        dish.setFileName(newFileName);//将新文件名保存在对象中
                        addFlag = dishService.addDish(dish);//添加至数据库
                        System.out.println("菜品" + dish.getDishName() + "添加成功");
                    } catch (IllegalStateException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                } else {
                    fifleFlag = "图片不能大于500KB";
                }
            } else {
                fifleFlag = "请上传JPG格式图片";
            }
        }
        if (addFlag) {//添加成功时
            //刷新缓存
            redisUtil.del("allDishes");
            return JSON.toJSONString("OK");
        } else {
            return "{'fifleFlag':'" + fifleFlag + "'}";
        }
    }

    //ajax验证菜品名是否存在
    @ResponseBody
    @RequestMapping("/dishNameIsExist.do")
            pager.setList(providerService.getProviderList(pager));
            modelAndView.setViewName("daily/provider/providerList");
            modelAndView.addObject("pager",pager);
        }
        return modelAndView;
    }
    //删除供应商
    @RequestMapping("/delProviderById.do")
    @ResponseBody
    public Object delProviderById(Pager pager){
        return JSON.toJSONString(providerService.delProviderById(pager));
    }
    //更改供应商
    @RequestMapping("/updateProvider.do")
    @ResponseBody
    public Object updateProvider(Provider provider){
        return JSON.toJSONString(providerService.updateProvider(provider));
    }
}

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping("/addUser.do")
    public Object addUser(User user){
        return JSON.toJSONString(userService.addUser(user));
    }

    @RequestMapping("/showUserList.do")
    public ModelAndView showUserList(ModelAndView modelAndView, Pager pager){
		if(session.getAttribute("user")==null){//权限控制
			return "redirect:login.html";
		}
		if(bpager.getBeginDate()!=null && bpager.getEndDate()==null){//当只填写了开始日期时单独查询这天的账单
			bpager.setOpr("otherday");
			bpager.setOthDate(bpager.getBeginDate());
			bpager.setTotalCount(1);//给pager设置总数据量
			bpager.setPageSize(PagerTools.billSummaryPagerSize);//设置页面大小
			bpager.count();//格式化数据
		}else if(bpager.getBeginDate()!=null && bpager.getEndDate()!=null){//都填写了
			int  billSummaryCount=deskBillService.getBillSummaryCount(bpager);//得到总数据量
			bpager.setTotalCount(billSummaryCount);//给pager设置总数据量
			bpager.setPageSize(PagerTools.billSummaryPagerSize);//设置页面大小
			bpager.count();//格式化数据
		}else{//都没填写
			bpager.setOpr("date");
			int  billSummaryCount=deskBillService.getBillSummaryCount(bpager);//得到总数据量
			bpager.setTotalCount(billSummaryCount);//给pager设置总数据量
			bpager.setPageSize(PagerTools.billSummaryPagerSize);//设置页面大小
			bpager.count();//格式化数据
		}
		bpager.setList(deskBillService.getBillSummarys(bpager));
		model.addAttribute("bpager", bpager);
		return "/bill/datebill";
	}
	
	//日详情
	@ResponseBody
	@RequestMapping("/ajax")
	public ModelAndView ajax(ModelAndView m,DeskBillPager dpager,BillSummaryPager bpager){
		int totalCount=deskBillService.getCount(dpager.getBillDate());//查询当天账单总条数
		bpager.setOpr("otherday");//设置查询类型
		bpager.setFirstData(0);
		bpager.setPageSize(1);
		dpager.setTotalCount(totalCount);//设置总数
		dpager.setPageSize(PagerTools.deskBillPagerSize);//设置每一页数据量
		dpager.count();//格式化数据
		Map map=new HashMap();
		map.put("billSummarys",  deskBillService.getBillSummarys(bpager));//当天账单汇总
		List<Deskbill> deskBills=deskBillService.getDekBills(dpager);//分页查询
		dpager.setList(deskBills);//将数据保存在pager对象内
		m.setViewName("/bill/dateDetail");
		map.put("deskBillpager", dpager);
		m.addAllObjects(map);
		m.addObject("a", "CHANGEX");
		return m;
	}

	//ajax查看账单曲线
	@RequestMapping("/deskCodeIsExist.do")
	public Object deskCodeIsExist(@RequestParam(required =false) String deskCode){
		boolean flag=deskService.isExist(deskCode);
		return flag?JSON.toJSONString("1"):JSON.toJSONString("0");
	}

	//添加桌位
	@ResponseBody
	@RequestMapping("/addDesk.do")
	public Object addDesk(Desk desk){
		System.out.println("~~~~~~~~~~~~~~~~~~~~~添加桌位:"+desk.getDeskCode()+"~~~~~~~~~~~~~~~~~~~~~");
		boolean flag=deskService.addDesk(desk);
		if(flag){
			System.out.println("~~~~~~~~~~~~~~~~~~~~~添加桌位:"+desk.getDeskCode()+"成功~~~~~~~~~~~~~~~~~~~~~");
		}else{
			System.out.println("~~~~~~~~~~~~~~~~~~~~~添加桌位:"+desk.getDeskCode()+"失败~~~~~~~~~~~~~~~~~~~~~");
		}
		return flag?JSON.toJSONString("1"):JSON.toJSONString("0");
	}

	//ajax分页加载桌位
	@ResponseBody
	@RequestMapping("/ajaxShowDesk.do")
	public ModelAndView ajaxShowDesk(DeskPager pager, ModelAndView modelAndView){
		modelAndView.setViewName("/daily/desk/deskList");
		pager.setPageSize(PagerTools.delDishListPagerSize);
		pager.setTotalCount(deskService.getTotalCount(pager));
		pager.count();
		pager.setList(deskService.getDesksByPager(pager));
		modelAndView.addObject("pager",pager);
		return modelAndView;
	}

	//删除桌位
	@ResponseBody
	@RequestMapping("/delDesk.do")
	public Object delDesk(@RequestParam(required=false) String id){
		int data=deskService.delDesk(id);
		return JSON.toJSONString(data);
	}

	//更改桌位
	@ResponseBody
	@RequestMapping("/alertDesk.do")
	public Object delDesk(Desk desk){
		boolean data=deskService.updateDesk(desk);
		return JSON.toJSONString(data?"1":"0");
	}

}
	}
	
	//处理注销
	@RequestMapping(value="/logout.html")
	public String logout(HttpSession session){
		session.invalidate();
		return "redirect:login.html";
	}
}

/**
 * 日志增强
 */
public class AdviceLog {
    private static final Logger log=Logger.getLogger(AdviceLog.class);

    /**
     * 前置增强
     */
    public void before(JoinPoint joinpoint){
        log.info("~~~~~~~~~~~~~~~~~~~~调用"+joinpoint.getTarget().getClass()+"的"+joinpoint.getSignature().getName()+
                "方法开始~~~~~~~~~~~~~~~~~~~~");
    }
    /**
     * 后置增强
     */
    public void afterReturning(JoinPoint joinpoint){
        log.info("~~~~~~~~~~~~~~~~~~~~调用"+joinpoint.getTarget().getClass()+"的"+joinpoint.getSignature().getName()+
                "方法结束~~~~~~~~~~~~~~~~~~~~");
    }

}

        int identityFlag=-1;
        int userCodeFlag=-1;
        if(user.getUserCode()!=null && !user.getUserCode().equals("")){
            userCodeFlag=userService.userIsExist(user);
        }
        if(user.getIdentity()!=null && !"".equals(user.getIdentity())){
            identityFlag=userService.userIsExist(user);
        }
        if(user.getPhone()!=null && !"".equals(user.getPhone())){
            phoneFlag=userService.userIsExist(user);
        }
        return "{\"userCodeFlag\":\""+userCodeFlag+"\",\"phoneFlag\":\""+phoneFlag+"\",\"identityFlag\":\""+identityFlag+"\"}";
    }
}

@Controller
public class LoginController {
	@Autowired
	private UserService userService;
	
	//登录页面入口
	@RequestMapping(value="login.html",method=RequestMethod.GET)
	public String showLogin(){
		return "login";
	}
	
	//处理登录
	@RequestMapping(value="login.html",method=RequestMethod.POST)
	public String doLogin(User user,HttpSession session,Model model){
		User logUser=userService.login(user);
		if(logUser!=null){
			session.setAttribute("user", logUser);
			return "redirect:desklist.html?show=desk";
		}else{
			model.addAttribute("error", "账号和密码不匹配");
			return "login";
		}	
	}
	
	//处理注销
	@RequestMapping(value="/logout.html")
	public String logout(HttpSession session){
        return JSON.toJSONString("1");//不存在该菜品
    }

    //加载菜品列表
    @ResponseBody
    @RequestMapping("/dishList.do")
    public ModelAndView dishList(Pager pager, ModelAndView modelAndView,
                                 @RequestParam(required = false) String dishName) {
        if (dishName == null || "".equals(dishName)) {//如果没有输入查询名字则当作opr=allDish
            pager.setOpr("allDish");
        }
        modelAndView.setViewName("/daily/dish/dishList");
        Dishes dishes = Dishes.getDishes();
        pager.setPageSize(PagerTools.delDishListPagerSize);
        if (dishes.getAllDishCount() == 0) {
            if(redisUtil.getList("allDishes")==null){
                redisUtil.addList("allDishes",dishService.getDish());
            }
            dishes.setAllDish(redisUtil.getList("allDishes"));
        }
        pager.setTotalCount(dishes.getAllDishCount());
        if ("serchDish".equals(pager.getOpr())) {//优先查询
            pager.setPageSize(dishes.getAllDishCount());//搜索时把所有菜品全部查出
            System.out.println("~~~~~~~~~~~~~~~~~~~~~~" + dishName);
        }
        pager.count();
        List<Dish> list = dishes.getAllDish(pager);
        if ("serchDish".equals(pager.getOpr())) {//优先查询
            List<Dish> serchList = new ArrayList<Dish>();
            if (dishName != null && !"".equals(dishName)) {
                System.out.println("~~~~~~~~查找相同菜品的数据~~~~~~~~~~");
                for (Dish dish : list) {
                    if(dish.getDishName().contains(dishName)){
                        System.out.println("~~~~~~~~~~~找到与"+dishName+"相似的菜品~~~~~~~~~~~");
                        serchList.add(dish);
                    }
                }
                pager.setList(serchList);
            }
        } else {
            pager.setList(list);
        }
        modelAndView.addObject("pager", pager);
        return modelAndView;
				redisUtil.del(deskCode);//删除缓存内的桌位菜单信息
			}
		}else if(status==2){//如果桌位状态为未买单
			if(deskCode!=null && deskCode!=""){//传过来的桌位编号不为空时
				List<DeskInfo_detail> deskDish=redisUtil.getList(deskCode);//从缓存取出当前桌位的点菜信息
				Double totalMoney=0.0;//总计
				if (deskDish==null || deskDish.size()==0) {
					deskDish=new ArrayList<DeskInfo_detail>();
					redisUtil.addList(deskCode, deskDish);
				}
				for (int i = 0; i < deskDish.size(); i++) {
					if(deskDish.get(i).getCost()!=null){
						totalMoney+=deskDish.get(i).getCost();
					}			
				}
				model.addAttribute("totalMoney", totalMoney);
				model.addAttribute("deskDish", deskDish);
			}
		}
		List dishes=redisUtil.getList("allDishes");//先从缓存中查询
		if(dishes == null || dishes.size()==0){//如果缓存中没有则从数据库查
			dishes=dishMapper.getDish();
			redisUtil.addList("allDishes",dishes);
		}
		Dishes dishesUtil=Dishes.getDishes();//菜单工具类
		dishesUtil.setAllDish(dishes);//将查询出来的菜品放在工具类中
		dishesUtil.count();//格式化菜品(分类)
		//session.setAttribute("dishUtil",dishesUtil);
		model.addAttribute("desk", desk);
		return "/desk/deskinfo";
	}
	
	//ajax点菜
	@RequestMapping("/selectDish.do")
	@ResponseBody
	public Object selectDish(DeskInfo_detail deskInfo_detail,@RequestParam(required=false)String deskCode){
		List<DeskInfo_detail> deskDish=redisUtil.getList(deskCode);
		if(deskDish==null){
			deskDish=new ArrayList<DeskInfo_detail>();
			System.out.println("------------------------------新建桌位号"+deskCode+"菜单列表------------------------------");
		}
		boolean addFlag=true;//标记是否有相同的菜品,默认为true表名不存在相同菜名
    }

    //加载销售信息
    @RequestMapping("/loadSuplusDrinkBill.do")
    @ResponseBody
    public ModelAndView loadSuplusDrinkBill(ModelAndView modelAndView, DrinkBillPager pager) {
        int totalCount = providerService.getDrinkSellBillCount(pager);
        if (totalCount != 0) {
            pager.setTotalCount(totalCount);
        } else {
            pager.setTotalCount(1);
        }
        pager.setPageSize(PagerTools.drinkBillPagerSize);
        pager.count();
        pager.setList(providerService.getSuplusDrinkBill(pager));
        modelAndView.addObject("pager", pager);
        modelAndView.setViewName("/drink/suplusDrinkBillList");
        return modelAndView;
    }

    //添加供应商
    @RequestMapping("/addProvider.do")
    @ResponseBody
    public Object addProvider(Provider provider){
        return JSON.toJSONString(providerService.addProvider(provider));
    }
    //验证供应商是否存在
    @RequestMapping("/isProExist.do")
    @ResponseBody
    public Object isProExist(@RequestParam(required = false) String proName){
        return JSON.toJSONString(providerService.isProExist(proName));
    }
    //加载供应商列表
    @RequestMapping("/showProviderList.do")
    public ModelAndView showProviderList(ModelAndView modelAndView,Pager pager){
        pager.setTotalCount(providerService.getTotalCount(pager));
        pager.setPageSize(3);
        pager.count();
        if("".equals(pager.getOpr()) || pager.getOpr()==null){
            modelAndView.addObject("provider",providerService.getProviderList(pager).get(0));
            modelAndView.setViewName("daily/provider/updateProvider");
        }else{
            pager.setList(providerService.getProviderList(pager));
            modelAndView.setViewName("daily/provider/providerList");
            modelAndView.addObject("pager",pager);
        }
        return modelAndView;
    }
    //删除供应商
    @RequestMapping("/delProviderById.do")
    @ResponseBody
    public Object delProviderById(Pager pager){

@Controller
public class DeskBillController {
	@Autowired
	private DeskBillService deskBillService;
	@Resource(name="redisUtil")
	private RedisUtil redisUtil;
	@Autowired
	private DeskService deskService;
	
	
	// ajax结账
	@RequestMapping("/pay.do")
	@ResponseBody
	public Object pay(Deskbill deskBill) {
		deskBill.setBillCode(BillCodeUtil.getBillCode());// 设置账单编号为当前毫秒数
		deskBillService.addDeskBill(deskBill);//添加账单
		int deskBillId=deskBill.getId();//得到本次账单的id
		int deskId=deskBill.getDeskId();//得到该账单所属的桌位id
		Desk desk=deskService.getDeskById(deskId+"");//查询该ID的桌位
		String deskCode=desk.getDeskCode();//得到桌位编号
		//从缓存取出菜单列表,并且遍历账单列表一条一条插入账单详情
		List<DeskInfo_detail> deskDishes=redisUtil.getList(deskCode);//取出菜单列表
		if(deskDishes!=null){
			for (DeskInfo_detail deskInfo_detail : deskDishes) {
				if(deskInfo_detail.getDrinkBillCode()!=null && !deskInfo_detail.getDrinkBillCode().equals("")){//增加销售信息
					deskBillService.sellDrink(deskInfo_detail.getDrinkBillCode(),deskInfo_detail.getDishNum());
				}
				deskInfo_detail.setDeskBillId(deskBillId);
				deskBillService.addDeskBillDetail(deskInfo_detail);

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

java毕业

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值