67,513
社区成员
发帖
与我相关
我的任务
分享
public String finishedAdd(){
//获取商品编号
HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
String goodsId = request.getParameter("goodsId");
//根据商品编号获取商品实例
GoodsListing goodsListing = goodsService.getGoodsById(goodsId);
//获取该商品编号的所有详细信息
List<GoodsDetail> goodsDetails = goodsDetailService.getAllGoodsDetailByGoodsId(goodsId);
int goodsNumber = 0;
for (int i = 0; i < goodsDetails.size(); i++) {
GoodsDetail goodsDetail = goodsDetails.get(i);
goodsNumber = goodsNumber+goodsDetail.getGoodsNumber();;
}
goodsListing.setGoodsExitNumber(goodsNumber);
goodsService.updateGoods(goodsListing);
ActionContext.getContext().put("message", "添加商品信息成功...");
ActionContext.getContext().put("type", "goodsAddSuc");
return "finishedAdd";
}