作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !216
@@ -2,8 +2,10 @@ @@ -2,8 +2,10 @@
2 2
3 namespace App\Console\Commands\Test; 3 namespace App\Console\Commands\Test;
4 4
  5 +use App\Helper\Arr;
5 use App\Models\Collect\CollectTask; 6 use App\Models\Collect\CollectTask;
6 use App\Models\Com\UpdateLog; 7 use App\Models\Com\UpdateLog;
  8 +use App\Models\Product\Product;
7 use App\Services\ProjectServer; 9 use App\Services\ProjectServer;
8 use Illuminate\Console\Command; 10 use Illuminate\Console\Command;
9 use Illuminate\Support\Facades\DB; 11 use Illuminate\Support\Facades\DB;
@@ -27,23 +29,29 @@ class Temp extends Command @@ -27,23 +29,29 @@ class Temp extends Command
27 29
28 public function handle() 30 public function handle()
29 { 31 {
30 - $data = UpdateLog::where('api_type', 'website_info')->get(); 32 + $data_project = [1, 2, 3, 4, 15, 77, 101, 162, 452, 475];
  33 + $data_news = [40, 50, 452, 475];
  34 + $data_blog = [452];
31 35
32 - foreach ($data as $item) {  
33 - $project_id = $item->project_id; 36 + foreach ($data_project as $project_id) {
34 $project = ProjectServer::useProject($project_id); 37 $project = ProjectServer::useProject($project_id);
35 if ($project) { 38 if ($project) {
36 - try {  
37 - DB::connection('custom_mysql')->statement("ALTER TABLE `gl_news_category` ADD COLUMN `original_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '来源id'");  
38 - } catch (\Exception $e) {  
39 - echo $project_id . '已存在'.PHP_EOL;  
40 - continue; 39 + $list = Product::get();
  40 + foreach ($list as $item) {
  41 + $seo = json_decode($item->seo_mate, true);
  42 + if ($seo) {
  43 + $seo['title'] = substr(strip_tags($seo['title']), 0, 70);
  44 + $seo['keyword'] = substr(strip_tags($seo['keyword']), 0, 255);
  45 + $seo['description'] = substr(strip_tags($seo['description']), 0, 200);
  46 + $item->seo_mate = Arr::a2s($seo);
  47 + $item->save();
  48 + }
41 } 49 }
42 } 50 }
43 //关闭数据库 51 //关闭数据库
44 DB::disconnect('custom_mysql'); 52 DB::disconnect('custom_mysql');
45 53
46 - echo $project_id.'成功'.PHP_EOL; 54 + echo $project_id . '成功, product' . PHP_EOL;
47 } 55 }
48 } 56 }
49 } 57 }
@@ -199,6 +199,7 @@ class KeywordLogic extends BaseLogic @@ -199,6 +199,7 @@ class KeywordLogic extends BaseLogic
199 $return = []; 199 $return = [];
200 $keyword_arr = explode('^v6sp$',$keyword); 200 $keyword_arr = explode('^v6sp$',$keyword);
201 foreach ($keyword_arr as $v){ 201 foreach ($keyword_arr as $v){
  202 + if($v){
202 $keyword_info = $this->model->read(['title'=>$v]); 203 $keyword_info = $this->model->read(['title'=>$v]);
203 if(!$keyword_info){ 204 if(!$keyword_info){
204 $k_id = $this->model->addReturnId(['title'=>$v,'project_id'=>$project_id]); 205 $k_id = $this->model->addReturnId(['title'=>$v,'project_id'=>$project_id]);
@@ -209,6 +210,7 @@ class KeywordLogic extends BaseLogic @@ -209,6 +210,7 @@ class KeywordLogic extends BaseLogic
209 } 210 }
210 $return[] = $k_id; 211 $return[] = $k_id;
211 } 212 }
  213 + }
212 //清除缓存 214 //清除缓存
213 Common::del_user_cache('product_keyword',$project_id); 215 Common::del_user_cache('product_keyword',$project_id);
214 return ','.implode(',',$return).','; 216 return ','.implode(',',$return).',';