|
@@ -192,51 +192,7 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
SecondGoodsRecommendVo item = mapper.querySecondGoodsDetail(goodsId, "user_" + phoneId, position);
|
|
SecondGoodsRecommendVo item = mapper.querySecondGoodsDetail(goodsId, "user_" + phoneId, position);
|
|
|
-
|
|
|
|
|
- if (item != null) {
|
|
|
|
|
- // 设置图片信息
|
|
|
|
|
- QueryWrapper<StoreImg> query = new QueryWrapper<>();
|
|
|
|
|
- query.lambda()
|
|
|
|
|
- .eq(StoreImg::getImgType, 18) // 商品 图片
|
|
|
|
|
- .eq(StoreImg::getDeleteFlag, 0)
|
|
|
|
|
- .eq(StoreImg::getStoreId, goodsId);
|
|
|
|
|
- List<StoreImg> storeImgs = storeImgMapper.selectList(query);
|
|
|
|
|
- // 设置图片信息
|
|
|
|
|
- if (storeImgs.size() > 0) {
|
|
|
|
|
- // 先按视频后缀排序,再按ImgSort排序
|
|
|
|
|
- String[] items = storeImgs.stream()
|
|
|
|
|
- .sorted((o1, o2) -> {
|
|
|
|
|
- boolean o1IsMp4 = isVideoUrl(o1.getImgUrl());
|
|
|
|
|
- boolean o2IsMp4 = isVideoUrl(o2.getImgUrl());
|
|
|
|
|
- // 如果都是.mp4或都不是.mp4,则按ImgSort排序
|
|
|
|
|
- if (o1IsMp4 && o2IsMp4 || !o1IsMp4 && !o2IsMp4) {
|
|
|
|
|
- return o1.getImgSort().compareTo(o2.getImgSort());
|
|
|
|
|
- }
|
|
|
|
|
- // 否则,.mp4的排在前面
|
|
|
|
|
- return o1IsMp4 ? -1 : 1;
|
|
|
|
|
- }).map(StoreImg::getImgUrl).toArray(String[]::new);
|
|
|
|
|
- item.setImgList(items);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 查看是否关注
|
|
|
|
|
- QueryWrapper<LifeFans> query1 = new QueryWrapper<>();
|
|
|
|
|
- query1.lambda()
|
|
|
|
|
- .eq(LifeFans::getFollowedId, item.getUserPhone()) // 商品图片
|
|
|
|
|
- .eq(LifeFans::getDeleteFlag, 0)
|
|
|
|
|
- .eq(LifeFans::getFansId, "user_" + phoneId);
|
|
|
|
|
- List<LifeFans> lifeFans = lifeFansMapper.selectList(query1);
|
|
|
|
|
- // 关注状态添加
|
|
|
|
|
- if (lifeFans.size() > 0) {
|
|
|
|
|
- item.setFansStatus(1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 距离拼接
|
|
|
|
|
- if (StringUtil.isNotBlank(item.getDist())) {
|
|
|
|
|
- item.setPosition("距离" + item.getDist() + "km");
|
|
|
|
|
- }
|
|
|
|
|
- item.setPrice(item.getAmount() != null ? item.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ applySecondGoodsDetailEnrichment(item, phoneId, goodsId);
|
|
|
return item;
|
|
return item;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("SecondRecommendServiceImpl.querySecondGoodsDetail Error Mgs={}", e.getMessage());
|
|
log.error("SecondRecommendServiceImpl.querySecondGoodsDetail Error Mgs={}", e.getMessage());
|
|
@@ -251,58 +207,57 @@ public class SecondRecommendServiceImpl extends ServiceImpl<SecondRecommendMappe
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
SecondGoodsRecommendVo item = mapper.querySecondGoodsDetail(goodsId, "user_" + phoneId, position);
|
|
SecondGoodsRecommendVo item = mapper.querySecondGoodsDetail(goodsId, "user_" + phoneId, position);
|
|
|
-
|
|
|
|
|
- if (item != null) {
|
|
|
|
|
- // 设置图片信息
|
|
|
|
|
- QueryWrapper<StoreImg> query = new QueryWrapper<>();
|
|
|
|
|
- query.lambda()
|
|
|
|
|
- .eq(StoreImg::getImgType, 18) // 商品 图片
|
|
|
|
|
- .eq(StoreImg::getDeleteFlag, 0)
|
|
|
|
|
- .eq(StoreImg::getStoreId, goodsId);
|
|
|
|
|
- List<StoreImg> storeImgs = storeImgMapper.selectList(query);
|
|
|
|
|
- // 设置图片信息
|
|
|
|
|
- if (storeImgs.size() > 0) {
|
|
|
|
|
- // 先按视频后缀排序,再按ImgSort排序
|
|
|
|
|
- String[] items = storeImgs.stream()
|
|
|
|
|
- .sorted((o1, o2) -> {
|
|
|
|
|
- boolean o1IsMp4 = isVideoUrl(o1.getImgUrl());
|
|
|
|
|
- boolean o2IsMp4 = isVideoUrl(o2.getImgUrl());
|
|
|
|
|
- // 如果都是.mp4或都不是.mp4,则按ImgSort排序
|
|
|
|
|
- if (o1IsMp4 && o2IsMp4 || !o1IsMp4 && !o2IsMp4) {
|
|
|
|
|
- return o1.getImgSort().compareTo(o2.getImgSort());
|
|
|
|
|
- }
|
|
|
|
|
- // 否则,.mp4的排在前面
|
|
|
|
|
- return o1IsMp4 ? -1 : 1;
|
|
|
|
|
- }).map(StoreImg::getImgUrl).toArray(String[]::new);
|
|
|
|
|
- item.setImgList(items);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 查看是否关注
|
|
|
|
|
- QueryWrapper<LifeFans> query1 = new QueryWrapper<>();
|
|
|
|
|
- query1.lambda()
|
|
|
|
|
- .eq(LifeFans::getFollowedId, item.getUserPhone()) // 商品图片
|
|
|
|
|
- .eq(LifeFans::getDeleteFlag, 0)
|
|
|
|
|
- .eq(LifeFans::getFansId, "user_" + phoneId);
|
|
|
|
|
- List<LifeFans> lifeFans = lifeFansMapper.selectList(query1);
|
|
|
|
|
- // 关注状态添加
|
|
|
|
|
- if (lifeFans.size() > 0) {
|
|
|
|
|
- item.setFansStatus(1);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 距离拼接
|
|
|
|
|
- if (StringUtil.isNotBlank(item.getDist())) {
|
|
|
|
|
- item.setPosition("距离" + item.getDist() + "km");
|
|
|
|
|
- }
|
|
|
|
|
- item.setPrice(item.getAmount() != null ? item.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ applySecondGoodsDetailEnrichment(item, phoneId, goodsId);
|
|
|
return item;
|
|
return item;
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.error("SecondRecommendServiceImpl.querySecondGoodsDetail Error Mgs={}", e.getMessage());
|
|
|
|
|
|
|
+ log.error("SecondRecommendServiceImpl.querySecondGoodsDetailWithOutJWT Error Mgs={}", e.getMessage());
|
|
|
throw new Exception(e);
|
|
throw new Exception(e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 二手商品详情公共填充:图片列表(含视频排序)、关注状态、距离文案、价格展示
|
|
|
|
|
+ */
|
|
|
|
|
+ private void applySecondGoodsDetailEnrichment(SecondGoodsRecommendVo item, String phoneId, Integer goodsId) {
|
|
|
|
|
+ if (item == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ QueryWrapper<StoreImg> query = new QueryWrapper<>();
|
|
|
|
|
+ query.lambda()
|
|
|
|
|
+ .eq(StoreImg::getImgType, 18) // 商品 图片
|
|
|
|
|
+ .eq(StoreImg::getDeleteFlag, 0)
|
|
|
|
|
+ .eq(StoreImg::getStoreId, goodsId);
|
|
|
|
|
+ List<StoreImg> storeImgs = storeImgMapper.selectList(query);
|
|
|
|
|
+ if (storeImgs.size() > 0) {
|
|
|
|
|
+ // 先按视频后缀排序,再按ImgSort排序
|
|
|
|
|
+ String[] imgArr = storeImgs.stream()
|
|
|
|
|
+ .sorted((o1, o2) -> {
|
|
|
|
|
+ boolean o1IsMp4 = isVideoUrl(o1.getImgUrl());
|
|
|
|
|
+ boolean o2IsMp4 = isVideoUrl(o2.getImgUrl());
|
|
|
|
|
+ if (o1IsMp4 && o2IsMp4 || !o1IsMp4 && !o2IsMp4) {
|
|
|
|
|
+ return o1.getImgSort().compareTo(o2.getImgSort());
|
|
|
|
|
+ }
|
|
|
|
|
+ return o1IsMp4 ? -1 : 1;
|
|
|
|
|
+ }).map(StoreImg::getImgUrl).toArray(String[]::new);
|
|
|
|
|
+ item.setImgList(imgArr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ QueryWrapper<LifeFans> query1 = new QueryWrapper<>();
|
|
|
|
|
+ query1.lambda()
|
|
|
|
|
+ .eq(LifeFans::getFollowedId, item.getUserPhone())
|
|
|
|
|
+ .eq(LifeFans::getDeleteFlag, 0)
|
|
|
|
|
+ .eq(LifeFans::getFansId, "user_" + phoneId);
|
|
|
|
|
+ List<LifeFans> lifeFans = lifeFansMapper.selectList(query1);
|
|
|
|
|
+ if (lifeFans.size() > 0) {
|
|
|
|
|
+ item.setFansStatus(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtil.isNotBlank(item.getDist())) {
|
|
|
|
|
+ item.setPosition("距离" + item.getDist() + "km");
|
|
|
|
|
+ }
|
|
|
|
|
+ item.setPrice(item.getAmount() != null ? item.getAmount().setScale(2, BigDecimal.ROUND_HALF_UP).toString() : null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
List<StoreImg> storeImgs = new ArrayList<>();
|
|
List<StoreImg> storeImgs = new ArrayList<>();
|
|
|
StoreImg storeImg = new StoreImg();
|
|
StoreImg storeImg = new StoreImg();
|