|
|
@@ -47,14 +47,16 @@ public class AirDropService {
|
|
|
throw new BusinessException("空投数量不能超过300");
|
|
|
if (AirDropType.coupon == record.getType()) {
|
|
|
Coupon coupon = couponRepo.findById(record.getCouponId()).orElseThrow(new BusinessException("兑换券不存在"));
|
|
|
- record.getUserIds().stream().parallel().forEach(userId -> {
|
|
|
- UserCoupon userCoupon = new UserCoupon();
|
|
|
- BeanUtils.copyProperties(coupon, userCoupon);
|
|
|
- userCoupon.setId(null);
|
|
|
- userCoupon.setCouponId(coupon.getId());
|
|
|
- userCoupon.setUserId(userId);
|
|
|
- userCouponRepo.save(userCoupon);
|
|
|
- });
|
|
|
+ for (DropTarget target : record.getTargets()) {
|
|
|
+ for (int i = 0; i < target.getNum(); i++) {
|
|
|
+ UserCoupon userCoupon = new UserCoupon();
|
|
|
+ BeanUtils.copyProperties(coupon, userCoupon);
|
|
|
+ userCoupon.setId(null);
|
|
|
+ userCoupon.setCouponId(coupon.getId());
|
|
|
+ userCoupon.setUserId(target.getUserId());
|
|
|
+ userCouponRepo.save(userCoupon);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
Collection collection = collectionRepo.findById(record.getCollectionId())
|
|
|
.orElseThrow(new BusinessException("藏品不存在"));
|