class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity> implements CommodityService {

    @Autowired
    private WechatLivePlayerUtil wechatLivePlayerUtil;
    @Autowired
    private GoodsSkuService goodsSkuService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addCommodity(List<Commodity> commodityList) {<FILL_FUNCTION_BODY>}

    private void checkCommodity(Commodity commodity) {
        //商品是否审核通过
        GoodsSku goodsSku = goodsSkuService.getById(commodity.getSkuId());
        if (!goodsSku.getAuthFlag().equals(GoodsAuthEnum.PASS.name())) {
            throw new ServiceException(goodsSku.getGoodsName() + " 未审核通过，不能添加直播商品");
        }
        //是否已添加规格商品
        if (this.count(new LambdaQueryWrapper<Commodity>().eq(Commodity::getSkuId, commodity.getSkuId())) > 0) {
            throw new ServiceException(goodsSku.getGoodsName() + " 已添加规格商品，无法重复增加");
        }
    }

    @Override
    public boolean deleteCommodity(String goodsId) {
        AuthUser currentUser = UserContext.getCurrentUser();
        if (currentUser == null || (currentUser.getRole().equals(UserEnums.STORE) && currentUser.getStoreId() == null)) {
            throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
        }
        JSONObject json = wechatLivePlayerUtil.deleteGoods(goodsId);
        if ("0".equals(json.getStr("errcode"))) {
            return this.remove(new LambdaQueryWrapper<Commodity>().eq(Commodity::getLiveGoodsId, goodsId).eq(Commodity::getStoreId, currentUser.getStoreId()));
        }
        return false;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void getGoodsWareHouse() {
        //查询审核中的商品
        List<String> goodsIdList = this.baseMapper.getAuditCommodity();
        if (!goodsIdList.isEmpty()) {
            //同步状态
            JSONObject json = wechatLivePlayerUtil.getGoodsWareHouse(goodsIdList);
            //修改状态
            List<CommodityDTO> commodityDTOList = JSONUtil.toList((JSONArray) json.get("goods"), CommodityDTO.class);
            for (CommodityDTO commodityDTO : commodityDTOList) {
                //修改审核状态
                this.update(new LambdaUpdateWrapper<Commodity>()
                        .eq(Commodity::getLiveGoodsId, commodityDTO.getGoods_id())
                        .set(Commodity::getAuditStatus, commodityDTO.getAudit_status()));
            }
        }
    }

    @Override
    public IPage<CommodityVO> commodityList(PageVO pageVO, String name, String auditStatus) {
        return this.baseMapper.commodityVOList(PageUtil.initPage(pageVO),
                new QueryWrapper<CommodityVO>().like(name != null, "c.name", name)
                        .eq(auditStatus != null, "c.audit_status", auditStatus)
                        .eq(Objects.requireNonNull(UserContext.getCurrentUser()).getRole().equals(UserEnums.STORE), "c.store_id", UserContext.getCurrentUser().getStoreId())
                        .orderByDesc("create_time"));
    }

    @Override
    public List<Commodity> getCommodityByRoomId(Integer roomId) {
        return this.baseMapper.getCommodityByRoomId(roomId);
    }

    @Override
    public List<String> getSimpleCommodityByRoomId(Integer roomId) {
        return this.baseMapper.getSimpleCommodityByRoomId(roomId);
    }
}

        String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
        for (Commodity commodity : commodityList) {
            //检测直播商品
            checkCommodity(commodity);
            commodity.setStoreId(storeId);
            //添加直播商品
            JSONObject json = wechatLivePlayerUtil.addGoods(commodity);
            if (!"0".equals(json.getStr("errcode"))) {
                log.error(json.getStr("errmsg"));
                throw new ServiceException(ResultCode.COMMODITY_ERROR);
            }
            commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId")));
            commodity.setAuditId(json.getStr("auditId"));
            //默认为待审核状态
            commodity.setAuditStatus("0");
            this.save(commodity);
        }
        return true;
    
<no_super_class>