From 11c95afd1e44bcd3d70dbcf77e790596ec80a53e Mon Sep 17 00:00:00 2001
From: cloudroam <cloudroam>
Date: 星期二, 24 九月 2024 18:54:59 +0800
Subject: [PATCH] fix: 剔除加价限制条件
---
src/main/java/com/mzl/flower/service/point/PointGoodsService.java | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
index 28efa42..e56ab9f 100644
--- a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
+++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
@@ -143,7 +143,7 @@
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>()
@@ -190,8 +190,6 @@
//更新库存
p.setStock(p.getStock()- dto.getNum());
pointGoodsMapper.updateById(p);
- }catch (Exception e){
- throw new ValidationException("兑换失败");
}finally {
lockService.releaseObjectLock(key,"");
}
@@ -220,6 +218,7 @@
record.setOrderId(orderId);
pointGoodsRecordMapper.updateById(record);
}
+
public void revertExchangeGoods(Long recordId) {
PointGoodsRecord record = pointGoodsRecordMapper.selectById(recordId);
if(record == null){
@@ -228,7 +227,7 @@
if(!Constants.POINT_GOODS_RECORD_STATUS.U.name().equals(record.getStatus())){
throw new ValidationException("兑换券未使用或过期");
}
- if(!SecurityUtils.getUserId().equals(record.getUserId())){
+ if(SecurityUtils.getUserId() != null && !SecurityUtils.getUserId().equals(record.getUserId())){
throw new ValidationException("兑换券不属于当前用户");
}
record.setStatus(Constants.POINT_GOODS_RECORD_STATUS.A.name());
--
Gitblit v1.9.3