| | |
| | | if(!Constants.POINT_GOODS_STATUS.A.name().equals(p.getStatus())){ |
| | | throw new ValidationException("商品未上架"); |
| | | } |
| | | if(p.getStock()< dto.getNum()){ |
| | | if(p.getStock() <=0 || p.getStock()< dto.getNum()){ |
| | | throw new ValidationException("商品库存不足"); |
| | | } |
| | | CustomerPoint cp = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>() |
| | |
| | | //更新库存 |
| | | p.setStock(p.getStock()- dto.getNum()); |
| | | pointGoodsMapper.updateById(p); |
| | | }catch (Exception e){ |
| | | throw new ValidationException("兑换失败"); |
| | | }finally { |
| | | lockService.releaseObjectLock(key,""); |
| | | } |