ssm+vue餐厅点菜管理系统源码和论文

ssm+vue餐厅点菜管理系统源码和论文141

 开发工具:idea 或eclipse
 数据库mysql5.7+
 数据库链接工具:navcat,小海豚等
  技术:ssm

摘  要

网络技术和计算机技术发展至今,已经拥有了深厚的理论基础,并在现实中进行了充分运用,尤其是基于计算机运行的软件更是受到各界的关注。加上现在人们已经步入信息时代,所以对于信息的宣传和管理就很关键。因此餐厅点菜信息的管理计算机化,系统化是必要的。设计开发餐厅点菜管理系统不仅会节约人力和管理成本,还会安全保存庞大的数据量,对于餐厅点菜信息的维护和检索也不需要花费很多时间,非常的便利。

餐厅点菜管理系统是在MySQL中建立数据表保存信息,运用Vue框架和Java语言编写。并按照软件设计开发流程进行设计实现。系统具备友好性且功能完善。其管理员管理食物库存,菜品信息,管理预订和未预定餐桌,管理店内订单流水以及外卖订单。用户查看餐厅资讯,收藏菜品,下单购买菜品,查看外卖订单,用户也可以在餐厅内预订餐桌,对菜品进行点餐,查看店内订单记录。

餐厅点菜管理系统在让餐厅点菜信息规范化的同时,也能及时通过数据输入的有效性规则检测出错误数据,让数据的录入达到准确性的目的,进而提升餐厅点菜管理系统提供的数据的可靠性,让系统数据的错误率降至最低。

关键词:餐厅点菜管理系统;MySQL;Vue框架


Abstract

Network technology and computer technology have developed so far, they already have a solid theoretical foundation, and they have been fully used in reality, especially the software based on computer operation has attracted the attention of all walks of life. In addition, now that people have entered the information age, the promotion and management of information is very important. Therefore, it is necessary to computerize and systemize the management of restaurant ordering information. Designing and developing a restaurant ordering management system will not only save manpower and management costs, but also securely store a huge amount of data. It does not take a lot of time to maintain and retrieve restaurant ordering information, which is very convenient.

The restaurant ordering management system is to establish a data table in MySQL to save the information, using Vue framework and Java language to write. And in accordance with the software design and development process for design and implementation. The system is friendly and fully functional. Its administrator manages food inventory, dish information, manages reserved and unreserved tables, manages in-store order flow and takeaway orders. Users view restaurant information, collect dishes, place orders to purchase dishes, and view takeaway orders. Users can also reserve a table in the restaurant, order dishes, and view in-store order records.

While standardizing restaurant ordering information, the restaurant ordering management system can also detect incorrect data in a timely manner through the validity rules of data input, so that data entry can achieve the purpose of accuracy, thereby improving the data provided by the restaurant ordering management system The reliability of the system minimizes the error rate of system data.

Key WordsRestaurant order management system; MySQL; Vue framework

package com.controller;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;

import com.entity.*;
import com.entity.view.CaipinView;
import com.service.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;

import com.utils.PageUtils;
import com.utils.R;

/**
 * 菜品表
 * 后端接口
 * @author
 * @email
 * @date 2021-03-08
*/
@RestController
@Controller
@RequestMapping("/caipin")
public class CaipinController {
    private static final Logger logger = LoggerFactory.getLogger(CaipinController.class);

    @Autowired
    private CaipinService caipinService;

    @Autowired
    private KuchuenService kuchuenService;

    @Autowired
    private LiushuiService liushuiService;


    @Autowired
    private YudingcanzhuoService yudingcanzhuoService;

    @Autowired
    private DingdanxiangqingService dingdanxiangqingService;

    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params){
        logger.debug("Controller:"+this.getClass().getName()+",page方法");
        PageUtils page = caipinService.queryPage(params);
        return R.ok().put("data", page);
    }
    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
        logger.debug("Controller:"+this.getClass().getName()+",info方法");
        CaipinEntity caipin = caipinService.selectById(id);
        if(caipin!=null){
            CaipinView caipinView = new CaipinView();
            BeanUtils.copyProperties(caipin, caipinView);
            KuchuenEntity kuchuenEntity = kuchuenService.selectById(caipin.getHxTypes());
            BeanUtils.copyProperties(kuchuenEntity, caipinView ,new String[]{ "id", "createDate"});
            return R.ok().put("data", caipinView);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody CaipinEntity caipin, HttpServletRequest request){
        logger.debug("Controller:"+this.getClass().getName()+",save");
        Wrapper<CaipinEntity> queryWrapper = new EntityWrapper<CaipinEntity>()
            .eq("hx_types", caipin.getHxTypes())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CaipinEntity caipinEntity = caipinService.selectOne(queryWrapper);
        if("".equals(caipin.getImgPhoto()) || "null".equals(caipin.getImgPhoto())){
            caipin.setImgPhoto(null);
        }
        if(caipinEntity==null){
            caipinService.insert(caipin);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody CaipinEntity caipin, HttpServletRequest request){
        logger.debug("Controller:"+this.getClass().getName()+",update");
        //根据字段查询是否有相同数据
        Wrapper<CaipinEntity> queryWrapper = new EntityWrapper<CaipinEntity>()
            .notIn("id",caipin.getId())
            .eq("hx_types", caipin.getHxTypes())
            .eq("money", caipin.getMoney())
            .eq("caipin_content", caipin.getCaipinContent())
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        CaipinEntity caipinEntity = caipinService.selectOne(queryWrapper);
        if("".equals(caipin.getImgPhoto()) || "null".equals(caipin.getImgPhoto())){
                caipin.setImgPhoto(null);
        }
        if(caipinEntity==null){
            caipinService.updateById(caipin);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }


    /**
    * 删除
    */
    @RequestMapping("/diancai")
    public R diancai(@RequestParam Map<String, Object> params, HttpServletRequest request){
        if(params.size() == 0){
            return R.error("请选择要购买的菜品");
        }
        //获取系统当前时间的时间戳作为订单号
        long danhao = new Date().getTime();
        //new 一个订单详情表
        DingdanxiangqingEntity dingdanxiangqing = new DingdanxiangqingEntity();
        //new 一个流水表
        LiushuiEntity liushui = new LiushuiEntity();
        //循环前端传过来的key
            for (String id: params.keySet()) {
                //根据前端传来的key(id)查询数据
                CaipinEntity caipin = caipinService.selectOne(new EntityWrapper<CaipinEntity>().eq("hx_types",id));
                //判断查出来的数据是否为空
                if(caipin == null){
                    //为空返回前台
                    return R.error();
                }
                //判断前端传来的菜品数量是否为空或者小于0
                if(StringUtils.isBlank((String)params.get(id)) || Integer.parseInt(String.valueOf(params.get(id))) <= 0){
                    return R.error("您选择的菜品数量不能小于0哦");
                }

                //根据前台传来的key(id)去库存表中查询数据
                KuchuenEntity kuchuenEntity = kuchuenService.selectById(id);
                //如果为空返回前台
                if(kuchuenEntity == null){
                    return R.error("这件菜品菜品不存在于库存");
                }
                //把map中的值转为Integger
                Integer zhi = Integer.parseInt(String.valueOf(kuchuenEntity.getId()));
                //根据当前登录人的id去已预约的餐桌信息表中查询数据
                YudingcanzhuoEntity yudingcanzhuo = yudingcanzhuoService.selectOne(new EntityWrapper().eq("yh_types", request.getSession().getAttribute("userId")));
                //如果为空就返回前端
                if(yudingcanzhuo == null){
                    return R.error("请先预定餐桌后再预定菜品,以免餐桌不足");
                }
                //如果为空就返回前端
                if(yudingcanzhuo.getCzTypes() == null){
                    return R.error("请先预定餐桌后再预定菜品,以免餐桌不足");
                }

                //判断库存中的菜品数量是否大于用户购买的数量
                if(kuchuenEntity.getNumber() < Integer.parseInt(String.valueOf(params.get(String.valueOf(zhi))))){
                    //库存小于是返回并提示
                    return R.error(kuchuenEntity.getName()+" 库存只剩:"+kuchuenEntity.getNumber()+" 个,不足:"+ params.get(id)+" 个!!!");
                }

                //订单详情中添加进用户购买数量
                dingdanxiangqing.setNumber(zhi);
                //在订单详情表中存入生成的订单号
                dingdanxiangqing.setOdd(String.valueOf(danhao));
                //在订单详情表中存入菜品信息
                dingdanxiangqing.setHxTypes(caipin.getHxTypes());
                //订单详情表中存入菜品价格
                dingdanxiangqing.setMoney(caipin.getMoney());
                //新增订单详情信息
                dingdanxiangqingService.insert(dingdanxiangqing);


                //给流水表中的总价赋值为0
                liushui.setMaxMoney(0.0);
                //获取系统当前时间
                liushui.setCreateTime(new Date());
                //设置上面生成的订单号
                liushui.setOdd(String.valueOf(danhao));
                //在流水表存入中查出来的餐桌信息
                liushui.setCzTypes(yudingcanzhuo.getCzTypes());
                //在流水表存入当前登录用户的信息
                liushui.setYhTypes((Integer) request.getSession().getAttribute("userId"));
                //设置为未支付
                liushui.setSfTypes(2);
                //计算总价
                liushui.setMaxMoney(liushui.getMaxMoney()+(dingdanxiangqing.getMoney()*dingdanxiangqing.getNumber()));

                //库存数量减去用户购买数量
                int i = kuchuenEntity.getNumber() - zhi;
                //将库存数量更新
                kuchuenEntity.setNumber(i);
                //修改库存数量
                kuchuenService.updateById(kuchuenEntity);
            }
        //新增流水信息
        liushuiService.insert(liushui);
        return R.ok();
    }

    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
        logger.debug("Controller:"+this.getClass().getName()+",delete");
        caipinService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

程序猿毕业分享网

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

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

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

打赏作者

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

抵扣说明:

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

余额充值