codestyle fix after codereview
This commit is contained in:
parent
2243e1ea17
commit
b9b84ce053
4 changed files with 14 additions and 60 deletions
|
@ -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();
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
$MESS["BONUS_ERROR_MSG"] = 'Нельзя потратить такое количество бонусов';
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Reference in a new issue