首页 > 其他分享 >lilishop 直播间添加商品方法

lilishop 直播间添加商品方法

时间:2022-09-20 20:00:51浏览次数:39  
标签:直播间 Integer goodsId 添加 studio new lilishop roomId

Request URL: https://store-api.ql65.cn/store/broadcast/studio/push/1/2
Request Method: PUT
Status Code: 400
Remote Address: 106.55.23.36:443
Referrer Policy: strict-origin-when-cross-origin

 

 1  @ApiOperation(value = "店铺直播间添加商品")
 2     @ApiImplicitParams({
 3             @ApiImplicitParam(name = "roomId", value = "房间ID", required = true, dataType = "Integer", paramType = "path"),
 4             @ApiImplicitParam(name = "liveGoodsId", value = "直播商品ID", required = true, dataType = "Integer", paramType = "path")
 5     })
 6     @PutMapping(value = "/push/{roomId}/{liveGoodsId}")
 7     public ResultMessage<Studio> push(@PathVariable Integer roomId, @PathVariable Integer liveGoodsId) {
 8         String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
 9         if (Boolean.TRUE.equals(studioService.push(roomId, liveGoodsId, storeId))) {
10             return ResultUtil.success(ResultCode.SUCCESS);
11         }
12         throw new ServiceException(ResultCode.ERROR);
13     }

 

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean push(Integer roomId, Integer goodsId, String storeId) {

        //判断直播间是否已添加商品
        if (studioCommodityService.getOne(
                new LambdaQueryWrapper<StudioCommodity>().eq(StudioCommodity::getRoomId, roomId)
                        .eq(StudioCommodity::getGoodsId, goodsId)) != null) {
            throw new ServiceException(ResultCode.STODIO_GOODS_EXIST_ERROR);
        }

//        Goods goods = goodsService.getOne(new LambdaQueryWrapper<Goods>().eq(Goods::getId, goodsId).eq(Goods::getStoreId, storeId));
//        if (goods == null) {
//            throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
//        }
       

        //调用微信接口添加直播间商品并进行记录
        if (Boolean.TRUE.equals(wechatLivePlayerUtil.pushGoods(roomId, goodsId))) {
            studioCommodityService.save(new StudioCommodity(roomId, goodsId));
            //添加直播间商品数量
            Studio studio = this.getByRoomId(roomId);
            studio.setRoomGoodsNum(studio.getRoomGoodsNum() != null ? studio.getRoomGoodsNum() + 1 : 1);
            //设置直播间默认的商品(前台展示)只展示两个
            if (studio.getRoomGoodsNum() < 3) {
                studio.setRoomGoodsList(JSONUtil.toJsonStr(commodityMapper.getSimpleCommodityByRoomId(roomId)));
            }
            return this.updateById(studio);
        }
        return false;
    }

上面这段 Goods有问题,应该用直播商品才对。

 

 

 

标签:直播间,Integer,goodsId,添加,studio,new,lilishop,roomId
From: https://www.cnblogs.com/Bruce_H21/p/16712289.html

相关文章