去重导出列固定顺序为 id/ASIN/国家/价格/品牌;QueryAsin 按店铺加载数据并修正前端回退逻辑
Build Backend JAR / build (push) Has been cancelled

This commit is contained in:
2026-08-25 22:38:38 +08:00
parent c287fe01a8
commit 7b238522ed
3 changed files with 59 additions and 10 deletions
@@ -24,6 +24,7 @@ import org.springframework.transaction.support.TransactionTemplate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -136,16 +137,33 @@ public class QueryAsinResolveService {
if (ordered.isEmpty()) {
throw new BusinessException("shop_names 无有效店铺名");
}
List<QueryAsinEntity> allAsins = queryAsinMapper.selectList(
new LambdaQueryWrapper<QueryAsinEntity>().orderByAsc(QueryAsinEntity::getId));
List<QueryAsinCountryAsinsDto> preloadedQueryAsins = toCountryAsins(allAsins);
Map<String, List<QueryAsinEntity>> rowsByShop = loadAsinsGroupByShop(new ArrayList<>(ordered));
ProductRiskMatchShopsVo vo = new ProductRiskMatchShopsVo();
for (String shopName : ordered) {
vo.getItems().add(matchOneShop(shopName, preloadedQueryAsins));
vo.getItems().add(matchOneShop(shopName,
toCountryAsins(rowsByShop.getOrDefault(shopName, List.of()))));
}
return vo;
}
private Map<String, List<QueryAsinEntity>> loadAsinsGroupByShop(List<String> shopNames) {
LambdaQueryWrapper<QueryAsinEntity> wrapper = shopNames.size() == 1
? new LambdaQueryWrapper<QueryAsinEntity>()
.eq(QueryAsinEntity::getShopName, shopNames.get(0))
.orderByAsc(QueryAsinEntity::getId)
: new LambdaQueryWrapper<QueryAsinEntity>()
.in(QueryAsinEntity::getShopName, shopNames)
.orderByAsc(QueryAsinEntity::getId);
Map<String, List<QueryAsinEntity>> rowsByShop = new HashMap<>();
for (QueryAsinEntity row : queryAsinMapper.selectList(wrapper)) {
if (row.getShopName() == null) {
continue;
}
rowsByShop.computeIfAbsent(row.getShopName(), k -> new ArrayList<>()).add(row);
}
return rowsByShop;
}
public List<QueryAsinCountryAsinsDto> loadQueryAsinsForShop(Long userId, String shopName) {
validateUserId(userId);
String normalizedShopName = ziniaoShopSwitchService.normalizeShopName(shopName);
@@ -153,7 +171,9 @@ public class QueryAsinResolveService {
return List.of();
}
List<QueryAsinEntity> rows = queryAsinMapper.selectList(
new LambdaQueryWrapper<QueryAsinEntity>().orderByAsc(QueryAsinEntity::getId));
new LambdaQueryWrapper<QueryAsinEntity>()
.eq(QueryAsinEntity::getShopName, normalizedShopName)
.orderByAsc(QueryAsinEntity::getId));
return toCountryAsins(rows);
}