|
|
@@ -249,15 +249,18 @@ public class ContentRecommendService {
|
|
|
|
|
|
// ==================== 商品推荐 ====================
|
|
|
|
|
|
- private List<RecommendItemVO> recommendProducts(String dimensionCode, Long userId,
|
|
|
- Long familyId, Set<Long> excludeIds) {
|
|
|
+private List<RecommendItemVO> recommendProducts(String dimensionCode, Long userId,
|
|
|
+ Long familyId, Set<Long> excludeIds) {
|
|
|
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<Product>()
|
|
|
.eq(Product::getStatus, "on_shelf")
|
|
|
.orderByDesc(Product::getSalesCount)
|
|
|
.last("LIMIT 50");
|
|
|
|
|
|
if (dimensionCode != null && !dimensionCode.trim().isEmpty()) {
|
|
|
- wrapper.eq(Product::getDomain, dimensionCode);
|
|
|
+ // P1: 权重感知查询 — 匹配 dimension_weights > 0 或兼容旧版 domain
|
|
|
+ wrapper.and(w -> w
|
|
|
+ .apply("COALESCE(JSON_EXTRACT(dimension_weights, CONCAT('$.', {0})), 0) > 0", dimensionCode.trim())
|
|
|
+ .or().eq(Product::getDomain, dimensionCode.trim()));
|
|
|
}
|
|
|
|
|
|
List<Product> allProducts = productMapper.selectList(wrapper);
|
|
|
@@ -356,7 +359,10 @@ public class ContentRecommendService {
|
|
|
.last("LIMIT 50");
|
|
|
|
|
|
if (dimensionCode != null && !dimensionCode.trim().isEmpty()) {
|
|
|
- wrapper.eq(Activity::getDimensionCode, dimensionCode);
|
|
|
+ // P1: 权重感知查询 — 匹配 dimension_weights > 0 或兼容旧版 dimension_code
|
|
|
+ wrapper.and(w -> w
|
|
|
+ .apply("COALESCE(JSON_EXTRACT(dimension_weights, CONCAT('$.', {0})), 0) > 0", dimensionCode.trim())
|
|
|
+ .or().eq(Activity::getDimensionCode, dimensionCode.trim()));
|
|
|
}
|
|
|
|
|
|
List<Activity> allActivities = activityMapper.selectList(wrapper);
|