huliguo
2025-04-17 19df67e19f23cd2a04d1c7f355e1e656f4140af4
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/BannerController.java
@@ -52,37 +52,27 @@
    @GetMapping("/list")
   @ApiOperation(value = "banner列表", tags = {"小程序-banner"})
   public R<List<Banner>> list(@ApiParam("名称") String name,
                                @ApiParam("跳转类型(1=无跳转,2=外部链接,3=商品详情,4=秒杀商品详情,5=领券中心)") Integer jumpType,
                                @ApiParam("跳转类型(1=无跳转,2=外部链接,3=商品详情,4=秒杀商品详情)") Integer jumpType,
                                @ApiParam("位置(1=首页,2=商城首页)") Integer position){
        List<Banner> list = bannerService.lambdaQuery().like(StringUtils.isNotEmpty(name), Banner::getName, name)
                .eq(jumpType!=null,Banner::getJumpType, jumpType)
                .eq(position!=null,Banner::getPosition, position)
                .list();
        Integer vipId = 0;
        String token = SecurityUtils.getToken(ServletUtils.getRequest());
        if(StringUtils.isNotEmpty(token)){
            Long userid = tokenService.getLoginUserApplet().getUserid();
            AppUser appUser = appUserClient.getAppUserById(userid);
            vipId = appUser.getVipId();
        }
        for (Banner banner : list) {
            Integer jumpType1 = banner.getJumpType();
            //商品详情
            if(null != jumpType1 && 3 == jumpType1){
                Goods goods = goodsService.getById(banner.getContent());
                if(null == goods || goods.getDelFlag() == 1){
                    banner.setJumpType(1);
                } else if(!goods.getCommodityAuthority().contains("-1") && !goods.getCommodityAuthority().contains(vipId.toString())){
                    banner.setJumpType(1);
                    banner.setJumpType(1);//商品不存在
                }
            }
            //秒杀活动
            if(null != jumpType1 && 4 == jumpType1){
                SeckillActivityInfo activityInfo = seckillActivityInfoService.getById(banner.getContent());
                if(null == activityInfo || activityInfo.getDelFlag() == 1 || !activityInfo.getVipIds().contains(vipId.toString())){
                    banner.setJumpType(1);
                if(null == activityInfo || activityInfo.getDelFlag() == 1 ){
                    banner.setJumpType(1);//秒杀活动不存在
                }
            }
        }
        return R.ok(list);