rk
2026-03-23 bf7b975c7ebe94ac801d72671cefc4d6ec01d56e
server/dmmall_service/src/main/java/com/doumee/service/business/impl/ShopcartServiceImpl.java
@@ -227,24 +227,21 @@
     * @param addCartGoodsRequest
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    @Transactional(rollbackFor = {Exception.class,BusinessException.class})
    public void addCart(AddCartGoodsRequest addCartGoodsRequest){
        //查询购物车是否存在当前选中的商品信息
        Shopcart shopcart = shopcartMapper.selectOne(new QueryWrapper<Shopcart>()
                .eq("MEMBER_ID",addCartGoodsRequest.getMemberId())
                .eq("GOODS_SKU_ID",addCartGoodsRequest.getGoodsSkuId())
        );
//        Goods goods = goodsMapper.selectById(addCartGoodsRequest.getGoodsId());
//        if(Objects.isNull(goods)){
//            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到商品信息");
//        }
//        if(!goods.getType().equals(Constants.ZERO)){
//            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"非商城商品无法加入购物车");
//        }
        GoodsSku goodsSku = goodsSkuMapper.selectById(addCartGoodsRequest.getGoodsSkuId());
        if(Objects.isNull(goodsSku)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到商品SKU信息");
        }
        Goods goods = goodsMapper.selectById(goodsSku.getGoodsId());
        if(Objects.isNull(goods)||!Constants.equalsInteger(goods.getStatus(),Constants.ZERO)||!Constants.equalsInteger(goods.getIsdeleted(),Constants.ZERO)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,商品已下架,无法加入购物车!");
        }
        if(!Objects.isNull(shopcart)){
            shopcart.setNum(shopcart.getNum() + addCartGoodsRequest.getNum());
            shopcart.setEditDate(new Date());