package com.softeem.jingdong.action; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionSupport; import com.softeem.jingdong.entity.ShoppingCarBean; import com.softeem.jingdong.entity.UsersBean; /** * 购物车 Action * @author Administrator * */ public class ShoppingCarAction extends ActionSupport { private static final long serialVersionUID = 5108850816643819815L; private String[] index; /** * 删除购物车中的商品信息 * @return */ public String deleteGoods(){ //获取用户 购物车集合 ShoppingCarBean shoppingCar = ((UsersBean)ActionContext.getContext().getSession().get("users")).getShoppingCar(); for(int i=index.length - 1;i>=0;i--){ //当前索引编号 int j = Integer.parseInt( index[i] ); //获取删除商品的单价 double price = shoppingCar.getList().get(j).getPrice(); //直接删除商品 shoppingCar.getList().remove(j); //修改剩余数量 shoppingCar.setNumber( shoppingCar.getNumber() - 1 ); //修改剩余价格 shoppingCar.setSumPrice( shoppingCar.getSumPrice() - price ); } return SUCCESS; } public String[] getIndex() { return index; } public void setIndex(String[] index) { this.index = index; } }

baoligeer LV5
2022年6月6日
任星浩 LV1
2021年11月18日
giantinheart LV3
2021年5月23日
wusiyin LV14
2020年12月17日
曾学成 LV2
2020年12月14日
refreshbird LV1
2020年12月14日
方立亮 LV1
2020年11月6日
渺无人烟 LV11
2020年7月31日
cpemy_abc LV10
2020年6月9日
远大帅比 LV6
2020年5月19日

sn764889012
4月16日
暂无贡献等级
dongandmin LV8
2024年12月31日
mianju
2024年12月19日
暂无贡献等级
lqzixi LV4
2024年11月6日
lyh1989 LV34
2024年7月21日
lyt010628 LV4
2024年7月9日
曾显示 LV6
2024年7月7日
樱花味小然子 LV5
2024年7月2日
微信网友_7034303418945536 LV1
2024年6月12日
chutianyu LV4
2024年6月6日