how2j.cn

-->
下载区
文件名 文件大小
请先登录 1m
增值内容 1m
1m

解压rar如果失败,请用5.21版本或者更高版本的winrar

点击下载 winrar5.21
步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 我的订单页   
步骤 4 : OrderService   
步骤 5 : OrderServiceImpl   
步骤 6 : ForeController.bought()   
步骤 7 : bought.jsp   
步骤 8 : boughtPage.jsp   

步骤 1 :

先运行,看到效果,再学习

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
我的订单页
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service; import java.util.List; import com.how2java.tmall.pojo.Order; import com.how2java.tmall.pojo.OrderItem; public interface OrderService { String waitPay = "waitPay"; String waitDelivery = "waitDelivery"; String waitConfirm = "waitConfirm"; String waitReview = "waitReview"; String finish = "finish"; String delete = "delete"; void add(Order c); float add(Order c,List<OrderItem> ois); void delete(int id); void update(Order c); Order get(int id); List list(); List list(int uid, String excludedStatus); }
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service.impl; import com.how2java.tmall.mapper.OrderMapper; import com.how2java.tmall.pojo.Order; import com.how2java.tmall.pojo.OrderExample; import com.how2java.tmall.pojo.OrderItem; import com.how2java.tmall.pojo.User; import com.how2java.tmall.service.OrderItemService; import com.how2java.tmall.service.OrderService; import com.how2java.tmall.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.List; @Service public class OrderServiceImpl implements OrderService { @Autowired OrderMapper orderMapper; @Autowired UserService userService; @Autowired OrderItemService orderItemService; @Override public void add(Order c) { orderMapper.insert(c); } @Override public void delete(int id) { orderMapper.deleteByPrimaryKey(id); } @Override public void update(Order c) { orderMapper.updateByPrimaryKeySelective(c); } @Override public Order get(int id) { return orderMapper.selectByPrimaryKey(id); } public List<Order> list(){ OrderExample example =new OrderExample(); example.setOrderByClause("id desc"); return orderMapper.selectByExample(example); } @Override public List list(int uid, String excludedStatus) { OrderExample example =new OrderExample(); example.createCriteria().andUidEqualTo(uid).andStatusNotEqualTo(excludedStatus); example.setOrderByClause("id desc"); return orderMapper.selectByExample(example); } ; public void setUser(List<Order> os){ for (Order o : os) setUser(o); } public void setUser(Order o){ int uid = o.getUid(); User u = userService.get(uid); o.setUser(u); } @Override @Transactional(propagation= Propagation.REQUIRED,rollbackForClassName="Exception") public float add(Order o, List<OrderItem> ois) { float total = 0; add(o); if(false) throw new RuntimeException(); for (OrderItem oi: ois) { oi.setOid(o.getId()); orderItemService.update(oi); total+=oi.getProduct().getPromotePrice()*oi.getNumber(); } return total; } }
步骤 6 :

ForeController.bought()

edit
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
@RequestMapping("forebought") public String bought( Model model,HttpSession session) { User user =(User) session.getAttribute("user"); List<Order> os= orderService.list(user.getId(),OrderService.delete); orderItemService.fill(os); model.addAttribute("os", os); return "fore/bought"; } }
package com.how2java.tmall.controller; import com.github.pagehelper.PageHelper; import com.how2java.tmall.pojo.*; import com.how2java.tmall.service.*; import comparator.*; import org.apache.commons.lang.math.RandomUtils; 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 org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.util.HtmlUtils; import javax.servlet.http.HttpSession; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; @Controller @RequestMapping("") public class ForeController { @Autowired CategoryService categoryService; @Autowired ProductService productService; @Autowired UserService userService; @Autowired ProductImageService productImageService; @Autowired PropertyValueService propertyValueService; @Autowired OrderService orderService; @Autowired OrderItemService orderItemService; @Autowired ReviewService reviewService; @RequestMapping("forehome") public String home(Model model) { List<Category> cs= categoryService.list(); productService.fill(cs); productService.fillByRow(cs); model.addAttribute("cs", cs); return "fore/home"; } @RequestMapping("foreregister") public String register(Model model,User user) { String name = user.getName(); name = HtmlUtils.htmlEscape(name); user.setName(name); boolean exist = userService.isExist(name); if(exist){ String m ="用户名已经被使用,不能使用"; model.addAttribute("msg", m); return "fore/register"; } userService.add(user); return "redirect:registerSuccessPage"; } @RequestMapping("forelogin") public String login(@RequestParam("name") String name, @RequestParam("password") String password, Model model, HttpSession session) { name = HtmlUtils.htmlEscape(name); User user = userService.get(name,password); if(null==user){ model.addAttribute("msg", "账号密码错误"); return "fore/login"; } session.setAttribute("user", user); return "redirect:forehome"; } @RequestMapping("forelogout") public String logout( HttpSession session) { session.removeAttribute("user"); return "redirect:forehome"; } @RequestMapping("foreproduct") public String product( int pid, Model model) { Product p = productService.get(pid); List<ProductImage> productSingleImages = productImageService.list(p.getId(), ProductImageService.type_single); List<ProductImage> productDetailImages = productImageService.list(p.getId(), ProductImageService.type_detail); p.setProductSingleImages(productSingleImages); p.setProductDetailImages(productDetailImages); List<PropertyValue> pvs = propertyValueService.list(p.getId()); List<Review> reviews = reviewService.list(p.getId()); productService.setSaleAndReviewNumber(p); model.addAttribute("reviews", reviews); model.addAttribute("p", p); model.addAttribute("pvs", pvs); return "fore/product"; } @RequestMapping("forecheckLogin") @ResponseBody public String checkLogin( HttpSession session) { User user =(User) session.getAttribute("user"); if(null!=user) return "success"; return "fail"; } @RequestMapping("foreloginAjax") @ResponseBody public String loginAjax(@RequestParam("name") String name, @RequestParam("password") String password,HttpSession session) { name = HtmlUtils.htmlEscape(name); User user = userService.get(name,password); if(null==user){ return "fail"; } session.setAttribute("user", user); return "success"; } @RequestMapping("forecategory") public String category(int cid,String sort, Model model) { Category c = categoryService.get(cid); productService.fill(c); productService.setSaleAndReviewNumber(c.getProducts()); if(null!=sort){ switch(sort){ case "review": Collections.sort(c.getProducts(),new ProductReviewComparator()); break; case "date" : Collections.sort(c.getProducts(),new ProductDateComparator()); break; case "saleCount" : Collections.sort(c.getProducts(),new ProductSaleCountComparator()); break; case "price": Collections.sort(c.getProducts(),new ProductPriceComparator()); break; case "all": Collections.sort(c.getProducts(),new ProductAllComparator()); break; } } model.addAttribute("c", c); return "fore/category"; } @RequestMapping("foresearch") public String search( String keyword,Model model){ PageHelper.offsetPage(0,20); List<Product> ps= productService.search(keyword); productService.setSaleAndReviewNumber(ps); model.addAttribute("ps",ps); return "fore/searchResult"; } @RequestMapping("forebuyone") public String buyone(int pid, int num, HttpSession session) { Product p = productService.get(pid); int oiid = 0; User user =(User) session.getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemService.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId().intValue()==p.getId().intValue()){ oi.setNumber(oi.getNumber()+num); orderItemService.update(oi); found = true; oiid = oi.getId(); break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUid(user.getId()); oi.setNumber(num); oi.setPid(pid); orderItemService.add(oi); oiid = oi.getId(); } return "redirect:forebuy?oiid="+oiid; } @RequestMapping("forebuy") public String buy( Model model,String[] oiid,HttpSession session){ List<OrderItem> ois = new ArrayList<>(); float total = 0; for (String strid : oiid) { int id = Integer.parseInt(strid); OrderItem oi= orderItemService.get(id); total +=oi.getProduct().getPromotePrice()*oi.getNumber(); ois.add(oi); } session.setAttribute("ois", ois); model.addAttribute("total", total); return "fore/buy"; } @RequestMapping("foreaddCart") @ResponseBody public String addCart(int pid, int num, Model model,HttpSession session) { Product p = productService.get(pid); User user =(User) session.getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemService.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId().intValue()==p.getId().intValue()){ oi.setNumber(oi.getNumber()+num); orderItemService.update(oi); found = true; break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUid(user.getId()); oi.setNumber(num); oi.setPid(pid); orderItemService.add(oi); } return "success"; } @RequestMapping("forecart") public String cart( Model model,HttpSession session) { User user =(User) session.getAttribute("user"); List<OrderItem> ois = orderItemService.listByUser(user.getId()); model.addAttribute("ois", ois); return "fore/cart"; } @RequestMapping("forechangeOrderItem") @ResponseBody public String changeOrderItem( Model model,HttpSession session, int pid, int number) { User user =(User) session.getAttribute("user"); if(null==user) return "fail"; List<OrderItem> ois = orderItemService.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId().intValue()==pid){ oi.setNumber(number); orderItemService.update(oi); break; } } return "success"; } @RequestMapping("foredeleteOrderItem") @ResponseBody public String deleteOrderItem( Model model,HttpSession session,int oiid){ User user =(User) session.getAttribute("user"); if(null==user) return "fail"; orderItemService.delete(oiid); return "success"; } @RequestMapping("forecreateOrder") public String createOrder( Model model,Order order,HttpSession session){ User user =(User) session.getAttribute("user"); String orderCode = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + RandomUtils.nextInt(10000); order.setOrderCode(orderCode); order.setCreateDate(new Date()); order.setUid(user.getId()); order.setStatus(OrderService.waitPay); List<OrderItem> ois= (List<OrderItem>) session.getAttribute("ois"); float total =orderService.add(order,ois); return "redirect:forealipay?oid="+order.getId() +"&total="+total; } @RequestMapping("forepayed") public String payed(int oid, float total, Model model) { Order order = orderService.get(oid); order.setStatus(OrderService.waitDelivery); order.setPayDate(new Date()); orderService.update(order); model.addAttribute("o", order); return "fore/payed"; } @RequestMapping("forebought") public String bought( Model model,HttpSession session) { User user =(User) session.getAttribute("user"); List<Order> os= orderService.list(user.getId(),OrderService.delete); orderItemService.fill(os); model.addAttribute("os", os); return "fore/bought"; } }
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <%@include file="../include/fore/header.jsp"%> <%@include file="../include/fore/top.jsp"%> <%@include file="../include/fore/simpleSearch.jsp"%> <%@include file="../include/fore/cart/boughtPage.jsp"%> <%@include file="../include/fore/footer.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>

<%@include file="../include/fore/header.jsp"%>
<%@include file="../include/fore/top.jsp"%>
<%@include file="../include/fore/simpleSearch.jsp"%>
<%@include file="../include/fore/cart/boughtPage.jsp"%>
<%@include file="../include/fore/footer.jsp"%>
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
boughtPage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <script> var deleteOrder = false; var deleteOrderid = 0; $(function(){ $("a[orderStatus]").click(function(){ var orderStatus = $(this).attr("orderStatus"); if('all'==orderStatus){ $("table[orderStatus]").show(); } else{ $("table[orderStatus]").hide(); $("table[orderStatus="+orderStatus+"]").show(); } $("div.orderType div").removeClass("selectedOrderType"); $(this).parent("div").addClass("selectedOrderType"); }); $("a.deleteOrderLink").click(function(){ deleteOrderid = $(this).attr("oid"); deleteOrder = false; $("#deleteConfirmModal").modal("show"); }); $("button.deleteConfirmButton").click(function(){ deleteOrder = true; $("#deleteConfirmModal").modal('hide'); }); $('#deleteConfirmModal').on('hidden.bs.modal', function (e) { if(deleteOrder){ var page="foredeleteOrder"; $.post( page, {"oid":deleteOrderid}, function(result){ if("success"==result){ $("table.orderListItemTable[oid="+deleteOrderid+"]").hide(); } else{ location.href="login.jsp"; } } ); } }) $(".ask2delivery").click(function(){ var link = $(this).attr("link"); $(this).hide(); page = link; $.ajax({ url: page, success: function(result){ alert("卖家已秒发,刷新当前页面,即可进行确认收货") } }); }); }); </script> <div class="boughtDiv"> <div class="orderType"> <div class="selectedOrderType"><a orderStatus="all" href="#nowhere">所有订单</a></div> <div><a orderStatus="waitPay" href="#nowhere">待付款</a></div> <div><a orderStatus="waitDelivery" href="#nowhere">待发货</a></div> <div><a orderStatus="waitConfirm" href="#nowhere">待收货</a></div> <div><a orderStatus="waitReview" href="#nowhere" class="noRightborder">待评价</a></div> <div class="orderTypeLastOne"><a class="noRightborder"></a></div> </div> <div style="clear:both"></div> <div class="orderListTitle"> <table class="orderListTitleTable"> <tr> <td>宝贝</td> <td width="100px">单价</td> <td width="100px">数量</td> <td width="120px">实付款</td> <td width="100px">交易操作</td> </tr> </table> </div> <div class="orderListItem"> <c:forEach items="${os}" var="o"> <table class="orderListItemTable" orderStatus="${o.status}" oid="${o.id}"> <tr class="orderListItemFirstTR"> <td colspan="2"> <b><fmt:formatDate value="${o.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></b> <span>订单号: ${o.orderCode} </span> </td> <td colspan="2"><img width="13px" src="img/site/orderItemTmall.png">天猫商场</td> <td colspan="1"> <a class="wangwanglink" href="#nowhere"> <div class="orderItemWangWangGif"></div> </a> </td> <td class="orderItemDeleteTD"> <a class="deleteOrderLink" oid="${o.id}" href="#nowhere"> <span class="orderListItemDelete glyphicon glyphicon-trash"></span> </a> </td> </tr> <c:forEach items="${o.orderItems}" var="oi" varStatus="st"> <tr class="orderItemProductInfoPartTR" > <td class="orderItemProductInfoPartTD"><img width="80" height="80" src="img/productSingle_middle/${oi.product.firstProductImage.id}.jpg"></td> <td class="orderItemProductInfoPartTD"> <div class="orderListItemProductLinkOutDiv"> <a href="foreproduct?pid=${oi.product.id}">${oi.product.name}</a> <div class="orderListItemProductLinkInnerDiv"> <img src="img/site/creditcard.png" title="支持信用卡支付"> <img src="img/site/7day.png" title="消费者保障服务,承诺7天退货"> <img src="img/site/promise.png" title="消费者保障服务,承诺如实描述"> </div> </div> </td> <td class="orderItemProductInfoPartTD" width="100px"> <div class="orderListItemProductOriginalPrice">¥<fmt:formatNumber type="number" value="${oi.product.originalPrice}" minFractionDigits="2"/></div> <div class="orderListItemProductPrice">¥<fmt:formatNumber type="number" value="${oi.product.promotePrice}" minFractionDigits="2"/></div> </td> <c:if test="${st.count==1}"> <td valign="top" rowspan="${fn:length(o.orderItems)}" class="orderListItemNumberTD orderItemOrderInfoPartTD" width="100px"> <span class="orderListItemNumber">${o.totalNumber}</span> </td> <td valign="top" rowspan="${fn:length(o.orderItems)}" width="120px" class="orderListItemProductRealPriceTD orderItemOrderInfoPartTD"> <div class="orderListItemProductRealPrice">¥<fmt:formatNumber minFractionDigits="2" maxFractionDigits="2" type="number" value="${o.total}"/></div> <div class="orderListItemPriceWithTransport">(含运费:¥0.00)</div> </td> <td valign="top" rowspan="${fn:length(o.orderItems)}" class="orderListItemButtonTD orderItemOrderInfoPartTD" width="100px"> <c:if test="${o.status=='waitConfirm' }"> <a href="foreconfirmPay?oid=${o.id}"> <button class="orderListItemConfirm">确认收货</button> </a> </c:if> <c:if test="${o.status=='waitPay' }"> <a href="forealipay?oid=${o.id}&total=${o.total}"> <button class="orderListItemConfirm">付款</button> </a> </c:if> <c:if test="${o.status=='waitDelivery' }"> <span>待发货</span> <%-- <button class="btn btn-info btn-sm ask2delivery" link="admin_order_delivery?id=${o.id}">催卖家发货</button> --%> </c:if> <c:if test="${o.status=='waitReview' }"> <a href="forereview?oid=${o.id}"> <button class="orderListItemReview">评价</button> </a> </c:if> </td> </c:if> </tr> </c:forEach> </table> </c:forEach> </div> </div>


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


问答区域    
2021-08-02 站长!后端只传过来一个list。 点击/所有订单/未付款/未收货/。。。。会出现不同的订单 这个筛选效果是怎么做出来的??我有发现前端有判断各自status再显示的逻辑呀?
vcaml

如题




1 个答案

how2j
答案时间:2021-08-21
这是在前端实现的,代码讲解在天猫前端项目里有: https://how2j.cn/k/tmall-front/tmall-front-842/842.html



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2020-07-06 由于截图所示教程代码和下载的项目代码不一致,待评价后边的线高一些,高一些,一些,些
zw747402259




如题。
加载中
下载项目代码:<div class="orderTypeLastOne"><a class="noRightborder">&nbsp;</a> </div>



教程代码:<div class="orderTypeLastOne"><a class="noRightborder"></a></div>


							


1 个答案

how2j
答案时间:2020-07-07
步骤1里的效果是否是对的呢?



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到





2020-03-20 站长,boughtPage.jsp里需要增加和修改
2020-01-03 订单完成,状态是不是漏了,哈哈~
2019-12-07 为什么每个订单各自的订单项的数量不是独立的


提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 4 条以前的提问,请 点击查看

提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 实践项目-天猫整站SSM-我的订单页 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 578362961
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图