Demo.php
5.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/2/7
* Time: 17:58
*/
namespace App\Console\Commands\Test;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\Blog\Blog;
use App\Models\Blog\BlogCategory;
use App\Models\Com\KeywordVideoTask;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\CustomModule\CustomModuleExtentContent;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
use App\Models\ExtentModule\ExtensionModuleValue;
use App\Models\File\File;
use App\Models\File\File as FileModel;
use App\Models\File\Image;
use App\Models\File\Image as ImageModel;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Models\Purchaser\Purchaser;
use App\Models\Purchaser\PurchaserInfo;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplateCom;
use App\Models\Template\Setting;
use App\Models\Template\Template;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use App\Utils\EncryptUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class Demo extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'demo';
/**
* The console command description.
*
* @var string
*/
protected $description = 'demo';
public function handle(){
// echo date('Y-m-d H:i:s') . 'project_id:' . PHP_EOL;
// ProjectServer::useProject(2837);
// $this->ceshi();
// DB::disconnect('custom_mysql');
$this->countTemplate();
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :统计当前模版使用情况
* @name :countTemplate
* @author :lyh
* @method :post
* @time :2025/1/9 10:59
*/
public function countTemplate(){
$bSettingModel = new Setting();
$lists = $bSettingModel->list();
$templateModel = new Template();
foreach ($lists as $v){
echo date('Y-m-d H:i:s') . '执行的模版id:' .$v['template_id'] . PHP_EOL;
$templateModel->where(['id'=>$v['template_id']])->increment('total',1);
}
return true;
}
/**
* @remark :更新产品
* @name :getProduct
* @author :lyh
* @method :post
* @time :2024/11/27 15:40
*/
public function getProduct(){
$productModel = new Product();
$lists = $productModel->list(['status'=>['!=',3]]);
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['keyword_video_id'])){
foreach ($v['keyword_video_id'] as $val){
$keywordRelaModel = new KeywordRelated();
echo date('Y-m-d H:i:s') . 'keyword_id :'.$val . 'product_id :'.$v['id'] . PHP_EOL;
$keywordRelaModel->edit(['type'=>2],['keyword_id'=>$val,'product_id'=>$v['id']]);
}
}
}
}
}
/**
* @remark :复制表及结构
* @name :copyProduct
* @author :lyh
* @method :post
* @time :2024/11/27 16:09
*/
public function copyProduct(){
$tableName = 'gl_product';
$copyTableName = 'gl_product_c';
if (Schema::connection('custom_mysql')->hasTable($copyTableName)) {
DB::connection('custom_mysql')->statement("DROP TABLE {$copyTableName}");
}
// 创建新表并复制数据
DB::connection('custom_mysql')->statement("CREATE TABLE {$copyTableName} LIKE {$tableName}");
DB::connection('custom_mysql')->statement("INSERT INTO {$copyTableName} SELECT * FROM {$tableName}");
}
/**
* @remark :保存供应商详情
* @name :savePurchaserInfo
* @author :lyh
* @method :post
* @time :2024/5/29 16:38
*/
public function savePurchaserInfo(){
$purchaserModel = new Purchaser();
$list = $purchaserModel->list();
foreach ($list as $val){
$project_id = $val['project_id'];
$keyword = $val['keyword'];
$data = json_decode($val['data'],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$purchaserInfoModel = new PurchaserInfo();
if(!empty($data)){
foreach ($data as $k =>$v){
$v['project_id'] = $project_id;
$v['keyword'] = $keyword;
$v['email'] = json_encode($v['email'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['mobile'] = json_encode($v['mobile'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['social_media'] = json_encode($v['social_media'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$v['image'] = str_replace('admin.hagro.cn','fob.ai.cc',$v['image'] ?? '');
$param = $v;
$info = $purchaserInfoModel->read(['keyword'=>$keyword,'buyer_id'=>$v['buyer_id'] ?? '','project_id'=>$project_id],['id']);
if($info === false){
echo date('Y-m-d H:i:s') . '执行新增 :' . PHP_EOL;
$purchaserInfoModel->add($param);
}else{
echo date('Y-m-d H:i:s') . '数据已存在 :'.$info['id'] . PHP_EOL;
}
}
}
}
return true;
}
}