public void delGoods(Integer goodsId) //删除购物车 { items.remove(goodsId); }
public void updateCart(Integer goodsId, int quantity) //更新购物车的数量 { TOrderItem orderItem = items.get(goodsId); orderItem.setGoodsQuantity(quantity); items.put(goodsId, orderItem); }
public int getTotalPrice() //计算总的价格 { int totalPrice = 0; for (Iterator it = items.values().iterator(); it.hasNext();) { TOrderItem orderItem = (TOrderItem) it.next(); TGoods goods = orderItem.getGoods(); int quantity = orderItem.getGoodsQuantity(); totalPrice += goods.getGoodsTejia() * quantity; 数量 } return totalPrice; } }
//单价乘以