基于Java网上点餐系统设计与实现

news/2024/7/2 7:43:08

博主介绍: ✌至今服务客户已经1000+、专注于Java技术领域、项目定制、技术答疑、开发工具、毕业项目实战 ✌
🍅 文末获取源码联系 🍅
👇🏻 精彩专栏 推荐订阅 👇🏻 不然下次找不到

Java项目精品实战专区icon-default.png?t=N7T8https://blog.csdn.net/java18343246781/category_12537229.htmlJava各种开发工具资源包网站icon-default.png?t=N7T8http://62.234.13.119:9000/html/visitor/softwareResourceList.html

软件安装+项目部署专区icon-default.png?t=N7T8https://blog.csdn.net/java18343246781/category_12539864.htmlv


系列文章目录

前言

一、运行环境

二、代码示例

三、系统展示


前言

  在快节奏的现代生活中,网上点餐系统成为了满足用户便捷用餐需求的重要工具。本文将为您介绍一款多功能而智能的网上点餐系统,为用户提供了全方位的用餐体验。该系统的前端设计涵盖了各类便捷功能,使得用户可以轻松浏览菜单、分类点菜、加入购物车、下单,同时享受查看订单、管理钱包、地址、留言等一系列便捷服务。同时,后端管理功能丰富,包括对菜单、用户、留言、订单、餐桌等的全面管理,为商家提供了高效的运营工具。

  用户可以通过系统直观而美观的界面,轻松浏览丰富的菜单,根据个人口味和需求分类点菜,并随时加入购物车,构建个性化的点餐体验。一键下单后,用户可以方便地查看自己的订单,进行支付,同时管理自己的钱包、地址等信息。系统还提供了投诉信息和留言功能,用户可以通过系统表达建议、意见和需求,促进用户与商家的有效沟通。

  对于商家而言,后端管理系统为其提供了高效的工具,可以对菜单进行灵活管理,维护用户信息,处理留言和投诉,以及有效管理订单和餐桌。这使得商家能够更好地把握经营状况,提高服务水平。

  希望这款网上点餐系统能够为用户和商家之间搭建起一座便捷而愉悦的沟通桥梁,为现代餐饮行业注入更多智能化、便捷化的元素。

一、运行环境

系统采用了JDK 1.8作为基础开发环境,并搭建在Spring Boot框架之上,实现了快速、简便的Java应用程序开发。数据库方面选择了MySQL,作为可靠的关系型数据库管理系统,用于存储和管理商品、用户以及订单等相关数据。持久层框架方面使用了MyBatis和MyBatis Plus,简化了数据访问层的开发,提供了便捷的操作和功能。

        在前端设计上,系统使用了Layui框架,为用户提供了直观而美观的界面,包括商城列表、购物车、订单列表等功能。同时,为了实现动态页面生成,系统引入了Thymeleaf技术,与Spring框架良好集成,使得前端页面与后端数据更加紧密地结合,提升了用户体验。

二、代码示例

代码如下(示例):

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wl.dto.OrdersDto;
import com.wl.enums.OrdersStateEnum;
import com.wl.enums.OrdersTypeEnum;
import com.wl.enums.TableStateEnum;
import com.wl.mapper.OrdersEntryMapper;
import com.wl.po.*;
import com.wl.service.*;
import org.apache.tomcat.util.buf.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;/*** 表现层控制类*/
@Controller
@RequestMapping("cart")
@Slf4j
public class ShoppingCartController {@Autowiredprivate ShoppingCartService shoppingCartService;@Autowiredprivate AddressService addressService;@Autowiredprivate WalletService walletService;@Autowiredprivate UserService userService;@Autowiredprivate DeskService deskService;@Autowiredprivate MenuService menuService;@Autowiredprivate OrdersService ordersService;@Autowiredprivate OrdersEntryService entryService;//加入购物车@ResponseBody@RequestMapping(value = "/addToCart", method = RequestMethod.GET)public String addToCart(String menuId, HttpSession session) {User user = comment(session);ShoppingCart cart = new ShoppingCart();cart.setUserId(Integer.parseInt(user.getId()));cart.setMenuId(Integer.parseInt(menuId));Integer count = shoppingCartService.selectCountByCart(cart);if (count == null || count == 0) {cart.setCount(1);shoppingCartService.addCart(cart);} else {cart.setCount(count + 1);shoppingCartService.updateCartCount(cart);}return "商品成功加入购物车";}//加入购物车@RequestMapping("addCart/{menuId}")public String addCart(@PathVariable("menuId") String menuId, HttpSession session) {User user = comment(session);ShoppingCart cart = new ShoppingCart();cart.setUserId(Integer.parseInt(user.getId()));cart.setMenuId(Integer.parseInt(menuId));Integer count = shoppingCartService.selectCountByCart(cart);if (count == null || count == 0) {cart.setCount(1);shoppingCartService.addCart(cart);} else {cart.setCount(count + 1);shoppingCartService.updateCartCount(cart);}return "redirect:/user/cart";}//批量删除购物车商品@RequestMapping("delAllCart")@ResponseBodypublic String delAllCart(String menuIds, HttpSession session) {String[] strings = null;String string = null;if (menuIds.contains("&")) {strings = menuIds.split("&");} else {string = menuIds;}User user = comment(session);if (string == null) {for (int i = 0; i < strings.length; i++) {ShoppingCart cart = new ShoppingCart();cart.setUserId(Integer.parseInt(user.getId()));cart.setMenuId(Integer.parseInt(strings[i]));shoppingCartService.delCart(cart);}} else {ShoppingCart cart = new ShoppingCart();cart.setUserId(Integer.parseInt(user.getId()));cart.setMenuId(Integer.parseInt(string));shoppingCartService.delCart(cart);}return "删除成功";}//购物车商品减一@RequestMapping("redCart/{menuId}")public String redCart(@PathVariable("menuId") String menuId, HttpSession session) {User user = comment(session);ShoppingCart cart = new ShoppingCart();cart.setUserId(Integer.parseInt(user.getId()));cart.setMenuId(Integer.parseInt(menuId));Integer count = shoppingCartService.selectCountByCart(cart);if (count > 1) {cart.setCount(count - 1);shoppingCartService.updateCartCount(cart);} else {shoppingCartService.delCart(cart);}return "redirect:/user/cart";}//单个商品下单详情页面@RequestMapping("choiceOrders")@ResponseBodypublic String choiceOrders(String menuIds, HttpSession session, Model model) {User user = comment(session);String[] strings = menuIds.split("&");//判断用户是否填写地址信息Address address = addressService.selectByUserId(user.getId());if (address.getAddress() == null || address.getName() == null || address.getPhoneNumber() == null) {return "地址信息未填写";}BigDecimal menuAllPrice = BigDecimal.ZERO;BigDecimal menuPrice;List<OrdersEntry> entryList = new ArrayList<>();for (int i = 0; i < strings.length; i++) {//购物车信息ShoppingCart cart = new ShoppingCart();cart.setUserId(Integer.parseInt(user.getId()));cart.setMenuId(Integer.parseInt(strings[i]));cart = shoppingCartService.selectCart(cart);//订单条目类Menu menu = menuService.selectByMenuId(Integer.parseInt(strings[i]));OrdersEntry entry = new OrdersEntry();entry.setCount(cart.getCount());entry.setDishName(menu.getDishName());entry.setPrice(menu.getPrice());menuPrice = menu.getPrice().multiply(new BigDecimal(cart.getCount()));entryList.add(entry);//累加计算订单总金额menuAllPrice = menuAllPrice.add(menuPrice);}//订单DTOOrdersDto ordersDto = new OrdersDto();ordersDto.setOrdersEntryList(entryList);ordersDto.setUserId(Integer.parseInt(user.getId()));ordersDto.setUserName(address.getName());ordersDto.setTotalPrice(menuAllPrice);ordersDto.setPhoneNumber(address.getPhoneNumber());ordersDto.setOrdersAddress(address.getAddress());ordersDto.setRemark(address.getRemark());ordersDto.setOrdersState(OrdersStateEnum.ORDERS_STATE_UNPROCESSED.getText());ordersDto.setOrdersType(OrdersTypeEnum.ORDERS_TYPE_ENTER.getText());model.addAttribute("ordersDto", ordersDto);session.setAttribute("choicePageSession", ordersDto);session.setAttribute("menuIdsSession", menuIds);return "true";}//单个下单,批量下单@ResponseBody@Transactional@RequestMapping("toOrdersOne")public String toOrdersOne(OrdersDto choiceDto, HttpSession session) {//判断的地址信息是否填写User user = comment(session);Address address = addressService.selectByUserId(user.getId());if (address.getAddress() == null || address.getName() == null || address.getPhoneNumber() == null) {return "地址信息未填写";}//下单前获取支付密码并判断输入密码是否正确Account account = (Account) session.getAttribute("account");Wallet wallet = walletService.selectWalletByAccountId(account.getId());OrdersDto dtoSession = (OrdersDto) session.getAttribute("choicePageSession");//余额判断if (dtoSession.getTotalPrice().compareTo(wallet.getMoney()) > 0) {return "余额不足";}if (!wallet.getPayPassword().equals(choiceDto.getPayPwd())) {return "密码错误";}//订单编号生成Date date = new Date();SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");String ordersNumber = format.format(date).concat(dtoSession.getUserId().toString());String menuIdsSession = (String) session.getAttribute("menuIdsSession");String[] strings = null;String string = null;if (menuIdsSession.contains("&")) {strings = menuIdsSession.split("&");} else {string = menuIdsSession;}//批量下单if (null == string) {for (String s : strings) {//购物车ShoppingCart cart = new ShoppingCart();cart.setUserId(dtoSession.getUserId());cart.setMenuId(Integer.parseInt(s));cart = shoppingCartService.selectCart(cart);//订单条目类Menu menu = menuService.selectByMenuId(Integer.parseInt(s));OrdersEntry entry = new OrdersEntry();entry.setCount(cart.getCount());entry.setDishName(menu.getDishName());entry.setOrdersNumber(ordersNumber);entry.setPrice(menu.getPrice());entryService.addEntry(entry);//订单生成后删除购物车中数据ShoppingCart cart1 = new ShoppingCart();cart1.setUserId(dtoSession.getUserId());cart1.setMenuId(Integer.parseInt(s));shoppingCartService.delCart(cart1);//商品销量加countmenu.setSale(menu.getSale() + cart.getCount());boolean b = menuService.updateDish(menu);}}//单个下单else {//购物车ShoppingCart cart = new ShoppingCart();cart.setUserId(dtoSession.getUserId());cart.setMenuId(Integer.parseInt(string));cart = shoppingCartService.selectCart(cart);//订单条目类Menu menu = menuService.selectByMenuId(Integer.parseInt(string));OrdersEntry entry = new OrdersEntry();entry.setCount(cart.getCount());entry.setDishName(menu.getDishName());entry.setOrdersNumber(ordersNumber);entry.setPrice(menu.getPrice());entryService.addEntry(entry);//订单生成后删除购物车中数据ShoppingCart cart1 = new ShoppingCart();cart1.setUserId(dtoSession.getUserId());cart1.setMenuId(Integer.parseInt(string));shoppingCartService.delCart(cart1);//商品销量加countmenu.setSale(menu.getSale() + cart.getCount());boolean b = menuService.updateDish(menu);}//订单Orders orders = new Orders();orders.setOrdersType(dtoSession.getOrdersType());//进店用餐 餐桌信息绑定if (dtoSession.getOrdersType().equals(OrdersTypeEnum.ORDERS_TYPE_ENTER.getText())) {orders.setOrdersTable(choiceDto.getOrdersTable());orders.setOrdersAddress(null);String reserveDate = choiceDto.getReserveDate();String ordersStartTime = choiceDto.getOrdersStartTime();String ordersEndTime = choiceDto.getOrdersEndTime();orders.setReserveDate(choiceDto.getReserveDate());orders.setOrdersStartTime(choiceDto.getOrdersStartTime());orders.setOrdersEndTime(choiceDto.getOrdersEndTime());deskService.updDesk(ordersNumber,choiceDto.getOrdersTable(), dtoSession.getUserId(), TableStateEnum.STATE_TRUE.getValue(), reserveDate,ordersStartTime,ordersEndTime);} else {//外卖配送 地址信息orders.setOrdersAddress(choiceDto.getOrdersAddress());orders.setOrdersTable(null);}orders.setPhoneNumber(choiceDto.getPhoneNumber());orders.setRemark(choiceDto.getRemark());orders.setUserId(dtoSession.getUserId());orders.setOrdersState(dtoSession.getOrdersState());orders.setOrdersType(dtoSession.getOrdersType());orders.setOrdersNumber(ordersNumber);orders.setUserName(dtoSession.getUserName());orders.setTotalPrice(dtoSession.getTotalPrice());ordersService.addOrders(orders);//钱包减BigDecimal subtract = wallet.getMoney().subtract(dtoSession.getTotalPrice());wallet.setMoney(subtract);walletService.updateWallet(wallet);return "下单成功";}//更新订单信息@ResponseBody@Transactional@RequestMapping("toUpdateOrders")public String toUpdateOrders(OrdersDto choiceDto, HttpSession session) {//下单前获取支付密码并判断输入密码是否正确Account account = (Account) session.getAttribute("account");//获取订单类型OrdersDto ordersDtoGetType = (OrdersDto)session.getAttribute("choicePageSession");//获取修改的订单编号String ordersNumberUpd = (String) session.getAttribute("ordersNumberUpd");Wallet wallet = walletService.selectWalletByAccountId(account.getId());if (!wallet.getPayPassword().equals(choiceDto.getPayPwd())) {return "密码错误";}//根据订单编号,更新订单信息Orders orders = new Orders();orders.setOrdersNumber(ordersNumberUpd);orders.setOrdersType(ordersDtoGetType.getOrdersType());//获取用户idUser user = userService.selectByAccountId(Integer.parseInt(account.getId()));//进店用餐if (orders.getOrdersType().equals(OrdersTypeEnum.ORDERS_TYPE_ENTER.getText())){orders.setOrdersAddress(null);orders.setOrdersTable(choiceDto.getOrdersTable());String reserveDate = choiceDto.getReserveDate();String ordersStartTime =choiceDto.getOrdersStartTime();String ordersEndTime = choiceDto.getOrdersEndTime();orders.setReserveDate(choiceDto.getReserveDate());orders.setOrdersStartTime(choiceDto.getOrdersStartTime());orders.setOrdersEndTime(choiceDto.getOrdersEndTime());deskService.updDesk(ordersNumberUpd,choiceDto.getOrdersTable(), Integer.parseInt(user.getId()), TableStateEnum.STATE_TRUE.getValue(), reserveDate,ordersStartTime,ordersEndTime);}//外卖配送else{orders.setOrdersAddress(choiceDto.getOrdersAddress());orders.setOrdersTable(null);}orders.setPhoneNumber(choiceDto.getPhoneNumber());orders.setRemark(choiceDto.getRemark());return ordersService.updateOrdersByNumber(orders);}//下单  订单类型@RequestMapping("ordersType/{type}")public String ordersType(@PathVariable("type") Integer type, HttpSession session,Model model) {String ordersType = "进店用餐";if (type == 1) {ordersType = "外卖配送";}OrdersDto choicePageSession = (OrdersDto) session.getAttribute("choicePageSession");choicePageSession.setOrdersType(ordersType);session.removeAttribute("choicePageSession");session.setAttribute("choicePageSession", choicePageSession);model.addAttribute("ordersDto", choicePageSession);return "user/choicePage";}//订单修改  订单类型@RequestMapping("ordersUpdType/{type}")public String ordersUpdType(@PathVariable("type") Integer type, HttpSession session,Model model) {String ordersType = "进店用餐";if (type == 1) {ordersType = "外卖配送";}OrdersDto choicePageSession = (OrdersDto) session.getAttribute("choicePageSession");choicePageSession.setOrdersType(ordersType);session.removeAttribute("choicePageSession");session.setAttribute("choicePageSession", choicePageSession);model.addAttribute("ordersDto", choicePageSession);return "user/editOrdersPage";}@RequestMapping("zhuan")public String zhuan(HttpSession session, Model model) {OrdersDto choicePageSession = (OrdersDto) session.getAttribute("choicePageSession");model.addAttribute("ordersDto", choicePageSession);return "user/choicePage";}//公共方法private User comment(HttpSession session) {Account account = (Account) session.getAttribute("account");return userService.selectByAccountId(Integer.parseInt(account.getId()));}}

三、系统展示

系统首页:可以通过餐品类别进行筛选。同时可以看到留言板,也可以进行留言。

基本信息:可更改自己的基本信息。

购物车信息:可以查看购物车的菜品,可以进行删除、下单。

菜品下单:可以备注预约餐桌与时间。支持进店用餐和外卖配送。

订单信息:查看订单详情,支持添加商品、修改信息、取消订单。

地址管理:如需外卖配送需要填写配送地址。

我的钱包:可以进行重置与更改密码。

投诉信息:可以对商家进行投诉。

后台管理员登录页面。

用户管理:可以重置用户密码。

钱包管理:查看用户钱包剩余金额。

菜品管理:可以新增、删除、修改。

餐桌管理:支持用户进店就餐。

订单管理:分为四种订单未处理、处理中、已完成、已取消订单。

留言管理:可以选择优质留言在首页进行展示。

投诉管理:商家可看到投诉信息并进行处理。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.cpky.cn/p/6165.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

几种读nii图像方法的轴序比较

读 .nii / .nii.gz 图像并转成 numpy 可用 medpy.io、nibabel、itk、SimpleITK 几种方法&#xff0c;然而几种方法读出来的轴序有出入&#xff0c;本篇比较此几种方法。 Datum 所用数据来自 verse&#xff0c;经 iTomxy/data/verse/preprocess.py 预处理&#xff0c;朝向和轴…

K8s实战入门

1.NameSpace Namespace是kubernetes系统中的一种非常重要资源&#xff0c;它的主要作用是用来实现多套环境的资源隔离或者多租户的资源隔离。 默认情况下&#xff0c;kubernetes集群中的所有的Pod都是可以相互访问的。但是在实际中&#xff0c;可能不想让两个Pod之间进行互相…

【Java集合类篇】HashMap的数据结构是怎样的?

HashMap的数据结构是怎样的? ✔️HashMap的数据结构✔️ 数组✔️ 链表 ✔️HashMap的数据结构 在Java中&#xff0c;保存数据有两种比较简单的数据结构: 数组和链表&#xff08;或红黑树&#xff09;。 HashMap是 Java 中常用的数据结构&#xff0c;它实现了 Map 接口。Has…

案例224:基于微信小程序的餐厅点餐系统

文末获取源码 开发语言&#xff1a;Java 框架&#xff1a;SSM JDK版本&#xff1a;JDK1.8 数据库&#xff1a;mysql 5.7 开发软件&#xff1a;eclipse/myeclipse/idea Maven包&#xff1a;Maven3.5.4 小程序框架&#xff1a;uniapp 小程序开发软件&#xff1a;HBuilder X 小程序…

获取网页信息

每次copy & paste总是很麻烦&#xff0c;现在有点问题&#xff0c;先记录下来。 需求&#xff1a;获取url 里Feature list&#xff0c;并输出表格形式 可以用Convert curl commands to code&#xff1a;得到get请求的header&#xff0c;cookie等 import requests import…

python股票分析挖掘预测金融大数据获取方法和实现(1)

本人股市多年的老韭菜了&#xff0c;各种股票分析书籍&#xff0c;技术指标书籍阅历无数&#xff0c;萌发想法&#xff0c;何不自己开发个股票预测分析软件&#xff0c;选择python因为够强大&#xff0c;它提供了很多高效便捷的数据分析工具包&#xff0c; 我们已经初步的接触…