2021-09-15

2021/9/16 6:06:22

本文主要是介绍2021-09-15,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

总结

  • 完成功能
    • 1.店铺首页销售趋势图
    • 2.后台商品管理
      • 相关页面:
      • 相关功能:
        • 1.商品查询:
        • 2.商品上架:
        • 3.商品下架:

完成功能

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();
    }


这篇关于2021-09-15的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程