|
@@ -73,14 +73,24 @@ public class TagService {
|
|
|
}
|
|
|
|
|
|
public List<MerchantProduct> getMerchantProductList(String tagId, String merchantId) {
|
|
|
- List<MerchantProductTagRelation> relationList = merchantProductTagRelationService.findByTagId(tagId);
|
|
|
+ List<MerchantProductTagRelation> relationList = merchantProductTagRelationService.findByTagId(tagId, BaseStatusEnum.NORMAL);
|
|
|
if (CollectionUtils.isEmpty(relationList)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
List<String> productIdList = new ArrayList<>();
|
|
|
relationList.forEach(relation -> productIdList.add(relation.getPid()));
|
|
|
- return merchantProductRepository.findByPidsAndMerchantId(productIdList, merchantId);
|
|
|
+ List<MerchantProduct> merchantProductList = merchantProductRepository.findByPidsAndMerchantId(productIdList, merchantId);
|
|
|
+ Map<String, MerchantProduct> merchantProductMap = ListUtil.convert(merchantProductList, "pid", MerchantProduct.class);
|
|
|
+
|
|
|
+ List<MerchantProduct> sortMerchantProductList = new ArrayList<>();
|
|
|
+ for (String productId : productIdList) {
|
|
|
+ MerchantProduct merchantProduct = merchantProductMap.get(productId);
|
|
|
+ if (merchantProduct != null) {
|
|
|
+ sortMerchantProductList.add(merchantProduct);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sortMerchantProductList;
|
|
|
}
|
|
|
|
|
|
// 搜索标签
|
|
@@ -104,7 +114,7 @@ public class TagService {
|
|
|
String merchantId = tag.getMerchantId();
|
|
|
|
|
|
List<MerchantProduct> merchantProductList = getMerchantProductList(tagId, merchantId);
|
|
|
- tag.setProducts(merchantProductList);
|
|
|
+ tag.setProductList(merchantProductList);
|
|
|
return APIResult.ok(tag);
|
|
|
}
|
|
|
|
|
@@ -127,7 +137,7 @@ public class TagService {
|
|
|
merchantProductTagRelationService.updateByTagId(tagId, merchantId, productIdList);
|
|
|
|
|
|
List<MerchantProduct> merchantProductList = getMerchantProductList(tagId, merchantId);
|
|
|
- tag.setProducts(merchantProductList);
|
|
|
+ tag.setProductList(merchantProductList);
|
|
|
|
|
|
return APIResult.ok(tag);
|
|
|
}
|
|
@@ -143,7 +153,7 @@ public class TagService {
|
|
|
merchantProductTagRelationService.updateByTagId(tagId, merchantId, productIdList);
|
|
|
|
|
|
List<MerchantProduct> merchantProductList = getMerchantProductList(tagId, merchantId);
|
|
|
- tag.setProducts(merchantProductList);
|
|
|
+ tag.setProductList(merchantProductList);
|
|
|
|
|
|
return APIResult.ok(tag);
|
|
|
}
|