fix: allow editing blind box pools referencing inactive gifts
Some checks failed
Build and Push Backend / docker (push) Failing after 7s
Some checks failed
Build and Push Backend / docker (push) Failing after 7s
This commit is contained in:
@@ -162,7 +162,7 @@ public class BlindBoxPoolAdminService {
|
||||
if (!tenantId.equals(config.getTenantId())) {
|
||||
throw new CustomException("盲盒不存在或已被移除");
|
||||
}
|
||||
PlayGiftInfoEntity rewardGift = requireRewardGift(tenantId, request.getRewardGiftId());
|
||||
PlayGiftInfoEntity rewardGift = requireRewardGiftForUpdate(tenantId, request.getRewardGiftId());
|
||||
validateTimeRange(request.getValidFrom(), request.getValidTo());
|
||||
Integer weight = requirePositiveWeight(request.getWeight(), rewardGift.getName());
|
||||
Integer remainingStock = normalizeRemainingStock(request.getRemainingStock(), rewardGift.getName());
|
||||
@@ -326,18 +326,30 @@ public class BlindBoxPoolAdminService {
|
||||
}
|
||||
|
||||
private PlayGiftInfoEntity requireRewardGift(String tenantId, String rewardGiftId) {
|
||||
return requireRewardGift(tenantId, rewardGiftId, true);
|
||||
}
|
||||
|
||||
private PlayGiftInfoEntity requireRewardGiftForUpdate(String tenantId, String rewardGiftId) {
|
||||
return requireRewardGift(tenantId, rewardGiftId, false);
|
||||
}
|
||||
|
||||
private PlayGiftInfoEntity requireRewardGift(String tenantId, String rewardGiftId, boolean strictAvailability) {
|
||||
if (StrUtil.isBlank(rewardGiftId)) {
|
||||
throw new CustomException("请选择中奖礼物");
|
||||
}
|
||||
PlayGiftInfoEntity gift = playGiftInfoMapper.selectById(rewardGiftId);
|
||||
if (gift == null
|
||||
|| !tenantId.equals(gift.getTenantId())
|
||||
|| !GiftHistory.CURRENT.getCode().equals(gift.getHistory())
|
||||
|| !GiftState.ACTIVE.getCode().equals(gift.getState())
|
||||
|| !GiftType.NORMAL.getCode().equals(gift.getType())
|
||||
|| Boolean.TRUE.equals(gift.getDeleted())) {
|
||||
throw new CustomException("中奖礼物不存在或已下架");
|
||||
}
|
||||
if (strictAvailability) {
|
||||
if (!GiftHistory.CURRENT.getCode().equals(gift.getHistory())
|
||||
|| !GiftState.ACTIVE.getCode().equals(gift.getState())) {
|
||||
throw new CustomException("中奖礼物不存在或已下架");
|
||||
}
|
||||
}
|
||||
return gift;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user