Neur0toxine
5f69051859
* New module structure (refactoring) * Simple serializer and deserializer with models, new architecture * Move logic to strategies * Partial api client facade implementation (full implementation is not necessary for now) * Loyalty feature installer * Sms verification order (#167) * Make updater self-sufficient * Fix for order submit & fix for incorrect component rendering in the constructor * Fix for loyalty personal area error handling * Fix for cart component identity * Fix for softlock when customer cannot be registered in loyalty Co-authored-by: Сергей Чазов <45812598+Chazovs@users.noreply.github.com> Co-authored-by: Sergey Chazov <oitv18@gmail.com>
126 lines
3.9 KiB
PHP
126 lines
3.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Class RetailCrmService
|
|
*/
|
|
class RetailCrmService
|
|
{
|
|
/**
|
|
* @param $order
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function unsetIntegrationDeliveryFields(array $order): array
|
|
{
|
|
$integrationDelivery = RetailcrmConfigProvider::getCrmIntegrationDelivery();
|
|
if (isset($order['delivery']['code'])) {
|
|
$deliveryCode = $order['delivery']['code'];
|
|
|
|
if (!empty($integrationDelivery[$deliveryCode])
|
|
&& $integrationDelivery[$deliveryCode] !== 'sdek'
|
|
&& $integrationDelivery[$deliveryCode] !== 'dpd'
|
|
&& $integrationDelivery[$deliveryCode] !== 'newpost'
|
|
) {
|
|
unset($order['weight']);
|
|
unset($order['firstName']);
|
|
unset($order['lastName']);
|
|
unset($order['phone']);
|
|
unset($order['delivery']['cost']);
|
|
unset($order['paymentType']);
|
|
unset($order['shipmentStore']);
|
|
unset($order['delivery']['address']);
|
|
unset($order['delivery']['data']);
|
|
}
|
|
|
|
switch ($integrationDelivery[$deliveryCode]) {
|
|
case "sdek":
|
|
unset($order['weight']);
|
|
unset($order['length']);
|
|
unset($order['width']);
|
|
unset($order['height']);
|
|
unset($order['phone']);
|
|
unset($order['delivery']['cost']);
|
|
unset($order['paymentType']);
|
|
unset($order['shipmentStore']);
|
|
unset($order['number']);
|
|
unset($order['delivery']['address']);
|
|
unset($order['delivery']['data']);
|
|
break;
|
|
case "dpd":
|
|
unset($order['weight']);
|
|
unset($order['manager']);
|
|
unset($order['phone']);
|
|
unset($order['firstName']);
|
|
unset($order['lastName']);
|
|
unset($order['delivery']['cost']);
|
|
unset($order['paymentType']);
|
|
unset($order['shipmentStore']);
|
|
unset($order['delivery']['address']);
|
|
unset($order['delivery']['data']);
|
|
break;
|
|
case "newpost":
|
|
unset($order['weight']);
|
|
unset($order['customer']);
|
|
unset($order['phone']);
|
|
unset($order['shipmentStore']);
|
|
unset($order['paymentType']);
|
|
unset($order['delivery']['cost']);
|
|
unset($order['delivery']['address']);
|
|
unset($order['delivery']['data']);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return $order;
|
|
}
|
|
|
|
/**
|
|
* @param array $data
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function selectIntegrationDeliveries(array $data): array
|
|
{
|
|
$result = [];
|
|
|
|
foreach ($data as $elem) {
|
|
if (!empty($elem['integrationCode'])) {
|
|
$result[$elem['code']] = $elem['integrationCode'];
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* @param array $data
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function selectIntegrationPayments(array $data): array
|
|
{
|
|
$result = [];
|
|
|
|
foreach ($data as $elem) {
|
|
if (!empty($elem['integrationModule'])) {
|
|
$result[] = $elem['code'];
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
/**
|
|
* @param int|null $paySystemId
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function isIntegrationPayment(?int $paySystemId): bool {
|
|
return in_array(
|
|
RetailcrmConfigProvider::getPaymentTypes()[$paySystemId] ?? null,
|
|
RetailcrmConfigProvider::getIntegrationPaymentTypes(),
|
|
true
|
|
);
|
|
}
|
|
}
|