From f249c277d066e151a84b766a6b82c3bbdbe1326b Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期二, 03 九月 2024 13:24:01 +0800 Subject: [PATCH] 1.优惠券-所有修改方法dto自传id 2.优惠券-积分-批量接口改成post方法 3.优惠券-定时任务-会员优惠券每月一号凌晨未使用自动过期 4.优惠券-优惠券下单接口 --- src/main/java/com/mzl/flower/service/point/PointGoodsService.java | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 43 insertions(+), 10 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..4c2ab59 100644 --- a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java +++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java @@ -24,6 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDate; import java.util.List; @Service @@ -70,8 +71,14 @@ return p.getId(); } - public void deletePointGoods(Long id){ - pointGoodsMapper.deleteById(id); + public void deletePointGoods(String idStr){ + List<String> ids = splitParam(idStr); + if (ids != null && ids.size() > 0) { + for(String idd : ids) { + Long id = Long.parseLong(idd); + pointGoodsMapper.deleteById(id); + } + } } public Page<PointGoodsListDTO> selectGoodsList(Page page, PointGoodsQueryDTO dto){ @@ -93,15 +100,21 @@ return dto; } - public void updateStatus(Long id, String status){ - PointGoods p = pointGoodsMapper.selectById(id); - if(p == null){ - throw new ValidationException("商品未找到"); - } + public void updateStatus(String idStr, String status){ + List<String> ids = splitParam(idStr); + if(ids != null && ids.size() > 0) { + for(String idd : ids) { + Long id = Long.parseLong(idd); + PointGoods p = pointGoodsMapper.selectById(id); + if (p == null) { + continue; + } - p.setStatus(status); - p.update(SecurityUtils.getUserId()); - pointGoodsMapper.updateById(p); + p.setStatus(status); + p.update(SecurityUtils.getUserId()); + pointGoodsMapper.updateById(p); + } + } } public synchronized void exchangeGoods(ExchangeGoodsDTO dto) { @@ -147,6 +160,8 @@ detail.setPoint(record.getTotalPoint()); detail.setChangeType(Constants.POINT_CHANGE_TYPE.reduce.name()); detail.setType(Constants.POINT_TYPE.exchange.name()); + detail.setRecordDate(LocalDate.now()); + detail.setRemarks(record.getName()); detail.create(SecurityUtils.getUserId()); customerPointDetailMapper.insert(detail); @@ -170,8 +185,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