Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Письменов Дмитрий Иванович
/
yourroomads
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 55f993bd
authored
Jun 07, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.veeble.ru/pismenov/yourroomads
2 parents
bd4953fb
b3d58ad3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
app/Service/Limits.php
app/Service/Limits.php
View file @
55f993b
...
@@ -66,16 +66,23 @@ class Limits implements \App\Service\Contract\Limits {
...
@@ -66,16 +66,23 @@ class Limits implements \App\Service\Contract\Limits {
$cost
=
$this
->
limitCosts
->
getCostObject
(
$request
);
$cost
=
$this
->
limitCosts
->
getCostObject
(
$request
);
$maxCount
=
$request
->
getMaxCount
();
$maxCount
=
$request
->
getMaxCount
();
if
(
$this
->
limitCosts
->
getCostCall
(
$request
)
>
$this
->
current
()){
return
0
;
}
if
(
$cost
==
0
||
$maxCount
===
self
::
NAN
){
if
(
$cost
==
0
||
$maxCount
===
self
::
NAN
){
return
self
::
NAN
;
return
self
::
NAN
;
}
}
$allowCount
=
floor
((
$this
->
current
()
-
$this
->
limitCosts
->
getCostCall
(
$request
))
/
$cost
);
$objectsCount
=
$request
->
getObjectsCount
();
if
(
$this
->
token
->
limits
->
count
()
>
0
){
if
(
$this
->
limitCosts
->
getCostCall
(
$request
)
>
$this
->
current
()){
return
0
;
}
$allowCount
=
floor
((
$this
->
current
()
-
$this
->
limitCosts
->
getCostCall
(
$request
))
/
$cost
);
$objectsCount
=
$request
->
getObjectsCount
();
}
else
{
$allowCount
=
$maxCount
;
//не было еще запросов, считаем что баллов хватает
$objectsCount
=
$maxCount
;
}
if
(
$objectsCount
>
$maxCount
)
{
if
(
$objectsCount
>
$maxCount
)
{
$objectsCount
=
$maxCount
;
$objectsCount
=
$maxCount
;
...
@@ -99,7 +106,7 @@ class Limits implements \App\Service\Contract\Limits {
...
@@ -99,7 +106,7 @@ class Limits implements \App\Service\Contract\Limits {
function
doRezerv
(
\App\Service\Contract\APIRequest
$request
,
int
$objects
)
:
int
function
doRezerv
(
\App\Service\Contract\APIRequest
$request
,
int
$objects
)
:
int
{
{
$limit
=
$this
->
getSpent
(
$objects
,
$request
);
$limit
=
$this
->
getSpent
(
$objects
,
$request
);
if
(
$this
->
token
->
limit
<
$limit
){
if
(
$this
->
token
->
limit
s
->
count
()
>
1
&&
$this
->
token
->
limit
<
$limit
){
throw
new
\Exception
(
'Недостаточно баллов'
);
throw
new
\Exception
(
'Недостаточно баллов'
);
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment