作者 lyh

gx脚本导出产品

@@ -17,7 +17,6 @@ yarn-error.log @@ -17,7 +17,6 @@ yarn-error.log
17 /.idea 17 /.idea
18 /.vscode 18 /.vscode
19 composer.lock 19 composer.lock
20 -app/Console/Commands/Test/Demo.php  
21 app/Console/Commands/Test/DataRecovery.php 20 app/Console/Commands/Test/DataRecovery.php
22 /public/upload 21 /public/upload
23 /public/runtime 22 /public/runtime
1 <?php 1 <?php
2 /** 2 /**
3 - * Created by PhpStorm.  
4 - * User: zhl  
5 - * Date: 2023/2/7  
6 - * Time: 17:58 3 + * @remark :
  4 + * @name :Demo.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/2/20 9:19
7 */ 8 */
8 -namespace App\Console\Commands\Test;  
9 9
  10 +namespace App\Console\Commands\Test;
10 11
11 -use App\Helper\Arr;  
12 -use App\Helper\Translate;  
13 -use App\Mail\TextMail;  
14 -use App\Models\Blog\Blog;  
15 -use App\Models\Blog\BlogCategory;  
16 -use App\Models\Com\KeywordVideoTask;  
17 -use App\Models\Com\KeywordVideoTaskLog;  
18 -use App\Models\CustomModule\CustomModuleCategory;  
19 -use App\Models\CustomModule\CustomModuleContent;  
20 -use App\Models\CustomModule\CustomModuleExtentContent;  
21 -use App\Models\Devops\ServerConfig;  
22 -use App\Models\Devops\Servers;  
23 -use App\Models\Devops\ServersIp;  
24 -use App\Models\ExtentModule\ExtensionModuleValue;  
25 -use App\Models\File\File;  
26 -use App\Models\File\File as FileModel;  
27 -use App\Models\File\Image;  
28 -use App\Models\File\Image as ImageModel;  
29 -use App\Models\News\News;  
30 -use App\Models\News\NewsCategory;  
31 -use App\Models\Product\Keyword;  
32 -use App\Models\Product\KeywordRelated;  
33 -use App\Models\Product\Product;  
34 -use App\Models\Project\AutoEmailLog;  
35 -use App\Models\Project\DeployOptimize;  
36 -use App\Models\Project\MinorLanguages;  
37 -use App\Models\Project\Project;  
38 -use App\Models\Purchaser\Purchaser;  
39 -use App\Models\Purchaser\PurchaserInfo;  
40 -use App\Models\RouteMap\RouteMap;  
41 -use App\Models\Template\BCustomTemplate;  
42 -use App\Models\Template\BTemplateCom;  
43 -use App\Models\Template\Setting;  
44 -use App\Models\Template\Template;  
45 -use Hashids\Hashids;  
46 use Illuminate\Console\Command; 12 use Illuminate\Console\Command;
47 -use Illuminate\Support\Facades\Config;  
48 -use Illuminate\Support\Facades\DB;  
49 -use Illuminate\Support\Facades\Mail;  
50 -use Illuminate\Support\Facades\Schema;  
51 -  
52 13
53 class Demo extends Command 14 class Demo extends Command
54 { 15 {
@@ -64,32 +25,35 @@ class Demo extends Command @@ -64,32 +25,35 @@ class Demo extends Command
64 * 25 *
65 * @var string 26 * @var string
66 */ 27 */
67 - protected $description = 'demo'; 28 + protected $description = '';
68 29
69 public function handle(){ 30 public function handle(){
70 - return true; 31 + return $this->getExtendProjects();
71 } 32 }
72 33
73 -  
74 - public function toQueue(){  
75 - $info = [  
76 - 'email' => '1123736022@qq.com', // 收件人邮箱  
77 - 'title' => '测试邮件', // 邮件标题  
78 - 'content' => '这是来自163邮箱的测试邮件', // 邮件内容  
79 - ];  
80 - Config::set('mail.mailers.smtp.host', 'smtp.163.com');  
81 - Config::set('mail.mailers.smtp.username', 'lyh103433@163.com');  
82 - Config::set('mail.mailers.smtp.password', 'BMf8B327Nhncunnb');  
83 - Config::set('mail.from.address', 'lyh103433@163.com');  
84 - Config::set('mail.from.name', 'lyh'); 34 + public function getExtendProjects($api_no = null)
  35 + {
  36 + $key = 'extend_projects_list';
  37 + $data = Cache::get($key);
  38 + if (!$data) {
  39 + $api_url = 'http://api.quanqiusou.cn/google-rank/api/extend_projects.php';
85 try { 40 try {
86 - $status = AutoEmailLog::STATUS_SUCCESS;  
87 - Mail::to([$info['email']])->send(new TextMail(['subject' => $info['title'], 'text' => $info['content']]));  
88 - } catch (\Exception $e) {  
89 - $status = AutoEmailLog::STATUS_ERROR;  
90 - $this->output('任务:' . $info['id'] . ' 邮箱' . $info['email'] . '发送失败,' . $e->getMessage()); 41 + $data = HttpUtils::get($api_url, []);
  42 + if ($data) {
  43 + $data = Arr::s2a($data);
  44 + Cache::put($key, $data, 4 * 3600);
  45 + }
  46 + } catch (\Exception | GuzzleException $e) {
  47 + errorLog('复制站点项目获取失败', [], $e);
  48 + return false;
  49 + }
  50 + }
  51 + if ($api_no !== null) {
  52 + $data = collect($data)->where('apino', $api_no)->first();
  53 + return $data ?: [];
91 } 54 }
92 - return $status; 55 + echo date('Y-m-d H:i:s') . 'end'.json_encode($data) . PHP_EOL;
  56 + return $data;
93 } 57 }
94 58
95 } 59 }