WIP
Some checks failed
Telegram Mini App Shop Builder / Compute version metadata (push) Has been cancelled
Telegram Mini App Shop Builder / Run Frontend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run Backend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run PHP_CodeSniffer (push) Has been cancelled
Telegram Mini App Shop Builder / Build module. (push) Has been cancelled
Telegram Mini App Shop Builder / release (push) Has been cancelled
Some checks failed
Telegram Mini App Shop Builder / Compute version metadata (push) Has been cancelled
Telegram Mini App Shop Builder / Run Frontend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run Backend tests (push) Has been cancelled
Telegram Mini App Shop Builder / Run PHP_CodeSniffer (push) Has been cancelled
Telegram Mini App Shop Builder / Build module. (push) Has been cancelled
Telegram Mini App Shop Builder / release (push) Has been cancelled
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
APP_DEBUG=true
|
||||
PULSE_API_HOST=https://pulse.telecart.pro/api/
|
||||
PULSE_API_HOST=https://pulse.megapay.pro/api/
|
||||
PULSE_HEARTBEAT_SECRET=c5261f5d-529e-45ad-a69c-9778b755b7cb
|
||||
|
||||
TELECART_CACHE_DRIVER=redis
|
||||
#TELECART_REDIS_HOST=redis
|
||||
#TELECART_REDIS_PORT=6379
|
||||
#TELECART_REDIS_DATABASE=0
|
||||
MEGAPAY_CACHE_DRIVER=redis
|
||||
#MEGAPAY_REDIS_HOST=redis
|
||||
#MEGAPAY_REDIS_PORT=6379
|
||||
#MEGAPAY_REDIS_DATABASE=0
|
||||
|
||||
SENTRY_ENABLED=false
|
||||
SENTRY_DSN=
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
APP_DEBUG=false
|
||||
PULSE_API_HOST=https://pulse.telecart.pro/api/
|
||||
PULSE_API_HOST=https://pulse.megapay.pro/api/
|
||||
PULSE_HEARTBEAT_SECRET=c5261f5d-529e-45ad-a69c-9778b755b7cb
|
||||
TELECART_CACHE_DRIVER=mysql
|
||||
TELECART_REDIS_HOST=redis
|
||||
TELECART_REDIS_PORT=6379
|
||||
TELECART_REDIS_DATABASE=0
|
||||
MEGAPAY_CACHE_DRIVER=mysql
|
||||
MEGAPAY_REDIS_HOST=redis
|
||||
MEGAPAY_REDIS_PORT=6379
|
||||
MEGAPAY_REDIS_DATABASE=0
|
||||
|
||||
SENTRY_ENABLED=false
|
||||
SENTRY_DSN=
|
||||
|
||||
@@ -10,7 +10,7 @@ use Openguru\OpenCartFramework\ImageTool\ImageToolServiceProvider;
|
||||
use Openguru\OpenCartFramework\QueryBuilder\QueryBuilderServiceProvider;
|
||||
use Openguru\OpenCartFramework\Router\RouteServiceProvider;
|
||||
use Openguru\OpenCartFramework\Support\Arr;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartPulseServiceProvider;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\MegaPayPulseServiceProvider;
|
||||
use Openguru\OpenCartFramework\Scheduler\SchedulerServiceProvider;
|
||||
use Openguru\OpenCartFramework\Telegram\TelegramServiceProvider;
|
||||
use Openguru\OpenCartFramework\Telegram\TelegramValidateInitDataMiddleware;
|
||||
@@ -34,7 +34,7 @@ class ApplicationFactory
|
||||
TelegramServiceProvider::class,
|
||||
SchedulerServiceProvider::class,
|
||||
ValidatorServiceProvider::class,
|
||||
TeleCartPulseServiceProvider::class,
|
||||
MegaPayPulseServiceProvider::class,
|
||||
ImageToolServiceProvider::class,
|
||||
])
|
||||
->withMiddlewares([
|
||||
|
||||
@@ -32,9 +32,9 @@ class ETLHandler
|
||||
COALESCE((
|
||||
SELECT MAX(date_modified)
|
||||
FROM oc_order as o
|
||||
where o.customer_id = telecart_customers.oc_customer_id
|
||||
where o.customer_id = megapay_customers.oc_customer_id
|
||||
), 0),
|
||||
telecart_customers.updated_at
|
||||
megapay_customers.updated_at
|
||||
)
|
||||
';
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class ETLHandler
|
||||
$lastUpdatedAtSql = $this->getLastUpdatedAtSql();
|
||||
|
||||
return $this->builder->newQuery()
|
||||
->from('telecart_customers')
|
||||
->from('megapay_customers')
|
||||
->where('allows_write_to_pm', '=', 1)
|
||||
->when($updatedAt !== null, function (Builder $builder) use ($lastUpdatedAtSql, $updatedAt) {
|
||||
$builder->where(new RawExpression($lastUpdatedAtSql), '>=', $updatedAt);
|
||||
@@ -101,7 +101,7 @@ class ETLHandler
|
||||
'username',
|
||||
'photo_url',
|
||||
'telegram_user_id' => 'tg_user_id',
|
||||
'telecart_customers.oc_customer_id',
|
||||
'megapay_customers.oc_customer_id',
|
||||
'is_premium',
|
||||
'last_seen_at',
|
||||
'orders_count' => 'orders_count_total',
|
||||
@@ -110,14 +110,14 @@ class ETLHandler
|
||||
'(
|
||||
SELECT MIN(date_added)
|
||||
FROM oc_order
|
||||
WHERE oc_order.customer_id = telecart_customers.oc_customer_id
|
||||
WHERE oc_order.customer_id = megapay_customers.oc_customer_id
|
||||
) AS first_order_date'
|
||||
),
|
||||
new RawExpression(
|
||||
'(
|
||||
SELECT MAX(date_added)
|
||||
FROM oc_order
|
||||
WHERE oc_order.customer_id = telecart_customers.oc_customer_id
|
||||
WHERE oc_order.customer_id = megapay_customers.oc_customer_id
|
||||
) AS last_order_date'
|
||||
),
|
||||
new RawExpression(
|
||||
@@ -127,7 +127,7 @@ class ETLHandler
|
||||
FROM
|
||||
oc_order
|
||||
WHERE
|
||||
oc_order.customer_id = telecart_customers.oc_customer_id
|
||||
oc_order.customer_id = megapay_customers.oc_customer_id
|
||||
AND oc_order.order_status_id IN ($successOrderStatusIds)
|
||||
), 0) AS total_spent"
|
||||
),
|
||||
@@ -138,7 +138,7 @@ class ETLHandler
|
||||
FROM
|
||||
oc_order
|
||||
WHERE
|
||||
oc_order.customer_id = telecart_customers.oc_customer_id
|
||||
oc_order.customer_id = megapay_customers.oc_customer_id
|
||||
AND oc_order.order_status_id IN ($successOrderStatusIds)
|
||||
), 0) AS orders_count_success"
|
||||
),
|
||||
|
||||
@@ -32,7 +32,7 @@ class FormsHandler
|
||||
}
|
||||
|
||||
$form = $this->builder->newQuery()
|
||||
->from('telecart_forms')
|
||||
->from('megapay_forms')
|
||||
->where('alias', '=', $alias)
|
||||
->firstOrNull();
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Handlers;
|
||||
|
||||
use App\Services\TelecartCustomerService;
|
||||
use App\Services\MegapayCustomerService;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Openguru\OpenCartFramework\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Openguru\OpenCartFramework\Support\Arr;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TrackingIdGenerator;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\TrackingIdGenerator;
|
||||
use Openguru\OpenCartFramework\Telegram\Enums\TelegramHeader;
|
||||
use Openguru\OpenCartFramework\Telegram\Exceptions\DecodeTelegramInitDataException;
|
||||
use Openguru\OpenCartFramework\Telegram\TelegramInitDataDecoder;
|
||||
@@ -19,12 +19,12 @@ use Throwable;
|
||||
|
||||
class TelegramCustomerHandler
|
||||
{
|
||||
private TelecartCustomerService $telegramCustomerService;
|
||||
private MegapayCustomerService $telegramCustomerService;
|
||||
private LoggerInterface $logger;
|
||||
private TelegramInitDataDecoder $initDataDecoder;
|
||||
|
||||
public function __construct(
|
||||
TelecartCustomerService $telegramCustomerService,
|
||||
MegapayCustomerService $telegramCustomerService,
|
||||
LoggerInterface $logger,
|
||||
TelegramInitDataDecoder $initDataDecoder
|
||||
) {
|
||||
|
||||
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
||||
namespace App\Handlers;
|
||||
|
||||
use Openguru\OpenCartFramework\Http\Request;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\PulseIngestException;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartPulseService;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\PulseIngestException;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\MegaPayPulseService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -14,14 +14,14 @@ use Throwable;
|
||||
|
||||
class TelemetryHandler
|
||||
{
|
||||
private TeleCartPulseService $teleCartPulseService;
|
||||
private MegaPayPulseService $megaPayPulseService;
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(
|
||||
TeleCartPulseService $teleCartPulseService,
|
||||
MegaPayPulseService $megaPayPulseService,
|
||||
LoggerInterface $logger
|
||||
) {
|
||||
$this->teleCartPulseService = $teleCartPulseService;
|
||||
$this->megaPayPulseService = $megaPayPulseService;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class TelemetryHandler
|
||||
*/
|
||||
public function ingest(Request $request): JsonResponse
|
||||
{
|
||||
$this->teleCartPulseService->handleIngest($request->json());
|
||||
$this->megaPayPulseService->handleIngest($request->json());
|
||||
|
||||
return new JsonResponse([], Response::HTTP_NO_CONTENT);
|
||||
}
|
||||
@@ -38,9 +38,9 @@ class TelemetryHandler
|
||||
public function heartbeat(): JsonResponse
|
||||
{
|
||||
try {
|
||||
$this->teleCartPulseService->handleHeartbeat();
|
||||
$this->megaPayPulseService->handleHeartbeat();
|
||||
} catch (Throwable $e) {
|
||||
$this->logger->warning('TeleCart Pulse Heartbeat failed: ' . $e->getMessage(), ['exception' => $e]);
|
||||
$this->logger->warning('MegaPay Pulse Heartbeat failed: ' . $e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
|
||||
return new JsonResponse(['status' => 'ok']);
|
||||
|
||||
@@ -7,12 +7,12 @@ namespace App\Models;
|
||||
use Carbon\Carbon;
|
||||
use Openguru\OpenCartFramework\QueryBuilder\Builder;
|
||||
use Openguru\OpenCartFramework\QueryBuilder\Connections\ConnectionInterface;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TrackingIdGenerator;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\TrackingIdGenerator;
|
||||
use RuntimeException;
|
||||
|
||||
class TelegramCustomer
|
||||
{
|
||||
private const TABLE_NAME = 'telecart_customers';
|
||||
private const TABLE_NAME = 'megapay_customers';
|
||||
|
||||
private ConnectionInterface $database;
|
||||
private Builder $builder;
|
||||
|
||||
@@ -44,7 +44,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
$registry->addCommand(
|
||||
'start',
|
||||
StartCommand::class,
|
||||
'Базовая команда Telegram бота. Присылает ссылку на открытие Telecart магазина.'
|
||||
'Базовая команда Telegram бота. Присылает ссылку на открытие Megapay магазина.'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class OcCustomerService
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
public function create(array $orderData, ?int $telecartCustomerId): ?int
|
||||
public function create(array $orderData, ?int $megapayCustomerId): ?int
|
||||
{
|
||||
$customerData = [
|
||||
'customer_group_id' => $orderData['customer_group_id'],
|
||||
@@ -41,10 +41,10 @@ class OcCustomerService
|
||||
$this->database->insert(db_table('customer'), $customerData);
|
||||
$lastInsertId = $this->database->lastInsertId();
|
||||
|
||||
if ($telecartCustomerId) {
|
||||
if ($megapayCustomerId) {
|
||||
$this->builder
|
||||
->where('id', '=', $telecartCustomerId)
|
||||
->update('telecart_customers', [
|
||||
->where('id', '=', $megapayCustomerId)
|
||||
->update('megapay_customers', [
|
||||
'oc_customer_id' => $lastInsertId,
|
||||
]);
|
||||
}
|
||||
@@ -52,15 +52,15 @@ class OcCustomerService
|
||||
return $lastInsertId;
|
||||
}
|
||||
|
||||
public function findByTelecartCustomerId(int $telegramCustomerId): ?array
|
||||
public function findByMegapayCustomerId(int $telegramCustomerId): ?array
|
||||
{
|
||||
return $this->builder->newQuery()
|
||||
->select(['oc_customers.*'])
|
||||
->from(db_table('customer'), 'oc_customers')
|
||||
->join('telecart_customers', function (JoinClause $join) {
|
||||
$join->on('telecart_customers.oc_customer_id', '=', 'oc_customers.customer_id');
|
||||
->join('megapay_customers', function (JoinClause $join) {
|
||||
$join->on('megapay_customers.oc_customer_id', '=', 'oc_customers.customer_id');
|
||||
})
|
||||
->where('telecart_customers.id', '=', $telegramCustomerId)
|
||||
->where('megapay_customers.id', '=', $telegramCustomerId)
|
||||
->firstOrNull();
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ class OcCustomerService
|
||||
->firstOrNull();
|
||||
}
|
||||
|
||||
public function findOrCreateByTelecartCustomerId(int $telecartCustomerId, array $orderData): ?array
|
||||
public function findOrCreateByMegapayCustomerId(int $megapayCustomerId, array $orderData): ?array
|
||||
{
|
||||
$ocCustomer = $this->findByTelecartCustomerId($telecartCustomerId);
|
||||
$ocCustomer = $this->findByMegapayCustomerId($megapayCustomerId);
|
||||
|
||||
if (! $ocCustomer) {
|
||||
$ocCustomerId = $this->create($orderData, $telecartCustomerId);
|
||||
$ocCustomerId = $this->create($orderData, $megapayCustomerId);
|
||||
|
||||
return $this->findById($ocCustomerId);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class OrderCreateService
|
||||
private SettingsService $settings;
|
||||
private TelegramService $telegramService;
|
||||
private LoggerInterface $logger;
|
||||
private TelecartCustomerService $telecartCustomerService;
|
||||
private MegapayCustomerService $megapayCustomerService;
|
||||
private OcCustomerService $ocCustomerService;
|
||||
private OrderMetaService $orderMetaService;
|
||||
|
||||
@@ -34,7 +34,7 @@ class OrderCreateService
|
||||
SettingsService $settings,
|
||||
TelegramService $telegramService,
|
||||
LoggerInterface $logger,
|
||||
TelecartCustomerService $telegramCustomerService,
|
||||
MegapayCustomerService $telegramCustomerService,
|
||||
OcCustomerService $ocCustomerService,
|
||||
OrderMetaService $orderMetaService
|
||||
) {
|
||||
@@ -44,7 +44,7 @@ class OrderCreateService
|
||||
$this->settings = $settings;
|
||||
$this->telegramService = $telegramService;
|
||||
$this->logger = $logger;
|
||||
$this->telecartCustomerService = $telegramCustomerService;
|
||||
$this->megapayCustomerService = $telegramCustomerService;
|
||||
$this->ocCustomerService = $ocCustomerService;
|
||||
$this->orderMetaService = $orderMetaService;
|
||||
}
|
||||
@@ -110,9 +110,9 @@ class OrderCreateService
|
||||
try {
|
||||
$this->database->beginTransaction();
|
||||
|
||||
$telecartCustomer = $this->telecartCustomerService->saveOrUpdate($telegramUserdata);
|
||||
$telecartCustomerId = (int) $telecartCustomer['id'];
|
||||
$ocCustomer = $this->ocCustomerService->findOrCreateByTelecartCustomerId($telecartCustomerId, $orderData);
|
||||
$megapayCustomer = $this->megapayCustomerService->saveOrUpdate($telegramUserdata);
|
||||
$megapayCustomerId = (int) $megapayCustomer['id'];
|
||||
$ocCustomer = $this->ocCustomerService->findOrCreateByMegapayCustomerId($megapayCustomerId, $orderData);
|
||||
$ocCustomerId = (int) $ocCustomer['customer_id'];
|
||||
|
||||
$orderData['customer_id'] = $ocCustomerId;
|
||||
@@ -131,10 +131,10 @@ class OrderCreateService
|
||||
|
||||
// Insert order meta data
|
||||
if ($customOrderFields) {
|
||||
$this->orderMetaService->insert($orderId, $storeId, $customOrderFields, $telecartCustomerId);
|
||||
$this->orderMetaService->insert($orderId, $storeId, $customOrderFields, $megapayCustomerId);
|
||||
}
|
||||
|
||||
$this->telecartCustomerService->increaseOrdersCount($telecartCustomerId);
|
||||
$this->megapayCustomerService->increaseOrdersCount($megapayCustomerId);
|
||||
|
||||
$this->database->commitTransaction();
|
||||
} catch (Throwable $exception) {
|
||||
|
||||
@@ -13,15 +13,15 @@ class OrderMetaService
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function insert(int $orderId, int $storeId, array $fields, ?int $telecartCustomerId = null): void
|
||||
public function insert(int $orderId, int $storeId, array $fields, ?int $megapayCustomerId = null): void
|
||||
{
|
||||
$orderMeta = [
|
||||
'oc_order_id' => $orderId,
|
||||
'oc_store_id' => $storeId,
|
||||
'telecart_customer_id' => $telecartCustomerId,
|
||||
'megapay_customer_id' => $megapayCustomerId,
|
||||
'meta_data' => json_encode($fields, JSON_THROW_ON_ERROR),
|
||||
];
|
||||
|
||||
$this->connection->insert('telecart_order_meta', $orderMeta);
|
||||
$this->connection->insert('megapay_order_meta', $orderMeta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ class ProductsService
|
||||
$data['share'] = Str::htmlEntityEncode(
|
||||
$this->oc->url->link('product/product', [
|
||||
'product_id' => $productId,
|
||||
'utm_source' => 'telecart',
|
||||
'utm_source' => 'megapay',
|
||||
'utm_medium' => 'telegram',
|
||||
'utm_campaign' => 'product_click',
|
||||
'utm_content' => 'product_button',
|
||||
|
||||
@@ -11,7 +11,7 @@ use Openguru\OpenCartFramework\Support\Arr;
|
||||
use Openguru\OpenCartFramework\Support\Utils;
|
||||
use RuntimeException;
|
||||
|
||||
class TelecartCustomerService
|
||||
class MegapayCustomerService
|
||||
{
|
||||
private TelegramCustomer $telegramCustomer;
|
||||
private Settings $settings;
|
||||
@@ -87,7 +87,7 @@ class TelecartCustomerService
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign OpenCart Customer to Telegram User ID and return Telecart Customer ID if it exists.
|
||||
* Assign OpenCart Customer to Telegram User ID and return Megapay Customer ID if it exists.
|
||||
*
|
||||
* @param $telegramUserId
|
||||
* @param int $ocCustomerId
|
||||
@@ -111,9 +111,9 @@ class TelecartCustomerService
|
||||
return (int)$customer['id'];
|
||||
}
|
||||
|
||||
public function increaseOrdersCount(int $telecartCustomerId): void
|
||||
public function increaseOrdersCount(int $megapayCustomerId): void
|
||||
{
|
||||
$this->telegramCustomer->increase($telecartCustomerId, 'orders_count');
|
||||
$this->telegramCustomer->increase($megapayCustomerId, 'orders_count');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,7 +42,7 @@ class LinkCommand extends TelegramCommand
|
||||
$greeting = $this->telegram->escapeTgSpecialCharacters(
|
||||
<<<HTML
|
||||
Это удобный инструмент, который поможет вам 📎 создать красивое
|
||||
сообщение с кнопкой для открытия вашего 🛒 Telecart магазина.
|
||||
сообщение с кнопкой для открытия вашего 🛒 Megapay магазина.
|
||||
|
||||
📌 Такое сообщение можно закрепить в канале или группе.
|
||||
📤 Переслать клиентам в личные сообщения.
|
||||
@@ -102,7 +102,7 @@ HTML;
|
||||
MARKDOWN;
|
||||
|
||||
$text = $this->telegram->prepareMessage($template, [
|
||||
'{LINK}' => 'https://telecart-labs.github.io/docs/telegram/telegram/#direct-link',
|
||||
'{LINK}' => 'https://megapay-labs.github.io/docs/telegram/telegram/#direct-link',
|
||||
]);
|
||||
$this->telegram->sendMessage($chatId, $text);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use Openguru\OpenCartFramework\ImageTool\ImageToolServiceProvider;
|
||||
use Openguru\OpenCartFramework\QueryBuilder\QueryBuilderServiceProvider;
|
||||
use Openguru\OpenCartFramework\Router\RouteServiceProvider;
|
||||
use Openguru\OpenCartFramework\Support\Arr;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartPulseServiceProvider;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\MegaPayPulseServiceProvider;
|
||||
use Openguru\OpenCartFramework\Telegram\TelegramServiceProvider;
|
||||
|
||||
class ApplicationFactory
|
||||
@@ -33,7 +33,7 @@ class ApplicationFactory
|
||||
AppServiceProvider::class,
|
||||
CacheServiceProvider::class,
|
||||
TelegramServiceProvider::class,
|
||||
TeleCartPulseServiceProvider::class,
|
||||
MegaPayPulseServiceProvider::class,
|
||||
ImageToolServiceProvider::class,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class FormsHandler
|
||||
}
|
||||
|
||||
$form = $this->builder->newQuery()
|
||||
->from('telecart_forms')
|
||||
->from('megapay_forms')
|
||||
->where('alias', '=', $alias)
|
||||
->firstOrNull();
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ class LogsHandler
|
||||
|
||||
private function findLastLogsFileInDir(string $dir): ?string
|
||||
{
|
||||
$files = glob($dir . '/telecart-*.log');
|
||||
$files = glob($dir . '/megapay-*.log');
|
||||
|
||||
return $files ? end($files) : null;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class SendMessageHandler
|
||||
* Извлечь ID записи из запроса
|
||||
*
|
||||
* @param Request $request HTTP запрос
|
||||
* @return int ID записи в таблице telecart_customers
|
||||
* @return int ID записи в таблице megapay_customers
|
||||
* @throws RuntimeException Если ID отсутствует или невалиден
|
||||
*/
|
||||
private function extractCustomerId(Request $request): int
|
||||
|
||||
@@ -112,7 +112,7 @@ class SettingsHandler
|
||||
$data['scheduled_jobs'] = $this->scheduledJob->all();
|
||||
|
||||
$forms = $this->builder->newQuery()
|
||||
->from('telecart_forms')
|
||||
->from('megapay_forms')
|
||||
->get();
|
||||
|
||||
if ($forms) {
|
||||
@@ -184,7 +184,7 @@ class SettingsHandler
|
||||
$schema = json_encode($form['schema'], JSON_THROW_ON_ERROR);
|
||||
$this->builder->newQuery()
|
||||
->where('alias', '=', $form['alias'])
|
||||
->update('telecart_forms', [
|
||||
->update('megapay_forms', [
|
||||
'friendly_name' => $form['friendly_name'],
|
||||
'is_custom' => $form['is_custom'],
|
||||
'schema' => $schema,
|
||||
@@ -267,7 +267,7 @@ class SettingsHandler
|
||||
$info['MySQL Version'] = 'Error: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
$cacheDriver = env('TELECART_CACHE_DRIVER', 'mysql');
|
||||
$cacheDriver = env('MEGAPAY_CACHE_DRIVER', 'mysql');
|
||||
$cacheClass = get_class($this->cache);
|
||||
$info['Cache Driver'] = $cacheDriver . ' (' . basename(str_replace('\\', '/', $cacheClass)) . ')';
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ class StatsHandler
|
||||
new RawExpression('SUM(orders.total) AS orders_total_amount'),
|
||||
])
|
||||
->from(db_table('order'), 'orders')
|
||||
->join('telecart_customers', function (JoinClause $join) {
|
||||
$join->on('orders.customer_id', '=', 'telecart_customers.oc_customer_id');
|
||||
->join('megapay_customers', function (JoinClause $join) {
|
||||
$join->on('orders.customer_id', '=', 'megapay_customers.oc_customer_id');
|
||||
})
|
||||
->join('telecart_order_meta', function (JoinClause $join) {
|
||||
$join->on('orders.order_id', '=', 'telecart_order_meta.oc_order_id')
|
||||
->whereRaw('orders.store_id = telecart_order_meta.oc_store_id');
|
||||
->join('megapay_order_meta', function (JoinClause $join) {
|
||||
$join->on('orders.order_id', '=', 'megapay_order_meta.oc_order_id')
|
||||
->whereRaw('orders.store_id = megapay_order_meta.oc_store_id');
|
||||
})
|
||||
->firstOrNull();
|
||||
|
||||
@@ -54,7 +54,7 @@ class StatsHandler
|
||||
private function countCustomersCount(): int
|
||||
{
|
||||
return $this->builder->newQuery()
|
||||
->from('telecart_customers')
|
||||
->from('megapay_customers')
|
||||
->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
namespace Bastion\Handlers;
|
||||
|
||||
use Openguru\OpenCartFramework\Cache\CacheInterface;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartEvent;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\MegaPayEvent;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class TeleCartPulseStatsHandler
|
||||
class MegaPayPulseStatsHandler
|
||||
{
|
||||
private TeleCartEvent $eventModel;
|
||||
private MegaPayEvent $eventModel;
|
||||
private CacheInterface $cache;
|
||||
private const CACHE_KEY = 'telecart_pulse_stats';
|
||||
private const CACHE_KEY = 'megapay_pulse_stats';
|
||||
private const CACHE_TTL = 3600; // 1 час
|
||||
|
||||
public function __construct(TeleCartEvent $eventModel, CacheInterface $cache)
|
||||
public function __construct(MegaPayEvent $eventModel, CacheInterface $cache)
|
||||
{
|
||||
$this->eventModel = $eventModel;
|
||||
$this->cache = $cache;
|
||||
|
||||
@@ -12,7 +12,7 @@ use Openguru\OpenCartFramework\Support\Arr;
|
||||
|
||||
class TelegramCustomersHandler
|
||||
{
|
||||
private const TABLE_NAME = 'telecart_customers';
|
||||
private const TABLE_NAME = 'megapay_customers';
|
||||
private const DEFAULT_PAGE = 1;
|
||||
private const DEFAULT_ROWS = 20;
|
||||
private const DEFAULT_SORT_FIELD = 'last_seen_at';
|
||||
|
||||
@@ -6,15 +6,15 @@ use GuzzleHttp\Exception\GuzzleException;
|
||||
use Openguru\OpenCartFramework\Cache\CacheInterface;
|
||||
use Openguru\OpenCartFramework\Config\Settings;
|
||||
use Openguru\OpenCartFramework\Scheduler\TaskInterface;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartEvent;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartPulseEventsSender;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\MegaPayEvent;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\MegaPayPulseEventsSender;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
class TeleCartPulseSendEventsTask implements TaskInterface
|
||||
class MegaPayPulseSendEventsTask implements TaskInterface
|
||||
{
|
||||
private TeleCartEvent $eventModel;
|
||||
private TeleCartPulseEventsSender $eventsSender;
|
||||
private MegaPayEvent $eventModel;
|
||||
private MegaPayPulseEventsSender $eventsSender;
|
||||
private LoggerInterface $logger;
|
||||
private CacheInterface $cache;
|
||||
private Settings $settings;
|
||||
@@ -23,8 +23,8 @@ class TeleCartPulseSendEventsTask implements TaskInterface
|
||||
|
||||
public function __construct(
|
||||
Settings $settings,
|
||||
TeleCartEvent $eventModel,
|
||||
TeleCartPulseEventsSender $eventsSender,
|
||||
MegaPayEvent $eventModel,
|
||||
MegaPayPulseEventsSender $eventsSender,
|
||||
LoggerInterface $logger,
|
||||
CacheInterface $cache
|
||||
) {
|
||||
@@ -82,7 +82,7 @@ class TeleCartPulseSendEventsTask implements TaskInterface
|
||||
'failed' => $failed,
|
||||
]);
|
||||
} catch (Throwable $e) {
|
||||
$this->logger->error("TeleCartPulseSendEventsTask failed: " . $e->getMessage(), [
|
||||
$this->logger->error("MegaPayPulseSendEventsTask failed: " . $e->getMessage(), [
|
||||
'exception' => $e,
|
||||
]);
|
||||
} finally {
|
||||
@@ -117,8 +117,8 @@ class TeleCartPulseSendEventsTask implements TaskInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
// TeleCart Pulse не вернул подтверждение
|
||||
$errorReason = 'No confirmation received from TeleCart Pulse';
|
||||
// MegaPay Pulse не вернул подтверждение
|
||||
$errorReason = 'No confirmation received from MegaPay Pulse';
|
||||
$this->handleFailedAttempt($eventId, $attemptsCount, $errorReason);
|
||||
} catch (GuzzleException $e) {
|
||||
// Ошибка HTTP запроса
|
||||
@@ -170,6 +170,6 @@ class TeleCartPulseSendEventsTask implements TaskInterface
|
||||
*/
|
||||
private function clearStatsCache(): void
|
||||
{
|
||||
$this->cache->delete('telecart_pulse_stats');
|
||||
$this->cache->delete('megapay_pulse_stats');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ class SettingsService
|
||||
public function update(array $data): void
|
||||
{
|
||||
$this->connection->transaction(function () use ($data) {
|
||||
$this->registry->model_setting_setting->editSetting('module_telecart', [
|
||||
'module_telecart_settings' => $data,
|
||||
$this->registry->model_setting_setting->editSetting('module_megapay', [
|
||||
'module_megapay_settings' => $data,
|
||||
]);
|
||||
|
||||
$this->registry->model_setting_setting->editSetting('module_tgshop', [
|
||||
|
||||
@@ -8,7 +8,7 @@ use Bastion\Handlers\LogsHandler;
|
||||
use Bastion\Handlers\SendMessageHandler;
|
||||
use Bastion\Handlers\SettingsHandler;
|
||||
use Bastion\Handlers\StatsHandler;
|
||||
use Bastion\Handlers\TeleCartPulseStatsHandler;
|
||||
use Bastion\Handlers\MegaPayPulseStatsHandler;
|
||||
use Bastion\Handlers\TelegramCustomersHandler;
|
||||
use Bastion\Handlers\TelegramHandler;
|
||||
|
||||
@@ -33,5 +33,5 @@ return [
|
||||
'sendMessageToCustomer' => [SendMessageHandler::class, 'sendMessage'],
|
||||
'testTgMessage' => [TelegramHandler::class, 'testTgMessage'],
|
||||
'tgGetMe' => [TelegramHandler::class, 'tgGetMe'],
|
||||
'getTeleCartPulseStats' => [TeleCartPulseStatsHandler::class, 'getStats'],
|
||||
'getMegaPayPulseStats' => [MegaPayPulseStatsHandler::class, 'getStats'],
|
||||
];
|
||||
|
||||
@@ -42,7 +42,7 @@ $prefix = DB_PREFIX;
|
||||
$dsn = "mysql:host=$host;port=$port;dbname=$dbName";
|
||||
$pdo = new PDO($dsn, $username, $password);
|
||||
$connection = new MySqlConnection($pdo);
|
||||
$raw = $connection->select("SELECT value FROM `{$prefix}setting` WHERE `key` = 'module_telecart_settings'");
|
||||
$raw = $connection->select("SELECT value FROM `{$prefix}setting` WHERE `key` = 'module_megapay_settings'");
|
||||
$timezone = $connection->select("SELECT value FROM `{$prefix}setting` WHERE `key` = 'config_timezone'");
|
||||
$timezone = $timezone[0]['value'] ?? 'UTC';
|
||||
$json = json_decode($raw[0]['value'], true, 512, JSON_THROW_ON_ERROR);
|
||||
@@ -79,10 +79,10 @@ $items = Arr::mergeArraysRecursively($json, [
|
||||
],
|
||||
]);
|
||||
|
||||
$logger = new Logger('TeleCart_CLI', [], [], new DateTimeZone('UTC'));
|
||||
$logger = new Logger('MegaPay_CLI', [], [], new DateTimeZone('UTC'));
|
||||
$logger->pushHandler(
|
||||
new RotatingFileHandler(
|
||||
DIR_LOGS . '/telecart.log', 14, $debug ? Logger::DEBUG : Logger::INFO
|
||||
DIR_LOGS . '/megapay.log', 14, $debug ? Logger::DEBUG : Logger::INFO
|
||||
),
|
||||
);
|
||||
|
||||
@@ -90,7 +90,7 @@ $app = ApplicationFactory::create($items);
|
||||
$app->setLogger($logger);
|
||||
$app->boot();
|
||||
|
||||
$console = new Application('TeleCart', module_version());
|
||||
$console = new Application('MegaPay', module_version());
|
||||
$console->add($app->get(VersionCommand::class));
|
||||
$console->add($app->get(ScheduleRunCommand::class));
|
||||
$console->add($app->get(PulseSendEventsCommand::class));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
return [
|
||||
'app' => [
|
||||
'app_enabled' => true,
|
||||
'app_name' => 'Telecart',
|
||||
'app_name' => 'Megapay',
|
||||
'app_icon' => null,
|
||||
"theme_light" => "light",
|
||||
"theme_dark" => "dark",
|
||||
@@ -104,15 +104,15 @@ HTML,
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'namespace' => 'telecart',
|
||||
'namespace' => 'megapay',
|
||||
'default_lifetime' => 60 * 60 * 24,
|
||||
'options' => [
|
||||
'db_table' => 'telecart_cache_items',
|
||||
'db_table' => 'megapay_cache_items',
|
||||
],
|
||||
],
|
||||
|
||||
'paths' => [
|
||||
'images_cache' => 'cache/telecart',
|
||||
'images_cache' => 'cache/megapay',
|
||||
],
|
||||
|
||||
'cron' => [
|
||||
|
||||
@@ -10,7 +10,7 @@ use Openguru\OpenCartFramework\ImageTool\ImageToolServiceProvider;
|
||||
use Openguru\OpenCartFramework\QueryBuilder\QueryBuilderServiceProvider;
|
||||
use Openguru\OpenCartFramework\Scheduler\SchedulerServiceProvider;
|
||||
use Openguru\OpenCartFramework\Support\Arr;
|
||||
use Openguru\OpenCartFramework\TeleCartPulse\TeleCartPulseServiceProvider;
|
||||
use Openguru\OpenCartFramework\MegaPayPulse\MegaPayPulseServiceProvider;
|
||||
use Openguru\OpenCartFramework\Telegram\TelegramServiceProvider;
|
||||
|
||||
class ApplicationFactory
|
||||
@@ -28,7 +28,7 @@ class ApplicationFactory
|
||||
AppServiceProvider::class,
|
||||
CacheServiceProvider::class,
|
||||
TelegramServiceProvider::class,
|
||||
TeleCartPulseServiceProvider::class,
|
||||
MegaPayPulseServiceProvider::class,
|
||||
SchedulerServiceProvider::class,
|
||||
ImageToolServiceProvider::class,
|
||||
]);
|
||||
|
||||
@@ -10,10 +10,10 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class CacheClearCommand extends TeleCartCommand
|
||||
class CacheClearCommand extends MegaPayCommand
|
||||
{
|
||||
protected static $defaultName = 'cache:clear';
|
||||
protected static $defaultDescription = 'Очистка кеша модуля TeleCart';
|
||||
protected static $defaultDescription = 'Очистка кеша модуля MegaPay';
|
||||
|
||||
private CacheInterface $cache;
|
||||
|
||||
@@ -27,7 +27,7 @@ class CacheClearCommand extends TeleCartCommand
|
||||
{
|
||||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$io->title('Очистка кеша модуля TeleCart');
|
||||
$io->title('Очистка кеша модуля MegaPay');
|
||||
|
||||
try {
|
||||
$this->cache->clear();
|
||||
|
||||
@@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class CustomerCountsCommand extends TeleCartCommand
|
||||
class CustomerCountsCommand extends MegaPayCommand
|
||||
{
|
||||
protected static $defaultName = 'customer:counts';
|
||||
protected static $defaultDescription = 'Обновление счетчиков заказов для всех клиентов';
|
||||
@@ -29,8 +29,8 @@ class CustomerCountsCommand extends TeleCartCommand
|
||||
$io->writeln('Выполняется пересчёт счетчиков заказов...');
|
||||
|
||||
$sql = <<<SQL
|
||||
update telecart_customers
|
||||
set orders_count = (select count(*) from oc_order where oc_order.customer_id = telecart_customers.oc_customer_id)
|
||||
update megapay_customers
|
||||
set orders_count = (select count(*) from oc_order where oc_order.customer_id = megapay_customers.oc_customer_id)
|
||||
where true;
|
||||
SQL;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class ImagesCacheClearCommand extends TeleCartCommand
|
||||
class ImagesCacheClearCommand extends MegaPayCommand
|
||||
{
|
||||
protected static $defaultName = 'images:cache-clear';
|
||||
protected static $defaultDescription = 'Очистка кеша изображений товаров';
|
||||
@@ -31,7 +31,7 @@ class ImagesCacheClearCommand extends TeleCartCommand
|
||||
|
||||
// Получаем пути из конфига
|
||||
$imagesDir = $this->container->getConfigValue('paths.images');
|
||||
$cachePath = $this->container->getConfigValue('paths.images_cache', 'cache/telecart');
|
||||
$cachePath = $this->container->getConfigValue('paths.images_cache', 'cache/megapay');
|
||||
$cachePath = ltrim($cachePath, '/');
|
||||
$fullCachePath = rtrim($imagesDir, '/') . '/' . $cachePath;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class ImagesWarmupCacheCommand extends TeleCartCommand
|
||||
class ImagesWarmupCacheCommand extends MegaPayCommand
|
||||
{
|
||||
protected static $defaultName = 'images:warmup';
|
||||
protected static $defaultDescription = 'Прогрев кеша изображений товаров';
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
|
||||
namespace Console\Commands;
|
||||
|
||||
use Bastion\ScheduledTasks\TeleCartPulseSendEventsTask;
|
||||
use Bastion\ScheduledTasks\MegaPayPulseSendEventsTask;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class PulseSendEventsCommand extends TeleCartCommand
|
||||
class PulseSendEventsCommand extends MegaPayCommand
|
||||
{
|
||||
protected static $defaultName = 'pulse:send';
|
||||
protected static $defaultDescription = 'Manually send pulse events ignoring schedule.';
|
||||
private TeleCartPulseSendEventsTask $teleCartPulseSendEventsTask;
|
||||
private MegaPayPulseSendEventsTask $megaPayPulseSendEventsTask;
|
||||
|
||||
public function __construct(TeleCartPulseSendEventsTask $teleCartPulseSendEventsTask)
|
||||
public function __construct(MegaPayPulseSendEventsTask $megaPayPulseSendEventsTask)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->teleCartPulseSendEventsTask = $teleCartPulseSendEventsTask;
|
||||
$this->megaPayPulseSendEventsTask = $megaPayPulseSendEventsTask;
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$output->writeln('<info>Sending Pulse events.</info>');
|
||||
$this->teleCartPulseSendEventsTask->execute();
|
||||
$this->megaPayPulseSendEventsTask->execute();
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class ScheduleRunCommand extends TeleCartCommand
|
||||
class ScheduleRunCommand extends MegaPayCommand
|
||||
{
|
||||
private SchedulerService $scheduler;
|
||||
private Settings $settings;
|
||||
@@ -46,7 +46,7 @@ class ScheduleRunCommand extends TeleCartCommand
|
||||
|
||||
$output->writeln(
|
||||
sprintf(
|
||||
'[%s] <info>TeleCart Scheduler Running...</info>',
|
||||
'[%s] <info>MegaPay Scheduler Running...</info>',
|
||||
Carbon::now()->toJSON(),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Console\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
abstract class TeleCartCommand extends Command
|
||||
abstract class MegaPayCommand extends Command
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@@ -6,13 +6,13 @@ use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class VersionCommand extends TeleCartCommand
|
||||
class VersionCommand extends MegaPayCommand
|
||||
{
|
||||
protected static $defaultName = 'version';
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$output->writeln('TeleCart Version: ' . module_version());
|
||||
$output->writeln('MegaPay Version: ' . module_version());
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ return new class extends Migration {
|
||||
return;
|
||||
}
|
||||
|
||||
$newSettings = $opencart->model_setting_setting->getSetting('module_telecart');
|
||||
$newSettings = $opencart->model_setting_setting->getSetting('module_megapay');
|
||||
|
||||
static $mapLegacyToNewSettings = [
|
||||
'module_tgshop_app_icon' => 'app.app_icon',
|
||||
@@ -62,8 +62,8 @@ return new class extends Migration {
|
||||
}
|
||||
}
|
||||
|
||||
$opencart->model_setting_setting->editSetting('module_telecart', [
|
||||
'module_telecart_settings' => $data,
|
||||
$opencart->model_setting_setting->editSetting('module_megapay', [
|
||||
'module_megapay_settings' => $data,
|
||||
]);
|
||||
|
||||
$this->logger->info('Выполнено обновление настроек с 1й версии модуля.');
|
||||
|
||||
@@ -6,7 +6,7 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
CREATE TABLE IF NOT EXISTS `telecart_forms` (
|
||||
CREATE TABLE IF NOT EXISTS `megapay_forms` (
|
||||
`id` bigint(11) AUTO_INCREMENT PRIMARY KEY,
|
||||
`alias` varchar(100) NOT NULL,
|
||||
`friendly_name` varchar(100) NOT NULL,
|
||||
|
||||
@@ -8,7 +8,7 @@ return new class extends Migration {
|
||||
{
|
||||
$checkoutForm = json_encode(self::getCheckoutFormSchema(), JSON_THROW_ON_ERROR);
|
||||
|
||||
$this->database->insert('telecart_forms', [
|
||||
$this->database->insert('megapay_forms', [
|
||||
'alias' => 'checkout',
|
||||
'friendly_name' => 'Оформление заказа',
|
||||
'schema' => $checkoutForm,
|
||||
|
||||
@@ -5,7 +5,7 @@ use Openguru\OpenCartFramework\Migrations\Migration;
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$tableName = 'telecart_customers';
|
||||
$tableName = 'megapay_customers';
|
||||
|
||||
$sql = <<<SQL
|
||||
CREATE TABLE IF NOT EXISTS `{$tableName}` (
|
||||
|
||||
@@ -6,7 +6,7 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
ALTER TABLE `telecart_customers`
|
||||
ALTER TABLE `megapay_customers`
|
||||
ADD COLUMN `privacy_consented_at` TIMESTAMP NULL DEFAULT NULL AFTER `referral`;
|
||||
SQL;
|
||||
|
||||
|
||||
@@ -5,21 +5,21 @@ use Openguru\OpenCartFramework\Migrations\Migration;
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$tableName = 'telecart_order_meta';
|
||||
$tableName = 'megapay_order_meta';
|
||||
|
||||
$sql = <<<SQL
|
||||
CREATE TABLE IF NOT EXISTS `{$tableName}` (
|
||||
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`oc_order_id` INT(11) UNSIGNED NOT NULL,
|
||||
`oc_store_id` INT(11) UNSIGNED NOT NULL,
|
||||
`telecart_customer_id` INT(11) UNSIGNED DEFAULT NULL,
|
||||
`megapay_customer_id` INT(11) UNSIGNED DEFAULT NULL,
|
||||
`meta_data` JSON DEFAULT NULL,
|
||||
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `unique_oc_order_id` (`oc_order_id`),
|
||||
KEY `idx_oc_store_id` (`oc_store_id`),
|
||||
KEY `idx_telecart_customer_id` (`telecart_customer_id`)
|
||||
KEY `idx_megapay_customer_id` (`megapay_customer_id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB;
|
||||
SQL;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
ALTER TABLE `telecart_customers`
|
||||
ALTER TABLE `megapay_customers`
|
||||
ADD COLUMN `orders_count` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `referral`;
|
||||
SQL;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
ALTER TABLE `telecart_customers`
|
||||
ALTER TABLE `megapay_customers`
|
||||
ADD COLUMN `tracking_id` VARCHAR(64) NOT NULL AFTER `oc_customer_id`;
|
||||
SQL;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use Openguru\OpenCartFramework\Migrations\Migration;
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$tableName = 'telecart_events';
|
||||
$tableName = 'megapay_events';
|
||||
|
||||
$sql = <<<SQL
|
||||
CREATE TABLE IF NOT EXISTS `{$tableName}` (
|
||||
|
||||
@@ -10,14 +10,14 @@ return new class extends Migration {
|
||||
$opencart = $this->app->get(OcRegistryDecorator::class);
|
||||
$opencart->load->model('setting/setting');
|
||||
|
||||
$currentSettings = $opencart->model_setting_setting->getSetting('module_telecart');
|
||||
$currentSettings = $opencart->model_setting_setting->getSetting('module_megapay');
|
||||
|
||||
if (! $currentSettings || ! isset($currentSettings['module_telecart_settings'])) {
|
||||
if (! $currentSettings || ! isset($currentSettings['module_megapay_settings'])) {
|
||||
$this->logger->info("Settings not found in database, migration skipped");
|
||||
return;
|
||||
}
|
||||
|
||||
$allSettings = $currentSettings['module_telecart_settings'];
|
||||
$allSettings = $currentSettings['module_megapay_settings'];
|
||||
|
||||
// Проверяем наличие store.enable_store
|
||||
$enableStore = Arr::get($allSettings, 'store.enable_store');
|
||||
@@ -41,8 +41,8 @@ return new class extends Migration {
|
||||
$this->logger->info("Removed store.enable_store from settings");
|
||||
|
||||
// Сохраняем обновленные настройки через OpenCart модель
|
||||
$opencart->model_setting_setting->editSetting('module_telecart', [
|
||||
'module_telecart_settings' => $allSettings,
|
||||
$opencart->model_setting_setting->editSetting('module_megapay', [
|
||||
'module_megapay_settings' => $allSettings,
|
||||
]);
|
||||
|
||||
$this->logger->info("Successfully migrated store.enable_store to product_interaction_mode and removed store.enable_store from settings");
|
||||
|
||||
@@ -6,7 +6,7 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
update telecart_customers
|
||||
update megapay_customers
|
||||
set username = telegram_user_id
|
||||
where username is null
|
||||
SQL;
|
||||
|
||||
@@ -6,7 +6,7 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
ALTER TABLE `telecart_customers`
|
||||
ALTER TABLE `megapay_customers`
|
||||
ADD COLUMN `store_id` INT NOT NULL DEFAULT 0 AFTER `oc_customer_id`
|
||||
SQL;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$sql = <<<SQL
|
||||
CREATE TABLE IF NOT EXISTS `telecart_scheduled_jobs` (
|
||||
CREATE TABLE IF NOT EXISTS `megapay_scheduled_jobs` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`task` varchar(1024) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
use Bastion\ScheduledTasks\TeleCartPulseSendEventsTask;
|
||||
use Bastion\ScheduledTasks\MegaPayPulseSendEventsTask;
|
||||
use Openguru\OpenCartFramework\Migrations\Migration;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$this->database->insert('telecart_scheduled_jobs', [
|
||||
'name' => 'telecart_pulse_send_events',
|
||||
'task' => TeleCartPulseSendEventsTask::class,
|
||||
$this->database->insert('megapay_scheduled_jobs', [
|
||||
'name' => 'megapay_pulse_send_events',
|
||||
'task' => MegaPayPulseSendEventsTask::class,
|
||||
'is_enabled' => 0,
|
||||
'cron_expression' => '*/10 * * * *',
|
||||
'last_success_at' => null,
|
||||
|
||||
@@ -31,10 +31,10 @@ class CacheServiceProvider extends ServiceProvider
|
||||
|
||||
// Регистрация RedisAdapter для Redis кеша
|
||||
$this->container->singleton(RedisAdapter::class, function (Container $container) {
|
||||
$host = env('TELECART_REDIS_HOST', '127.0.0.1');
|
||||
$port = (int) env('TELECART_REDIS_PORT', 6379);
|
||||
$password = env('TELECART_REDIS_PASSWORD', null);
|
||||
$database = (int) env('TELECART_REDIS_DATABASE', 0);
|
||||
$host = env('MEGAPAY_REDIS_HOST', '127.0.0.1');
|
||||
$port = (int) env('MEGAPAY_REDIS_PORT', 6379);
|
||||
$password = env('MEGAPAY_REDIS_PASSWORD', null);
|
||||
$database = (int) env('MEGAPAY_REDIS_DATABASE', 0);
|
||||
|
||||
$redisConfig = [
|
||||
'host' => $host,
|
||||
@@ -56,7 +56,7 @@ class CacheServiceProvider extends ServiceProvider
|
||||
|
||||
// Регистрация CacheInterface с выбором драйвера
|
||||
$this->container->singleton(CacheInterface::class, function (Container $container) {
|
||||
$driver = env('TELECART_CACHE_DRIVER', 'mysql');
|
||||
$driver = env('MEGAPAY_CACHE_DRIVER', 'mysql');
|
||||
|
||||
if ($driver === 'redis') {
|
||||
return new SymfonyRedisCache($container->get(RedisAdapter::class));
|
||||
|
||||
@@ -31,7 +31,7 @@ class ImageFactory
|
||||
'format' => 'webp',
|
||||
'quality' => 90,
|
||||
'no_image_path' => 'no_image.png',
|
||||
'cache_path' => 'cache/telecart',
|
||||
'cache_path' => 'cache/megapay',
|
||||
];
|
||||
|
||||
public function __construct(string $imageDir, string $siteUrl, string $driver, array $options = [])
|
||||
@@ -180,7 +180,7 @@ class ImageFactory
|
||||
$filename .= '_' . substr(hash('SHA256', json_encode($this->modifications)), 0, 12);
|
||||
}
|
||||
|
||||
$cachePath = $this->options['cache_path'] ?? 'cache/telecart';
|
||||
$cachePath = $this->options['cache_path'] ?? 'cache/megapay';
|
||||
$cachePath = ltrim($cachePath, '/');
|
||||
|
||||
return $this->imageDir . '/' . $cachePath . '/' . $imagePath . $filename . '.' . $format;
|
||||
|
||||
@@ -17,7 +17,7 @@ class ImageToolServiceProvider extends ServiceProvider
|
||||
$container->getConfigValue('app.shop_base_url'),
|
||||
$driver,
|
||||
[
|
||||
'cache_path' => $container->getConfigValue('paths.images_cache', 'cache/telecart'),
|
||||
'cache_path' => $container->getConfigValue('paths.images_cache', 'cache/megapay'),
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ class MigratorService
|
||||
|
||||
private function getMigrationsTableName(): string
|
||||
{
|
||||
return 'telecart_migrations';
|
||||
return 'megapay_migrations';
|
||||
}
|
||||
|
||||
private function ensureMigrationsTableExists(): void
|
||||
|
||||
@@ -10,7 +10,7 @@ use Openguru\OpenCartFramework\QueryBuilder\Builder;
|
||||
|
||||
class ScheduledJob
|
||||
{
|
||||
private const TABLE_NAME = 'telecart_scheduled_jobs';
|
||||
private const TABLE_NAME = 'megapay_scheduled_jobs';
|
||||
|
||||
private Builder $builder;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use JsonException;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
final class PulseEvents
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use Exception;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
class StartParamSerializer
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Openguru\OpenCartFramework\QueryBuilder\Builder;
|
||||
@@ -11,9 +11,9 @@ use Openguru\OpenCartFramework\QueryBuilder\RawExpression;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use RuntimeException;
|
||||
|
||||
class TeleCartEvent
|
||||
class MegaPayEvent
|
||||
{
|
||||
private const TABLE_NAME = 'telecart_events';
|
||||
private const TABLE_NAME = 'megapay_events';
|
||||
|
||||
private ConnectionInterface $database;
|
||||
private Builder $builder;
|
||||
@@ -94,7 +94,7 @@ class TeleCartEvent
|
||||
}
|
||||
|
||||
$errorMessage = $error ? $error[1] : 'Unknown error';
|
||||
throw new RuntimeException("Failed to insert telecart event. Error: {$errorMessage}");
|
||||
throw new RuntimeException("Failed to insert megapay event. Error: {$errorMessage}");
|
||||
}
|
||||
|
||||
return $this->database->lastInsertId();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Openguru\OpenCartFramework\Support\Arr;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class TeleCartPulseEventsSender
|
||||
class MegaPayPulseEventsSender
|
||||
{
|
||||
private PayloadSigner $payloadSigner;
|
||||
private LoggerInterface $logger;
|
||||
@@ -84,7 +84,7 @@ class TeleCartPulseEventsSender
|
||||
'timeout' => env('PULSE_TIMEOUT', 5.0),
|
||||
'headers' => [
|
||||
'Authorization' => 'Bearer ' . $this->apiKey,
|
||||
'X-TELECART-VERSION' => module_version(),
|
||||
'X-MEGAPAY-VERSION' => module_version(),
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
@@ -13,13 +13,13 @@ use Openguru\OpenCartFramework\Telegram\TelegramService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
|
||||
class TeleCartPulseService
|
||||
class MegaPayPulseService
|
||||
{
|
||||
private TelegramInitDataDecoder $initDataDecoder;
|
||||
private TelegramService $telegramService;
|
||||
private CacheInterface $cache;
|
||||
private LoggerInterface $logger;
|
||||
private TeleCartEvent $eventModel;
|
||||
private MegaPayEvent $eventModel;
|
||||
private ?string $apiKey;
|
||||
private ?PayloadSigner $heartbeatPayloadSigner;
|
||||
|
||||
@@ -28,7 +28,7 @@ class TeleCartPulseService
|
||||
TelegramService $telegramService,
|
||||
CacheInterface $cache,
|
||||
LoggerInterface $logger,
|
||||
TeleCartEvent $eventModel,
|
||||
MegaPayEvent $eventModel,
|
||||
?string $apiKey = null,
|
||||
?PayloadSigner $heartbeatPayloadSigner = null
|
||||
) {
|
||||
@@ -132,16 +132,16 @@ class TeleCartPulseService
|
||||
*/
|
||||
public function handleHeartbeat(): void
|
||||
{
|
||||
if ($this->cache->get('telecart_pulse_heartbeat')) {
|
||||
if ($this->cache->get('megapay_pulse_heartbeat')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->cache->set('telecart_pulse_heartbeat', time(), 3600);
|
||||
$this->cache->set('megapay_pulse_heartbeat', time(), 3600);
|
||||
$me = $this->telegramService->getMe();
|
||||
} catch (Throwable $e) {
|
||||
$this->logger->warning(
|
||||
'TeleCart Pulse heartbeat prerequisites failed: ' . $e->getMessage(),
|
||||
'MegaPay Pulse heartbeat prerequisites failed: ' . $e->getMessage(),
|
||||
['exception' => $e]
|
||||
);
|
||||
|
||||
@@ -173,7 +173,7 @@ class TeleCartPulseService
|
||||
$signature = $this->heartbeatPayloadSigner->sign($payload);
|
||||
} catch (PayloadSignException $exception) {
|
||||
$this->logger->warning(
|
||||
'TeleCart Pulse heartbeat signing failed: ' . $exception->getMessage(),
|
||||
'MegaPay Pulse heartbeat signing failed: ' . $exception->getMessage(),
|
||||
['exception' => $exception]
|
||||
);
|
||||
|
||||
@@ -199,7 +199,7 @@ class TeleCartPulseService
|
||||
'base_uri' => $baseUri,
|
||||
'timeout' => env('PULSE_TIMEOUT', 2.0),
|
||||
'headers' => [
|
||||
'X-TELECART-VERSION' => module_version(),
|
||||
'X-MEGAPAY-VERSION' => module_version(),
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use Openguru\OpenCartFramework\Cache\CacheInterface;
|
||||
use Openguru\OpenCartFramework\Container\Container;
|
||||
@@ -9,7 +9,7 @@ use Openguru\OpenCartFramework\Telegram\TelegramInitDataDecoder;
|
||||
use Openguru\OpenCartFramework\Telegram\TelegramService;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class TeleCartPulseServiceProvider extends ServiceProvider
|
||||
class MegaPayPulseServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
@@ -19,23 +19,23 @@ class TeleCartPulseServiceProvider extends ServiceProvider
|
||||
);
|
||||
});
|
||||
|
||||
$this->container->singleton(TeleCartPulseService::class, function (Container $app) {
|
||||
$this->container->singleton(MegaPayPulseService::class, function (Container $app) {
|
||||
$heartbeatSecret = $app->getConfigValue('pulse.heartbeat_secret') ?? env('PULSE_HEARTBEAT_SECRET');
|
||||
$heartbeatSigner = $heartbeatSecret ? new PayloadSigner($heartbeatSecret) : null;
|
||||
|
||||
return new TeleCartPulseService(
|
||||
return new MegaPayPulseService(
|
||||
$app->get(TelegramInitDataDecoder::class),
|
||||
$app->get(TelegramService::class),
|
||||
$app->get(CacheInterface::class),
|
||||
$app->get(LoggerInterface::class),
|
||||
$app->get(TeleCartEvent::class),
|
||||
$app->get(MegaPayEvent::class),
|
||||
$app->getConfigValue('pulse.api_key'),
|
||||
$heartbeatSigner,
|
||||
);
|
||||
});
|
||||
|
||||
$this->container->singleton(TeleCartPulseEventsSender::class, function (Container $app) {
|
||||
return new TeleCartPulseEventsSender(
|
||||
$this->container->singleton(MegaPayPulseEventsSender::class, function (Container $app) {
|
||||
return new MegaPayPulseEventsSender(
|
||||
$app->get(PayloadSigner::class),
|
||||
$app->get(LoggerInterface::class),
|
||||
$app->getConfigValue('pulse.api_key'),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Openguru\OpenCartFramework\TeleCartPulse;
|
||||
namespace Openguru\OpenCartFramework\MegaPayPulse;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class StartCommand extends TelegramCommand
|
||||
{
|
||||
$chatId = $update['message']['chat']['id'];
|
||||
|
||||
$message = $this->settings->get('texts.start_message', 'Welcome to Telecart - Telegram e-commerce solution.');
|
||||
$message = $this->settings->get('texts.start_message', 'Welcome to Megapay - Telegram e-commerce solution.');
|
||||
$buttons = [
|
||||
'inline_keyboard' => [
|
||||
[
|
||||
|
||||
@@ -46,7 +46,7 @@ class TestCase extends BaseTestCase
|
||||
$app = ApplicationFactory::create([
|
||||
'app' => [
|
||||
'app_enabled' => true,
|
||||
'app_name' => 'Telecart',
|
||||
'app_name' => 'Megapay',
|
||||
'app_icon' => null,
|
||||
"theme_light" => "light",
|
||||
"theme_dark" => "dark",
|
||||
@@ -108,10 +108,10 @@ class TestCase extends BaseTestCase
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'namespace' => 'telecart',
|
||||
'namespace' => 'megapay',
|
||||
'default_lifetime' => 60 * 60 * 24,
|
||||
'options' => [
|
||||
'db_table' => 'telecart_cache_items',
|
||||
'db_table' => 'megapay_cache_items',
|
||||
],
|
||||
],
|
||||
|
||||
@@ -161,7 +161,7 @@ class TestCase extends BaseTestCase
|
||||
|
||||
protected function getNullLogger(): LoggerInterface
|
||||
{
|
||||
$logger = new Logger('Telecart_Tests');
|
||||
$logger = new Logger('Megapay_Tests');
|
||||
$logger->pushHandler(new NullHandler());
|
||||
|
||||
return $logger;
|
||||
|
||||
@@ -403,10 +403,10 @@ class ArrTest extends TestCase
|
||||
public function testMergeArraysRecursivelyWithDotNotationRealWorldExample(): void
|
||||
{
|
||||
$json = [
|
||||
'module_telecart_settings' => [
|
||||
'module_megapay_settings' => [
|
||||
'app' => [
|
||||
'app_enabled' => true,
|
||||
'app_name' => 'Telecart',
|
||||
'app_name' => 'Megapay',
|
||||
],
|
||||
'telegram' => [
|
||||
'bot_token' => 'old_token',
|
||||
@@ -415,22 +415,22 @@ class ArrTest extends TestCase
|
||||
];
|
||||
|
||||
$envOverrides = [
|
||||
'app.logs.path' => '/var/log/telecart',
|
||||
'app.logs.path' => '/var/log/megapay',
|
||||
'app.app_debug' => true,
|
||||
'telegram.bot_token' => 'new_token_from_env',
|
||||
];
|
||||
|
||||
$result = Arr::mergeArraysRecursivelyWithDotNotation(
|
||||
$json['module_telecart_settings'],
|
||||
$json['module_megapay_settings'],
|
||||
$envOverrides
|
||||
);
|
||||
|
||||
$expected = [
|
||||
'app' => [
|
||||
'app_enabled' => true,
|
||||
'app_name' => 'Telecart',
|
||||
'app_name' => 'Megapay',
|
||||
'logs' => [
|
||||
'path' => '/var/log/telecart',
|
||||
'path' => '/var/log/megapay',
|
||||
],
|
||||
'app_debug' => true,
|
||||
],
|
||||
@@ -667,7 +667,7 @@ class ArrTest extends TestCase
|
||||
public function testExceptRemovesSpecifiedKeys(): void
|
||||
{
|
||||
$array = [
|
||||
'app' => 'telecart',
|
||||
'app' => 'megapay',
|
||||
'debug' => true,
|
||||
'version' => '1.0.0',
|
||||
];
|
||||
@@ -675,7 +675,7 @@ class ArrTest extends TestCase
|
||||
$result = Arr::except($array, ['debug', 'nonexistent']);
|
||||
|
||||
$expected = [
|
||||
'app' => 'telecart',
|
||||
'app' => 'megapay',
|
||||
'version' => '1.0.0',
|
||||
];
|
||||
|
||||
@@ -685,7 +685,7 @@ class ArrTest extends TestCase
|
||||
public function testExceptReturnsOriginalArrayWhenNoKeysProvided(): void
|
||||
{
|
||||
$array = [
|
||||
'app' => 'telecart',
|
||||
'app' => 'megapay',
|
||||
'debug' => true,
|
||||
];
|
||||
|
||||
|
||||
@@ -519,7 +519,7 @@ class BuilderTest extends TestCase
|
||||
$connection->expects($this->once())
|
||||
->method('statement')
|
||||
->with(
|
||||
'UPDATE `telecart_settings` SET `alias` = ?, `foo` = ? WHERE alias = ?',
|
||||
'UPDATE `megapay_settings` SET `alias` = ?, `foo` = ? WHERE alias = ?',
|
||||
['foobar2', 'bar2', 'foobar']
|
||||
)
|
||||
->willReturn(true);
|
||||
@@ -528,7 +528,7 @@ class BuilderTest extends TestCase
|
||||
|
||||
$builder->newQuery()
|
||||
->where('alias', '=', 'foobar')
|
||||
->update('telecart_settings', [
|
||||
->update('megapay_settings', [
|
||||
'alias' => 'foobar2',
|
||||
'foo' => 'bar2',
|
||||
]);
|
||||
@@ -542,7 +542,7 @@ class BuilderTest extends TestCase
|
||||
$connection->expects($this->once())
|
||||
->method('statement')
|
||||
->with(
|
||||
'UPDATE `telecart_settings` SET `json` = ? WHERE alias = ?',
|
||||
'UPDATE `megapay_settings` SET `json` = ? WHERE alias = ?',
|
||||
[$json, 'foobar']
|
||||
)
|
||||
->willReturn(true);
|
||||
@@ -551,7 +551,7 @@ class BuilderTest extends TestCase
|
||||
|
||||
$builder->newQuery()
|
||||
->where('alias', '=', 'foobar')
|
||||
->update('telecart_settings', [
|
||||
->update('megapay_settings', [
|
||||
'json' => $json,
|
||||
]);
|
||||
}
|
||||
@@ -564,7 +564,7 @@ class BuilderTest extends TestCase
|
||||
$connection->expects($this->once())
|
||||
->method('statement')
|
||||
->with(
|
||||
'UPDATE `telecart_settings` SET `json` = ? WHERE alias = ?',
|
||||
'UPDATE `megapay_settings` SET `json` = ? WHERE alias = ?',
|
||||
[$json, 'foobar']
|
||||
)
|
||||
->willReturn(true);
|
||||
@@ -573,7 +573,7 @@ class BuilderTest extends TestCase
|
||||
|
||||
$builder->newQuery()
|
||||
->where('alias', '=', 'foobar')
|
||||
->update('telecart_settings', [
|
||||
->update('megapay_settings', [
|
||||
'json' => $json,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ class ImageFactoryTest extends TestCase
|
||||
|
||||
$factory = new ImageFactory($this->imageDir, $this->siteUrl, 'gd');
|
||||
|
||||
// Ожидание: http://localhost/image/cache/telecart/catalog/test_...
|
||||
// Ожидание: http://localhost/image/cache/megapay/catalog/test_...
|
||||
$url = $factory->make('catalog/test.png')->url();
|
||||
|
||||
// Проверяем, что 'cache' не пострадал от ltrim и путь содержит telecart
|
||||
$this->assertStringContainsString('/image/cache/telecart/catalog/test', $url, 'URL corrupted: ' . $url);
|
||||
// Проверяем, что 'cache' не пострадал от ltrim и путь содержит megapay
|
||||
$this->assertStringContainsString('/image/cache/megapay/catalog/test', $url, 'URL corrupted: ' . $url);
|
||||
}
|
||||
|
||||
public function testFilenameLengthAndDuplication()
|
||||
@@ -84,7 +84,7 @@ class ImageFactoryTest extends TestCase
|
||||
$expectedHash = substr(hash('SHA256', json_encode(['resize' => ['width' => 100, 'height' => 100]])), 0, 12);
|
||||
$this->assertStringContainsString($expectedHash, $filename);
|
||||
|
||||
$this->assertFileExists($this->imageDir . '/cache/telecart/test_' . $expectedHash . '.webp');
|
||||
$this->assertFileExists($this->imageDir . '/cache/megapay/test_' . $expectedHash . '.webp');
|
||||
}
|
||||
|
||||
public function testMissingImageFallback()
|
||||
@@ -100,7 +100,7 @@ class ImageFactoryTest extends TestCase
|
||||
$this->assertStringContainsString('no_image', $url);
|
||||
|
||||
// Проверяем, что сам файл создался (конвертация в webp)
|
||||
$this->assertFileExists($this->imageDir . '/cache/telecart/no_image.webp');
|
||||
$this->assertFileExists($this->imageDir . '/cache/megapay/no_image.webp');
|
||||
}
|
||||
|
||||
public function testMissingFallbackImageSafeFail()
|
||||
|
||||
@@ -7,7 +7,7 @@ use App\Services\OcCustomerService;
|
||||
use App\Services\OrderCreateService;
|
||||
use App\Services\OrderMetaService;
|
||||
use App\Services\SettingsService;
|
||||
use App\Services\TelecartCustomerService;
|
||||
use App\Services\MegapayCustomerService;
|
||||
use Carbon\Carbon;
|
||||
use Mockery as m;
|
||||
use Openguru\OpenCartFramework\OpenCart\Decorators\OcRegistryDecorator;
|
||||
@@ -67,7 +67,7 @@ class OrderCreateServiceTest extends TestCase
|
||||
$orderId = 1111;
|
||||
$orderProductId = 223;
|
||||
$ocCustomerId = 333;
|
||||
$telecartCustomerId = 444;
|
||||
$megapayCustomerId = 444;
|
||||
|
||||
$product = [
|
||||
'product_id' => 93,
|
||||
@@ -176,24 +176,24 @@ class OrderCreateServiceTest extends TestCase
|
||||
$telegramServiceMock = m::mock(TelegramService::class);
|
||||
$loggerMock = m::mock(LoggerInterface::class);
|
||||
|
||||
$telegramCustomerService = m::mock(TelecartCustomerService::class);
|
||||
$telegramCustomerService = m::mock(MegapayCustomerService::class);
|
||||
$telegramCustomerService->shouldReceive('saveOrUpdate')->once()
|
||||
->with($tgData['user'])
|
||||
->andReturn(['id' => $telecartCustomerId]);
|
||||
->andReturn(['id' => $megapayCustomerId]);
|
||||
|
||||
$telegramCustomerService->shouldReceive('increaseOrdersCount')->once()
|
||||
->with($telecartCustomerId)
|
||||
->with($megapayCustomerId)
|
||||
->andReturnNull();
|
||||
|
||||
$ocCustomerService = m::mock(OcCustomerService::class);
|
||||
$ocCustomerService->shouldReceive('findOrCreateByTelecartCustomerId')->once()
|
||||
->with($telecartCustomerId, m::type('array'))
|
||||
$ocCustomerService->shouldReceive('findOrCreateByMegapayCustomerId')->once()
|
||||
->with($megapayCustomerId, m::type('array'))
|
||||
->andReturn(['customer_id' => $ocCustomerId]);
|
||||
|
||||
$orderMetaService = m::mock(OrderMetaService::class);
|
||||
$orderMetaService->shouldReceive('insert')
|
||||
->once()
|
||||
->with($orderId, $storeId, $customOrderFields, $telecartCustomerId)
|
||||
->with($orderId, $storeId, $customOrderFields, $megapayCustomerId)
|
||||
->andReturnNull();
|
||||
|
||||
$service = new OrderCreateService(
|
||||
|
||||
Reference in New Issue
Block a user