步骤 2 : 模仿和排错 步骤 3 : 界面效果 步骤 4 : 评价产品页面 步骤 5 : 提交评价
增值内容,请先登录
完整的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项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
@RequestMapping("forereview")
public String review( Model model,int oid) {
Order o = orderService.get(oid);
orderItemService.fill(o);
Product p = o.getOrderItems().get(0).getProduct();
List<Review> reviews = reviewService.list(p.getId());
productService.setSaleAndReviewNumber(p);
model.addAttribute("p", p);
model.addAttribute("o", o);
model.addAttribute("reviews", reviews);
return "fore/review";
}
<%@ 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/reviewPage.jsp"%>
<%@include file="../include/fore/footer.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false"%>
<div class="reviewDiv">
<div class="reviewProductInfoDiv">
<div class="reviewProductInfoImg"><img width="400px" height="400px" src="img/productSingle/${p.firstProductImage.id}.jpg"></div>
<div class="reviewProductInfoRightDiv">
<div class="reviewProductInfoRightText">
${p.name}
</div>
<table class="reviewProductInfoTable">
<tr>
<td width="75px">价格:</td>
<td><span class="reviewProductInfoTablePrice">¥<fmt:formatNumber type="number" value="${p.originalPrice}" minFractionDigits="2"/></span> 元 </td>
</tr>
<tr>
<td>配送</td>
<td>快递: 0.00</td>
</tr>
<tr>
<td>月销量:</td>
<td><span class="reviewProductInfoTableSellNumber">${p.saleCount}</span> 件</td>
</tr>
</table>
<div class="reviewProductInfoRightBelowDiv">
<span class="reviewProductInfoRightBelowImg"><img1 src="img/site/reviewLight.png"></span>
<span class="reviewProductInfoRightBelowText" >现在查看的是 您所购买商品的信息
于<fmt:formatDate value="${o.createDate}" pattern="yyyy年MM月dd"/>下单购买了此商品 </span>
</div>
</div>
<div style="clear:both"></div>
</div>
<div class="reviewStasticsDiv">
<div class="reviewStasticsLeft">
<div class="reviewStasticsLeftTop"></div>
<div class="reviewStasticsLeftContent">累计评价 <span class="reviewStasticsNumber"> ${p.reviewCount}</span></div>
<div class="reviewStasticsLeftFoot"></div>
</div>
<div class="reviewStasticsRight">
<div class="reviewStasticsRightEmpty"></div>
<div class="reviewStasticsFoot"></div>
</div>
</div>
<c:if test="${param.showonly==true}">
<div class="reviewDivlistReviews">
<c:forEach items="${reviews}" var="r">
<div class="reviewDivlistReviewsEach">
<div class="reviewDate"><fmt:formatDate value="${r.createDate}" pattern="yyyy-MM-dd"/></div>
<div class="reviewContent">${r.content}</div>
<div class="reviewUserInfo pull-right">${r.user.anonymousName}<span class="reviewUserInfoAnonymous">(匿名)</span></div>
</div>
</c:forEach>
</div>
</c:if>
<c:if test="${param.showonly!=true}">
<div class="makeReviewDiv">
<form method="post" action="foredoreview">
<div class="makeReviewText">其他买家,需要你的建议哦!</div>
<table class="makeReviewTable">
<tr>
<td class="makeReviewTableFirstTD">评价商品</td>
<td><textarea name="content"></textarea></td>
</tr>
</table>
<div class="makeReviewButtonDiv">
<input type="hidden" name="oid" value="${o.id}">
<input type="hidden" name="pid" value="${p.id}">
<button type="submit">提交评价</button>
</div>
</form>
</div>
</c:if>
</div>
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";
}
@RequestMapping("foreconfirmPay")
public String confirmPay( Model model,int oid) {
Order o = orderService.get(oid);
orderItemService.fill(o);
model.addAttribute("o", o);
return "fore/confirmPay";
}
@RequestMapping("foreorderConfirmed")
public String orderConfirmed( Model model,int oid) {
Order o = orderService.get(oid);
o.setStatus(OrderService.waitReview);
o.setConfirmDate(new Date());
orderService.update(o);
return "fore/orderConfirmed";
}
@RequestMapping("foredeleteOrder")
@ResponseBody
public String deleteOrder( Model model,int oid){
Order o = orderService.get(oid);
o.setStatus(OrderService.delete);
orderService.update(o);
return "success";
}
@RequestMapping("forereview")
public String review( Model model,int oid) {
Order o = orderService.get(oid);
orderItemService.fill(o);
Product p = o.getOrderItems().get(0).getProduct();
List<Review> reviews = reviewService.list(p.getId());
productService.setSaleAndReviewNumber(p);
model.addAttribute("p", p);
model.addAttribute("o", o);
model.addAttribute("reviews", reviews);
return "fore/review";
}
}
增值内容,请先登录
完整的SSM模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSM一整套技术栈, 从无到有涵盖全部126个知识点,560个开发步骤, 充实SSM项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
@RequestMapping("foredoreview")
public String doreview( Model model,HttpSession session,@RequestParam("oid") int oid,@RequestParam("pid") int pid,String content) {
Order o = orderService.get(oid);
o.setStatus(OrderService.finish);
orderService.update(o);
Product p = productService.get(pid);
content = HtmlUtils.htmlEscape(content);
User user =(User) session.getAttribute("user");
Review review = new Review();
review.setContent(content);
review.setPid(pid);
review.setCreateDate(new Date());
review.setUid(user.getId());
reviewService.add(review);
return "redirect:forereview?oid="+oid+"&showonly=true";
}
<c:if test="${param.showonly==true}">
<div class="reviewDivlistReviews">
<c:forEach items="${reviews}" var="r">
<div class="reviewDivlistReviewsEach">
<div class="reviewDate"><fmt:formatDate value="${r.createDate}" pattern="yyyy-MM-dd"/></div>
<div class="reviewContent">${r.content}</div>
<div class="reviewUserInfo pull-right">${r.user.anonymousName}<span class="reviewUserInfoAnonymous">(匿名)</span></div>
</div>
</c:forEach>
</div>
</c:if>
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";
}
@RequestMapping("foreconfirmPay")
public String confirmPay( Model model,int oid) {
Order o = orderService.get(oid);
orderItemService.fill(o);
model.addAttribute("o", o);
return "fore/confirmPay";
}
@RequestMapping("foreorderConfirmed")
public String orderConfirmed( Model model,int oid) {
Order o = orderService.get(oid);
o.setStatus(OrderService.waitReview);
o.setConfirmDate(new Date());
orderService.update(o);
return "fore/orderConfirmed";
}
@RequestMapping("foredeleteOrder")
@ResponseBody
public String deleteOrder( Model model,int oid){
Order o = orderService.get(oid);
o.setStatus(OrderService.delete);
orderService.update(o);
return "success";
}
@RequestMapping("forereview")
public String review( Model model,int oid) {
Order o = orderService.get(oid);
orderItemService.fill(o);
Product p = o.getOrderItems().get(0).getProduct();
List<Review> reviews = reviewService.list(p.getId());
productService.setSaleAndReviewNumber(p);
model.addAttribute("p", p);
model.addAttribute("o", o);
model.addAttribute("reviews", reviews);
return "fore/review";
}
@RequestMapping("foredoreview")
public String doreview( Model model,HttpSession session,@RequestParam("oid") int oid,@RequestParam("pid") int pid,String content) {
Order o = orderService.get(oid);
o.setStatus(OrderService.finish);
orderService.update(o);
Product p = productService.get(pid);
content = HtmlUtils.htmlEscape(content);
User user =(User) session.getAttribute("user");
Review review = new Review();
review.setContent(content);
review.setPid(pid);
review.setCreateDate(new Date());
review.setUid(user.getId());
reviewService.add(review);
return "redirect:forereview?oid="+oid+"&showonly=true";
}
}
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
问答区域
2020-12-14
站长,这里为啥不显示多个订单项的产品评价功能。。。。
1 个答案
how2j 跳转到问题位置 答案时间:2020-12-17 因为每个产品都要评价,页面就太复杂了,学员学起来曲线过陡峭,所以就用第一个产品来做了,这样好理解消化些。
理解掌握之后,有兴趣可以自己开发哈
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2020-06-03
关于多用户登录
回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
2020-05-11
报告一个bug
2020-04-23
跳过确认收货,直接在地址栏输入foredoReview的Controller地址和参数,类似的情况是不是不安全?怎样解决呢?解决方式和form表单的post有关吗
2020-03-26
关于步骤5获取参数的@RequestParam问题
提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 7 条以前的提问,请 点击查看
提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|