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
73c1fb7f
authored
Sep 02, 2024
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
sku描述图片批量替换
parent
63715f17
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
9 deletions
app/Http/Services/DealImageService.php
config/database.php
app/Http/Services/DealImageService.php
View file @
73c1fb7f
...
@@ -116,8 +116,7 @@ class DealImageService
...
@@ -116,8 +116,7 @@ class DealImageService
continue
;
continue
;
}
}
foreach
(
$itemList
[
'data'
][
'goods_id'
]
as
$skuId
)
{
foreach
(
$itemList
[
'data'
][
'goods_id'
]
as
$skuId
)
{
$skuDetail
=
DB
::
connection
(
'mongodb'
)
->
table
(
'sku_detail'
)
->
where
(
'sku_id'
,
(
string
)
$skuId
)
->
first
();
$skuDetail
=
DB
::
connection
(
'mongo'
)
->
table
(
'sku_detail'
)
->
where
(
'sku_id'
,
(
string
)
$skuId
)
->
first
();
dd
(
$skuDetail
);
$detail
=
$skuDetail
[
'detail'
];
$detail
=
$skuDetail
[
'detail'
];
if
(
empty
(
$detail
))
{
if
(
empty
(
$detail
))
{
continue
;
continue
;
...
@@ -129,24 +128,19 @@ class DealImageService
...
@@ -129,24 +128,19 @@ class DealImageService
}
}
//dump($imageUrls); // 输出所有提取出的 'img.ichunt.com' 图片链接
//dump($imageUrls); // 输出所有提取出的 'img.ichunt.com' 图片链接
$imageMap
=
self
::
downloadAndUploadToPicServer
(
$imageUrls
);
$imageMap
=
self
::
downloadAndUploadToPicServer
(
$imageUrls
);
//进行全局替换
//进行全局替换
foreach
(
$imageMap
as
$originImage
=>
$newImage
)
{
foreach
(
$imageMap
as
$originImage
=>
$newImage
)
{
$detail
=
str_replace
(
$originImage
,
$newImage
,
$detail
);
$detail
=
str_replace
(
$originImage
,
$newImage
,
$detail
);
}
}
//回写到mongo
//回写到mongo
DB
::
connection
(
'mongo'
)
->
table
(
'sku_detail'
)
->
where
(
'sku_id'
,
(
string
)
$skuId
)
->
update
([
DB
::
connection
(
'mongo'
)
->
table
(
'sku_detail'
)
->
where
(
'sku_id'
,
(
string
)
$skuId
)
->
update
([
'update_time'
=>
time
(),
'update_time'
=>
time
(),
'detail'
=>
$detail
,
'detail'
=>
$detail
,
]);
]);
$count
++
;
$count
++
;
}
}
dump
(
'已处理sku数量 : '
.
$count
);
}
}
dump
(
'已处理sku数量 : '
.
$count
);
}
}
...
...
config/database.php
View file @
73c1fb7f
...
@@ -357,7 +357,7 @@ return [
...
@@ -357,7 +357,7 @@ return [
'strict'
=>
false
,
'strict'
=>
false
,
],
],
'mongo
db
'
=>
[
'mongo'
=>
[
'driver'
=>
'mongodb'
,
'driver'
=>
'mongodb'
,
'host'
=>
env
(
'MONGO_HOST'
),
'host'
=>
env
(
'MONGO_HOST'
),
'port'
=>
27017
,
'port'
=>
27017
,
...
...
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