修复我的页统计空作品报错

This commit is contained in:
2026-07-24 22:17:30 +08:00
parent 3857065262
commit f4937b2dc2
2 changed files with 13 additions and 1 deletions
@@ -328,6 +328,7 @@ public class DashboardController {
List<Map<String, Object>> productOrderCounts = orderItemMapper.selectMaps(
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<OrderItemDO>()
.select("product_id, COUNT(*) as order_count")
.isNotNull("product_id")
.groupBy("product_id")
.orderByDesc("order_count")
.last("LIMIT 5")
@@ -337,7 +338,11 @@ public class DashboardController {
// 遍历查询结果,获取商品详情
for (Map<String, Object> map : productOrderCounts) {
Long productId = Long.valueOf(map.get("product_id").toString());
Object productIdValue = map.get("product_id");
if (productIdValue == null) {
continue;
}
Long productId = Long.valueOf(productIdValue.toString());
ProductDO product = productMapper.selectById(productId);
if (product != null && (shopId == null || shopId.equals(product.getShopId()))) {