|
|
|
@ -766,34 +766,24 @@ public class GoodsServiceImpl implements GoodsService { |
|
|
|
return retlist; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 从购物车中移除一个元素 |
|
|
|
* @param userIsli |
|
|
|
* @param goodsIsli |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void delShoppingCar(String userIsli, String goodsIsli) { |
|
|
|
String shopRedisKey = "car_" + userIsli; |
|
|
|
Object shopCar = RedisUtil.get(shopRedisKey); |
|
|
|
if (shopCar != null) { |
|
|
|
JSONObject shopCarJson = JSONObject.parseObject(shopCar.toString()); |
|
|
|
JSONArray jsonArray = shopCarJson.getJSONArray("data"); |
|
|
|
//
|
|
|
|
JSONObject carjson = new JSONObject(); |
|
|
|
List carlist = new ArrayList(); |
|
|
|
//
|
|
|
|
if (jsonArray.size() > 0) { |
|
|
|
for (int x = 0; x < jsonArray.size(); x++) { |
|
|
|
JSONObject tmpJson = (JSONObject) jsonArray.get(x); |
|
|
|
String tmpgoodsisli = tmpJson.getString("goods_isli"); |
|
|
|
// not equal save into list
|
|
|
|
if (!goodsIsli.equals(tmpgoodsisli)) { |
|
|
|
carlist.add(jsonArray.get(x)); |
|
|
|
} |
|
|
|
} |
|
|
|
// save into new car
|
|
|
|
carjson.put("data", carlist); |
|
|
|
RedisUtil.set(shopRedisKey, carjson); |
|
|
|
} else { |
|
|
|
RedisUtil.del(shopRedisKey); |
|
|
|
} |
|
|
|
public Map<String,Object> delShoppingCar(String userIsli, String goodsIsli) { |
|
|
|
Map retmap =new HashMap(); |
|
|
|
JSONObject retjson =SzCarUtils.delCart(userIsli,goodsIsli); |
|
|
|
if(retjson==retjson){ |
|
|
|
retmap.put("code",400); |
|
|
|
retmap.put("msg","购物车中没有此标的"); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
retmap.put("code",200); |
|
|
|
retmap.put("msg","成功"); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|