作者 lyh

jiaoben

@@ -245,14 +245,13 @@ class VideoTask extends Command @@ -245,14 +245,13 @@ class VideoTask extends Command
245 */ 245 */
246 public function getRecommendAndHotProducts($keyword_id): ?array 246 public function getRecommendAndHotProducts($keyword_id): ?array
247 { 247 {
248 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('进入', true) . PHP_EOL, FILE_APPEND);  
249 $productIds = []; 248 $productIds = [];
250 - $productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(7)->get();  
251 - if (!empty($productsQuery)){ 249 + $productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(13)->get();
  250 + if (count($productsQuery) > 0){
252 foreach ($productsQuery as $item){ 251 foreach ($productsQuery as $item){
253 $productIds[] = $item->id; 252 $productIds[] = $item->id;
254 } 253 }
255 - if (count($productIds)<7){ 254 + if (count($productIds) < 13){
256 $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray(); 255 $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray();
257 $randomData = Product::whereIn("id", $product_all_id)->get(); 256 $randomData = Product::whereIn("id", $product_all_id)->get();
258 $products = $productsQuery->merge($randomData); 257 $products = $productsQuery->merge($randomData);
@@ -262,7 +261,6 @@ class VideoTask extends Command @@ -262,7 +261,6 @@ class VideoTask extends Command
262 }else{ 261 }else{
263 $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray(); 262 $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();
264 $products = Product::whereIn("id", $product_all_id)->get(); 263 $products = Product::whereIn("id", $product_all_id)->get();
265 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($products, true) . PHP_EOL, FILE_APPEND);  
266 } 264 }
267 $data = []; 265 $data = [];
268 if (!empty($products)){ 266 if (!empty($products)){
@@ -277,7 +275,8 @@ class VideoTask extends Command @@ -277,7 +275,8 @@ class VideoTask extends Command
277 if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) { 275 if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) {
278 //不包含 276 //不包含
279 $productModel = new Product(); 277 $productModel = new Product();
280 - $keyword_id_str = ','.$keyword_ids.',' . $keyword_id.','; 278 + $keyword_ids = !empty($keyword_ids) ? ','.$keyword_ids.',' : ',' ;
  279 + $keyword_id_str = $keyword_ids . $keyword_id.',';
281 $productModel->edit(['keyword_id'=>$keyword_id_str],['id'=>$item->id]); 280 $productModel->edit(['keyword_id'=>$keyword_id_str],['id'=>$item->id]);
282 } 281 }
283 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title]; 282 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
@@ -14,7 +14,6 @@ use App\Models\File\File as FileModel; @@ -14,7 +14,6 @@ use App\Models\File\File as FileModel;
14 use App\Models\File\Image; 14 use App\Models\File\Image;
15 use App\Models\File\Image as ImageModel; 15 use App\Models\File\Image as ImageModel;
16 use App\Models\Product\Keyword; 16 use App\Models\Product\Keyword;
17 -use App\Models\Product\Product;  
18 use App\Models\Project\DeployOptimize; 17 use App\Models\Project\DeployOptimize;
19 use App\Models\Project\MinorLanguages; 18 use App\Models\Project\MinorLanguages;
20 use App\Models\Project\Project; 19 use App\Models\Project\Project;
@@ -42,61 +41,24 @@ class Demo extends Command @@ -42,61 +41,24 @@ class Demo extends Command
42 protected $description = 'demo'; 41 protected $description = 'demo';
43 42
44 43
45 - /**  
46 - * Execute the job.  
47 - *  
48 - * @return void  
49 - */  
50 - public function handle()  
51 - {  
52 - ProjectServer::useProject(110);  
53 - return $this->getRecommendAndHotProducts(1970);  
54 - DB::disconnect('custom_mysql');  
55 -  
56 - }  
57 -  
58 - public function getRecommendAndHotProducts($keyword_id): ?array  
59 - {  
60 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('进入', true) . PHP_EOL, FILE_APPEND);  
61 - $productIds = [];  
62 - $productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(7)->get();  
63 - if (!empty($productsQuery)){  
64 - foreach ($productsQuery as $item){  
65 - $productIds[] = $item->id;  
66 - }  
67 - if (count($productIds)<7){  
68 - $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray();  
69 - $randomData = Product::whereIn("id", $product_all_id)->get();  
70 - $products = $productsQuery->merge($randomData);  
71 - }else{  
72 - $products = $productsQuery;  
73 - }  
74 - }else{  
75 - $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();  
76 - $products = Product::whereIn("id", $product_all_id)->get();  
77 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($products, true) . PHP_EOL, FILE_APPEND);  
78 - }  
79 - $data = [];  
80 - if (!empty($products)){  
81 - foreach ($products as $item){  
82 - if(empty($item->thumb) || ($item->thumb['url'] == "")){  
83 - continue;  
84 - }  
85 - if(count($data) > 13){  
86 - break;  
87 - }  
88 - $keyword_ids = implode(',',$item->keyword_id);  
89 - if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) {  
90 - //不包含  
91 - $productModel = new Product();  
92 - $keyword_id_str = ','.$keyword_ids.',' . $keyword_id.',';  
93 - $productModel->edit(['keyword_id'=>$keyword_id_str],['id'=>$item->id]);  
94 - }  
95 - $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];  
96 - }  
97 - }  
98 - return $data;  
99 - } 44 +// /**
  45 +// * Execute the job.
  46 +// *
  47 +// * @return void
  48 +// */
  49 +// public function handle()
  50 +// {
  51 +// $this->param['project_id'] = 181;
  52 +// $imageModel = new ImageModel();
  53 +// //获取当前项目的所有图片
  54 +// $imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);
  55 +// if(!empty($imageList)){
  56 +// $amazonS3Service = new AmazonS3Service();
  57 +// foreach ($imageList as $k => $v){
  58 +// $amazonS3Service->syncImageFiles(getImageUrl($v['path']));
  59 +// $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
  60 +// }
  61 +// }
100 // 62 //
101 // $fileModel = new FileModel(); 63 // $fileModel = new FileModel();
102 // $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']); 64 // $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
@@ -178,4 +140,26 @@ class Demo extends Command @@ -178,4 +140,26 @@ class Demo extends Command
178 // } 140 // }
179 // return true; 141 // return true;
180 // } 142 // }
  143 +
  144 + public function handle(){
  145 + $minorLanguageModel = new MinorLanguages();
  146 + $lists = $minorLanguageModel->list();
  147 + foreach ($lists as $v){
  148 + $d = new DeployOptimize();
  149 + $info = $d->read(['project_id'=>$v['project_id']]);
  150 + if($info === false){
  151 + continue;
  152 + }
  153 + if(!empty($info['minor_keywords'])){
  154 + echo '关键字'.json_decode($info['minor_keywords']);
  155 + $minor_keywords = json_decode($info['minor_keywords']);
  156 + foreach ($minor_keywords as $v1){
  157 + $v1 = (array)$v1;
  158 + if($v['language'] == $v1['name']){
  159 + $minorLanguageModel->edit(['minor_keywords'=>$v1['keyword']],['id'=>$v['id']]);
  160 + }
  161 + }
  162 + }
  163 + }
  164 + }
181 } 165 }