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) {