This commit is contained in:
wangjinlei
2023-09-27 15:57:35 +08:00
parent 1755a78a8d
commit c3ba1d9691
9 changed files with 144 additions and 12 deletions

View File

@@ -1,6 +1,10 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.peanut.common.utils.ExcludeEmptyQueryWrapper;
import com.peanut.modules.book.entity.ShopCategoryEntity;
import com.peanut.modules.book.entity.ShopProudictBookEntity;
import com.peanut.modules.book.service.ShopProudictBookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -20,6 +24,7 @@ import com.peanut.modules.book.service.ShopProductService;
@Service("shopProductService")
public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProductEntity> implements ShopProductService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
String userid = (String) params.get("userid");
@@ -73,7 +78,6 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
new Query<ShopProductEntity>().getPage(params),
new QueryWrapper<ShopProductEntity>().orderByDesc("sum_sales")
);
System.out.println("page"+page);
return new PageUtils(page);
}
@@ -86,4 +90,5 @@ public class ShopProductServiceImpl extends ServiceImpl<ShopProductDao, ShopProd
return new PageUtils(page);
}
}

View File

@@ -1,4 +1,5 @@
package com.peanut.modules.book.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -82,5 +83,30 @@ public class ShopProudictBookServiceImpl extends ServiceImpl<ShopProudictBookDa
return ids;
}
@Override
public Integer getProductByBookId(Integer bookId) {
LambdaQueryWrapper<ShopProudictBookEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ShopProudictBookEntity::getBookId,bookId);
wrapper.eq(ShopProudictBookEntity::getDelFlag,0);
wrapper.groupBy(ShopProudictBookEntity::getProudictId);
List<ShopProudictBookEntity> shopProudictBookEntities = this.getBaseMapper().selectList(wrapper);
List ids = new ArrayList();
for (ShopProudictBookEntity s : shopProudictBookEntities){
ids.add(s.getProudictId());
}
if(ids.size()==0){
return null;
}
LambdaQueryWrapper<ShopProductEntity> wrapper1 = new LambdaQueryWrapper<>();
wrapper1.eq(ShopProductEntity::getDelFlag,0);
wrapper1.in(ShopProductEntity::getProductId,ids);
wrapper1.orderByAsc(ShopProductEntity::getPrice);
wrapper1.last("limit 1");
List<ShopProductEntity> shopProductEntities = shopProductService.getBaseMapper().selectList(wrapper1);
ShopProductEntity shopProductEntity = shopProductEntities.get(0);
return shopProductEntity.getProductId();
}
}