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 9c40e9d5
authored
May 12, 2021
by
Vladislav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#19459 Вывод для основного аккаунта списка его РК из кеша
1 parent
91e43e51
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
94 deletions
app/Http/Controllers/TokensController.php
app/Models/Campaigns.php
app/Models/Tokens.php
app/Service/Requests/Direct/GetCampaigns.php
database/migrations/2021_05_04_140851_create_limits_table.php
database/migrations/2021_05_11_084828_create_campaigns_table.php
resources/js/Pages/Tokens/Edit.vue
app/Http/Controllers/TokensController.php
View file @
9c40e9d
...
@@ -39,7 +39,11 @@ class TokensController extends Controller
...
@@ -39,7 +39,11 @@ class TokensController extends Controller
'api'
=>
$token
->
api
,
'api'
=>
$token
->
api
,
'token'
=>
$token
->
token
,
'token'
=>
$token
->
token
,
'type'
=>
$token
->
type
,
'type'
=>
$token
->
type
,
'campaigns'
=>
(
$token
->
type
==
Tokens
::
MAIN
?
[]
:
null
),
'campaigns'
=>
(
$token
->
type
==
Tokens
::
MAIN
?
$token
->
campaigns
:
null
),
'cities'
=>
(
$token
->
type
==
Tokens
::
GOAL
?
[]
:
null
),
'cities'
=>
(
$token
->
type
==
Tokens
::
GOAL
?
[]
:
null
),
],
],
'types'
=>
$mainToken
->
count
()
&&
$token
->
type
!=
Tokens
::
MAIN
'types'
=>
$mainToken
->
count
()
&&
$token
->
type
!=
Tokens
::
MAIN
...
...
app/Models/Campaigns.php
View file @
9c40e9d
...
@@ -9,25 +9,6 @@ class Campaigns extends Model
...
@@ -9,25 +9,6 @@ class Campaigns extends Model
{
{
use
HasFactory
;
use
HasFactory
;
protected
$fillable
=
[
'external_id'
,
'Name'
,
'token'
,
'TimeTargeting'
,
'NegativeKeywords'
,
'BlockedIps'
,
'ExcludedSites'
,
'DailyBudget'
,
'TextCampaignStrategySearch'
,
'TextCampaignStrategyNetwork'
,
'Settings'
,
'CounterIds'
,
'RelevantKeywordsSettingBudgetPercent'
,
'RelevantKeywordsSettingOptimizeGoalId'
,
'AttributionModel'
,
'updated'
];
public
function
scopeForUpdated
(
$query
)
public
function
scopeForUpdated
(
$query
)
{
{
$query
->
whereNotNull
(
'updated'
);
$query
->
whereNotNull
(
'updated'
);
...
...
app/Models/Tokens.php
View file @
9c40e9d
...
@@ -27,4 +27,9 @@ class Tokens extends Model
...
@@ -27,4 +27,9 @@ class Tokens extends Model
{
{
return
$this
->
hasMany
(
Limits
::
class
,
'token'
,
'id'
)
->
orderBy
(
'updated_at'
,
'DESC'
);
return
$this
->
hasMany
(
Limits
::
class
,
'token'
,
'id'
)
->
orderBy
(
'updated_at'
,
'DESC'
);
}
}
public
function
campaigns
()
{
return
$this
->
hasMany
(
Campaigns
::
class
,
'token'
,
'id'
)
->
orderBy
(
'updated_at'
,
'DESC'
);
}
}
}
app/Service/Requests/Direct/GetCampaigns.php
View file @
9c40e9d
...
@@ -4,6 +4,7 @@ namespace App\Service\Requests\Direct;
...
@@ -4,6 +4,7 @@ namespace App\Service\Requests\Direct;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Jobs\ProcessCallLimitedAPI
;
use
App\Models\Campaigns
;
use
App\Models\Campaigns
;
use
App\Service\Requests\DirectRequest
;
use
App\Service\Requests\DirectRequest
;
use
Illuminate\Support\Facades\Log
;
class
GetCampaigns
extends
DirectRequest
{
class
GetCampaigns
extends
DirectRequest
{
protected
$timestamp
;
protected
$timestamp
;
...
@@ -15,47 +16,51 @@ class GetCampaigns extends DirectRequest{
...
@@ -15,47 +16,51 @@ class GetCampaigns extends DirectRequest{
}
}
function
handle
(
$response
){
function
handle
(
$response
){
$data
=
[];
try
{
foreach
(
$response
[
'result'
][
'Campaigns'
]
as
$campaign
){
$data
=
[];
$data
[]
=
[
foreach
(
$response
[
'result'
][
'Campaigns'
]
as
$campaign
){
'external_id'
=>
$campaign
[
'Id'
],
$data
[]
=
[
'token'
=>
$this
->
getToken
()
->
id
,
'external_id'
=>
$campaign
[
'Id'
],
'Name'
=>
$campaign
[
'Name'
],
'token'
=>
$this
->
getToken
()
->
id
,
'TimeTargeting'
=>
json_encode
(
$campaign
[
'TimeTargeting'
]),
'name'
=>
$campaign
[
'Name'
],
'NegativeKeywords'
=>
!
empty
(
$campaign
[
'NegativeKeywords'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'NegativeKeywords'
][
'Items'
])
:
''
,
'time_targeting'
=>
json_encode
(
$campaign
[
'TimeTargeting'
]),
'BlockedIps'
=>
!
empty
(
$campaign
[
'BlockedIps'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'BlockedIps'
][
'Items'
])
:
''
,
'negative_keywords'
=>
!
empty
(
$campaign
[
'NegativeKeywords'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'NegativeKeywords'
][
'Items'
])
:
''
,
'ExcludedSites'
=>
!
empty
(
$campaign
[
'ExcludedSites'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'ExcludedSites'
][
'Items'
])
:
''
,
'blocked_ips'
=>
!
empty
(
$campaign
[
'BlockedIps'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'BlockedIps'
][
'Items'
])
:
''
,
'DailyBudget'
=>
json_encode
(
$campaign
[
'DailyBudget'
]),
'excluded_sites'
=>
!
empty
(
$campaign
[
'ExcludedSites'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'ExcludedSites'
][
'Items'
])
:
''
,
'TextCampaignStrategySearch'
=>
$campaign
[
'TextCampaign'
][
'BiddingStrategy'
][
'Search'
][
'BiddingStrategyType'
],
'daily_budget'
=>
json_encode
(
$campaign
[
'DailyBudget'
]),
'TextCampaignStrategyNetwork'
=>
$campaign
[
'TextCampaign'
][
'BiddingStrategy'
][
'Network'
][
'BiddingStrategyType'
],
'text_campaign_strategy_search'
=>
$campaign
[
'TextCampaign'
][
'BiddingStrategy'
][
'Search'
][
'BiddingStrategyType'
],
'Settings'
=>
json_encode
(
$campaign
[
'TextCampaign'
][
'Settings'
]),
'text_campaign_strategy_network'
=>
$campaign
[
'TextCampaign'
][
'BiddingStrategy'
][
'Network'
][
'BiddingStrategyType'
],
'CounterIds'
=>
!
empty
(
$campaign
[
'TextCampaign'
][
'CounterIds'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'TextCampaign'
][
'CounterIds'
][
'Items'
])
:
''
,
'settings'
=>
json_encode
(
$campaign
[
'TextCampaign'
][
'Settings'
]),
'RelevantKeywordsSettingBudgetPercent'
=>
$campaign
[
'TextCampaign'
][
'RelevantKeywords'
][
'BudgetPercent'
],
'counter_ids'
=>
!
empty
(
$campaign
[
'TextCampaign'
][
'CounterIds'
][
'Items'
])
?
implode
(
"
\n
"
,
$campaign
[
'TextCampaign'
][
'CounterIds'
][
'Items'
])
:
''
,
'RelevantKeywordsSettingOptimizeGoalId'
=>
$campaign
[
'TextCampaign'
][
'RelevantKeywords'
][
'OptimizeGoalId'
],
'relevant_keywords_setting_budget_percent'
=>
$campaign
[
'TextCampaign'
][
'RelevantKeywords'
][
'BudgetPercent'
],
'AttributionModel'
=>
$campaign
[
'TextCampaign'
][
'AttributionModel'
],
'relevant_keywords_setting_optimize_goal_id'
=>
$campaign
[
'TextCampaign'
][
'RelevantKeywords'
][
'OptimizeGoalId'
],
'PriorityGoals'
=>
json_encode
(
$campaign
[
'TextCampaign'
][
'PriorityGoals'
]),
'attribution_model'
=>
$campaign
[
'TextCampaign'
][
'AttributionModel'
],
'updated'
=>
null
'priority_goals'
=>
json_encode
(
$campaign
[
'TextCampaign'
][
'PriorityGoals'
]),
];
'updated'
=>
null
];
}
Campaigns
::
upsert
(
$data
,
[
'external_id'
],[
'token'
,
'name'
,
'time_targeting'
,
'negative_keywords'
,
'blocked_ips'
,
'excluded_sites'
,
'daily_budget'
,
'text_campaign_strategy_search'
,
'text_campaign_strategy_network'
,
'settings'
,
'counter_ids'
,
'relevant_keywords_setting_budget_percent'
,
'relevant_keywords_setting_optimize_goal_id'
,
'attribution_model'
,
'updated'
]);
}
catch
(
\Exception
$e
)
{
Log
::
debug
(
$e
);
}
}
Campaigns
::
upsert
(
$data
,
[
'external_id'
],[
'token'
,
'Name'
,
'TimeTargeting'
,
'NegativeKeywords'
,
'BlockedIps'
,
'ExcludedSites'
,
'DailyBudget'
,
'TextCampaignStrategySearch'
,
'TextCampaignStrategyNetwork'
,
'Settings'
,
'CounterIds'
,
'RelevantKeywordsSettingBudgetPercent'
,
'RelevantKeywordsSettingOptimizeGoalId'
,
'AttributionModel'
,
'updated'
]);
}
}
private
function
requestPrepare
(
$filter
){
private
function
requestPrepare
(
$filter
){
...
@@ -63,12 +68,12 @@ class GetCampaigns extends DirectRequest{
...
@@ -63,12 +68,12 @@ class GetCampaigns extends DirectRequest{
$this
->
setMethod
(
'get'
);
$this
->
setMethod
(
'get'
);
$params
=
[
$params
=
[
'SelectionCriteria'
=>
[
'SelectionCriteria'
=>
[
'Types'
=>
[
"TEXT_CAMPAIGN"
]
'Types'
=>
[
"TEXT_CAMPAIGN"
]
],
],
"FieldNames"
=>
[
"FieldNames"
=>
[
"Id"
,
"Name"
,
"TimeTargeting"
,
"TimeZone"
,
"NegativeKeywords"
,
"BlockedIps"
,
"ExcludedSites"
,
"DailyBudget"
"Id"
,
"Name"
,
"TimeTargeting"
,
"TimeZone"
,
"NegativeKeywords"
,
"BlockedIps"
,
"ExcludedSites"
,
"DailyBudget"
],
],
"TextCampaignFieldNames"
=>
[
"TextCampaignFieldNames"
=>
[
"BiddingStrategy"
,
"Settings"
,
"CounterIds"
,
"RelevantKeywords"
,
"PriorityGoals"
,
"AttributionModel"
"BiddingStrategy"
,
"Settings"
,
"CounterIds"
,
"RelevantKeywords"
,
"PriorityGoals"
,
"AttributionModel"
]
]
];
];
...
...
database/migrations/2021_05_04_140851_create_limits_table.php
View file @
9c40e9d
...
@@ -39,12 +39,6 @@ class CreateLimitsTable extends Migration
...
@@ -39,12 +39,6 @@ class CreateLimitsTable extends Migration
*/
*/
public
function
down
()
public
function
down
()
{
{
Schema
::
table
(
'limits'
,
function
(
Blueprint
$table
)
{
$table
->
dropForeign
(
'limits_token_foreign'
);
});
Schema
::
table
(
'tokens'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'limit'
);
});
Schema
::
dropIfExists
(
'limits'
);
Schema
::
dropIfExists
(
'limits'
);
}
}
}
}
database/migrations/2021_05_11_084828_create_campaigns_table.php
View file @
9c40e9d
...
@@ -17,20 +17,20 @@ class CreateCampaignsTable extends Migration
...
@@ -17,20 +17,20 @@ class CreateCampaignsTable extends Migration
$table
->
id
();
$table
->
id
();
$table
->
bigInteger
(
'token'
);
$table
->
bigInteger
(
'token'
);
$table
->
bigInteger
(
'external_id'
)
->
unique
();
$table
->
bigInteger
(
'external_id'
)
->
unique
();
$table
->
string
(
'
N
ame'
,
255
)
->
nullable
();
$table
->
string
(
'
n
ame'
,
255
)
->
nullable
();
$table
->
json
(
'
TimeT
argeting'
)
->
nullable
();
$table
->
json
(
'
time_t
argeting'
)
->
nullable
();
$table
->
text
(
'
NegativeK
eywords'
)
->
nullable
();
$table
->
text
(
'
negative_k
eywords'
)
->
nullable
();
$table
->
text
(
'
BlockedI
ps'
)
->
nullable
();
$table
->
text
(
'
blocked_i
ps'
)
->
nullable
();
$table
->
text
(
'
ExcludedS
ites'
)
->
nullable
();
$table
->
text
(
'
excluded_s
ites'
)
->
nullable
();
$table
->
json
(
'
DailyB
udget'
)
->
nullable
();
$table
->
json
(
'
daily_b
udget'
)
->
nullable
();
$table
->
string
(
'
TextCampaignStrategyS
earch'
)
->
nullable
();
$table
->
string
(
'
text_campaign_strategy_s
earch'
)
->
nullable
();
$table
->
string
(
'
TextCampaignStrategyN
etwork'
)
->
nullable
();
$table
->
string
(
'
text_campaign_strategy_n
etwork'
)
->
nullable
();
$table
->
json
(
'
S
ettings'
)
->
nullable
();
$table
->
json
(
'
s
ettings'
)
->
nullable
();
$table
->
text
(
'
CounterI
ds'
)
->
nullable
();
$table
->
text
(
'
counter_i
ds'
)
->
nullable
();
$table
->
integer
(
'
RelevantKeywordsSettingBudgetP
ercent'
)
->
nullable
();
$table
->
integer
(
'
relevant_keywords_setting_budget_p
ercent'
)
->
nullable
();
$table
->
bigInteger
(
'
RelevantKeywordsSettingOptimizeGoalI
d'
)
->
nullable
();
$table
->
bigInteger
(
'
relevant_keywords_setting_optimize_goal_i
d'
)
->
nullable
();
$table
->
string
(
'
AttributionM
odel'
,
4
)
->
nullable
();
$table
->
string
(
'
attribution_m
odel'
,
4
)
->
nullable
();
$table
->
json
(
'
PriorityG
oals'
)
->
nullable
();
$table
->
json
(
'
priority_g
oals'
)
->
nullable
();
$table
->
enum
(
'updated'
,
[
$table
->
enum
(
'updated'
,
[
\App\Service\Requests\Direct\CheckCampaignsChange
::
CHILDREN
,
\App\Service\Requests\Direct\CheckCampaignsChange
::
CHILDREN
,
\App\Service\Requests\Direct\CheckCampaignsChange
::
SELF
,
\App\Service\Requests\Direct\CheckCampaignsChange
::
SELF
,
...
@@ -49,9 +49,6 @@ class CreateCampaignsTable extends Migration
...
@@ -49,9 +49,6 @@ class CreateCampaignsTable extends Migration
*/
*/
public
function
down
()
public
function
down
()
{
{
Schema
::
table
(
'campaigns'
,
function
(
Blueprint
$table
)
{
$table
->
dropForeign
(
'campaigns_token_foreign'
);
});
Schema
::
dropIfExists
(
'campaigns'
);
Schema
::
dropIfExists
(
'campaigns'
);
}
}
}
}
resources/js/Pages/Tokens/Edit.vue
View file @
9c40e9d
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
{{
form
.
login
}}
{{
form
.
login
}}
</h1>
</h1>
<div
class=
"bg-white rounded-md shadow overflow-hidden max-w-3xl"
>
<div
class=
"bg-white rounded-md shadow overflow-hidden max-w-3xl"
>
<form
@
submit
.
prevent=
"
u
pdate"
>
<form
@
submit
.
prevent=
"
tokenU
pdate"
>
<div
class=
"p-8 -mr-6 -mb-8 flex flex-wrap"
>
<div
class=
"p-8 -mr-6 -mb-8 flex flex-wrap"
>
<text-input
v-model=
"form.login"
:error=
"form.errors.login"
:readonly=
"true"
class=
"pr-6 pb-8 w-full lg:w-1/2"
<text-input
v-model=
"form.login"
:error=
"form.errors.login"
:readonly=
"true"
class=
"pr-6 pb-8 w-full lg:w-1/2"
label=
"Login"
/>
label=
"Login"
/>
...
@@ -23,11 +23,15 @@
...
@@ -23,11 +23,15 @@
</select-input>
</select-input>
</div>
</div>
<div
class=
"px-8 py-4 bg-gray-50 border-t border-gray-100 flex items-center"
>
<div
class=
"px-8 py-4 bg-gray-50 border-t border-gray-100 flex items-center"
>
<button
class=
"text-red-600 hover:underline"
tabindex=
"-1"
<button
class=
"text-red-600 hover:underline"
type=
"button"
@
click=
"destroy"
>
Delete Token
tabindex=
"-1"
type=
"button"
@
click=
"tokenDestroy"
>
Delete Token
</button>
</button>
<loading-button
:loading=
"form.processing"
v-if=
"!this.token.type"
class=
"btn-indigo ml-auto"
type=
"submit"
>
Update
<loading-button
:loading=
"form.processing"
v-if=
"!this.token.type"
class=
"btn-indigo ml-auto"
type=
"submit"
>
Token
Update
Token
</loading-button>
</loading-button>
</div>
</div>
</form>
</form>
...
@@ -38,12 +42,24 @@
...
@@ -38,12 +42,24 @@
<table
class=
"w-full whitespace-nowrap"
>
<table
class=
"w-full whitespace-nowrap"
>
<tr
class=
"text-left font-bold"
>
<tr
class=
"text-left font-bold"
>
<th
class=
"px-6 pt-6 pb-4"
>
Name
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Name
</th>
<th
class=
"px-6 pt-6 pb-4"
>
Action
</th>
</tr>
</tr>
<tr
v-for=
"campaign in token.campaigns"
:key=
"campaign.id"
<tr
v-for=
"campaign in token.campaigns"
:key=
"campaign.id"
class=
"hover:bg-gray-100 focus-within:bg-gray-100"
>
class=
"hover:bg-gray-100 focus-within:bg-gray-100"
>
<td
class=
"border-t"
>
<td
class=
"border-t
py-3
"
>
{{
campaign
.
name
}}
{{
campaign
.
name
}}
</td>
</td>
<td
class=
"border-t py-3"
>
<input
:id=
"'campaign-enabled-' + campaign.id"
type=
"checkbox"
>
<label
:for=
"'campaign-enabled-' + campaign.id"
>
Enabled
</label>
<button
class=
"text-red-600 hover:underline"
tabindex=
"-1"
type=
"button"
@
click=
"campaignDestroy"
>
Delete Campaign
</button>
</td>
</tr>
</tr>
<tr
v-if=
"token.campaigns.length === 0"
>
<tr
v-if=
"token.campaigns.length === 0"
>
<td
class=
"border-t px-6 py-4"
colspan=
"4"
>
No campaigns found.
</td>
<td
class=
"border-t px-6 py-4"
colspan=
"4"
>
No campaigns found.
</td>
...
@@ -112,10 +128,15 @@ export default {
...
@@ -112,10 +128,15 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
u
pdate
()
{
tokenU
pdate
()
{
this
.
form
.
post
(
this
.
route
(
'token.update'
,
this
.
token
.
id
))
this
.
form
.
post
(
this
.
route
(
'token.update'
,
this
.
token
.
id
))
},
},
destroy
()
{
tokenDestroy
()
{
if
(
confirm
(
'Are you sure you want to delete this token?'
))
{
this
.
$inertia
.
delete
(
this
.
route
(
'token.destroy'
,
this
.
token
.
id
))
}
},
campaignDestroy
()
{
if
(
confirm
(
'Are you sure you want to delete this token?'
))
{
if
(
confirm
(
'Are you sure you want to delete this token?'
))
{
this
.
$inertia
.
delete
(
this
.
route
(
'token.destroy'
,
this
.
token
.
id
))
this
.
$inertia
.
delete
(
this
.
route
(
'token.destroy'
,
this
.
token
.
id
))
}
}
...
...
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