/** Found the valid prize group definition recursively. */ private PrizeGroup determinePrizeGroup(Merchant merchant) throws ApplicationException { if (Merchant.SUPER_MERCHANT_ID == merchant.getId()) { return null; } PrizeGroup prizeGroup = merchant.getPrizeGroup(); if (prizeGroup == null) { throw new ApplicationException( SystemException.CODE_MERCHANT_UNALLOWED_PAY, "No any prize group definition found of Merchant(" + merchant + "), System will simply reject this payout request."); } if (PrizeGroup.ALLOWTYPE_USEPARENT == prizeGroup.getAllowType()) { prizeGroup = this.determinePrizeGroup(merchant.getParentMerchant()); } else { if (logger.isDebugEnabled()) { logger.debug( "Use the payout-limit setting(max=" + prizeGroup.getMaxPayoutAmount() + ",min=" + prizeGroup.getMinPayoutAmount() + ") of merhcant(" + merchant + ") to verify payout limit."); } if (!prizeGroup.isPayoutAllowed()) { throw new ApplicationException( SystemException.CODE_MERCHANT_UNALLOWED_PAY, "Merchant(" + merchant + ") doesn't allow payout."); } } return prizeGroup; }