document
API test

获取最新价格

POST

Description or Example

# 知识点 ## 为什么获取最新价格? 因为添加购物车或下单的时候, 相隔了非常长时间, 因此, 我们需要重新获取最新价格 # 代码 ```java /** * 获取订单想最新的价格 * @return */ @RequestMapping("/skus/currentPrice") public Map<Long, BigDecimal> getCurrentPrice(@RequestParam List<Long> skuIds) { return skuInfoService.getCurrentPrice(skuIds); } ``` ```java @Override public Map<Long, BigDecimal> getCurrentPrice(List<Long> skuIds) { List<SkuInfoEntity> currentPriceList = skuInfoDao.getCurrentPrice(skuIds); // 查询出指定sku的sku和价格信息 if (currentPriceList != null && !currentPriceList.isEmpty()) { // 非空判断 return currentPriceList.stream().collect(Collectors.toMap(SkuInfoEntity::getSkuId, SkuInfoEntity::getPrice)); } return null; } ```