From 91ef154afb85113d7761ca7f95aef92f5557a534 Mon Sep 17 00:00:00 2001 From: gongzuming <gongzuming> Date: 星期四, 29 八月 2024 16:05:59 +0800 Subject: [PATCH] 退还兑换券 --- src/main/java/com/mzl/flower/service/point/PointGoodsService.java | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 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 da76c43..9e408ea 100644 --- a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java +++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java @@ -170,8 +170,26 @@ if(!Constants.POINT_GOODS_RECORD_STATUS.A.name().equals(record.getStatus())){ throw new ValidationException("兑换券已使用或过期"); } + if(!SecurityUtils.getUserId().equals(record.getUserId())){ + throw new ValidationException("兑换券不属于当前用户"); + } record.setStatus(Constants.POINT_GOODS_RECORD_STATUS.U.name()); record.setOrderId(orderId); pointGoodsRecordMapper.updateById(record); } + public void revertExchangeGoods(Long recordId) { + PointGoodsRecord record = pointGoodsRecordMapper.selectById(recordId); + if(record == null){ + throw new ValidationException("兑换券不存在"); + } + if(!Constants.POINT_GOODS_RECORD_STATUS.U.name().equals(record.getStatus())){ + throw new ValidationException("兑换券未使用或过期"); + } + if(!SecurityUtils.getUserId().equals(record.getUserId())){ + throw new ValidationException("兑换券不属于当前用户"); + } + record.setStatus(Constants.POINT_GOODS_RECORD_STATUS.A.name()); + record.setOrderId(null); + pointGoodsRecordMapper.updateById(record); + } } -- Gitblit v1.9.3