42 if (empty($this->restrictions) || !self::canUse())
49 $this->lockRestrictions();
51 $codes = array_keys($this->restrictions);
52 $query = RestrictionTable::query()
58 ->whereIn(
'CODE', $codes)
59 ->where(
'DATE_CREATE',
new Date())
60 ->setLimit(count($this->restrictions))
63 foreach($query->exec() as $row)
67 $this->restrictions[$code]
68 ->setCounter($row[
'COUNTER'])
69 ->setAdditionalParams($row[
'ADDITIONAL_PARAMS'])
73 if (!$this->checkRestrictions())
79 $connection->startTransaction();
81 foreach($this->restrictions as $restriction)
83 if (!$restriction->increase())
85 $this->notPassedRestriction = $restriction;
86 $connection->rollbackTransaction();
91 $connection->commitTransaction();
97 $this->unlockRestrictions();
98 if (isset($this->notPassedRestriction))
100 $this->notPassedRestriction->log();