|
|
|
@ -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<jsonArray.size(); x++) { |
|
|
|
JSONObject caritem = jsonArray.getJSONObject(x); |
|
|
|
String tmpgoodsIsli = caritem.getString("goods_isli"); |
|
|
|
if(!tmpgoodsIsli.equals(goodsIsli)){ |
|
|
|
ncarlist.add(caritem); |
|
|
|
} |
|
|
|
} |
|
|
|
RedisUtil.del(shopRedisKey); |
|
|
|
// 存入新的数据
|
|
|
|
Map nmap =new HashMap(); |
|
|
|
nmap.put("user_isli",useIsli); |
|
|
|
nmap.put("data",ncarlist); |
|
|
|
// 存入整理后的购物车
|
|
|
|
RedisUtil.set(shopRedisKey,new JSONObject(nmap).toJSONString()); |
|
|
|
}else{ |
|
|
|
log.error("购物车商品数据为空"+carjson); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|