From 29edae4968427630f3a1b79c073c34fcaf420dc7 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Tue, 30 Jul 2019 15:21:33 +0800 Subject: [PATCH] =?UTF-8?q?[C=E7=AB=AF=E9=A6=96=E9=A1=B5][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9][=E6=8D=A2=E4=B8=80=E6=8D=A2=E6=8B=BC=E5=9B=A2?= =?UTF-8?q?=E5=92=8C=E7=A0=8D=E4=BB=B7]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WxCouponChannelServiceImpl.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java index c8a5a0664..9b5b86653 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -144,16 +144,20 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { couponId = record.getCouponId(); record.setCouponId(null); } + List voList = wxCouponChannelMapper.findVoList(record); + if (voList.isEmpty()) { + return null; + } + if (voList.size() == 1) { + return voList.get(0); + } Long finalCouponId = couponId; - List voList = wxCouponChannelMapper.findVoList(record).stream() + voList = voList.stream() .filter(wxCouponChannelVo -> !wxCouponChannelVo.getCouponId().equals(finalCouponId)) .collect(Collectors.toList()); - if (!voList.isEmpty()) { - int size = voList.size(); - Random random = new Random(); - return voList.get(random.nextInt(size)); - } - return null; + int size = voList.size(); + Random random = new Random(); + return voList.get(random.nextInt(size)); } private boolean isCouponMerchantValid(Long couponId) {