src/PHPDish/Bundle/PostBundle/Service/CategoryManager.php
public function addCategoryIncome(UserInterface $user, CategoryInterface $category, UserInterface $follower, $amount = null)
    {
        $wallet = $this->walletManager->getUserWallet($user);
        $history = $this->walletManager->createHistory();

        if ($category->isBook()) {
            $description = $this->translator->trans('payment.buy_your_book', [
                '%username%' => sprintf('<a href="%s">%s</a>',
                    $this->router->generate('user_view', ['username' => $follower->getUsername()]),
                    $follower->getUsername()
                ),
                '%book%' => sprintf('<a href="%s">《%s》</a>',
                    $this->router->generate('book_view', ['slug' => $category->getSlug()]),
                    $category->getName()
                ),
            ]);

        } else {
            $description = $this->translator->trans('payment.subscribe_your_category', [
                '%username%' => sprintf('<a href="%s">%s</a>',
                    $this->router->generate('user_view', ['username' => $follower->getUsername()]),
                    $follower->getUsername()
                ),
                '%category%' => sprintf('<a href="%s">《%s》</a>',
                    $this->router->generate('category_view', ['slug' => $category->getSlug()]),
                    $category->getName()
                ),
            ]);
        }

        //设置历史
        $history->setAmount($amount ?: $category->getCharge())
            ->setType($category->isBook() ? PaymentInterface::TYPE_BOOK_INCOME : PaymentInterface::TYPE_CATEGORY_INCOME)
            ->setDescription($description)
            ->setStatus(PaymentInterface::STATUS_OK)
            ->setUser($wallet->getUser());

        $this->walletManager->addHistory($wallet, $history);
    }
public function addCategoryIncome(UserInterface $user, CategoryInterface $category, UserInterface $follower, $amount = null)
    {
        $wallet = $this->walletManager->getUserWallet($user);
        $history = $this->walletManager->createHistory();

        if ($category->isBook()) {
            $description = $this->translator->trans('payment.buy_your_book', [
                '%username%' => sprintf('<a href="%s">%s</a>',
                    $this->router->generate('user_view', ['username' => $follower->getUsername()]),
                    $follower->getUsername()
                ),
                '%book%' => sprintf('<a href="%s">《%s》</a>',
                    $this->router->generate('book_view', ['slug' => $category->getSlug()]),
                    $category->getName()
                ),
            ]);

        } else {
            $description = $this->translator->trans('payment.subscribe_your_category', [
                '%username%' => sprintf('<a href="%s">%s</a>',
                    $this->router->generate('user_view', ['username' => $follower->getUsername()]),
                    $follower->getUsername()
                ),
                '%category%' => sprintf('<a href="%s">《%s》</a>',
                    $this->router->generate('category_view', ['slug' => $category->getSlug()]),
                    $category->getName()
                ),
            ]);
        }

        //设置历史
        $history->setAmount($amount ?: $category->getCharge())
            ->setType($category->isBook() ? PaymentInterface::TYPE_BOOK_INCOME : PaymentInterface::TYPE_CATEGORY_INCOME)
            ->setDescription($description)
            ->setStatus(PaymentInterface::STATUS_OK)
            ->setUser($wallet->getUser());

        $this->walletManager->addHistory($wallet, $history);
    }
{@inheritdoc}