|
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
@ -82,4 +83,28 @@ public class SzCarUtils { |
|
|
|
// 3 retun result
|
|
|
|
return outjson; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取用户的购物车 |
|
|
|
* @param carkey |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public static Map<String,Object> getCar(String carkey){ |
|
|
|
Object shopCar = RedisUtil.get(carkey); |
|
|
|
if (shopCar == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
//find jsonarray
|
|
|
|
JSONObject shopCarJson = JSONObject.parseObject(shopCar.toString()); |
|
|
|
JSONArray jsonArray = shopCarJson.getJSONArray("data"); |
|
|
|
Map retmap = new HashMap(); |
|
|
|
if(jsonArray!=null){ |
|
|
|
for(int i=0;i<jsonArray.size();i++){ |
|
|
|
JSONObject tmpCarItem = (JSONObject) jsonArray.get(i); |
|
|
|
String tgisli = tmpCarItem.getString("goods_isli"); |
|
|
|
retmap.put(tgisli,jsonArray.get(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
} |
|
|
|
|