From 962b940abc2d7c63fa1ade9f016757b431f7b5eb Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Thu, 30 May 2024 21:28:58 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20?= =?utf8?q?=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=BA=D0=BE?= =?utf8?q?=D0=B4=D0=B0=20=D0=BE=D1=82=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD?= =?utf8?q?=D1=82=D0=B0=20=D0=B2=20=D0=B1=D0=BB=D0=BE=D0=BA=20=D1=81=D0=BF?= =?utf8?q?=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B1=D0=BE=D0=BD=D1=83?= =?utf8?q?=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/BonusController.php | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/erp24/api2/controllers/BonusController.php b/erp24/api2/controllers/BonusController.php index 98a2c9ff..9a430407 100644 --- a/erp24/api2/controllers/BonusController.php +++ b/erp24/api2/controllers/BonusController.php @@ -664,12 +664,13 @@ class BonusController extends BaseController return $this->asJson($mess); } - file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '--' . __LINE__, FILE_APPEND); - if ($user->keycode != strval($auth_code)) { - - file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '-auth_code not valid-' . __LINE__ . ' keycode ' .$user->keycode . '| auth_code ' . strval($auth_code), FILE_APPEND); - return $this->asJson(['error' => 'auth_code not valid']); - } +// старая точка проверки кода +// file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '--' . __LINE__, FILE_APPEND); +// if ($user->keycode != strval($auth_code)) { +// +// file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '-auth_code not valid-' . __LINE__ . ' keycode ' .$user->keycode . '| auth_code ' . strval($auth_code), FILE_APPEND); +// return $this->asJson(['error' => 'auth_code not valid']); +// } file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '--' . __LINE__, FILE_APPEND); $user_id = $user->id; @@ -710,6 +711,13 @@ class BonusController extends BaseController $user_balans_new = $user_balans; if ($write_off_bonuses && !$writeOffAlready) { + // Проверка кода только при списании + file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '--' . __LINE__, FILE_APPEND); + if ($user->keycode != strval($auth_code)) { + + file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '-auth_code not valid-' . __LINE__ . ' keycode ' .$user->keycode . '| auth_code ' . strval($auth_code), FILE_APPEND); + return $this->asJson(['error' => 'auth_code not valid']); + } file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '--' . __LINE__, FILE_APPEND); $user_balans_new = $user_balans - $write_off_bonuses; @@ -766,6 +774,14 @@ class BonusController extends BaseController file_put_contents(self::$USERS_AUTH_CALL_LOG2, "" . date("d.m.Y H:i:s", time()) . " MINUS write_off_bonuses=" . $write_off_bonuses . "\n", FILE_APPEND | LOCK_EX); + + $mess["result"] = true; + $mess["message_cashier"] = "Бонусы списаны"; + + LogService::apiLogs(1, json_encode($mess, JSON_UNESCAPED_UNICODE)); + file_put_contents(self::OUT_DIR . '/sale_bonuses_' . $fl . '.json', PHP_EOL . '--' . __LINE__ . ' OK ', FILE_APPEND); + // Выход, так как происходит либо списание бонусов , либо начисление + return $this->asJson($mess); } //начисляем кэшбек клиенту 10% от покупки - с базы за вычитом бонусов которые он списывает -- 2.39.5