|
|
@@ -57,6 +57,9 @@ public class FsStoreUserEndCategoryScrmServiceImpl implements IFsStoreUserEndCat
|
|
|
if (categoryId == null) return new ArrayList<>();
|
|
|
List<Long> productIds = productUserEndCategoryMapper.selectDistinctProductIdsByCategoryId(categoryId, keyword);
|
|
|
if (productIds == null || productIds.isEmpty()) return new ArrayList<>();
|
|
|
+ long total = (productIds instanceof Page) ? ((Page<?>) productIds).getTotal() : productIds.size();
|
|
|
+ int pageNum = (productIds instanceof Page) ? ((Page<?>) productIds).getPageNum() : 1;
|
|
|
+ int pageSize = (productIds instanceof Page) ? ((Page<?>) productIds).getPageSize() : 10;
|
|
|
List<FsStoreProductScrm> products = fsStoreProductScrmMapper.getStoreProductInProductIds(productIds);
|
|
|
Map<Long, FsStoreProductScrm> productMap = products.stream().collect(Collectors.toMap(FsStoreProductScrm::getProductId, p -> p, (a, b) -> a));
|
|
|
List<FsStoreProductTagNameVO> tagNames = productTagRelationMapper.selectProductTagNamesByProductIds(productIds);
|
|
|
@@ -87,19 +90,31 @@ public class FsStoreUserEndCategoryScrmServiceImpl implements IFsStoreUserEndCat
|
|
|
vo.setTagList(tagMap.getOrDefault(pid, new ArrayList<>()));
|
|
|
result.add(vo);
|
|
|
}
|
|
|
- return result;
|
|
|
+ // 包装为 Page 以携带正确的 total,供 getDataTable 使用
|
|
|
+ Page<FsStoreUserEndCategoryProductVO> pageResult = new Page<>(pageNum, pageSize);
|
|
|
+ pageResult.setTotal(total);
|
|
|
+ pageResult.addAll(result);
|
|
|
+ return pageResult;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> listProductsForApp(Long id, String keyword, Integer pageNum, Integer pageSize) {
|
|
|
+ public Map<String, Object> listProductsForApp(Long id, String keyword, Integer pageNum, Integer pageSize, Long storeId, Integer position) {
|
|
|
Map<String, Object> out = new HashMap<>();
|
|
|
out.put("list", new ArrayList<FsStoreUserEndCategoryProductVO>());
|
|
|
out.put("total", 0L);
|
|
|
if (pageNum == null || pageSize == null || pageSize <= 0) return out;
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
- List<Long> productIds = (id != null && id != 0L)
|
|
|
- ? productUserEndCategoryMapper.selectDistinctProductIdsByCategoryId(id, keyword)
|
|
|
- : productUserEndCategoryMapper.selectDistinctProductIds(keyword);
|
|
|
+ List<Long> productIds;
|
|
|
+ if (position == null) {
|
|
|
+ position = 1;
|
|
|
+ }
|
|
|
+ if (position == 1 || position == 2) {
|
|
|
+ productIds = productUserEndCategoryMapper.selectDistinctProductIdsByPosition(id,storeId, position, keyword);
|
|
|
+ } else if (id != null && id != 0L) {
|
|
|
+ productIds = productUserEndCategoryMapper.selectDistinctProductIdsByCategoryId(id, keyword);
|
|
|
+ } else {
|
|
|
+ productIds = productUserEndCategoryMapper.selectDistinctProductIds(keyword);
|
|
|
+ }
|
|
|
long total = productIds instanceof Page ? ((Page<?>) productIds).getTotal() : (productIds != null ? productIds.size() : 0);
|
|
|
if (productIds == null || productIds.isEmpty()) {
|
|
|
out.put("total", total);
|