|
@@ -14,6 +14,7 @@ use App\Models\File\File as FileModel; |
|
@@ -14,6 +14,7 @@ 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;
|
|
17
|
use App\Models\Project\DeployOptimize;
|
18
|
use App\Models\Project\DeployOptimize;
|
|
18
|
use App\Models\Project\MinorLanguages;
|
19
|
use App\Models\Project\MinorLanguages;
|
|
19
|
use App\Models\Project\Project;
|
20
|
use App\Models\Project\Project;
|
|
@@ -41,24 +42,58 @@ class Demo extends Command |
|
@@ -41,24 +42,58 @@ class Demo extends Command |
|
41
|
protected $description = 'demo';
|
42
|
protected $description = 'demo';
|
|
42
|
|
43
|
|
|
43
|
|
44
|
|
|
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
|
-// }
|
45
|
+ /**
|
|
|
|
46
|
+ * Execute the job.
|
|
|
|
47
|
+ *
|
|
|
|
48
|
+ * @return void
|
|
|
|
49
|
+ */
|
|
|
|
50
|
+ public function handle()
|
|
|
|
51
|
+ {
|
|
|
|
52
|
+ return $this->getRecommendAndHotProducts(1970);
|
|
|
|
53
|
+ }
|
|
|
|
54
|
+
|
|
|
|
55
|
+ public function getRecommendAndHotProducts($keyword_id): ?array
|
|
|
|
56
|
+ {
|
|
|
|
57
|
+ @file_put_contents(storage_path('logs/lyh_error.log'), var_export('进入', true) . PHP_EOL, FILE_APPEND);
|
|
|
|
58
|
+ $productIds = [];
|
|
|
|
59
|
+ $productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(7)->get();
|
|
|
|
60
|
+ if (!empty($productsQuery)){
|
|
|
|
61
|
+ foreach ($productsQuery as $item){
|
|
|
|
62
|
+ $productIds[] = $item->id;
|
|
|
|
63
|
+ }
|
|
|
|
64
|
+ if (count($productIds)<7){
|
|
|
|
65
|
+ $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20 - count($productIds))->pluck('id')->toArray();
|
|
|
|
66
|
+ $randomData = Product::whereIn("id", $product_all_id)->get();
|
|
|
|
67
|
+ $products = $productsQuery->merge($randomData);
|
|
|
|
68
|
+ }else{
|
|
|
|
69
|
+ $products = $productsQuery;
|
|
|
|
70
|
+ }
|
|
|
|
71
|
+ }else{
|
|
|
|
72
|
+ $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray();
|
|
|
|
73
|
+ $products = Product::whereIn("id", $product_all_id)->get();
|
|
|
|
74
|
+ @file_put_contents(storage_path('logs/lyh_error.log'), var_export($products, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
75
|
+ }
|
|
|
|
76
|
+ $data = [];
|
|
|
|
77
|
+ if (!empty($products)){
|
|
|
|
78
|
+ foreach ($products as $item){
|
|
|
|
79
|
+ if(empty($item->thumb) || ($item->thumb['url'] == "")){
|
|
|
|
80
|
+ continue;
|
|
|
|
81
|
+ }
|
|
|
|
82
|
+ if(count($data) > 13){
|
|
|
|
83
|
+ break;
|
|
|
|
84
|
+ }
|
|
|
|
85
|
+ $keyword_ids = implode(',',$item->keyword_id);
|
|
|
|
86
|
+ if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) {
|
|
|
|
87
|
+ //不包含
|
|
|
|
88
|
+ $productModel = new Product();
|
|
|
|
89
|
+ $keyword_id_str = ','.$keyword_ids.',' . $keyword_id.',';
|
|
|
|
90
|
+ $productModel->edit(['keyword_id'=>$keyword_id_str],['id'=>$item->id]);
|
|
|
|
91
|
+ }
|
|
|
|
92
|
+ $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
|
|
|
|
93
|
+ }
|
|
|
|
94
|
+ }
|
|
|
|
95
|
+ return $data;
|
|
|
|
96
|
+ }
|
|
62
|
//
|
97
|
//
|
|
63
|
// $fileModel = new FileModel();
|
98
|
// $fileModel = new FileModel();
|
|
64
|
// $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
|
99
|
// $fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','name']);
|