Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7c76d512
authored
Jul 07, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
标签批量修改接口
parent
901b7554
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
20 deletions
app/Http/Controllers/Api/SupplierApiController.php
app/Http/Controllers/Api/SupplierTagApiController.php
app/Http/Services/SupplierTagService.php
app/Http/Controllers/Api/SupplierApiController.php
View file @
7c76d512
...
...
@@ -656,21 +656,4 @@ class SupplierApiController extends Controller
$this
->
response
(
0
,
'申请审核成功'
);
}
//批量新增标签
public
function
BatchAddTags
(
$request
)
{
$supplierIds
=
$request
->
get
(
'supplier_ids'
);
$systemTags
=
$request
->
get
(
'system_tags'
);
$customTags
=
$request
->
get
(
'custom_tags'
);
$supplierIds
=
$supplierIds
?
explode
(
','
,
$supplierIds
)
:
[];
$systemTags
=
$systemTags
?
explode
(
','
,
$systemTags
)
:
[];
$customTags
=
$customTags
?
explode
(
','
,
$customTags
)
:
[];
$supplierService
=
new
SupplierService
();
if
(
empty
(
$systemTags
)
&&
empty
(
$customTags
))
{
$this
->
response
(
-
1
,
'请设置标签'
);
}
$supplierService
->
batchAddTags
(
$supplierIds
,
$systemTags
,
$customTags
);
$this
->
response
(
0
,
'批量新增标签成功'
);
}
}
app/Http/Controllers/Api/SupplierTagApiController.php
View file @
7c76d512
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Controllers\Api
;
use
App\Http\Controllers\Controller
;
use
App\Http\Services\SupplierService
;
use
App\Http\Services\SupplierTagService
;
use
App\Http\Transformers\SupplierLogTransformer
;
use
App\Model\LogModel
;
...
...
@@ -25,4 +26,21 @@ class SupplierTagApiController extends Controller
$data
=
$supplierTagService
->
getSystemTags
();
$this
->
response
(
0
,
'ok'
,
$data
,
count
(
$data
));
}
//批量新增标签
public
function
BatchAddTags
(
$request
)
{
$supplierIds
=
$request
->
get
(
'supplier_ids'
);
$systemTags
=
$request
->
get
(
'system_tags'
);
$customTags
=
$request
->
get
(
'customer_tags'
);
$supplierIds
=
$supplierIds
?
explode
(
','
,
$supplierIds
)
:
[];
$systemTags
=
$systemTags
?
explode
(
','
,
$systemTags
)
:
[];
$customTags
=
$customTags
?
explode
(
','
,
$customTags
)
:
[];
$supplierTagService
=
new
SupplierTagService
();
if
(
empty
(
$systemTags
)
&&
empty
(
$customTags
))
{
$this
->
response
(
-
1
,
'请设置标签'
);
}
$supplierTagService
->
batchAddTags
(
$supplierIds
,
$systemTags
,
$customTags
);
$this
->
response
(
0
,
'批量新增标签成功'
);
}
}
app/Http/Services/SupplierTagService.php
View file @
7c76d512
...
...
@@ -126,9 +126,16 @@ class SupplierTagService
{
$suppliers
=
SupplierChannelModel
::
whereIn
(
'supplier_id'
,
$supplierIds
)
->
get
()
->
toArray
();
foreach
(
$suppliers
as
$supplier
)
{
$systemTags
=
$supplier
[
'system_tags'
]
?
explode
(
','
,
$supplier
[
'system_tags'
])
:
[];
$customTags
=
$supplier
[
'custom_tags'
]
?
explode
(
','
,
$supplier
[
'custom_tags'
])
:
[];
$oldSystemTags
=
$supplier
[
'system_tags'
]
?
explode
(
','
,
$supplier
[
'system_tags'
])
:
[];
$oldCustomTags
=
$supplier
[
'customer_tags'
]
?
explode
(
','
,
$supplier
[
'customer_tags'
])
:
[];
$newSystemTags
=
array_merge
(
$oldSystemTags
,
$addSysTags
);
$newCustomTags
=
array_merge
(
$oldCustomTags
,
$addCusTags
);
$this
->
saveTags
(
$supplier
[
'supplier_id'
],
self
::
TAG_TYPE_SYSTEM
,
$newSystemTags
,
$oldSystemTags
);
$this
->
saveTags
(
$supplier
[
'supplier_id'
],
self
::
TAG_TYPE_CUSTOMER
,
$newCustomTags
,
$oldCustomTags
);
SupplierChannelModel
::
where
(
'supplier_id'
,
$supplier
[
'supplier_id'
])
->
update
([
'system_tags'
=>
$newSystemTags
,
'customer_tags'
=>
$newCustomTags
]);
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment