package web;
import domain.*;
import service.Impl.OrderServiceImpl;
import service.Impl.ShopServiceImpl;
import service.OrderService;
import service.ShopService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@WebServlet("/order/*")
public class OrderServlet extends BaseServlet {
OrderService orderService = new OrderServiceImpl();
public void getOrderDetail(HttpServletRequest request, HttpServletResponse response) throws IOException {
String _oid = request.getParameter("oid");
int oid = Integer.parseInt(_oid);
System.out.println("已经接收到查看订单详细的请求");
List<OrderDetail> list = orderService.getOrderDetail(oid);
Map<String,Integer> map = new HashMap<>();
for(int i=0;i<list.size();i++){
//System.out.println(list.get(i));
if(map.get(list.get(i).getName())==null){
map.put(list.get(i).getName(),1);
}
else {
map.put(list.get(i).getName(), map.get(list.get(i).getName())+1);
}
}
ResultInfo info = new ResultInfo();
Object[] objects = {list,map};
info.setData(objects);
info.setFlag(true);
writeValue(response,info);
}
public void getNowOrders(HttpServletRequest request, HttpServletResponse response) throws IOException {
User user = (User) request.getSession().getAttribute("user");
List<Orders> list = orderService.getAll(user.getId());
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
ResultInfo info = new ResultInfo();
info.setData(list);
info.setFlag(true);
writeValue(response,info);
}
public void submitAll(HttpServletRequest request, HttpServletResponse response) throws IOException {
Cookie[] cookies = request.getCookies();
int addressid=1;
for (Cookie cookie:cookies
) {
if(cookie.getName().equals("addressid")){
addressid = Integer.parseInt(cookie.getValue());
System.out.println("上一次使用的地址的ID是: "+addressid);
}
}
User user = (User) request.getSession().getAttribute("user");
System.out.println("已经接收到一键提交的请求");
List<Orders> list = orderService.submitAll(user.getId(),addressid);
ResultInfo info = new ResultInfo();
info.setFlag(true);
writeValue(response,info);
}
public void getHisOrderInfo(HttpServletRequest request, HttpServletResponse response) throws IOException {
User user = (User) request.getSession().getAttribute("user");
System.out.println("已经接收到查看历史订单的请求");
List<Orders> list = orderService.getHisOrders(user.getId());
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
ResultInfo info = new ResultInfo();
info.setData(list);
info.setFlag(true);
writeValue(response,info);
}
public void submit(HttpServletRequest request, HttpServletResponse response) throws IOException {
String _addressid = request.getParameter("addressid");
int addressid = Integer.parseInt(_addressid);
request.getSession().setAttribute("addressid",addressid);
Cookie cookie_addressid = new Cookie("addressid",_addressid);
cookie_addressid.setPath(request.getContextPath());
cookie_addressid.setMaxAge(30*24*60*60);
response.addCookie(cookie_addressid);
String _sid = request.getParameter("sid");
int sid = Integer.parseInt(_sid);
User user = (User) request.getSession().getAttribute("user");
orderService.submit(user.getId(),sid,addressid);
System.out.println("已经接收到提交订单的请求");
ResultInfo info = new ResultInfo();
info.setFlag(true);
writeValue(response,info);
}
public void addmeal(HttpServletRequest request, HttpServletResponse response) throws IOException {
ResultInfo info = new ResultInfo();
String _id = request.getParameter("id");
Integer id = Integer.parseInt(_id);
System.out.println("已经接受到添加套餐的请求力");
User user =(User) request.getSession().getAttribute("user");
int uid=-1;
if (user==null){
info.setFlag(false);
writeValue(response,info);
}
else {
uid = user.getId();
orderService.addMeal(id,uid,user);
}
info.setFlag(true);
writeValue(response,info);
}
public void add(HttpServletRequest request, HttpServletResponse response) throws IOException {
ResultInfo info = new ResultInfo();
String _id = request.getParameter("id");
Integer id = Integer.parseInt(_id);
System.out.println("已经接受到添加菜品的请求力");
User user =(User) request.getSession().getAttribute("user");
int uid=-1;
if (user==null){
info.setFlag(false);
writeValue(response,info);
}
else {
uid = user.getId();
orderService.addDish(id,uid,user);
}
info.setFlag(true);
writeValue(response,info);
}
public void deletemeal(HttpServletRequest request, HttpServletResponse response) throws IOException {
ResultInfo info = new ResultInfo();
String _id = request.getParameter("id");
Integer id = Integer.parseInt(_id);
System.out.println("已经接受到移除套餐的请求力");
User user =(User) request.getSession().getAttribute("user");
int uid=-1;
if (user==null){
info.setFlag(false);
writeValue(response,info);
}
else {
uid = user.getId();
}
orderService.remMeal(id,uid);
info.setFlag(true);
writeValue(response,info);
}
public void delete(HttpServletRequest request, HttpServletResponse response) throws IOException {
ResultInfo info = new ResultInfo();
String _id = request.getParameter("id");
Integer id = Integer.parseInt(_id);
System.out.println("已经接受到移除菜品的请求力");
User user =(User) request.getSession().getAttribute("user");
int uid=-1;
if (user==null){
info.setFlag(false);
writeValue(response,info);
}
else {
uid = user.getId();
}
orderService.remDish(id,uid);
info.setFlag(true);
writeValue(response,info);
}
public void countmeal(HttpServletRequest request, HttpServletResponse response) throws IOException {
ResultInfo info = new ResultInfo();
String _id = request.getParameter("id");
int id = Integer.parseInt(_id);
User user =(User) request.getSession().getAttribute("user");
int uid=-1;
if (user==null){
info.setFlag(false);
writeValue(response, info);
}
else {
uid = user.getId();
}
int count = orderService.findMealCount(id,uid);
info.setFlag(true);
if(count==0){
info.setFlag(false);
}
info.setData(count);
writeValue(response, info);
}
public void count(HttpServletRequest request, HttpServletResponse response) throws IOException {
ResultInfo info = new ResultInfo();
String _id = request.getParameter("id");
int id = Integer.parseInt(_id);
User user =(User) request.getSession().getAttribute("user");
int uid=-1;
if (
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于Java的外卖软件设计源码,该项目包含570个文件,主要文件类型有184个png图像文件,以及78个javascript文件。此外,还包括62个svg图像文件,57个java源文件,以及47个html页面文件。该项目是一个基于Java的外卖软件设计源码,可能涉及用户界面设计、应用逻辑实现、数据存储等多个方面。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java的外卖软件设计源码,包含商家管理后台和用户点菜页面 (571个子文件)
axure-chrome-extension.crx 31KB
common.css 275KB
index.css 227KB
vant.min.css 141KB
bootstrap.min.css 118KB
jquery-ui-themes.css 28KB
bootstrap-theme.min.css 23KB
default.css 20KB
main.css 17KB
demo.css 8KB
sitemap.css 8KB
normalize.css 8KB
index.css 6KB
add-order.css 6KB
axure_rp_page.css 5KB
debug.css 4KB
common.css 4KB
user.css 4KB
menu.css 4KB
page_notes.css 4KB
page.css 4KB
search.css 4KB
address.css 3KB
address-edit.css 3KB
order.css 3KB
route-detail.css 3KB
index.css 2KB
register.css 2KB
ranking-list.css 2KB
login.css 2KB
login.css 2KB
index.css 2KB
pay-success.css 2KB
login.css 2KB
recordplay.css 2KB
styles.css 1KB
no-wify.css 1KB
shop_list.css 1KB
orders.css 1KB
iconfont.css 733B
previewfonts.css 596B
reset.css 479B
touch.cur 17KB
glyphicons-halflings-regular.eot 20KB
splitter.gif 1KB
newwindow.gif 112B
note.gif 98B
transparent.gif 43B
.gitignore 182B
index.html 23KB
add.html 18KB
header.html 17KB
list.html 17KB
demo_index.html 12KB
shop_detail.html 12KB
list.html 9KB
add-order.html 9KB
register.html 9KB
list.html 9KB
index.html 8KB
shop_list.html 8KB
list.html 8KB
user.html 7KB
address-edit.html 7KB
address.html 7KB
add.html 7KB
order.html 7KB
index.html 6KB
list.html 6KB
login.html 6KB
chrome.html 5KB
dish_detail.html 5KB
meal_detail.html 5KB
safari.html 4KB
login.html 4KB
login.html 4KB
login.html 4KB
elogin.html 4KB
pay-success.html 3KB
header.html 3KB
now.html 3KB
expand.html 2KB
history.html 2KB
no-wify.html 2KB
upload.html 2KB
orderdetail.html 2KB
elogin_ok.html 2KB
shop_cart.html 2KB
footer.html 1KB
footer.html 1KB
images.html 1KB
ewait.html 1KB
Other.html 835B
reload.html 511B
500.html 228B
404.html 222B
favico.ico 5KB
favicon_play.ico 5KB
favicon.ico 4KB
delivery-app.iml 4KB
共 571 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
沐知全栈开发
- 粉丝: 4814
- 资源: 4984
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功