From 2dd20539824ec404bf6c145a76b9498e484c3861 Mon Sep 17 00:00:00 2001 From: xyiege Date: Tue, 1 Nov 2022 22:48:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E8=B4=AD=E7=89=A9=E8=BD=A6=E4=B8=AD?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=B7=B2=E7=BB=8F=E4=B8=8B=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/chjyj/szwh/utils/SzOrderUtils.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/main/java/cn/chjyj/szwh/utils/SzOrderUtils.java b/src/main/java/cn/chjyj/szwh/utils/SzOrderUtils.java index 21de5a1..ad70a4d 100644 --- a/src/main/java/cn/chjyj/szwh/utils/SzOrderUtils.java +++ b/src/main/java/cn/chjyj/szwh/utils/SzOrderUtils.java @@ -2,10 +2,12 @@ package cn.chjyj.szwh.utils; import cn.chjyj.szwh.bean.*; import cn.chjyj.szwh.exception.ChException; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.omg.CORBA.PUBLIC_MEMBER; import java.math.BigDecimal; import java.math.RoundingMode; @@ -240,4 +242,42 @@ public class SzOrderUtils { retmap.put("service_charge",serviceCharge); return retmap; } + + /** + * 从购物车中移除已经下单的商品 + * @param shopRedisKey 购物车名称 键名 + * @param goodsIsli + */ + public static void delOdGoodsIsliFromCar(String shopRedisKey,String goodsIsli){ + // get shopping car from redis + Object shopCar = RedisUtil.get(shopRedisKey); + if (shopCar == null) { + log.error(shopRedisKey+"购物车为空"); + } + JSONObject carjson = JSONObject.parseObject(shopCar.toString()); + // 购物车 是数组形式 + //JSONObject shopCarJson = JSONObject.parseObject(carjson.toString()); + JSONArray jsonArray = carjson.getJSONArray("data"); + String useIsli= carjson.getString("user_isli"); + if(jsonArray.size()>0){ + List ncarlist = new ArrayList(); + for (int x =0; x