Files
2026-09-15 10:35:56 +08:00

21 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Esun\Reward\Block\Account;
use Esun\Reward\Model\BalanceManager;
use Esun\Reward\Model\Config;
use Esun\Reward\Model\TierResolver;
use Magento\Customer\Model\Session;
use Magento\Framework\View\Element\Template;
use Magento\Store\Model\StoreManagerInterface;
class Index extends Template
{
public function __construct(Template\Context $context, private readonly Session $session, private readonly StoreManagerInterface $stores, private readonly BalanceManager $balances, private readonly TierResolver $tiers, private readonly Config $config, array $data = []) { parent::__construct($context, $data); }
public function getAccount(): array { return $this->balances->getAccount((int)$this->session->getCustomerId(), (int)$this->stores->getWebsite()->getId()); }
public function getTier(): array { $account = $this->getAccount(); return $this->tiers->resolveEffective((string)$account['tier_code'], (float)$account['lifetime_spend_base'], (int)$this->stores->getStore()->getId()); }
public function getTransactions(): array { return $this->balances->getTransactions((int)$this->session->getCustomerId(), 100); }
public function getActivityName(string $type): string { return (string)$this->config->earningRule($type, (int)$this->stores->getStore()->getId())['name']; }
}