Restaurant cash register system | Restaurant cash register system based on SSM

Author Homepage: Programming Compass

About the author: High-quality creator in the Java field, CSDN blog expert, invited author of Nuggets, many years of architect design experience, resident lecturer in Tencent Classroom

Main content: Java project, graduation design, resume template, learning materials, interview question bank, technical mutual assistance

Favorites, likes, don't get lost, it's good to follow the author

Get the source code at the end of the article 

Item number: BS--XX-091

1. Environmental introduction

Locale: Java: jdk1.8

Database: Mysql: mysql5.7

Application server: Tomcat: tomcat8.5.31

Development tools: IDEA or eclipse

Development technology: spring+spring mvc+mybatis+bootstrap+jquery

2. Project introduction

This project implements the cash register management system for restaurants based on SSM, including four modules

1. Desk module

The table module is mainly used to manage the table, including the process from ordering to checkout.

Setting the number of people at the table to 0 can make the current table empty

2. Billing module

The bill module records the bill summary of each day, and provides the statistics of the year, month, and day bills. In the daily bills, you can view all the consumption details of the day, and also provides the function of searching bills by date or date range

3. Daily maintenance module

Provides the configuration function of the table menu user supplier, that is,
  when adding, deleting, modifying, checking and adding dishes, when adding drinks, you can choose the drinks in the purchase. In this way, if the customer orders the drink after checkout, the sales information will be recorded In the sales information in the wine inventory

4. Wine inventory module

View the purchase, sales and inventory information of added wine

Three, system display

The following shows the operating modules of the system:

user login

Data maintenance—dish maintenance

Table Maintenance

Account Maintenance

Account Maintenance

open table

a la carte

Bill, please

view bill

View Single Table Consumption

Fourth, the core code display

package controller;

import com.alibaba.fastjson.JSON;
import dao.user.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import pojo.Pager;
import pojo.Provider;
import pojo.User;
import service.user.UserService;
import tools.PagerTools;

import java.util.HashMap;
import java.util.Map;

@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;
    }






    @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+"\"}";
    }
}
package controller;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import pojo.*;
import service.drink.ProviderService;
import tools.BillCodeUtil;
import tools.PagerTools;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.sound.midi.Soundbank;
import java.util.List;

@Controller
public class DrinkController {
    @Autowired
    private ProviderService providerService;

    @RequestMapping("/drink.html")
    public String drink(HttpSession session) {
        if(session.getAttribute("user")==null){//权限控制
            return "redirect:login.html";
        }
        return "/drink/drink";
    }

    ;

    //加载供应下拉列表
    @RequestMapping("/loadProviderSelect.do")
    @ResponseBody
    public Object loadProviderSelect() {
        return JSON.toJSONString(providerService.getProvider());
    }

    ;

    //加载进货信息
    @RequestMapping("/loadDrinkBill.do")
    @ResponseBody
    public ModelAndView loadDrinkBill(ModelAndView modelAndView, DrinkBillPager pager) {
        int totalCount = providerService.getDrinkBillCount(pager);
        if (totalCount != 0) {
            pager.setTotalCount(totalCount);
        } else {
            pager.setTotalCount(1);
        }
        pager.setPageSize(PagerTools.drinkBillPagerSize);
        pager.count();
        pager.setList(providerService.getDrinkBill(pager));
        modelAndView.addObject("pager", pager);
        modelAndView.setViewName("/drink/ajaxJinhuoList");
        return modelAndView;
    }

    //加载进货信息
    @RequestMapping("/loadDrinkBillCode.do")
    @ResponseBody
    public Object loadDrinkBillCode(DrinkBillPager pager) {
        int totalCount = providerService.getDrinkBillCount(pager);
        if (totalCount != 0) {
            pager.setTotalCount(totalCount);
        } else {
            pager.setTotalCount(1);
        }
        pager.setPageSize(100);
        pager.count();
        List<Drinkbill> drinkBills=providerService.getDrinkBill(pager);
        return JSON.toJSONString(drinkBills);
    }

    //del删除进货信息
    @RequestMapping("/delDrinkBill.do")
    @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");
        return modelAndView;
    }

    //加载销售信息
    @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){
        return JSON.toJSONString(providerService.delProviderById(pager));
    }
    //更改供应商
    @RequestMapping("/updateProvider.do")
    @ResponseBody
    public Object updateProvider(Provider provider){
        return JSON.toJSONString(providerService.updateProvider(provider));
    }
}
package controller;

import com.alibaba.fastjson.JSON;
import org.apache.commons.io.FilenameUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import pojo.Dish;
import pojo.Pager;
import pojo.dish.Dishes;
import service.dish.DishService;
import tools.BillCodeUtil;
import tools.PagerTools;
import tools.RedisUtil;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Controller
public class DishController {
    @Autowired
    private DishService dishService;
    @Resource(name = "redisUtil")
    private RedisUtil redisUtil;

    @ResponseBody
    @RequestMapping(value = "/addDish.do", produces = "application/json;charset=utf-8")
    public Object addDish(Dish dish, @RequestParam(required = false) MultipartFile file,
                          HttpServletRequest request) {
        boolean addFlag = false;//添加标记
        String fifleFlag = null;//文件上传状态标记
        System.out.println("addDish~~~~~~~~~~~~~~~~~~~~~~~");
        System.out.println("~~~~~~~~~~~~~~~~~~~dishName:" + dish.getDishName());
        if (!file.isEmpty()) {
            String path = request.getSession().getServletContext().getRealPath("assets" + File.separator + "img");//获取/statics/upload的地址
            System.out.println("存储地址:" + path);
            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 (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";
                }

        }
        if (addFlag) {//添加成功时
            //刷新缓存
            redisUtil.del("allDishes");
            return JSON.toJSONString("OK");
        } else {
            return "{'fifleFlag':'" + fifleFlag + "'}";
        }
    }

    //ajax验证菜品名是否存在
    @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);
                    }
                }
                pager.setList(serchList);
            }
        } else {
            pager.setList(list);
        }
        modelAndView.addObject("pager", pager);
        return modelAndView;
    }

    //ajax删除菜品
    @ResponseBody
    @RequestMapping("/delDishFromMenu.do")
    public Object delDish(@RequestParam(required = false)String id){
        System.out.println("~~~~~~~~~~~~~~开始删除Dish~~~~~~~~~~~~~~~");
        boolean delFlag=false;
        System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~id="+id);
        if(id!=null && !"".equals(id)){
            System.out.println("~~~~~~~~~~~~~~~进入删除~~~~~~~~~~~~~~~~");
            delFlag=dishService.delDishById(id);
        }
        if(delFlag){//删除成功
            System.out.println("~~~~~~~~~~~~~~删除Dish成功~~~~~~~~~~~~~~~");
            redisUtil.del("allDishes");//刷新redis
            Dishes.getDishes().setAllDish(null);//刷新单例
            return JSON.toJSONString(0);//删除成功
        }
        return JSON.toJSONString(1);//删除失败
    }

}

V. Project Summary

   The function of the project is complete, the operation is correct, and it is suitable for graduation design 

Guess you like

Origin blog.csdn.net/whirlwind526/article/details/130217407