手機網(wǎng)站開發(fā) 手機模擬器發(fā)帖推廣平臺
博主介紹: ?至今服務客戶已經1000+、專注于Java技術領域、項目定制、技術答疑、開發(fā)工具、畢業(yè)項目實戰(zhàn) ?
🍅 文末獲取源碼聯(lián)系 🍅
👇🏻 精彩專欄 推薦訂閱 👇🏻 不然下次找不到
Java項目精品實戰(zhàn)專區(qū)
https://blog.csdn.net/java18343246781/category_12537229.htmlJava各種開發(fā)工具資源包網(wǎng)站
http://62.234.13.119:9000/html/visitor/softwareResourceList.html
軟件安裝+項目部署專區(qū)
https://blog.csdn.net/java18343246781/category_12539864.htmlv
系列文章目錄
前言
一、運行環(huán)境
二、代碼示例
三、系統(tǒng)展示
前言
? 在快節(jié)奏的現(xiàn)代生活中,網(wǎng)上點餐系統(tǒng)成為了滿足用戶便捷用餐需求的重要工具。本文將為您介紹一款多功能而智能的網(wǎng)上點餐系統(tǒng),為用戶提供了全方位的用餐體驗。該系統(tǒng)的前端設計涵蓋了各類便捷功能,使得用戶可以輕松瀏覽菜單、分類點菜、加入購物車、下單,同時享受查看訂單、管理錢包、地址、留言等一系列便捷服務。同時,后端管理功能豐富,包括對菜單、用戶、留言、訂單、餐桌等的全面管理,為商家提供了高效的運營工具。
? 用戶可以通過系統(tǒng)直觀而美觀的界面,輕松瀏覽豐富的菜單,根據(jù)個人口味和需求分類點菜,并隨時加入購物車,構建個性化的點餐體驗。一鍵下單后,用戶可以方便地查看自己的訂單,進行支付,同時管理自己的錢包、地址等信息。系統(tǒng)還提供了投訴信息和留言功能,用戶可以通過系統(tǒng)表達建議、意見和需求,促進用戶與商家的有效溝通。
? 對于商家而言,后端管理系統(tǒng)為其提供了高效的工具,可以對菜單進行靈活管理,維護用戶信息,處理留言和投訴,以及有效管理訂單和餐桌。這使得商家能夠更好地把握經營狀況,提高服務水平。
? 希望這款網(wǎng)上點餐系統(tǒng)能夠為用戶和商家之間搭建起一座便捷而愉悅的溝通橋梁,為現(xiàn)代餐飲行業(yè)注入更多智能化、便捷化的元素。
一、運行環(huán)境
系統(tǒng)采用了JDK 1.8作為基礎開發(fā)環(huán)境,并搭建在Spring Boot框架之上,實現(xiàn)了快速、簡便的Java應用程序開發(fā)。數(shù)據(jù)庫方面選擇了MySQL,作為可靠的關系型數(shù)據(jù)庫管理系統(tǒng),用于存儲和管理商品、用戶以及訂單等相關數(shù)據(jù)。持久層框架方面使用了MyBatis和MyBatis Plus,簡化了數(shù)據(jù)訪問層的開發(fā),提供了便捷的操作和功能。
? ? ? ? 在前端設計上,系統(tǒng)使用了Layui框架,為用戶提供了直觀而美觀的界面,包括商城列表、購物車、訂單列表等功能。同時,為了實現(xiàn)動態(tài)頁面生成,系統(tǒng)引入了Thymeleaf技術,與Spring框架良好集成,使得前端頁面與后端數(shù)據(jù)更加緊密地結合,提升了用戶體驗。
二、代碼示例
代碼如下(示例):
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;/*** 表現(xiàn)層控制類*/
@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);//訂單生成后刪除購物車中數(shù)據(jù)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);//訂單生成后刪除購物車中數(shù)據(jù)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 "密碼錯誤";}//根據(jù)訂單編號,更新訂單信息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()));}}
三、系統(tǒng)展示
系統(tǒng)首頁:可以通過餐品類別進行篩選。同時可以看到留言板,也可以進行留言。
基本信息:可更改自己的基本信息。
購物車信息:可以查看購物車的菜品,可以進行刪除、下單。
菜品下單:可以備注預約餐桌與時間。支持進店用餐和外賣配送。
訂單信息:查看訂單詳情,支持添加商品、修改信息、取消訂單。
地址管理:如需外賣配送需要填寫配送地址。
我的錢包:可以進行重置與更改密碼。
投訴信息:可以對商家進行投訴。
后臺管理員登錄頁面。
用戶管理:可以重置用戶密碼。
錢包管理:查看用戶錢包剩余金額。
菜品管理:可以新增、刪除、修改。
餐桌管理:支持用戶進店就餐。
訂單管理:分為四種訂單未處理、處理中、已完成、已取消訂單。
留言管理:可以選擇優(yōu)質留言在首頁進行展示。
投訴管理:商家可看到投訴信息并進行處理。