|
|
|
|
@@ -52,6 +52,14 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductSociologyMarketDao shopProductSociologyMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToPsycheLabelDao shopProductToPsycheLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductPsycheLabelDao shopProductPsycheLabelDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductToPsycheMarketDao shopProductToPsycheMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductPsycheMarketDao shopProductPsycheMarketDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ShopProductBookDao shopProductBookDao;
|
|
|
|
|
@Autowired
|
|
|
|
|
private BookDao bookDao;
|
|
|
|
|
@@ -149,6 +157,44 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|
|
|
|
shopProductToSociologyMarketDao.delete(new LambdaQueryWrapper<ShopProductToSociologyMarket>().eq(ShopProductToSociologyMarket::getProductId,product).eq(ShopProductToSociologyMarket::getSociologyMarketId,marketId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void bindProductAndPsycheLabel(String[] productIds, Integer labelId) {
|
|
|
|
|
for (String p : productIds){
|
|
|
|
|
Integer integer = shopProductToPsycheLabelDao.selectCount(new LambdaQueryWrapper<ShopProductToPsycheLabel>().eq(ShopProductToPsycheLabel::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheLabel::getPsycheLabelId, labelId));
|
|
|
|
|
if(integer>0){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ShopProductToPsycheLabel shopProductToPsycheLabel = new ShopProductToPsycheLabel();
|
|
|
|
|
shopProductToPsycheLabel.setProductId(Integer.valueOf(p));
|
|
|
|
|
shopProductToPsycheLabel.setPsycheLabelId(labelId);
|
|
|
|
|
shopProductToPsycheLabelDao.insert(shopProductToPsycheLabel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void unbindProductAndPsycheLabel(int productId, int labelId) {
|
|
|
|
|
shopProductToPsycheLabelDao.delete(new LambdaQueryWrapper<ShopProductToPsycheLabel>().eq(ShopProductToPsycheLabel::getProductId, productId).eq(ShopProductToPsycheLabel::getPsycheLabelId, labelId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void bindProductAndPsycheMarket(String[] productId, int marketId) {
|
|
|
|
|
for (String p:productId){
|
|
|
|
|
Integer integer = shopProductToPsycheMarketDao.selectCount(new LambdaQueryWrapper<ShopProductToPsycheMarket>().eq(ShopProductToPsycheMarket::getProductId, Integer.valueOf(p)).eq(ShopProductToPsycheMarket::getPsycheMarketId, marketId));
|
|
|
|
|
if(integer>0){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
ShopProductToPsycheMarket shopProductToPsycheMarket = new ShopProductToPsycheMarket();
|
|
|
|
|
shopProductToPsycheMarket.setProductId(Integer.valueOf(p));
|
|
|
|
|
shopProductToPsycheMarket.setPsycheMarketId(marketId);
|
|
|
|
|
shopProductToPsycheMarketDao.insert(shopProductToPsycheMarket);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void unbindProductAndPsycheMarket(int product, int marketId) {
|
|
|
|
|
shopProductToPsycheMarketDao.delete(new LambdaQueryWrapper<ShopProductToPsycheMarket>().eq(ShopProductToPsycheMarket::getProductId,product).eq(ShopProductToPsycheMarket::getPsycheMarketId,marketId));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void bindProductAndMedicineLabel(String[] productId, int labelId) {
|
|
|
|
|
for (String p : productId){
|
|
|
|
|
@@ -405,7 +451,34 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("medicineMarket",medicineMarket);
|
|
|
|
|
|
|
|
|
|
//心理学标签
|
|
|
|
|
List<Integer> psycheLabelIds = shopProductToPsycheLabelDao.selectList(new LambdaQueryWrapper<ShopProductToPsycheLabel>().eq(ShopProductToPsycheLabel::getProductId, productId)).stream().map(ShopProductToPsycheLabel::getPsycheLabelId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductPsycheLabel> shopProductPsycheLabels = shopProductPsycheLabelDao.selectList(null);
|
|
|
|
|
List<ShopProductPsycheLabel> psycheLabel = shopProductPsycheLabels.stream().filter(m -> m.getPid() == 0)
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(psycheLabelIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getPsycheLabelChildrens(m, shopProductPsycheLabels, psycheLabelIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("psycheLabel",psycheLabel);
|
|
|
|
|
//心理学运营标签
|
|
|
|
|
List<Integer> psycheMarketIds = shopProductToPsycheMarketDao.selectList(new LambdaQueryWrapper<ShopProductToPsycheMarket>().eq(ShopProductToPsycheMarket::getProductId, productId)).stream().map(ShopProductToPsycheMarket::getPsycheMarketId).collect(Collectors.toList());
|
|
|
|
|
List<ShopProductPsycheMarket> shopProductPsycheMarkets = shopProductPsycheMarketDao.selectList(null);
|
|
|
|
|
List<ShopProductPsycheMarket> psycheMarket = shopProductPsycheMarkets.stream().filter(m -> m.getPid() == 0)
|
|
|
|
|
.map((m) -> {
|
|
|
|
|
if (m.getIsLast() == 1) {
|
|
|
|
|
m.setSelect(psycheMarketIds.contains(m.getId()));
|
|
|
|
|
}
|
|
|
|
|
m.setChildren(getPsycheMarketChildrens(m, shopProductPsycheMarkets, psycheMarketIds));
|
|
|
|
|
return m;
|
|
|
|
|
}).sorted((label1, label2) -> {
|
|
|
|
|
return (label1.getSort() == null ? 0 : label1.getSort()) - (label2.getSort() == null ? 0 : label2.getSort());
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
flag.put("psycheMarket",psycheMarket);
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -503,4 +576,35 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return children;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ShopProductPsycheLabel> getPsycheLabelChildrens(ShopProductPsycheLabel root,List<ShopProductPsycheLabel> all,List<Integer> ids){
|
|
|
|
|
List<ShopProductPsycheLabel> 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(getPsycheLabelChildrens(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<ShopProductPsycheMarket> getPsycheMarketChildrens(ShopProductPsycheMarket root,List<ShopProductPsycheMarket> all,List<Integer> ids){
|
|
|
|
|
List<ShopProductPsycheMarket> 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(getPsycheMarketChildrens(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|