Commit 012e9ec9 by 杨树贤

修复文章缩略图

parent 29992d45
...@@ -33,7 +33,8 @@ class SetSupplierFollowUp extends Command ...@@ -33,7 +33,8 @@ class SetSupplierFollowUp extends Command
public function handle() public function handle()
{ {
//DealImageService::dealNewsImage(); //DealImageService::dealNewsImage();
DealImageService::dealNewsImage(); //DealImageService::dealNewsImage();
//DealImageService::dealSkuDetailAndImage(); //DealImageService::dealSkuDetailAndImage();
DealImageService::dealNewsPic();
} }
} }
...@@ -113,6 +113,32 @@ class DealImageService ...@@ -113,6 +113,32 @@ class DealImageService
} }
} }
//处理新闻的缩略图
public static function dealNewsPic()
{
$newsList = DB::connection('liexin')->table('article')->orderBy('art_id', 'desc')->limit(20)->get();
$redis = new RedisModel();
foreach ($newsList as $news) {
$imageUrl = self::checkImage($news['litpic']);
if (empty($imageUrl)) {
continue;
}
if (!$redis->hget('pic_news_backup_xian', $news['art_id'])) {
$redis->hset('pic_news_backup_xian', $news['art_id'], $news['litpic']);
}
$imageMap = self::downloadAndUploadToPicServer([$imageUrl]);
//进行全局替换
foreach ($imageMap as $originImage => $newImage) {
$news['litpic'] = str_replace($originImage, $newImage, $news['litpic']);
}
dump($news['art_id']);
//回写到数据库
DB::connection('liexin')->table('article')->where('art_id', $news['art_id'])->update([
'litpic' => $news['litpic']
]);
}
}
//处理sku详细描述 //处理sku详细描述
public static function dealSkuDetailAndImage() public static function dealSkuDetailAndImage()
{ {
...@@ -175,7 +201,7 @@ class DealImageService ...@@ -175,7 +201,7 @@ class DealImageService
if (empty($imageUrl)) { if (empty($imageUrl)) {
continue; continue;
} }
if (!$redis->hget('image_sku_detail_backup_xian', $skuId)) { if (!$redis->hget('image_goods_backup_xian', $skuId)) {
$redis->hset('image_goods_backup_xian', $skuId, $skuDBData['goods_images']); $redis->hset('image_goods_backup_xian', $skuId, $skuDBData['goods_images']);
} }
...@@ -204,7 +230,7 @@ class DealImageService ...@@ -204,7 +230,7 @@ class DealImageService
public static function getSearchDomain() public static function getSearchDomain()
{ {
$host = request()->getHost(); $host = request()->getHost();
if (strpos($host, 'ichunt.com') !== false) { if (strpos($host, 'ichunt.net') !== false) {
return 'https://icso.ichunt.com'; return 'https://icso.ichunt.com';
} else { } else {
return 'http://search.liexindev.net'; return 'http://search.liexindev.net';
......
...@@ -84,7 +84,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -84,7 +84,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
\App\Http\Services\DealImageService::dealNewsImage(); \App\Http\Services\DealImageService::dealNewsPic();
//\App\Http\Services\SupplierAddressService::initUnitedAddress(); //\App\Http\Services\SupplierAddressService::initUnitedAddress();
//\App\Http\Services\DataService::checkSupplierBandAccount(); //\App\Http\Services\DataService::checkSupplierBandAccount();
//(new CompanyService())->checkSupplierCompanyAndAddress(11042); //(new CompanyService())->checkSupplierCompanyAndAddress(11042);
......
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