package com.xq.tmall.controller.fore;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xq.tmall.controller.BaseController;
import com.xq.tmall.entity.*;
import com.xq.tmall.service.*;
import com.xq.tmall.util.OrderUtil;
import com.xq.tmall.util.PageUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 订单列表页
* @author 贤趣项目小组
*/
@Controller
public class ForeOrderController extends BaseController {
@Resource(name = "productService")
private ProductService productService;
@Resource(name = "userService")
private UserService userService;
@Resource(name = "productOrderItemService")
private ProductOrderItemService productOrderItemService;
@Resource(name = "addressService")
private AddressService addressService;
@Resource(name = "categoryService")
private CategoryService categoryService;
@Resource(name = "productImageService")
private ProductImageService productImageService;
@Resource(name = "productOrderService")
private ProductOrderService productOrderService;
@Resource(name = "reviewService")
private ReviewService reviewService;
@Resource(name = "lastIDService")
private LastIDService lastIDService;
//转到前台天猫-订单列表页
@RequestMapping(value = "order", method = RequestMethod.GET)
public String goToPageSimple() {
return "redirect:/order/0/10";
}
@RequestMapping(value = "order/{index}/{count}", method = RequestMethod.GET)
public String goToPage(HttpSession session, Map<String, Object> map,
@RequestParam(required = false) Byte status,
@PathVariable("index") Integer index/* 页数 */,
@PathVariable("count") Integer count/* 行数*/) {
logger.info("检查用户是否登录");
Object userId = checkUser(session);
User user;
if (userId != null) {
logger.info("获取用户信息");
user = userService.get(Integer.parseInt(userId.toString()));
map.put("user", user);
} else {
return "redirect:/login";
}
Byte[] status_array = null;
if (status != null) {
status_array = new Byte[]{status};
}
PageUtil pageUtil = new PageUtil(index, count);
logger.info("根据用户ID:{}获取订单列表", userId);
List<ProductOrder> productOrderList = productOrderService.getList(
new ProductOrder().setProductOrder_user(
new User().setUser_id(Integer.valueOf(userId.toString()))
), status_array, new OrderUtil("productOrder_id", true), pageUtil
);
//订单总数量
Integer orderCount = 0;
if (productOrderList.size() > 0) {
orderCount = productOrderService.getTotal(new ProductOrder().setProductOrder_user(new User().setUser_id(Integer.valueOf(userId.toString()))), status_array);
logger.info("获取订单项信息及对应的产品信息");
for (ProductOrder order : productOrderList) {
List<ProductOrderItem> productOrderItemList = productOrderItemService.getListByOrderId(
order.getProductOrder_id(), null
);
if (productOrderItemList != null) {
for (ProductOrderItem productOrderItem : productOrderItemList) {
Integer product_id = productOrderItem.getProductOrderItem_product().getProduct_id();
Product product = productService.get(product_id);
product.setSingleProductImageList(productImageService.getList(
product_id, (byte) 0, new PageUtil(0, 1)
));
productOrderItem.setProductOrderItem_product(product);
if (order.getProductOrder_status() == 3) {
productOrderItem.setIsReview(reviewService.getTotalByOrderItemId(
productOrderItem.getProductOrderItem_id()) > 0
);
}
}
}
order.setProductOrderItemList(productOrderItemList);
}
}
pageUtil.setTotal(orderCount);
logger.info("获取产品分类列表信息");
List<Category> categoryList = categoryService.getList(null, new PageUtil(0, 5));
map.put("pageUtil", pageUtil);
map.put("productOrderList", productOrderList);
map.put("categoryList", categoryList);
map.put("status", status);
logger.info("转到前台天猫-订单列表页");
return "fore/orderListPage";
}
//转到前台天猫-订单建立页
@RequestMapping(value = "order/create/{product_id}", method = RequestMethod.GET)
public String goToOrderConfirmPage(@PathVariable("product_id") Integer product_id,
@RequestParam(required = false, defaultValue = "1") Short product_number,
Map<String, Object> map,
HttpSession session,
HttpServletRequest request) throws UnsupportedEncodingException {
logger.info("检查用户是否登录");
Object userId = checkUser(session);
User user;
if (userId != null) {
logger.info("获取用户信息");
user = userService.get(Integer.parseInt(userId.toString()));
map.put("user", user);
} else {
return "redirect:/login";
}
logger.info("通过产品ID获取产品信息:{}", product_id);
Product product = productService.get(product_id);
if (product == null) {
return "redirect:/";
}
logger.info("获取产品的详细信息");
product.setProduct_category(categoryService.get(product.getProduct_category().getCategory_id()));
product.setSingleProductImageList(productImageService.getList(product_id, (byte) 0, new PageUtil(0, 1)));
logger.info("封装订单项对象");
ProductOrderItem productOrderItem = new ProductOrderItem();
productOrderItem.setProductOrderItem_product(product);
productOrderItem.setProductOrderItem_number(product_number);
productOrderItem.setProductOrderItem_price(product.getProduct_sale_price() * product_number);
productOrderItem.setProductOrderItem_user(new User().setUser_id(Integer.valueOf(userId.toString())));
//初始化订单地址信息
String addressId = "110000";
String cityAddressId = "110100";
String districtAddressId = "110101";
String detailsAddress = null;
String order_post = null;
String order_receiver = null;
String order_phone = null;
Cookie[] cookies = request.getCookies();
//如果读取到了浏览器Cookie
if (cookies != null) {
for (Cookie cookie : cookies) {
String cookieName = cookie.getName();
String cookieValue = cookie.getValue();
switch (cookieName) {
case "addressId":
addressId = cookieValue;
break;
case "cityAddressId":
cityAddressId = cookieValue;
break;
case "districtAddressId":
没有合适的资源?快使用搜索试试~ 我知道了~
基于springboot的商城管理系统源码.zip
共1504个文件
jpg:1140个
png:96个
xml:94个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 14 浏览量
2023-06-19
00:18:11
上传
评论
收藏 188.72MB ZIP 举报
温馨提示
源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经过本地编译可运行的,下载完成之后配置相应环境即可使用。源码功能都是经过老师肯定的,都能满足要求,有需要放心下载即可。源码是经
资源推荐
资源详情
资源评论
收起资源包目录
基于springboot的商城管理系统源码.zip (1504个子文件)
bootstrap.min.css 118KB
fore_productDetails.css 18KB
fore_productBuyCarPage.css 12KB
fore_productBuyPage.css 10KB
admin_main.css 9KB
fore_productList.css 8KB
fore_home.css 7KB
bootstrap-select.min.css 6KB
admin_home.css 6KB
fore_nav.css 6KB
fore_orderConfirmPage.css 6KB
fore_addReview.css 6KB
fore_orderList.css 5KB
fore_login.css 4KB
fore_userDatiles.css 4KB
fore_orderPaySuccess.css 4KB
admin_login.css 3KB
fore_register.css 3KB
fore_orderSuccessPage.css 3KB
fore_orderPay.css 3KB
fore_main.css 2KB
fore_foot_two.css 1KB
fore_foot_special.css 1002B
fore_foot.css 894B
Dockerfile 513B
.gitignore 158B
.gitignore 30B
404.html 3KB
500.html 290B
tmall_48px_1193412_easyicon.net.ico 8KB
tmall_48px_1193412_easyicon.net.ico 8KB
tmall.iml 7KB
ForeOrderController.java 56KB
ProductController.java 25KB
ForeProductDetailsController.java 10KB
AdminHomeController.java 9KB
OrderController.java 9KB
ForeProductListController.java 9KB
CategoryController.java 8KB
UserController.java 8KB
ProductOrder.java 8KB
ForeReviewController.java 8KB
Product.java 7KB
ForeUserController.java 6KB
AccountController.java 6KB
User.java 5KB
RewardController.java 5KB
ForeHomeController.java 5KB
ProductOrderItem.java 5KB
ForeRegisterController.java 4KB
Reward.java 3KB
ProductOrderItemServiceImpl.java 3KB
ForeRewardController.java 3KB
Review.java 3KB
Admin.java 2KB
AdminLoginController.java 2KB
ProductOrderServiceImpl.java 2KB
ReviewServiceImpl.java 2KB
Category.java 2KB
ProductServiceImpl.java 2KB
ForeLoginController.java 2KB
ProductImageServiceImpl.java 2KB
PropertyValueServiceImpl.java 2KB
PropertyValue.java 2KB
ProductImage.java 2KB
RewardServiceImpl.java 2KB
PropertyServiceImpl.java 2KB
Property.java 2KB
AdminPermissionFilter.java 2KB
AdminServiceImpl.java 2KB
OrderGroup.java 2KB
UserServiceImpl.java 2KB
CategoryServiceImpl.java 2KB
ProductOrderItemMapper.java 1KB
ForeAddressController.java 1KB
AddressServiceImpl.java 1KB
PageUtil.java 1KB
Address.java 1KB
ProductMapper.java 1KB
ProductOrderMapper.java 1KB
TmallSpringBootApplication.java 1KB
ReviewMapper.java 1KB
ProductOrderItemService.java 1KB
BaseController.java 962B
ProductImageMapper.java 948B
RewardMapper.java 923B
PropertyValueMapper.java 885B
ProductOrderService.java 826B
ProductService.java 782B
PropertyMapper.java 770B
AdminMapper.java 733B
UserMapper.java 726B
ReviewService.java 722B
CategoryMapper.java 628B
ProductImageService.java 588B
RewardService.java 582B
OrderUtil.java 571B
PropertyValueService.java 570B
LastIDServiceImpl.java 569B
AddressMapper.java 561B
共 1504 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16
资源评论
知一NN
- 粉丝: 42
- 资源: 4157
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于SimPy和贝叶斯优化的流程仿真系统.zip
- (源码)基于Java Web的个人信息管理系统.zip
- (源码)基于C++和OTL4的PostgreSQL数据库连接系统.zip
- (源码)基于ESP32和AWS IoT Core的室内温湿度监测系统.zip
- (源码)基于Arduino的I2C协议交通灯模拟系统.zip
- coco.names 文件
- (源码)基于Spring Boot和Vue的房屋租赁管理系统.zip
- (源码)基于Android的饭店点菜系统.zip
- (源码)基于Android平台的权限管理系统.zip
- (源码)基于CC++和wxWidgets框架的LEGO模型火车控制系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功