1
0
Fork 0
mirror of synced 2025-04-18 16:41:02 +00:00

codestyle fix after codereview

This commit is contained in:
Sergey Chazov 2020-10-12 14:24:17 +03:00 committed by Neur0toxine
parent 2243e1ea17
commit b9b84ce053
4 changed files with 14 additions and 60 deletions

View file

@ -12,6 +12,8 @@
*/
namespace Intaro\RetailCrm\Component\Loyalty;
IncludeModuleLangFile(__FILE__);
use Bitrix\Main\ArgumentException;
use Bitrix\Main\Event;
use Bitrix\Main\HttpRequest;
@ -20,6 +22,7 @@ use Bitrix\Main\SystemException;
use Bitrix\Sale\PaySystem\Manager;
use Exception;
use Intaro\RetailCrm\Component\ConfigProvider;
use Intaro\RetailCrm\Component\Constants;
use Intaro\RetailCrm\Repository\PaySystemActionRepository;
use Intaro\RetailCrm\Service\LoyaltyService;
@ -114,19 +117,16 @@ class EventsHandlers
public function OnSaleComponentOrderResultPreparedHandler($order, $arUserResult, HttpRequest $request, $arParams, &$arResult): void
{
if (ConfigProvider::getLoyaltyProgramStatus() === 'Y') {
$isBonusError = false;
$bonusInput = (int)$request->get('bonus-input');
$availableBonuses = (int)$request->get('available-bonuses');
if ($bonusInput > $availableBonuses) {
$arResult['LOYALTY']['ERROR'] = self::BONUS_ERROR_MSG;
$isBonusError = true;
$arResult['LOYALTY']['ERROR'] = GetMessage('BONUS_ERROR_MSG');
return;
}
if (
$bonusInput > 0
if ($bonusInput > 0
&& $availableBonuses > 0
&& $isBonusError === false
&& $arResult['JS_DATA']['TOTAL']['ORDER_TOTAL_PRICE'] >= $bonusInput
) {
$arResult['JS_DATA']['TOTAL']['ORDER_TOTAL_PRICE'] -= $bonusInput;
@ -149,7 +149,8 @@ class EventsHandlers
if (isset($_POST['bonus-input'], $_POST['available-bonuses'])
&& $isNew
&& (int)$_POST['available-bonuses'] >= (int)$_POST['bonus-input']) {
&& (int) $_POST['available-bonuses'] >= (int) $_POST['bonus-input']
) {
$orderId = $order->getId();
$bonusCount = $_POST['bonus-input'];
$service = new LoyaltyService();

View file

@ -0,0 +1,2 @@
<?php
$MESS["BONUS_ERROR_MSG"] = 'Нельзя потратить такое количество бонусов';

View file

@ -1,48 +0,0 @@
<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Service
* @author retailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Service;
use Intaro\RetailCrm\Component\Factory\ClientFactory;
use Intaro\RetailCrm\Component\Json\Deserializer;
use Intaro\RetailCrm\Model\Api\Response\Settings\CredentialsResponse;
/**
* Class SettingsService
*
* @package Intaro\RetailCrm\Service
*/
class SettingsService
{
/**
* @var \Intaro\RetailCrm\Component\ApiClient\ClientAdapter
*/
private $client;
/**
* LoyaltyService constructor.
*/
public function __construct()
{
$this->client = ClientFactory::createClientAdapter();
}
/**
* @return \Intaro\RetailCrm\Model\Api\Response\Settings\CredentialsResponse
*/
public function getCredentials(): CredentialsResponse
{
$response = $this->client->getCredentials();
return Deserializer::deserializeArray($response->getResponseBody(), CredentialsResponse::class);
}
}

View file

@ -903,12 +903,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
);
}
function replaceDefaultSaleTemplates(){
function replaceDefaultSaleTemplates() {
let templates = [];
let i = 0;
$('#lp-templates input:checkbox:checked')
.each(
$('#lp-templates input:checkbox:checked').each(
function(index, checkbox){
templates[i] = {
'name': $(checkbox).val(),
@ -917,9 +916,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
i++;
}
);
let requestAddress = 'intaro:retailcrm.api.adminpanel.createSaleTemplate';
BX.ajax.runAction(requestAddress,
BX.ajax.runAction(
'intaro:retailcrm.api.adminpanel.createSaleTemplate',
{
data: {
sessid: BX.bitrix_sessid(),