|
|
@@ -167,6 +167,11 @@ public class MintOrderService {
|
|
|
if (!mintActivity.isOnShelf()) {
|
|
|
throw new BusinessException("活动已下架");
|
|
|
}
|
|
|
+ if (mintActivity.getHoldingTags() != null && !mintActivity.getHoldingTags().isEmpty()) {
|
|
|
+ if (!checkHolding(user.getId(), mintActivity)) {
|
|
|
+ throw new BusinessException("您不满足参与条件");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
UserAddress userAddress = null;
|
|
|
if (addressId != null) {
|
|
|
@@ -340,6 +345,11 @@ public class MintOrderService {
|
|
|
// if (!mintActivity.isOnShelf()) {
|
|
|
// throw new BusinessException("活动已下架");
|
|
|
// }
|
|
|
+ if (mintActivity.getHoldingTags() != null && !mintActivity.getHoldingTags().isEmpty()) {
|
|
|
+ if (!checkHolding(user.getId(), mintActivity)) {
|
|
|
+ throw new BusinessException("您不满足参与条件");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
UserAddress userAddress = null;
|
|
|
if (addressId != null) {
|
|
|
@@ -492,7 +502,7 @@ public class MintOrderService {
|
|
|
.type(AirDropType.asset)
|
|
|
.userIds(Collections.singletonList(mintOrder.getUserId()))
|
|
|
.collectionId(mintActivity.getAirDropCollectionId())
|
|
|
- .targets(Collections.singletonList(new DropTarget(user.getId(), user.getPhone(), user.getNickname(), 1)))
|
|
|
+ .targets(Collections.singletonList(new DropTarget(user.getId(), user.getPhone(), user.getNickname(), mintActivity.getAutoDropNum())))
|
|
|
.auto(true)
|
|
|
.companyId(mintActivity.getCompanyId())
|
|
|
.build());
|
|
|
@@ -808,4 +818,25 @@ public class MintOrderService {
|
|
|
public void releaseOrderLock(Long orderId) {
|
|
|
redisTemplate.delete(RedisKeys.MINT_ORDER_LOCK + orderId);
|
|
|
}
|
|
|
+
|
|
|
+ public boolean checkHolding(Long userId, Long mintActivityId) {
|
|
|
+ return checkHolding(userId, mintActivityRepo.findById(mintActivityId)
|
|
|
+ .orElseThrow(new BusinessException("活动不存在")));
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean checkHolding(Long userId, MintActivity mintActivity) {
|
|
|
+ if (mintActivity.getHoldingTags() != null && !mintActivity.getHoldingTags().isEmpty()) {
|
|
|
+ List<Asset> assets = assetRepo.findByUserIdAndStatusAndTagsIdIn(userId, AssetStatus.NORMAL, mintActivity.getHoldingTags());
|
|
|
+ for (Long tag : mintActivity.getHoldingTags()) {
|
|
|
+ Asset a = assets.stream().filter(asset -> asset.getTags().stream().anyMatch(t -> t.getId().equals(tag)))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (a == null) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ assets.remove(a);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|