Commit 0944584029a86955542d4d821428475846971a84

Authored by owen
1 parent 9c341be4

商品:用户未登录时,不记录商品浏览记录

yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/history/ProductBrowseHistoryServiceImpl.java
... ... @@ -27,6 +27,11 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ
27 27  
28 28 @Override
29 29 public Long createBrowseHistory(Long userId, Long spuId) {
  30 + // 用户未登录时不记录
  31 + if (userId == null) {
  32 + return null;
  33 + }
  34 +
30 35 // 情况一:同一个商品,只保留最新的一条记录
31 36 ProductBrowseHistoryDO historyDO = browseHistoryMapper.selectOne(ProductBrowseHistoryDO::getUserId, userId, ProductBrowseHistoryDO::getSpuId, spuId);
32 37 if (historyDO != null) {
... ...