@RequestMapping("listgoodscart"
)
public ResultEntity listGoodsCart(@RequestParam(name = "data", required =
true) String data,
@RequestParam(name = "userid", required =
true) String userId) {
GoodsCartDTO goodsCartDTO;
try {
goodsCartDTO =
decodeByBase64(data, GoodsCartDTO.class);
} catch (Exception e) {
e.printStackTrace();
return error(ResultCode.PARAM_DECODE_ERROR);
}
if(StringUtils.isBlank(goodsCartDTO.getArea())) {
return error(ResultCode.PARAM_CHECK_ERROR);
}
List<GoodsCart> goodsCartList =
this.iGoodsCartService
.selectList(new EntityWrapper<GoodsCart>
()
.eq("is_deleted", 0
)
.eq("is_enable", 1
)
.eq("user_id"
, userId)
.eq("is_balance", 0
)
.groupBy("shop_id"
)
.setSqlSelect("shop_id as shopId"
));
Map<Integer, List<Map<String, Object>>> map =
Maps.newHashMap();
if (goodsCartList !=
null && !
goodsCartList.isEmpty()) {
for (GoodsCart goodsCart : goodsCartList) {
Integer shopId =
goodsCart.getShopId();
List<Map<String, Object>> list =
this.iGoodsCartService.listGoodCartInfo(shopId,
Integer.valueOf(userId),goodsCartDTO.getArea());
if (list !=
null && !
list.isEmpty()) {
for (Map<String, Object>
data1 : list) {
List<Map<String, Object>> mapList =
map.get(shopId);
if (mapList !=
null && !
mapList.isEmpty()) {
mapList.add(data1);
} else {
mapList =
Lists.newArrayList();
mapList.add(data1);
map.put(shopId, mapList);
}
}
}
}
}
List<GoodsCartVO> goodsCartVOList =
Lists.newArrayList();
if (!
map.isEmpty()) {
Set<Map.Entry<Integer, List<Map<String, Object>>>> set =
map.entrySet();
for (Map.Entry<Integer, List<Map<String, Object>>>
entry : set) {
GoodsCartVO goodsCartVO =
new GoodsCartVO();
ShopInfo shopInfo =
this.iShopInfoService.selectOne(
new EntityWrapper<ShopInfo>().eq("is_deleted", 0
)
.eq("is_enable", 1).eq("id", entry.getKey()).eq("status", 1).eq("business_status", 1
));
goodsCartVO.setShopInfo(shopInfo);
goodsCartVO.setGoodsBaseInfoList(entry.getValue());
goodsCartVOList.add(goodsCartVO);
}
}
return success(goodsCartVOList);
}
转载于:https://www.cnblogs.com/dianzan/p/11439781.html
相关资源:JAVA上百实例源码以及开源项目