|
@@ -264,21 +264,22 @@ public class ItemService {
|
|
|
continue;
|
|
|
}
|
|
|
List<Goods> tmpList = goodsMap.get(productId);
|
|
|
+ List<ItemGoodsVo> itemGoodsVoList = new ArrayList<>();
|
|
|
if (null == tmpList){
|
|
|
log.error("productId not Found in goodsMap, pid={}", productId);
|
|
|
- continue;
|
|
|
- }
|
|
|
- tmpList.sort(new Comparator<Goods>() {
|
|
|
- @Override
|
|
|
- public int compare(Goods o1, Goods o2) {
|
|
|
- return o1.getSort() - o2.getSort();
|
|
|
+ }else{
|
|
|
+ tmpList.sort(new Comparator<Goods>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Goods o1, Goods o2) {
|
|
|
+ return o1.getSort() - o2.getSort();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ for (Goods goods : tmpList) {
|
|
|
+ ItemGoodsVo itemGoodsVo = convert(goods);
|
|
|
+ itemGoodsVoList.add(itemGoodsVo);
|
|
|
}
|
|
|
- });
|
|
|
- List<ItemGoodsVo> itemGoodsVoList = new ArrayList<>();
|
|
|
- for (Goods goods : tmpList) {
|
|
|
- ItemGoodsVo itemGoodsVo = convert(goods);
|
|
|
- itemGoodsVoList.add(itemGoodsVo);
|
|
|
}
|
|
|
+
|
|
|
itemVo.setGoods(itemGoodsVoList);
|
|
|
itemVoList.add(itemVo);
|
|
|
}
|
|
@@ -330,6 +331,33 @@ public class ItemService {
|
|
|
return APIResult.ok(page);
|
|
|
}
|
|
|
|
|
|
+ public List<ItemVo> findPageByTagId(String tagId, String merchantId) {
|
|
|
+ MerchantProductTagRelation relation = new MerchantProductTagRelation();
|
|
|
+ relation.setTagId(tagId);
|
|
|
+ relation.setMerchantId(merchantId);
|
|
|
+ relation.setStatus(BaseStatusEnum.NORMAL);
|
|
|
+ Long total = merchantProductTagRelationRepository.count(relation);
|
|
|
+
|
|
|
+
|
|
|
+ List<ItemVo> result = new ArrayList<>();
|
|
|
+ // sort
|
|
|
+ LinkedHashMap<String, BaseOrderEnum> sort = new LinkedHashMap() { {
|
|
|
+ this.put("sort", BaseOrderEnum.ASC);
|
|
|
+ }};
|
|
|
+ List<MerchantProductTagRelation> relationList = merchantProductTagRelationRepository.find(relation, JpaSortUtil.sort(sort));
|
|
|
+ if (CollectionUtils.isEmpty(relationList)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> productIdList = new ArrayList<>();
|
|
|
+ for (MerchantProductTagRelation merchantProductTagRelation : relationList) {
|
|
|
+ String productId = merchantProductTagRelation.getPid();
|
|
|
+ productIdList.add(productId);
|
|
|
+ }
|
|
|
+ result = this.findByIds(merchantId, productIdList);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public static ItemVo convert(Course course) {
|
|
|
ItemVo itemVo = new ItemVo();
|
|
|
itemVo.setId(course.getId());
|