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 d4934254
authored
May 11, 2021
by
Евгений
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Улучшение #19453
Первоначальная загрузка всех РК аккаунтов.
1 parent
b94fb42e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
11 deletions
app/Console/Commands/CheckChangeCampaigns.php
app/Console/Commands/FirstLoadCampaigns.php
app/Service/Requests/Direct/CheckDictionariesChange.php
app/Service/Requests/Direct/GetCampaigns.php
database/migrations/2021_04_29_142844_create_tokens_table.php
app/Console/Commands/CheckChangeCampaigns.php
0 → 100644
View file @
d493425
<?php
namespace
App\Console\Commands
;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Models\Tokens
;
use
App\Service\API\API
;
use
App\Service\Direct\CheckDictionaries
;
use
App\Service\Direct\GetCampaigns
;
use
App\Service\Requests\APIRequest
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\Bus
;
class
CheckChangeCampaigns
extends
Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected
$signature
=
'campaigns:checkChange'
;
/**
* The console command description.
*
* @var string
*/
protected
$description
=
'Проверка изменений в РК'
;
/**
* Create a new command instance.
*
* @return void
*/
public
function
__construct
()
{
parent
::
__construct
();
}
/**
* Execute the console command.
*
* @return int
*/
public
function
handle
()
{
$token
=
Tokens
::
where
(
'type'
,
Tokens
::
MAIN
)
->
first
();
if
(
!
$token
){
throw
new
\Exception
(
'Не найден токен блин'
);
}
$factory
=
APIRequest
::
getInstance
(
API
::
YANDEX
);
$factory
->
setToken
(
$token
);
$factory
->
getRequest
(
'change'
,
'checkCampaigns'
)
->
call
();
return
0
;
}
}
app/Console/Commands/FirstLoadCampaigns.php
View file @
d493425
...
@@ -53,9 +53,8 @@ class FirstLoadCampaigns extends Command
...
@@ -53,9 +53,8 @@ class FirstLoadCampaigns extends Command
$factory
->
setToken
(
$token
);
$factory
->
setToken
(
$token
);
$factory
->
getRequest
(
'change'
,
'CheckDictionaries'
)
$factory
->
getRequest
(
'change'
,
'CheckDictionaries'
)
->
call
(
->
call
();
$factory
->
getRequest
(
'campaigns'
,
'get'
)
$factory
->
getRequest
(
'campaigns'
,
'get'
)
->
call
();
);
return
0
;
return
0
;
}
}
...
...
app/Service/Requests/Direct/CheckDictionariesChange.php
View file @
d493425
...
@@ -17,9 +17,11 @@ class CheckDictionariesChange extends DirectRequest {
...
@@ -17,9 +17,11 @@ class CheckDictionariesChange extends DirectRequest {
}
}
function
handle
(
$response
){
function
handle
(
$response
){
if
(
$this
->
next
){
// if ($this->next){
$this
->
next
->
call
(
null
,
$response
);
// $this->next->call(null, $response);
}
// }
$this
->
token
->
timestamp
=
$response
[
'result'
][
'Timestamp'
]
??
''
;
$this
->
token
->
save
();
}
}
private
function
requestPrepare
(
$response
){
private
function
requestPrepare
(
$response
){
...
...
app/Service/Requests/Direct/GetCampaigns.php
View file @
d493425
...
@@ -59,7 +59,7 @@ class GetCampaigns extends DirectRequest{
...
@@ -59,7 +59,7 @@ class GetCampaigns extends DirectRequest{
private
function
requestPrepare
(
$response
){
private
function
requestPrepare
(
$response
){
$this
->
setService
(
'campaigns'
);
$this
->
setService
(
'campaigns'
);
$this
->
setMethod
(
'get'
);
$this
->
setMethod
(
'get'
);
$this
->
setTimestamp
(
$response
);
//
$this->setTimestamp($response);
$params
=
[
$params
=
[
'SelectionCriteria'
=>
[
'SelectionCriteria'
=>
[
'Types'
=>
[
"TEXT_CAMPAIGN"
]
'Types'
=>
[
"TEXT_CAMPAIGN"
]
...
@@ -74,8 +74,8 @@ class GetCampaigns extends DirectRequest{
...
@@ -74,8 +74,8 @@ class GetCampaigns extends DirectRequest{
$this
->
setParams
(
$params
);
$this
->
setParams
(
$params
);
}
}
private
function
setTimestamp
(
$response
){
//
private function setTimestamp($response){
$this
->
timestamp
=
$response
[
'result'
][
'Timestamp'
]
??
''
;
//
$this->timestamp = $response['result']['Timestamp'] ?? '';
}
//
}
}
}
database/migrations/2021_04_29_142844_create_tokens_table.php
View file @
d493425
...
@@ -20,7 +20,7 @@ class CreateTokensTable extends Migration
...
@@ -20,7 +20,7 @@ class CreateTokensTable extends Migration
$table
->
enum
(
'api'
,
[
'yd'
]);
$table
->
enum
(
'api'
,
[
'yd'
]);
$table
->
enum
(
'type'
,
[
'main'
,
'goal'
])
->
nullable
();
$table
->
enum
(
'type'
,
[
'main'
,
'goal'
])
->
nullable
();
$table
->
integer
(
'created_by'
);
$table
->
integer
(
'created_by'
);
$table
->
timestamps
();
$table
->
timestamps
()
->
nullable
()
;
$table
->
unique
(
'token'
);
$table
->
unique
(
'token'
);
});
});
...
...
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