Commit 73c1fb7f by 杨树贤

sku描述图片批量替换

parent 63715f17
...@@ -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);
} }
......
...@@ -357,7 +357,7 @@ return [ ...@@ -357,7 +357,7 @@ return [
'strict' => false, 'strict' => false,
], ],
'mongodb' => [ 'mongo' => [
'driver' => 'mongodb', 'driver' => 'mongodb',
'host' => env('MONGO_HOST'), 'host' => env('MONGO_HOST'),
'port' => 27017, 'port' => 27017,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment