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":
没有合适的资源?快使用搜索试试~ 我知道了~
Java项目:化妆品商城系统(java+Springboot+ssm+mysql+jsp+maven)
共1477个文件
jpg:904个
png:134个
xml:100个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 3 下载量 13 浏览量
2022-02-21
09:28:26
上传
评论 2
收藏 213.65MB ZIP 举报
温馨提示
一、项目简述 本系统主要实现的功能有: 网上商城系统,前台+后台管理,用户注册,登录,上架展示,分组展示,搜索,收货地址管理,购物车管理,添加,购买,个人信息修改。订单查询等等,后台商品管理,分类管理,库存管理,订单管理,评论管理,用户管理,信息修改等等。 二、项目运行 环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持) 项目技术: Springboot+ SpringMVC + MyBatis + Jsp + Html+ JavaScript + JQuery + Ajax + maven等等。
资源推荐
资源详情
资源评论
收起资源包目录
Java项目:化妆品商城系统(java+Springboot+ssm+mysql+jsp+maven) (1477个子文件)
ForeOrderController.class 38KB
ProductController.class 22KB
ForeProductDetailsController.class 12KB
OrderController.class 11KB
UserController.class 10KB
ForeReviewController.class 9KB
CategoryController.class 9KB
ForeProductListController.class 9KB
Product.class 8KB
ForeUserController.class 8KB
AdminHomeController.class 8KB
AccountController.class 8KB
ProductOrder.class 7KB
RewardController.class 7KB
User.class 6KB
ForeHomeController.class 6KB
ForeRewardController.class 5KB
ForeRegisterController.class 5KB
ProductOrderItem.class 4KB
ProductOrderItemServiceImpl.class 4KB
Reward.class 4KB
ProductServiceImpl.class 4KB
Review.class 4KB
ForeLoginController.class 4KB
ReviewServiceImpl.class 3KB
ProductOrderServiceImpl.class 3KB
Category.class 3KB
AdminLoginController.class 3KB
ProductImageServiceImpl.class 3KB
PropertyValueServiceImpl.class 3KB
RewardServiceImpl.class 3KB
PropertyServiceImpl.class 3KB
Property.class 3KB
Admin.class 3KB
AdminPermissionFilter.class 3KB
UserServiceImpl.class 2KB
PropertyValue.class 2KB
AdminServiceImpl.class 2KB
ProductImage.class 2KB
ForeAddressController.class 2KB
CategoryServiceImpl.class 2KB
AddressServiceImpl.class 2KB
ProductMapper.class 2KB
ProductOrderItemMapper.class 2KB
OrderGroup.class 2KB
PageUtil.class 2KB
Address.class 2KB
ProductOrderMapper.class 2KB
ReviewMapper.class 2KB
ProductService.class 2KB
TmallSpringBootApplication.class 1KB
ProductOrderItemService.class 1KB
RewardMapper.class 1KB
BaseController.class 1KB
ProductImageMapper.class 1KB
PropertyValueMapper.class 1KB
ProductOrderService.class 1KB
PropertyMapper.class 1KB
ReviewService.class 1KB
UserMapper.class 1KB
AdminMapper.class 1KB
RewardService.class 1KB
ProductImageService.class 983B
CategoryMapper.class 958B
PropertyValueService.class 952B
AddressMapper.class 950B
LastIDServiceImpl.class 896B
PropertyService.class 887B
UserService.class 842B
AdminService.class 776B
OrderUtil.class 773B
AddressService.class 672B
CategoryService.class 662B
LastIDMapper.class 232B
LastIDService.class 157B
bootstrap.min.css 118KB
bootstrap.min.css 118KB
fore_productDetails.css 18KB
fore_productDetails.css 18KB
fore_productBuyCarPage.css 12KB
fore_productBuyCarPage.css 12KB
fore_productBuyPage.css 10KB
fore_productBuyPage.css 10KB
admin_main.css 9KB
admin_main.css 9KB
fore_productList.css 8KB
fore_productList.css 8KB
fore_home.css 7KB
fore_home.css 7KB
bootstrap-select.min.css 6KB
bootstrap-select.min.css 6KB
admin_home.css 6KB
admin_home.css 6KB
fore_nav.css 6KB
fore_nav.css 6KB
fore_orderConfirmPage.css 6KB
fore_orderConfirmPage.css 6KB
fore_addReview.css 6KB
fore_addReview.css 6KB
fore_orderList.css 5KB
共 1477 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15
资源评论
- 心。涙2023-04-27资源值得借鉴的内容很多,那就浅学一下吧,值得下载!
- 我秃了呀2022-05-31用户下载后在一定时间内未进行评价,系统默认好评。
- 兰舟千帆2022-11-14感谢大佬,让我及时解决了当下的问题,解燃眉之急,必须支持!
qq1334611189
- 粉丝: 6829
- 资源: 393
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功