总结
完成功能
1.店铺首页销售趋势图
2.后台商品管理
相关页面:
相关功能:
1.商品查询:
@GetMapping("/searchShopGoods")
public Result<?> searchShopGoods(@RequestParam Integer shopId,@RequestParam Integer goodsId,@RequestParam String goodsTitle,@RequestParam Integer shelfState,@RequestParam Integer id,@RequestParam Integer typeLevel,@RequestParam Integer currentPage){
QueryWrapper<Goods> queryWrapper=new QueryWrapper<>();
Page<Goods> objectPage=new Page<>(currentPage,5);
queryWrapper.eq("shop_id",shopId);
if(goodsId!=0){
queryWrapper.like("goods_id",goodsId);
}
if(!goodsTitle.equals("")){
queryWrapper.like("goods_title",goodsTitle);
}
if(shelfState!=-2){
System.out.println(shelfState);
queryWrapper.eq("shelf_state",shelfState);
}
if(typeLevel==1){//一级分类查询
QueryWrapper<SecondLevel> secondLevelQueryWrapper=new QueryWrapper<>();
secondLevelQueryWrapper.eq("father_id",id);
List<SecondLevel> list=secondLevelService.list(secondLevelQueryWrapper);
String str="";
for(int i=0;i<list.size();i++){
if(i<list.size()-1){
str+=list.get(i).getId()+",";
}else {
str+=list.get(i).getId();
}
}
System.out.println(str);
QueryWrapper<ThirdLevel> thirdLevelQueryWrapper=new QueryWrapper<>();
thirdLevelQueryWrapper.inSql("father_id",str);
List<ThirdLevel> thirdLevels=thirdLevelService.list(thirdLevelQueryWrapper);
String str1="";
for(int i=0;i<thirdLevels.size();i++){
if(i<thirdLevels.size()-1){
str1+=thirdLevels.get(i).getId()+",";
}else {
str1+=thirdLevels.get(i).getId();
}
}
System.out.println(str1);
queryWrapper.inSql("goods_type_id",str1);
}else if(typeLevel==2){//根据二级分类查询
QueryWrapper<ThirdLevel> thirdLevelQueryWrapper=new QueryWrapper<>();
thirdLevelQueryWrapper.eq("father_id",id);
List<ThirdLevel> thirdLevels=thirdLevelService.list(thirdLevelQueryWrapper);
String str1="";
for(int i=0;i<thirdLevels.size();i++){
if(i<thirdLevels.size()-1){
str1+=thirdLevels.get(i).getId()+",";
}else {
str1+=thirdLevels.get(i).getId();
}
}
System.out.println(str1);
queryWrapper.inSql("goods_type_id",str1);
}else if(typeLevel==3) {
queryWrapper.eq("goods_type_id", id);
}
List<Goods> list=goodsService.page(objectPage, queryWrapper).getRecords();
List<List<GoodsSpecifications>> goodsSpecificationsList=new ArrayList<>();
List<ThirdLevel> thirdLevels=new ArrayList<>();
for(Goods goods:list){
QueryWrapper<GoodsSpecifications> queryWrapper1=new QueryWrapper<>();
queryWrapper1.eq("goods_id",goods.getGoodsId());
List<GoodsSpecifications> goodsSpecificationsList1=goodsSpecificationsService.list(queryWrapper1);
thirdLevels.add(thirdLevelService.getById(goods.getGoodsTypeId()));
goodsSpecificationsList.add(goodsSpecificationsList1);
}
Map<String,Object> map=new HashMap<>();
map.put("page",goodsService.page(objectPage, queryWrapper));
map.put("goodsSpecificationsList",goodsSpecificationsList);
map.put("types", thirdLevels);
return Result.success(map);
}
2.商品上架:
//--------------上架商品-----------------
@PostMapping("/putOnShelf")
public Result<?> putOnShelf(@RequestBody List<Goods> goodsList){
for(Goods goods:goodsList){
UpdateWrapper<Goods> updateWrapper=new UpdateWrapper<>();
updateWrapper.eq("goods_id",goods.getGoodsId()).set("shelf_state",0);
goodsService.update(updateWrapper);
}
return Result.success();
}
3.商品下架:
//--------------下架商品-----------------
@PostMapping("/putOffShelf")
public Result<?> putOffShelf(@RequestBody List<Goods> goodsList){
for(Goods goods:goodsList){
UpdateWrapper<Goods> updateWrapper=new UpdateWrapper<>();
updateWrapper.eq("goods_id",goods.getGoodsId()).set("shelf_state",1);
goodsService.update(updateWrapper);
}
return Result.success();
}