From 3870d3720683df6eee99969380cd48c8d68b875d Mon Sep 17 00:00:00 2001 From: gongbiao Date: Tue, 30 Jul 2019 13:12:04 +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 --- .../service/impl/WxCouponChannelServiceImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 9d2d1fa8a..b04a16c40 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java @@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; @Service public class WxCouponChannelServiceImpl implements WxCouponChannelService { @@ -144,9 +145,15 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { record.setCouponId(null); } Long finalCouponId = couponId; - return wxCouponChannelMapper.findVoList(record).parallelStream() + List voList = wxCouponChannelMapper.findVoList(record).stream() .filter(wxCouponChannelVo -> !wxCouponChannelVo.getCouponId().equals(finalCouponId)) - .findAny().orElse(null); + .collect(Collectors.toList()); + if (!voList.isEmpty()) { + int size = voList.size() - 1; + Random random = new Random(); + return voList.get(random.nextInt(size)); + } + return null; } private boolean isCouponMerchantValid(Long couponId) {