|
|
|
|
@@ -1,18 +1,47 @@
|
|
|
|
|
package com.peanut.modules.master.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.peanut.modules.common.dao.ShopProductDao;
|
|
|
|
|
import com.peanut.modules.common.entity.ShopProduct;
|
|
|
|
|
import com.peanut.modules.common.dao.*;
|
|
|
|
|
import com.peanut.modules.common.entity.*;
|
|
|
|
|
import com.peanut.modules.master.service.ShopProductService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service("masterShopProductService")
|
|
|
|
|
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProduct> implements ShopProductService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToBookLabelDao shopProductToBookLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductBookLabelDao shopProductBookLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToBookMarketDao shopProductToBookMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductBookMarketDao shopProductBookMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToMedicineLabelDao shopProductToMedicineLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductMedicineLabelDao shopProductMedicineLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToMedicineMarketDao shopProductToMedicineMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductMedicineMarketDao shopProductMedicineMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToSociologyLabelDao shopProductToSociologyLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductSociologyLabelDao shopProductSociologyLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToSociologyMarketDao shopProductToSociologyMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductSociologyMarketDao shopProductSociologyMarketDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getProductDetail(Integer productId) {
|
|
|
|
|
@@ -21,4 +50,190 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|
|
|
|
flag.put("detail",detail);
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getProductToLabel(Integer productId) {
|
|
|
|
|
HashMap<String, Object> flag = new HashMap<>();
|
|
|
|
|
//图书标签
|
|
|
|
|
List<Integer> bookLabelIds = shopProductToBookLabelDao.selectList(new LambdaQueryWrapper<ShopProductToBookLabel>().eq(ShopProductToBookLabel::getProductId, productId)).stream().map(ShopProductToBookLabel::getBookLabelId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductBookLabel> shopProductBookLabels = shopProductBookLabelDao.selectList(null);
|
|
|
|
|
List<ShopProductBookLabel> bookLabel = shopProductBookLabels.stream().filter((shopProductBookLabel -> shopProductBookLabel.getPid() == 0))
|
|
|
|
|
.map((l) -> {
|
|
|
|
|
if(l.getIsLast()==1){
|
|
|
|
|
l.setSelect(bookLabelIds.contains(l.getId()));
|
|
|
|
|
}
|
|
|
|
|
l.setChildren(getBookLabelChildrens(l, shopProductBookLabels,bookLabelIds));
|
|
|
|
|
return l;
|
|
|
|
|
}).sorted((label1,label2)->{
|
|
|
|
|
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("bookLabel",bookLabel);
|
|
|
|
|
//图书运营标签
|
|
|
|
|
List<Integer> bookMarketIds = shopProductToBookMarketDao.selectList(new LambdaQueryWrapper<ShopProductToBookMarket>().eq(ShopProductToBookMarket::getProductId, productId)).stream().map(ShopProductToBookMarket::getBookMarketId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductBookMarket> shopProductBookMarkets = shopProductBookMarketDao.selectList(null);
|
|
|
|
|
List<ShopProductBookMarket> bookMarket = shopProductBookMarkets.stream().filter(shopProductBookMarket -> shopProductBookMarket.getPid() == 0)
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(bookMarketIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getBookMarketChildrens(m, shopProductBookMarkets, bookMarketIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("bookMarket",bookMarket);
|
|
|
|
|
//国学标签
|
|
|
|
|
List<Integer> sociologyLabelIds = shopProductToSociologyLabelDao.selectList(new LambdaQueryWrapper<ShopProductToSociologyLabel>().eq(ShopProductToSociologyLabel::getProductId, productId)).stream().map(ShopProductToSociologyLabel::getSociologyLabelId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductSociologyLabel> shopProductSociologyLabels = shopProductSociologyLabelDao.selectList(null);
|
|
|
|
|
List<ShopProductSociologyLabel> sociologyLabel = shopProductSociologyLabels.stream().filter(m -> m.getPid() == 0)
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(sociologyLabelIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getSociologyLabelChildrens(m, shopProductSociologyLabels, sociologyLabelIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("sociologyLabel",sociologyLabel);
|
|
|
|
|
//国学运营标签
|
|
|
|
|
List<Integer> sociologyMarketIds = shopProductToSociologyMarketDao.selectList(new LambdaQueryWrapper<ShopProductToSociologyMarket>().eq(ShopProductToSociologyMarket::getProductId, productId)).stream().map(ShopProductToSociologyMarket::getSociologyMarketId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductSociologyMarket> shopProductSociologyMarkets = shopProductSociologyMarketDao.selectList(null);
|
|
|
|
|
List<ShopProductSociologyMarket> sociologyMarket = shopProductSociologyMarkets.stream().filter(m -> m.getPid() == 0)
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(sociologyMarketIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getSociologyMarketChildrens(m, shopProductSociologyMarkets, sociologyMarketIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("sociologyMarket",sociologyMarket);
|
|
|
|
|
//医学标签
|
|
|
|
|
List<Integer> medicineLabelIds = shopProductToMedicineLabelDao.selectList(new LambdaQueryWrapper<ShopProductToMedicineLabel>().eq(ShopProductToMedicineLabel::getProductId, productId)).stream().map(ShopProductToMedicineLabel::getMedicineLabelId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductMedicineLabel> shopProductMedicineLabels = shopProductMedicineLabelDao.selectList(null);
|
|
|
|
|
List<ShopProductMedicineLabel> medicineLabel = shopProductMedicineLabels.stream().filter(m -> m.getPid() == 0)
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(medicineLabelIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getMedicineLabelChildrens(m, shopProductMedicineLabels, medicineLabelIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("medicineLabel",medicineLabel);
|
|
|
|
|
//医学运营标签
|
|
|
|
|
List<Integer> medicineMarketIds = shopProductToMedicineMarketDao.selectList(new LambdaQueryWrapper<ShopProductToMedicineMarket>().eq(ShopProductToMedicineMarket::getProductId, productId)).stream().map(ShopProductToMedicineMarket::getMedicineMarketId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductMedicineMarket> shopProductMedicineMarkets = shopProductMedicineMarketDao.selectList(null);
|
|
|
|
|
List<ShopProductMedicineMarket> medicineMarket = shopProductMedicineMarkets.stream().filter(m -> m.getPid() == 0)
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(medicineMarketIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getMedicineMarketChildrens(m, shopProductMedicineMarkets, medicineMarketIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("medicineMarket",medicineMarket);
|
|
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ShopProductBookLabel> getBookLabelChildrens(ShopProductBookLabel root,List<ShopProductBookLabel> all,List<Integer> bookLabelIds){
|
|
|
|
|
List<ShopProductBookLabel> children = all.stream().filter(shopProductBookLabel -> {
|
|
|
|
|
return root.getId().equals(shopProductBookLabel.getPid());
|
|
|
|
|
}).map(l -> {
|
|
|
|
|
if(l.getIsLast()==1){
|
|
|
|
|
l.setSelect(bookLabelIds.contains(l.getId()));
|
|
|
|
|
}
|
|
|
|
|
l.setChildren(getBookLabelChildrens(l, all,bookLabelIds));
|
|
|
|
|
return l;
|
|
|
|
|
}).sorted((label1,label2)->{
|
|
|
|
|
return (label1.getSort()==null?0:label1.getSort()) - (label2.getSort()==null?0:label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ShopProductBookMarket> getBookMarketChildrens(ShopProductBookMarket market,List<ShopProductBookMarket> all,List<Integer> bookMarketIds){
|
|
|
|
|
List<ShopProductBookMarket> children = all.stream().filter((m) -> {
|
|
|
|
|
return m.getPid().equals(market.getId());
|
|
|
|
|
})
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(bookMarketIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getBookMarketChildrens(m, all, bookMarketIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ShopProductSociologyLabel> getSociologyLabelChildrens(ShopProductSociologyLabel root,List<ShopProductSociologyLabel> all,List<Integer> ids){
|
|
|
|
|
List<ShopProductSociologyLabel> children = all.stream().filter((m) -> {
|
|
|
|
|
return m.getPid().equals(root.getId());
|
|
|
|
|
})
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(ids.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getSociologyLabelChildrens(m, all, ids));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ShopProductSociologyMarket> getSociologyMarketChildrens(ShopProductSociologyMarket root,List<ShopProductSociologyMarket> all,List<Integer> ids){
|
|
|
|
|
List<ShopProductSociologyMarket> children = all.stream().filter((m) -> {
|
|
|
|
|
return m.getPid().equals(root.getId());
|
|
|
|
|
})
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(ids.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getSociologyMarketChildrens(m, all, ids));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ShopProductMedicineLabel> getMedicineLabelChildrens(ShopProductMedicineLabel root,List<ShopProductMedicineLabel> all,List<Integer> ids){
|
|
|
|
|
List<ShopProductMedicineLabel> children = all.stream().filter((m) -> {
|
|
|
|
|
return m.getPid().equals(root.getId());
|
|
|
|
|
})
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(ids.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getMedicineLabelChildrens(m, all, ids));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ShopProductMedicineMarket> getMedicineMarketChildrens(ShopProductMedicineMarket root,List<ShopProductMedicineMarket> all,List<Integer> ids){
|
|
|
|
|
List<ShopProductMedicineMarket> children = all.stream().filter((m) -> {
|
|
|
|
|
return m.getPid().equals(root.getId());
|
|
|
|
|
})
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(ids.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getMedicineMarketChildrens(m, all, ids));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|