| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | 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); |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |