作者主页:源码空间站2022
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
管理员角色包含以下功能:
管理员登录,桌位信息查看,查看账单,日常维护,酒水库存管理等功能。
环境需要
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版本;
技术栈
1. 后端:Spring+SpringMVC+Mybatis
2. 前端:HTML+CSS+JavaScript+jsp
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
运行截图
相关代码
订单控制器
package com.shop.controller;
import java.util.Date;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest;
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 com.shop.Utils.PageBean;
import com.shop.po.Cart;
import com.shop.po.CartItem;
import com.shop.po.Orderitem;
import com.shop.po.Orders;
import com.shop.po.User;
import com.shop.service.OrderService;
@Controller
public class orderController {
@Autowired
private OrderService orderService;
@RequestMapping("/toOrder")
public String toOrder(HttpServletRequest request,Model model) throws Exception {
Orders orders = new Orders();
Cart cart = (Cart) request.getSession().getAttribute("cart");
User loginUser = (User) request.getSession().getAttribute("loginUser");
if(loginUser==null){
model.addAttribute("message", "对不起您还没有登录");
return "msg";
}
// 0表示没有付款、1表示已付款即将发货 2表示确认收货 3表示交易成功
orders.setState(0);
orders.setOrderTime(new Date());
orders.setUid(loginUser.getUid());
orders.setMoney(cart.getTotale());
orderService.toOrder(orders);
Map<Integer, CartItem> cartItems = cart.getCartItem();
for (Entry<Integer, CartItem> entry : cartItems.entrySet()) {
CartItem cartItem = entry.getValue();
Orderitem orderitem = new Orderitem();
orderitem.setProduct(cartItem.getProduct());
orderitem.setCount(cartItem.getCount());
orderitem.setPid(cartItem.getProduct().getPid());
orderitem.setSubtotal(cartItem.getSubtotle());
orderitem.setOid(orders.getOid());
orders.getOiList().add(orderitem);
orderService.toOrderItem(orderitem);
}
cart.clearCart();
request.getSession().setAttribute("orders", orders);
return "order";
}
// 为定单付款
@RequestMapping("/payOrder")
public String payOrder(Orders orders,@RequestParam String receiveInfo,@RequestParam String phoNum,@RequestParam String accepter) throws Exception {
orders.setReceiveinfo(receiveInfo);
orders.setPhonum(phoNum);
orders.setAccepter(accepter);
orderService.payOrder(orders);
return "redirect:myOrder.action?page=1";
}
//payOrderAganin
@RequestMapping("/payOrderAganin")
public String payOrderAganin(@RequestParam int oid,HttpServletRequest request){
Orders noPayOrder = orderService.findOrderByOid(oid);
request.getSession().setAttribute("orders", noPayOrder);
return "order";
}
// 查询myOrder
@RequestMapping("/myOrder")
public String myOrder(@RequestParam int page, Model model,
HttpServletRequest request) throws Exception {
User loginUser = (User) request.getSession().getAttribute("loginUser");
PageBean<Orders> pageBean = orderService.findOrderByUidAndPage(page,loginUser.getUid());
model.addAttribute("pageBean", pageBean);
return "orderList";
}
// 确认收货
@RequestMapping("/updateState")
public String updateState(@RequestParam int oid ) throws Exception {
orderService.updateOrderStatus(oid, 3);
return "redirect:myOrder.action?page=1";
}
}
如果也想学习本系统,下面领取。关注并回复:173ssm