src/PHPDish/Bundle/PaymentBundle/Service/WalletManager.php
public function withdraw(WalletInterface $wallet, $amount, $alipay)
    {
        $amount = intval($amount);
        if ($amount < PaymentInterface::WITHDRAW_MAX_AMOUNT) {
            throw new \LogicException($this->translator->trans('withdraw.amount_should_greater_than',
                PaymentInterface::WITHDRAW_MAX_AMOUNT)
            );
        }
        if ($wallet->getAmount() < $amount) {
            throw new \LogicException($this->translator->trans('withdraw.not_encough_balance'));
        }
        if (!$alipay) {
            throw new \LogicException($this->translator->trans('withdraw.need_provide_alipay'));
        }

        $history = $this->createHistory();
        $history->setType(PaymentInterface::TYPE_WITHDRAW)
            ->setAmount($amount)
            ->setDescription('')
            ->setStatus(PaymentInterface::STATUS_WAITING)
            ->setDescription($this->translator->trans('withdraw.to', ['%alipay%' => $alipay]))
            ->setUser($wallet->getUser());
        //钱包余额冻结
        $wallet->freeze($amount);
        $this->addHistory($wallet, $history);

        return $history;
    }
public function withdraw(WalletInterface $wallet, $amount, $alipay)
    {
        $amount = intval($amount);
        if ($amount < PaymentInterface::WITHDRAW_MAX_AMOUNT) {
            throw new \LogicException($this->translator->trans('withdraw.amount_should_greater_than',
                PaymentInterface::WITHDRAW_MAX_AMOUNT)
            );
        }
        if ($wallet->getAmount() < $amount) {
            throw new \LogicException($this->translator->trans('withdraw.not_encough_balance'));
        }
        if (!$alipay) {
            throw new \LogicException($this->translator->trans('withdraw.need_provide_alipay'));
        }

        $history = $this->createHistory();
        $history->setType(PaymentInterface::TYPE_WITHDRAW)
            ->setAmount($amount)
            ->setDescription('')
            ->setStatus(PaymentInterface::STATUS_WAITING)
            ->setDescription($this->translator->trans('withdraw.to', ['%alipay%' => $alipay]))
            ->setUser($wallet->getUser());
        //钱包余额冻结
        $wallet->freeze($amount);
        $this->addHistory($wallet, $history);

        return $history;
    }
{@inheritdoc}