作者 赵彬吉
@@ -23,7 +23,7 @@ class UpgradeProjectCount extends Command @@ -23,7 +23,7 @@ class UpgradeProjectCount extends Command
23 * 23 *
24 * @var string 24 * @var string
25 */ 25 */
26 - protected $signature = 'upgrade_count'; 26 + protected $signature = 'upgrade_count {project_id}';
27 27
28 /** 28 /**
29 * The console command description. 29 * The console command description.
@@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command @@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command
33 protected $description = '升级项目统计'; 33 protected $description = '升级项目统计';
34 34
35 public function handle(){ 35 public function handle(){
36 - $project_id = 769; 36 + $project_id = $this->argument('project_id');
37 ProjectServer::useProject($project_id); 37 ProjectServer::useProject($project_id);
38 $this->count($project_id); 38 $this->count($project_id);
39 DB::disconnect('custom_mysql'); 39 DB::disconnect('custom_mysql');
@@ -100,7 +100,8 @@ class UpgradeProjectCount extends Command @@ -100,7 +100,8 @@ class UpgradeProjectCount extends Command
100 * @time :2023/6/14 15:40 100 * @time :2023/6/14 15:40
101 */ 101 */
102 public function pv_num($day){ 102 public function pv_num($day){
103 - $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count(); 103 + //$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count();
  104 + $pv = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->sum('depth');
104 return $pv; 105 return $pv;
105 } 106 }
106 107
@@ -51,7 +51,7 @@ class DomainInfo extends Command @@ -51,7 +51,7 @@ class DomainInfo extends Command
51 } 51 }
52 $ssl = $this->updateDomainSsl($v['domain']); 52 $ssl = $this->updateDomainSsl($v['domain']);
53 $time = $this->updateDomain($v['domain']); 53 $time = $this->updateDomain($v['domain']);
54 - if(!empty($time['start']) && !!empty($time['end'])){ 54 + if(!empty($time['start']) && !empty($time['end'])){
55 $data = [ 55 $data = [
56 'certificate_start_time'=>$ssl['from'], 56 'certificate_start_time'=>$ssl['from'],
57 'certificate_end_time'=>$ssl['to'], 57 'certificate_end_time'=>$ssl['to'],
@@ -26,7 +26,7 @@ class UpgradeProjectCount extends Command @@ -26,7 +26,7 @@ class UpgradeProjectCount extends Command
26 * 26 *
27 * @var string 27 * @var string
28 */ 28 */
29 - protected $signature = 'upgrade_month_count'; 29 + protected $signature = 'upgrade_month_count {project_id}';
30 30
31 /** 31 /**
32 * The console command description. 32 * The console command description.
@@ -36,13 +36,12 @@ class UpgradeProjectCount extends Command @@ -36,13 +36,12 @@ class UpgradeProjectCount extends Command
36 protected $description = '升级项目统计'; 36 protected $description = '升级项目统计';
37 37
38 public function handle(){ 38 public function handle(){
39 - $project_id = 769; 39 + $project_id = $this->argument('project_id');
40 $oldModel = new UpdateOldInfo(); 40 $oldModel = new UpdateOldInfo();
41 $info = $oldModel->read(['project_id'=>$project_id]); 41 $info = $oldModel->read(['project_id'=>$project_id]);
42 $url = $info['old_domain_online']; 42 $url = $info['old_domain_online'];
43 ProjectServer::useProject($project_id); 43 ProjectServer::useProject($project_id);
44 $this->count($project_id,$url); 44 $this->count($project_id,$url);
45 -  
46 DB::disconnect('custom_mysql'); 45 DB::disconnect('custom_mysql');
47 } 46 }
48 47
@@ -16,6 +16,8 @@ use App\Models\Manage\BelongingGroup; @@ -16,6 +16,8 @@ use App\Models\Manage\BelongingGroup;
16 use App\Models\Manage\Dept; 16 use App\Models\Manage\Dept;
17 use App\Models\Manage\EntryPosition; 17 use App\Models\Manage\EntryPosition;
18 use App\Models\Manage\ManageHr; 18 use App\Models\Manage\ManageHr;
  19 +use App\Models\Project\Project;
  20 +use App\Models\WebSetting\WebSettingService;
19 use App\Services\ProjectServer; 21 use App\Services\ProjectServer;
20 use App\Services\SyncService; 22 use App\Services\SyncService;
21 use GuzzleHttp\Client; 23 use GuzzleHttp\Client;
@@ -76,187 +78,200 @@ class Demo extends Command @@ -76,187 +78,200 @@ class Demo extends Command
76 /** 78 /**
77 * @return bool 79 * @return bool
78 */ 80 */
79 - public function handle()  
80 - {  
81 - return $this->domain();  
82 - $result = app(SyncService::class)->projectAcceptAddress(1);  
83 - dd($result);  
84 - $data = [  
85 - 'key' => 'productkey_keyword',  
86 - 'keywords' => 'apple watch'  
87 - ];  
88 - $result = Common::send_openai_msg('v2/openai_chat', $data);  
89 - dd();  
90 - $string = 'demo.globalso.site/';  
91 - $domain_array = parse_url($string);  
92 - $domain = $domain_array['host'] ?? $domain_array['path'];  
93 - dd($domain);  
94 - $data = [];  
95 - dd(isset($data['a']['b']));  
96 - $url = 'https://demo.globalso.site/';  
97 - $action = 'api/updateHtmlNotify/';  
98 - $data = [  
99 - 'project_id' => 1,  
100 - 'type' => 1,  
101 - 'route' => 1  
102 - ];;  
103 - $method = 'GET';  
104 - $result = $this->curlRequest($url . $action, $data, $method);  
105 - dd($result);  
106 -  
107 - $context = stream_context_create([  
108 - 'ssl' => [  
109 - 'capture_peer_cert' => true,  
110 - 'capture_peer_cert_chain' => false,  
111 - ],  
112 - ]);  
113 -  
114 - $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);  
115 -  
116 - if(!$stream) {  
117 - die("Failed to connect: $errno - $errstr");  
118 - }  
119 -  
120 - $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];  
121 -  
122 - if(!$remote_cert) {  
123 - die("Failed to retrieve certificate");  
124 - }  
125 -  
126 - $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);  
127 - $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);  
128 -  
129 - fclose($stream);  
130 -  
131 - echo "Certificate Valid From: $valid_from<br>";  
132 - echo "Certificate Valid To: $valid_to<br>";  
133 -  
134 - dd('end');  
135 - $dept_array = [  
136 - '品牌部',  
137 - '综合部',  
138 - '渠道部',  
139 - '广告推广部',  
140 - 'AICC运营部',  
141 - '黑格运营部',  
142 - '直营运营部',  
143 - '直营销售部',  
144 - '深圳跨境部',  
145 - '外贸部',  
146 - '研发部',  
147 - '技术部',  
148 - '售后部',  
149 - ];  
150 - foreach ($dept_array as $v) {  
151 - $dept = Dept::where(['title' => $v])->first();  
152 - if (FALSE == empty($dept))  
153 - continue;  
154 - $dept = new Dept();  
155 - $dept->title = $v;  
156 - $dept->save();  
157 - }  
158 -// dd('dept end');  
159 - $dept_map = Dept::pluck('title', 'id')->toArray();  
160 - $belonging_map = BelongingGroup::pluck('name', 'id')->toArray();  
161 -// dd($belonging_map);  
162 -  
163 - $filename = storage_path('logs/oa_hr.txt');  
164 - $string = file_get_contents($filename);  
165 - $data = explode("\r\n", $string);  
166 - $data = array_filter($data);  
167 - $dept = '';  
168 - foreach ($data as $k=>$v) {  
169 -// var_dump($v) . PHP_EOL;  
170 - if ($k == 1)  
171 - continue;  
172 - $tmp = explode("\t", $v);  
173 - if (count($tmp) == 3) {  
174 - $dept = $tmp[0] ? : $dept;  
175 - $position = $tmp[1];  
176 - $name = $tmp[2];  
177 - } else if (count($tmp) == 2) {  
178 - $position = $tmp[0];  
179 - $name = $tmp[1];  
180 - } else {  
181 - Log::info($v . PHP_EOL);  
182 - continue;  
183 - }  
184 -  
185 -  
186 -// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);  
187 -// continue;  
188 -  
189 - $dept_id = array_search($dept, $dept_map);  
190 - $belonging_id = 17;  
191 - if (FALSE !== strpos($dept,'技术部')) {  
192 - $belonging_string = str_replace('技术部', '', $dept);  
193 - if ($belonging_string) {  
194 - $belonging_string = $belonging_string . '组';  
195 - $belonging_id = array_search($belonging_string, $belonging_map);  
196 - }  
197 -  
198 - $dept_tmp = '技术部';  
199 - $dept_id = array_search($dept_tmp, $dept_map);  
200 - }  
201 - if (FALSE !== strpos($dept,'售后')) {  
202 - $belonging_string = str_replace('售后', '', $dept);  
203 - if ($belonging_string)  
204 - $belonging_id = array_search($belonging_string, $belonging_map);  
205 - $dept_tmp = '售后部';  
206 - $dept_id = array_search($dept_tmp, $dept_map);  
207 - }  
208 -  
209 - $position_log = EntryPosition::where(['name' => $position])->first();  
210 - if (empty($position_log)) {  
211 - $position_log = new EntryPosition();  
212 - $position_log->name = $position;  
213 - $position_log->save();  
214 - }  
215 - $position_id = $position_log->id;  
216 -  
217 - $hr = ManageHr::where(['name' => $name])->first();  
218 - if (empty($hr)) {  
219 - Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);  
220 - continue;  
221 - }  
222 -  
223 - $hr->belong_group = $belonging_id;  
224 - $hr->dept_id = $dept_id;  
225 - $hr->entry_position = $position_id;  
226 - $hr->save();  
227 - echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;  
228 -  
229 - }  
230 - dd('end');  
231 - exit; 81 +// public function handle()
  82 +// {
  83 +// return $this->domain();
  84 +// $result = app(SyncService::class)->projectAcceptAddress(1);
  85 +// dd($result);
  86 +// $data = [
  87 +// 'key' => 'productkey_keyword',
  88 +// 'keywords' => 'apple watch'
  89 +// ];
  90 +// $result = Common::send_openai_msg('v2/openai_chat', $data);
  91 +// dd();
  92 +// $string = 'demo.globalso.site/';
  93 +// $domain_array = parse_url($string);
  94 +// $domain = $domain_array['host'] ?? $domain_array['path'];
  95 +// dd($domain);
  96 +// $data = [];
  97 +// dd(isset($data['a']['b']));
  98 +// $url = 'https://demo.globalso.site/';
  99 +// $action = 'api/updateHtmlNotify/';
  100 +// $data = [
  101 +// 'project_id' => 1,
  102 +// 'type' => 1,
  103 +// 'route' => 1
  104 +// ];;
  105 +// $method = 'GET';
  106 +// $result = $this->curlRequest($url . $action, $data, $method);
  107 +// dd($result);
  108 +//
  109 +// $context = stream_context_create([
  110 +// 'ssl' => [
  111 +// 'capture_peer_cert' => true,
  112 +// 'capture_peer_cert_chain' => false,
  113 +// ],
  114 +// ]);
  115 +//
  116 +// $stream = stream_socket_client('ssl://oa.quanqiusou.cn:443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);
  117 +//
  118 +// if(!$stream) {
  119 +// die("Failed to connect: $errno - $errstr");
  120 +// }
  121 +//
  122 +// $remote_cert = stream_context_get_params($stream)['options']['ssl']['peer_certificate'];
  123 +//
  124 +// if(!$remote_cert) {
  125 +// die("Failed to retrieve certificate");
  126 +// }
  127 +//
  128 +// $valid_from = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validFrom_time_t']);
  129 +// $valid_to = date('Y-m-d H:i:s', openssl_x509_parse($remote_cert)['validTo_time_t']);
  130 +//
  131 +// fclose($stream);
  132 +//
  133 +// echo "Certificate Valid From: $valid_from<br>";
  134 +// echo "Certificate Valid To: $valid_to<br>";
  135 +//
  136 +// dd('end');
  137 +// $dept_array = [
  138 +// '品牌部',
  139 +// '综合部',
  140 +// '渠道部',
  141 +// '广告推广部',
  142 +// 'AICC运营部',
  143 +// '黑格运营部',
  144 +// '直营运营部',
  145 +// '直营销售部',
  146 +// '深圳跨境部',
  147 +// '外贸部',
  148 +// '研发部',
  149 +// '技术部',
  150 +// '售后部',
  151 +// ];
  152 +// foreach ($dept_array as $v) {
  153 +// $dept = Dept::where(['title' => $v])->first();
  154 +// if (FALSE == empty($dept))
  155 +// continue;
  156 +// $dept = new Dept();
  157 +// $dept->title = $v;
  158 +// $dept->save();
  159 +// }
  160 +//// dd('dept end');
  161 +// $dept_map = Dept::pluck('title', 'id')->toArray();
  162 +// $belonging_map = BelongingGroup::pluck('name', 'id')->toArray();
  163 +//// dd($belonging_map);
  164 +//
  165 +// $filename = storage_path('logs/oa_hr.txt');
  166 +// $string = file_get_contents($filename);
  167 +// $data = explode("\r\n", $string);
  168 +// $data = array_filter($data);
  169 +// $dept = '';
  170 +// foreach ($data as $k=>$v) {
  171 +//// var_dump($v) . PHP_EOL;
  172 +// if ($k == 1)
  173 +// continue;
  174 +// $tmp = explode("\t", $v);
  175 +// if (count($tmp) == 3) {
  176 +// $dept = $tmp[0] ? : $dept;
  177 +// $position = $tmp[1];
  178 +// $name = $tmp[2];
  179 +// } else if (count($tmp) == 2) {
  180 +// $position = $tmp[0];
  181 +// $name = $tmp[1];
  182 +// } else {
  183 +// Log::info($v . PHP_EOL);
  184 +// continue;
  185 +// }
  186 +//
  187 +//
  188 +//// Log::info($dept . '---' . $position . '---' . $name . PHP_EOL);
  189 +//// continue;
  190 +//
  191 +// $dept_id = array_search($dept, $dept_map);
  192 +// $belonging_id = 17;
  193 +// if (FALSE !== strpos($dept,'技术部')) {
  194 +// $belonging_string = str_replace('技术部', '', $dept);
  195 +// if ($belonging_string) {
  196 +// $belonging_string = $belonging_string . '组';
  197 +// $belonging_id = array_search($belonging_string, $belonging_map);
  198 +// }
  199 +//
  200 +// $dept_tmp = '技术部';
  201 +// $dept_id = array_search($dept_tmp, $dept_map);
  202 +// }
  203 +// if (FALSE !== strpos($dept,'售后')) {
  204 +// $belonging_string = str_replace('售后', '', $dept);
  205 +// if ($belonging_string)
  206 +// $belonging_id = array_search($belonging_string, $belonging_map);
  207 +// $dept_tmp = '售后部';
  208 +// $dept_id = array_search($dept_tmp, $dept_map);
  209 +// }
  210 +//
  211 +// $position_log = EntryPosition::where(['name' => $position])->first();
  212 +// if (empty($position_log)) {
  213 +// $position_log = new EntryPosition();
  214 +// $position_log->name = $position;
  215 +// $position_log->save();
  216 +// }
  217 +// $position_id = $position_log->id;
  218 +//
  219 +// $hr = ManageHr::where(['name' => $name])->first();
  220 +// if (empty($hr)) {
  221 +// Log::info($k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id);
  222 +// continue;
  223 +// }
  224 +//
  225 +// $hr->belong_group = $belonging_id;
  226 +// $hr->dept_id = $dept_id;
  227 +// $hr->entry_position = $position_id;
  228 +// $hr->save();
  229 +// echo $k . '-' . $name . '-' . $dept . '-' . $dept_id . '-' . $position . '-' . $position_id . '-' . '组' . '-' . $belonging_id . PHP_EOL;
  230 +//
  231 +// }
  232 +// dd('end');
  233 +// exit;
  234 +//
  235 +// if (($handle = fopen($filename, 'r')) !== false) {
  236 +// while (($data = fgetcsv($handle, 1000, ',')) !== false) {
  237 +// // 处理每行数据
  238 +// Log::info(var_export($data, true));
  239 +// }
  240 +// fclose($handle);
  241 +// }
  242 +// exit;
  243 +//
  244 +// $group = BelongingGroup::get();
  245 +// dd($group->toArray());
  246 +// $domain = parse_url('https//:dev.golbalso.site/');
  247 +// dd($domain);
  248 +// echo time() . PHP_EOL;
  249 +// $blogModel = new Image();
  250 +// $list = $blogModel->list();
  251 +// echo time() . PHP_EOL;
  252 +// dd(count($list));
  253 +//
  254 +// return;
  255 +// preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'
  256 +//@include("asdf")@include("")@include("asdtrw2erf")
  257 +// ',$include);
  258 +//
  259 +// print_r($include);
  260 +// }
232 261
233 - if (($handle = fopen($filename, 'r')) !== false) {  
234 - while (($data = fgetcsv($handle, 1000, ',')) !== false) {  
235 - // 处理每行数据  
236 - Log::info(var_export($data, true)); 262 + public function handle(){
  263 + $projectModel = new Project();
  264 + $list = $projectModel->list(['delete_status'=>0]);
  265 + foreach ($list as $v){
  266 + ProjectServer::useProject($v['id']);
  267 + $webSettingServiceModel = new WebSettingService();
  268 + $info = $webSettingServiceModel->read(['values'=>['like','%+86%']]);
  269 + if($info !== false){
  270 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
237 } 271 }
238 - fclose($handle); 272 + DB::disconnect('custom_mysql');
239 } 273 }
240 - exit;  
241 -  
242 - $group = BelongingGroup::get();  
243 - dd($group->toArray());  
244 - $domain = parse_url('https//:dev.golbalso.site/');  
245 - dd($domain);  
246 - echo time() . PHP_EOL;  
247 - $blogModel = new Image();  
248 - $list = $blogModel->list();  
249 - echo time() . PHP_EOL;  
250 - dd(count($list));  
251 -  
252 - return;  
253 - preg_match_all("/\@include\(\"([a-z0-9_]+)\"\)/i",'  
254 -@include("asdf")@include("")@include("asdtrw2erf")  
255 - ',$include);  
256 -  
257 - print_r($include);  
258 } 274 }
259 -  
260 public function printMessage() 275 public function printMessage()
261 { 276 {
262 $client = new Client(); 277 $client = new Client();
@@ -122,7 +122,7 @@ class ProjectUpdate extends Command @@ -122,7 +122,7 @@ class ProjectUpdate extends Command
122 $data = curl_c($url); 122 $data = curl_c($url);
123 if (isset($data['code']) && $data['code'] == 200) { 123 if (isset($data['code']) && $data['code'] == 200) {
124 $items = $data['data'] ?? []; 124 $items = $data['data'] ?? [];
125 - $this->category_insert($project_id, $items, 0); 125 + $this->category_insert($project_id, $items, 0, $domain_arr['host'], $web_url_domain, $home_url);
126 } else { 126 } else {
127 return true; 127 return true;
128 } 128 }
@@ -737,7 +737,7 @@ class ProjectUpdate extends Command @@ -737,7 +737,7 @@ class ProjectUpdate extends Command
737 } 737 }
738 738
739 //产品多级分类入库 739 //产品多级分类入库
740 - protected function category_insert($project_id, $items, $pid = 0) 740 + protected function category_insert($project_id, $items, $pid, $domain, $web_url_domain, $home_url)
741 { 741 {
742 $model = new Category(); 742 $model = new Category();
743 foreach ($items as $item) { 743 foreach ($items as $item) {
@@ -747,9 +747,17 @@ class ProjectUpdate extends Command @@ -747,9 +747,17 @@ class ProjectUpdate extends Command
747 if (!$parent) { 747 if (!$parent) {
748 try { 748 try {
749 $item['name'] = $this->special2str($item['name'] ?? ''); 749 $item['name'] = $this->special2str($item['name'] ?? '');
  750 + //图片
  751 + if (is_array($item['images'] ?? '')) {
  752 + $image = $item['images'][0] ?? '';
  753 + } else {
  754 + $image = $item['images'] ?? '';
  755 + }
  756 + $new_img = $this->source_download($image, $project_id, $domain, $web_url_domain, $home_url);
750 $parent_id = $model->addReturnId([ 757 $parent_id = $model->addReturnId([
751 'project_id' => $project_id, 758 'project_id' => $project_id,
752 'title' => $item['name'], 759 'title' => $item['name'],
  760 + 'image' => $new_img,
753 'pid' => $pid, 761 'pid' => $pid,
754 'keywords' => $item['keywords'] ?? '', 762 'keywords' => $item['keywords'] ?? '',
755 'describe' => $item['description'] ?? '', 763 'describe' => $item['description'] ?? '',
@@ -766,7 +774,7 @@ class ProjectUpdate extends Command @@ -766,7 +774,7 @@ class ProjectUpdate extends Command
766 } 774 }
767 775
768 if (!empty($item['children'] ?? [])) { 776 if (!empty($item['children'] ?? [])) {
769 - $this->category_insert($project_id, $item['children'], $parent_id); 777 + $this->category_insert($project_id, $item['children'], $parent_id, $domain, $web_url_domain, $home_url);
770 } 778 }
771 } 779 }
772 } 780 }
@@ -55,7 +55,7 @@ class UpdateRoute extends Command @@ -55,7 +55,7 @@ class UpdateRoute extends Command
55 */ 55 */
56 public function handle(){ 56 public function handle(){
57 $projectModel = new Project(); 57 $projectModel = new Project();
58 - $list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0,'id'=>['<',500]]); 58 + $list = $projectModel->list(['id'=>264]);
59 $data = []; 59 $data = [];
60 foreach ($list as $v){ 60 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
@@ -291,7 +291,7 @@ class WebTraffic extends Command @@ -291,7 +291,7 @@ class WebTraffic extends Command
291 }else{ 291 }else{
292 //大于9个月项目 292 //大于9个月项目
293 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); 293 $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
294 - $query->whereBetween('pdo.start_date', '<', $startTime); 294 + $query->where('pdo.start_date', '<', $startTime);
295 } 295 }
296 })->select('pdo.project_id')->forPage($page, 500)->get(); 296 })->select('pdo.project_id')->forPage($page, 500)->get();
297 //其他地方在引流的域名 297 //其他地方在引流的域名
@@ -727,7 +727,7 @@ class Translate @@ -727,7 +727,7 @@ class Translate
727 * @return \Illuminate\Http\Client\Response 727 * @return \Illuminate\Http\Client\Response
728 * @time 2022/3/30 15:58 728 * @time 2022/3/30 15:58
729 */ 729 */
730 - public static function translate($texts, $tls) 730 + public static function translate($texts, $tls, $sl = 'auto')
731 { 731 {
732 $action = 'translates'; 732 $action = 'translates';
733 if (is_string($texts)) { 733 if (is_string($texts)) {
@@ -738,7 +738,7 @@ class Translate @@ -738,7 +738,7 @@ class Translate
738 } 738 }
739 $data = [ 739 $data = [
740 'texts' => $texts, 740 'texts' => $texts,
741 - 'sl' => 'auto', 741 + 'sl' => $sl,
742 'tls' => $tls, 742 'tls' => $tls,
743 ]; 743 ];
744 return http_post(self::$url.$action, json_encode($data),self::$header); 744 return http_post(self::$url.$action, json_encode($data),self::$header);
@@ -6,9 +6,16 @@ use App\Enums\Common\Code; @@ -6,9 +6,16 @@ use App\Enums\Common\Code;
6 use App\Enums\Common\Common; 6 use App\Enums\Common\Common;
7 use App\Http\Controllers\Aside\BaseController; 7 use App\Http\Controllers\Aside\BaseController;
8 use App\Http\Logic\Aside\Manage\MenuLogic; 8 use App\Http\Logic\Aside\Manage\MenuLogic;
  9 +use App\Models\Domain\DomainInfo;
9 use App\Models\Inquiry\InquiryData; 10 use App\Models\Inquiry\InquiryData;
10 use App\Models\Manage\Manage; 11 use App\Models\Manage\Manage;
  12 +use App\Models\Product\Keyword;
  13 +use App\Models\Product\Product;
  14 +use App\Models\Project\Project;
  15 +use App\Models\RouteMap\RouteMap;
  16 +use App\Services\ProjectServer;
11 use Illuminate\Support\Facades\Cache; 17 use Illuminate\Support\Facades\Cache;
  18 +use Illuminate\Support\Facades\DB;
12 use Illuminate\Support\Facades\Hash; 19 use Illuminate\Support\Facades\Hash;
13 20
14 /** 21 /**
@@ -96,4 +103,56 @@ class IndexController extends BaseController @@ -96,4 +103,56 @@ class IndexController extends BaseController
96 $this->response('success'); 103 $this->response('success');
97 } 104 }
98 105
  106 + /**
  107 + * @remark :根据关键字获取产品主图
  108 + * @name :getKeywordList
  109 + * @author :lyh
  110 + * @method :post
  111 + * @time :2024/2/23 16:28
  112 + */
  113 + public function getKeywordImage(){
  114 + $arr = explode('/',trim(str_replace('https://', '', $this->param['url']),'/'));
  115 + if(empty($arr) || !is_array($arr)){
  116 + $this->response('当前项目不存在..',Code::SYSTEM_ERROR);
  117 + }
  118 + $domainModel = new DomainInfo();
  119 + $domainInfo = $domainModel->read(['domain'=>$arr[0]]);
  120 + if($domainInfo === false){
  121 + $this->response('当前项目不存在.',Code::SYSTEM_ERROR);
  122 + }
  123 + ProjectServer::useProject($domainInfo['project_id']);
  124 + $routeMapModel = new RouteMap();
  125 + $routeInfo = $routeMapModel->read(['route'=>$arr[1]]);
  126 + if($domainInfo === false){
  127 + $this->response('当前路由不存在.',Code::SYSTEM_ERROR);
  128 + }
  129 + $keywordModel = new Keyword();
  130 + $keywordInfo = $keywordModel->read(['id'=>$routeInfo['source_id']]);
  131 + $count = Product::where('keyword_id','like' ,'%,'.$keywordInfo['id'].',%')->count();
  132 + $productModel = new Product();
  133 + if($count < 5){
  134 + $productList = $productModel->list([],'sort',['thumb','title']);
  135 + //获取7个产品主图
  136 + }else{
  137 + $productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],['thumb','title']);
  138 + }
  139 + $product_image = [];
  140 + foreach ($productList as $k => $v){
  141 + $image = [];
  142 + $image['title'] = $v['title'];
  143 + if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
  144 + $image['image'] = getImageUrl($v['thumb']['url']);
  145 + }
  146 + $product_image[] = $image;
  147 + }
  148 + $data = [
  149 + 'title'=>$keywordInfo['title'],
  150 + 'keyword_title'=>$keywordInfo['keyword_title'],
  151 + 'keyword_content'=>$keywordInfo['keyword_content'],
  152 + 'product_list'=>$product_image
  153 + ];
  154 + DB::disconnect('custom_mysql');
  155 + $this->response('success',Code::SUCCESS,$data);
  156 + }
  157 +
99 } 158 }
@@ -213,7 +213,7 @@ class OptimizeController extends BaseController @@ -213,7 +213,7 @@ class OptimizeController extends BaseController
213 if(isset($this->map['level']) && !empty($this->map['level'])){ 213 if(isset($this->map['level']) && !empty($this->map['level'])){
214 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]); 214 $query = $query->whereRaw("FIND_IN_SET(?, gl_project.level) > 0", [$this->map['level']]);
215 } 215 }
216 - if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at'])){ 216 + if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at']) && is_array($this->map['online_updated_at'])){
217 $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']); 217 $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']);
218 } 218 }
219 if(isset($this->map['special'])){ 219 if(isset($this->map['special'])){
@@ -26,7 +26,6 @@ class ATemplateController extends BaseController @@ -26,7 +26,6 @@ class ATemplateController extends BaseController
26 */ 26 */
27 public function lists(ATemplateLogic $aTemplateLogic){ 27 public function lists(ATemplateLogic $aTemplateLogic){
28 $filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id']; 28 $filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
29 - $this->map['test_model'] = 0;  
30 $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed); 29 $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
31 if(!empty($lists) && !empty($lists['list'])){ 30 if(!empty($lists) && !empty($lists['list'])){
32 foreach ($lists['list'] as $k => $v){ 31 foreach ($lists['list'] as $k => $v){
@@ -300,4 +300,28 @@ class ComController extends BaseController @@ -300,4 +300,28 @@ class ComController extends BaseController
300 } 300 }
301 $this->response('success',Code::SUCCESS,['url'=>$url_link]); 301 $this->response('success',Code::SUCCESS,['url'=>$url_link]);
302 } 302 }
  303 +
  304 + /**
  305 + * @remark :根据手机号码,获取当前号码拥有的所有项目
  306 + * @name :getMobileProject
  307 + * @author :lyh
  308 + * @method :post
  309 + * @time :2024/2/22 9:32
  310 + */
  311 + public function getMobileProject(){
  312 + $data = [];
  313 + $userModel = new User();
  314 + $list = $userModel->list(['mobile'=>$this->user['mobile'],'project_id'=>['!=',$this->user['project_id']]],'id',['id','project_id']);
  315 + if(!empty($list)){
  316 + $projectModel = new Project();
  317 + foreach ($list as $k => $v){
  318 + $projectInfo = $projectModel->read(['id'=>$v['project_id']],['id','company']);
  319 + //获取当前项目详情
  320 + $data[] = ['project_id'=>$projectInfo['id'],'company'=>$projectInfo['company']];
  321 + }
  322 + }
  323 + //登录选择项目的有效时间
  324 + Cache::add('login-project-'.$this->user['mobile'],1,300);
  325 + $this->response('success',Code::SUCCESS,$data);
  326 + }
303 } 327 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :MonthReportController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/2/2 15:01
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\BCom;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Models\HomeCount\MonthCount;
  15 +
  16 +class MonthReportController extends BaseController
  17 +{
  18 + /**
  19 + * @remark :获取项目当前所有月份
  20 + * @name :getMonth
  21 + * @author :lyh
  22 + * @method :post
  23 + * @time :2024/2/2 15:14
  24 + */
  25 + public function getMonth(){
  26 + $monthCountModel = new MonthCount();
  27 + $this->map['project_id'] = $this->user['project_id'];
  28 + $month = $monthCountModel->formatQuery($this->map)->pluck('month')->unique()->toArray();
  29 + $this->response('success',Code::SUCCESS,$month);
  30 + }
  31 +
  32 + /**
  33 + * @remark :月报告详情
  34 + * @name :monthReportInfo
  35 + * @author :lyh
  36 + * @method :post
  37 + * @time :2024/2/2 15:02
  38 + */
  39 + public function monthReportInfo(){
  40 + $monthCountModel = new MonthCount();
  41 + $this->map['project_id'] = $this->user['project_id'];
  42 + $info = $monthCountModel->read($this->map);
  43 + foreach ($info as $k => $v){
  44 + if(!empty($v['source_country'])){
  45 + $v['source_country'] = json_decode($v['source_country']);
  46 + }
  47 + if(!empty($v['referrer_port'])){
  48 + $v['referrer_port'] = json_decode($v['referrer_port']);
  49 + }
  50 + if(!empty($v['referrer_url'])){
  51 + $v['referrer_url'] = json_decode($v['referrer_url']);
  52 + }
  53 + if(!empty($v['source'])){
  54 + $v['source'] = json_decode($v['source']);
  55 + }
  56 + if(!empty($v['country'])){
  57 + $v['country'] = json_decode($v['country']);
  58 + }
  59 + $lists[$k] = $v;
  60 + }
  61 + $this->response('success',Code::SUCCESS,$info);
  62 + }
  63 +}
@@ -94,11 +94,6 @@ class KeywordController extends BaseController @@ -94,11 +94,6 @@ class KeywordController extends BaseController
94 * @time :2023/8/23 16:57 94 * @time :2023/8/23 16:57
95 */ 95 */
96 public function info(Request $request, KeywordLogic $logic){ 96 public function info(Request $request, KeywordLogic $logic){
97 - $request->validate([  
98 - 'id'=>'required'  
99 - ],[  
100 - 'id.required' => 'ID不能为空'  
101 - ]);  
102 $data = $logic->getKeywordInfo(); 97 $data = $logic->getKeywordInfo();
103 if($data !== false){ 98 if($data !== false){
104 $data = $this->handleReturnInfo($data); 99 $data = $this->handleReturnInfo($data);
@@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo; @@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo;
17 use App\Models\Product\Keyword; 17 use App\Models\Product\Keyword;
18 use App\Models\Product\KeywordRelated; 18 use App\Models\Product\KeywordRelated;
19 use App\Models\Product\Product; 19 use App\Models\Product\Product;
  20 +use App\Models\RouteMap\RouteMap;
20 use App\Models\Template\Setting; 21 use App\Models\Template\Setting;
21 use App\Models\Template\BTemplate; 22 use App\Models\Template\BTemplate;
22 use App\Models\User\User; 23 use App\Models\User\User;
@@ -58,7 +59,7 @@ class ProductController extends BaseController @@ -58,7 +59,7 @@ class ProductController extends BaseController
58 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id 59 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL);//获取模版id
59 $userModel = new User(); 60 $userModel = new User();
60 foreach ($lists['list'] as $k=>$v){ 61 foreach ($lists['list'] as $k=>$v){
61 - $v['url'] = $this->user['domain'].$v['route'].'/'; 62 + $v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_PRODUCT,$v['id']);;
62 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data); 63 $v['category_id_text'] = $this->categoryName($v['category_id'],$cate_data);
63 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data); 64 $v['keyword_id_text'] = $this->keywordName($v['keyword_id'],$key_data);
64 $v['created_uid_text'] = $userModel->getName($v['created_uid']); 65 $v['created_uid_text'] = $userModel->getName($v['created_uid']);
1 -<?php  
2 -/**  
3 - * @remark :  
4 - * @name :UpdateHtml.php  
5 - * @author :lyh  
6 - * @method :post  
7 - * @time :2024/2/2 10:11  
8 - */  
9 -  
10 -namespace App\Http\Controllers\Html;  
11 -  
12 -use App\Http\Controllers\Controller;  
13 -use App\Models\Com\NoticeLog;  
14 -use App\Models\Project\Project;  
15 -use App\Models\RouteMap\RouteMap;  
16 -use App\Models\Service\Service as ServiceSettingModel;  
17 -use App\Models\Template\BTemplate;  
18 -use App\Services\ProjectServer;  
19 -use Illuminate\Support\Facades\DB;  
20 -  
21 -class UpdateHtml extends Controller  
22 -{  
23 - protected $param;  
24 - protected $project_id;  
25 - public function __construct($data){  
26 - $this->param = $data;//Todo::传递的参数  
27 - $this->project_id = $data['project_id'];  
28 - }  
29 -  
30 - /**  
31 - * @remark :更新界面  
32 - * @name :updateHtml  
33 - * @author :lyh  
34 - * @method :post  
35 - * @time :2024/2/2 10:12  
36 - */  
37 - public function updateHtml(){  
38 - ProjectServer::useProject($this->project_id);  
39 - if(isset($this->param['route']) && $this->param['route'] == 'all'){  
40 - //TODO::更新所有界面  
41 - }else{  
42 - //TODO::更新单页  
43 - $routeMapModel = new RouteMap();  
44 - }  
45 - DB::disconnect('custom_mysql');  
46 - }  
47 -  
48 - /**  
49 - * @remark :获取页面是否为 定制/非定制 页面  
50 - * @name :getPageHtmlIsCustomized  
51 - * @param :source:类型;is_list:是否为列表页 1:列表页面  
52 - * @author :lyh  
53 - * @method :post  
54 - * @time :2024/2/2 11:03  
55 - */  
56 - public function getPageHtmlIsCustomized($source,$is_list){  
57 - $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型  
58 - //查看当前页面是否定制,是否开启可视化  
59 - $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面  
60 - if (in_array($type, $page_array)) {//是定制界面  
61 - return BTemplate::IS_VISUALIZATION;  
62 - }  
63 - return BTemplate::IS_NO_VISUALIZATION;  
64 - }  
65 -  
66 - /**  
67 - * @remark :获取头部底部公共部分代码  
68 - * @name :getTemplateCommon  
69 - * @author :lyh  
70 - * @method :post  
71 - * @time :2024/2/2 11:02  
72 - */  
73 - public function getTemplateCommon(){  
74 -  
75 - }  
76 -  
77 - /**  
78 - * @remark :获取装修中间内容  
79 - * @name :getTemplateMainHtml  
80 - * @author :lyh  
81 - * @method :post  
82 - * @time :2024/2/2 11:01  
83 - */  
84 - public function getTemplateMainHtml(){  
85 -  
86 - }  
87 -  
88 - /**  
89 - * @remark :获取项目详情  
90 - * @name :getProjectInfo  
91 - * @author :lyh  
92 - * @method :post  
93 - * @time :2024/2/2 10:50  
94 - */  
95 - public function getProjectInfo($project_id){  
96 - $projectModel = new Project();  
97 - $info = $projectModel->read(['id'=>$project_id],['id','is_customized']);  
98 - return $info;  
99 - }  
100 -  
101 - /**  
102 - * @remark :拼接获取公共头部底部  
103 - * @name :getHeadFooter  
104 - * @author :lyh  
105 - * @method :post  
106 - * @time :2023/7/21 17:22  
107 - */  
108 - public function getHeadFooter($html){  
109 - //获取公共主题头部底部  
110 - $serviceSettingModel = new ServiceSettingModel();  
111 - $list = $serviceSettingModel->list(['type'=>2],'created_at');  
112 - //拼接html  
113 - foreach ($list as $v){  
114 - if($v['key'] == 'head'){  
115 - $html = $v['values'].$html;  
116 - }  
117 - if($v['key'] == 'footer'){  
118 - $html = $html.$v['values'];  
119 - }  
120 - }  
121 - return $html;  
122 - }  
123 -}  
@@ -43,6 +43,10 @@ class DomainInfoLogic extends BaseLogic @@ -43,6 +43,10 @@ class DomainInfoLogic extends BaseLogic
43 if(isset($this->param['id']) && !empty($this->param['id'])){ 43 if(isset($this->param['id']) && !empty($this->param['id'])){
44 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 44 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
45 }else{ 45 }else{
  46 + //查看域名是否以WWW开头
  47 + if (strpos($this->param['domain'], 'www.') === 0) {
  48 + $this->param['other_domain'] = json_encode([str_replace('www', '*', $this->param['domain']),str_replace('www.', '', $this->param['domain'])]);
  49 + }
46 $rs = $this->model->add($this->param); 50 $rs = $this->model->add($this->param);
47 } 51 }
48 if($rs === false){ 52 if($rs === false){
@@ -185,6 +189,48 @@ class DomainInfoLogic extends BaseLogic @@ -185,6 +189,48 @@ class DomainInfoLogic extends BaseLogic
185 } 189 }
186 190
187 /** 191 /**
  192 + * 编辑amp网站证书
  193 + * @param $initDomain
  194 + * @param $domain
  195 + * @return array
  196 + * @throws \App\Exceptions\AsideGlobalException
  197 + * @throws \App\Exceptions\BsideGlobalException
  198 + * @author Akun
  199 + * @date 2024/02/22 14:58
  200 + */
  201 + public function setAmpDomainSsl($initDomain,$domain)
  202 + {
  203 + if($this->param['amp_type'] == 2){
  204 + if(empty($this->param['amp_key'])){
  205 + $this->fail('AMP站点证书KEY值不能为空');
  206 + }
  207 + if(empty($this->param['amp_cert'])){
  208 + $this->fail('AMP站点证书cert值不能为空');
  209 + }
  210 + }
  211 + $api_url = 'http://'.$initDomain.'/api/createSiteAmp';
  212 + $api_param = [
  213 + 'domain' => $domain,
  214 + 'private_key' => $this->param['amp_key']??'',
  215 + 'cert' => $this->param['amp_cert']??''
  216 + ];
  217 +
  218 + try {
  219 + $rs = HttpUtils::get($api_url, $api_param);
  220 + $rs = json_decode($rs, true);
  221 + if(isset($rs['status']) && $rs['status'] == 200){
  222 + return $this->success();
  223 + }else{
  224 + $this->fail($rs['message']??'');
  225 + }
  226 + } catch (\Exception | GuzzleException $e) {
  227 + errorLog('创建AMP站点', $api_param, $e);
  228 + $this->fail('编辑AMP站点证书失败');
  229 + }
  230 + return $this->success();
  231 + }
  232 +
  233 + /**
188 * @remark :保存证书相关配置 234 * @remark :保存证书相关配置
189 * @name :sslSave 235 * @name :sslSave
190 * @author :lyh 236 * @author :lyh
@@ -218,6 +264,22 @@ class DomainInfoLogic extends BaseLogic @@ -218,6 +264,22 @@ class DomainInfoLogic extends BaseLogic
218 } 264 }
219 } 265 }
220 266
  267 + //如果要开通amp站点,判断m域名是否已经解析
  268 + if(isset($this->param['amp_status']) && $this->param['amp_status'] == 1){
  269 + $domain_array = parse_url($info['domain']);
  270 + $host = $domain_array['host'] ?? $domain_array['path'];
  271 + $host_array = explode('.',$host);
  272 + if(count($host_array) <= 2){
  273 + array_unshift($host_array,'m');
  274 + }else{
  275 + $host_array[0] = 'm';
  276 + }
  277 + $amp_domain = implode('.',$host_array);
  278 + if(!$this->check_cname($amp_domain, $server_info)){
  279 + $this->fail('AMP站点域名' . $amp_domain . '未解析至目标服务器');
  280 + }
  281 + }
  282 +
221 //保存301跳转数据+其他域名 283 //保存301跳转数据+其他域名
222 $data = [ 284 $data = [
223 'other_domain'=>json_encode($this->param['other_domain'] ?? []), 285 'other_domain'=>json_encode($this->param['other_domain'] ?? []),
@@ -225,10 +287,20 @@ class DomainInfoLogic extends BaseLogic @@ -225,10 +287,20 @@ class DomainInfoLogic extends BaseLogic
225 'type'=>$this->param['type'], 287 'type'=>$this->param['type'],
226 'private_key' => $this->param['key'] ?? '', 288 'private_key' => $this->param['key'] ?? '',
227 'private_cert' => $this->param['cert'] ?? '', 289 'private_cert' => $this->param['cert'] ?? '',
  290 + 'amp_status' => $this->param['amp_status'] ?? 0,
  291 + 'amp_type' => $this->param['amp_type'] ?? 0,
  292 + 'amp_private_key' => $this->param['amp_key'] ?? '',
  293 + 'amp_private_cert' => $this->param['amp_cert'] ?? '',
228 ]; 294 ];
229 $this->model->edit($data,['id'=>$this->param['id']]); 295 $this->model->edit($data,['id'=>$this->param['id']]);
230 //生成证书 296 //生成证书
231 $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? []); 297 $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'] ?? [],$this->param['other_domain'] ?? []);
  298 +
  299 + //amp站点生成证书
  300 + if($data['amp_status']){
  301 + $this->setAmpDomainSsl($server_info['init_domain'],$info['domain']);
  302 + }
  303 +
232 return $this->success(); 304 return $this->success();
233 } 305 }
234 306
@@ -156,13 +156,14 @@ class ProjectLogic extends BaseLogic @@ -156,13 +156,14 @@ class ProjectLogic extends BaseLogic
156 $this->syncImageFile($this->param['project_location'],$this->param['id']); 156 $this->syncImageFile($this->param['project_location'],$this->param['id']);
157 //创建站点 157 //创建站点
158 // $this->createSite($this->param); 158 // $this->createSite($this->param);
  159 + (new SyncService())->projectAcceptAddress($this->param['id']);
159 } 160 }
160 DB::commit(); 161 DB::commit();
161 }catch (\Exception $e){ 162 }catch (\Exception $e){
162 DB::rollBack(); 163 DB::rollBack();
163 $this->fail('保存失败,请联系管理员'); 164 $this->fail('保存失败,请联系管理员');
164 } 165 }
165 - (new SyncService())->projectAcceptAddress($this->param['id']); 166 +
166 return $this->success(); 167 return $this->success();
167 } 168 }
168 169
@@ -373,7 +374,7 @@ class ProjectLogic extends BaseLogic @@ -373,7 +374,7 @@ class ProjectLogic extends BaseLogic
373 'company' => $param['company'], 374 'company' => $param['company'],
374 'lead_name' => $param['lead_name'], 375 'lead_name' => $param['lead_name'],
375 'mobile' => $param['mobile'], 376 'mobile' => $param['mobile'],
376 - 'qq' => $param['qq'], 377 + 'qq' => $param['qq'] ?? '',
377 'channel' => json_encode($param['channel']), 378 'channel' => json_encode($param['channel']),
378 'requirement' => $param['requirement'], 379 'requirement' => $param['requirement'],
379 'cooperate_date' => $param['cooperate_date'], 380 'cooperate_date' => $param['cooperate_date'],
@@ -70,8 +70,7 @@ class AyrReleaseLogic extends BaseLogic @@ -70,8 +70,7 @@ class AyrReleaseLogic extends BaseLogic
70 $arr[] = $v; 70 $arr[] = $v;
71 } 71 }
72 } 72 }
73 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($arr, true) . PHP_EOL, FILE_APPEND);  
74 - return $this->success($arr); 73 + return $this->success($arr);
75 } 74 }
76 75
77 } 76 }
@@ -331,7 +331,10 @@ class BTemplateLogic extends BaseLogic @@ -331,7 +331,10 @@ class BTemplateLogic extends BaseLogic
331 if($info === false){ 331 if($info === false){
332 $this->fail('当前扩展模块不存在或已被删除'); 332 $this->fail('当前扩展模块不存在或已被删除');
333 } 333 }
334 - if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ 334 + if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){
  335 + return $this->success($template_id);
  336 + }
  337 + if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){
335 return $this->success($template_id); 338 return $this->success($template_id);
336 } 339 }
337 }else{ 340 }else{
@@ -367,9 +370,6 @@ class BTemplateLogic extends BaseLogic @@ -367,9 +370,6 @@ class BTemplateLogic extends BaseLogic
367 'type'=>$type, 370 'type'=>$type,
368 'is_custom'=>0, 371 'is_custom'=>0,
369 ]; 372 ];
370 - if($this->user['project_id'] == 427){  
371 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($data, true) . PHP_EOL, FILE_APPEND);  
372 - }  
373 $commonTemplateModel = new BTemplateCommon(); 373 $commonTemplateModel = new BTemplateCommon();
374 $commonInfo = $commonTemplateModel->read($data); 374 $commonInfo = $commonTemplateModel->read($data);
375 if($commonInfo === false){ 375 if($commonInfo === false){
@@ -173,8 +173,12 @@ class BaseLogic extends Logic @@ -173,8 +173,12 @@ class BaseLogic extends Logic
173 $data['project_id'] = $this->user['project_id']; 173 $data['project_id'] = $this->user['project_id'];
174 $str = http_build_query($data); 174 $str = http_build_query($data);
175 $url = $this->user['domain'].'api/delHtml/?'.$str; 175 $url = $this->user['domain'].'api/delHtml/?'.$str;
176 -// shell_exec($url);  
177 - curlGet($url); 176 + $rs = shell_exec('curl -k "'.$url.'"');
  177 +// if($this->user['project_id'] == 177){
  178 +// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($url, true) . PHP_EOL, FILE_APPEND);
  179 +// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($rs, true) . PHP_EOL, FILE_APPEND);
  180 +// }
  181 +// curlGet($url);
178 return $this->success(); 182 return $this->success();
179 } 183 }
180 } 184 }
@@ -96,7 +96,11 @@ class CountLogic extends BaseLogic @@ -96,7 +96,11 @@ class CountLogic extends BaseLogic
96 ]; 96 ];
97 $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']); 97 $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']);
98 if($data === false){ 98 if($data === false){
99 - $data = []; 99 + $param['updated_date'] = Carbon::yesterday()->toDateString();
  100 + $data = $rankDataModel->read($param,['first_num','first_page_num','first_three_pages_num','first_five_pages_num','first_ten_pages_num']);
  101 + if($data === false){
  102 + $data = [];
  103 + }
100 } 104 }
101 return $this->success($data); 105 return $this->success($data);
102 } 106 }
@@ -42,16 +42,19 @@ class WebSettingServiceLogic extends BaseLogic @@ -42,16 +42,19 @@ class WebSettingServiceLogic extends BaseLogic
42 $this->param['data'] = Common::uniqueMultiArray($this->param['data']); 42 $this->param['data'] = Common::uniqueMultiArray($this->param['data']);
43 //删除以前的数据 43 //删除以前的数据
44 $this->model->del(['project_id'=>$this->user['project_id']]); 44 $this->model->del(['project_id'=>$this->user['project_id']]);
  45 + $data = [];
45 foreach ($this->param['data'] as $k => $v){ 46 foreach ($this->param['data'] as $k => $v){
46 - if(!isset($v['values']) || empty($v['values'])){  
47 - $v['values'] = ''; 47 + if(isset($v['values']) && empty($v['values'])){
  48 + $v['project_id'] = $this->user['project_id'];
  49 + $v['created_at'] = date('Y-m-d H:i:s');
  50 + $v['updated_at'] = date('Y-m-d H:i:s');
  51 + $data[] = $v;
48 } 52 }
49 - $v['project_id'] = $this->user['project_id'];  
50 - $v['created_at'] = date('Y-m-d H:i:s');  
51 - $v['updated_at'] = date('Y-m-d H:i:s');  
52 - $this->param['data'][$k] = $v;  
53 } 53 }
54 - $this->model->insert($this->param['data']); 54 + if(!empty($data)){
  55 + $this->model->insert($data);
  56 + }
  57 +
55 DB::commit(); 58 DB::commit();
56 }catch (\Exception $e){ 59 }catch (\Exception $e){
57 DB::rollBack(); 60 DB::rollBack();
@@ -386,4 +386,5 @@ class UserLoginLogic @@ -386,4 +386,5 @@ class UserLoginLogic
386 throw new AsideGlobalException($code, $message); 386 throw new AsideGlobalException($code, $message);
387 } 387 }
388 388
  389 +
389 } 390 }
@@ -57,9 +57,12 @@ class CopyProjectJob implements ShouldQueue @@ -57,9 +57,12 @@ class CopyProjectJob implements ShouldQueue
57 $data = $data->getAttributes(); 57 $data = $data->getAttributes();
58 $type = $data['type']; 58 $type = $data['type'];
59 $data['type'] = 0; 59 $data['type'] = 0;
  60 + $data['status'] = 0;
60 $data['title'] = $data['title'].'-copy'; 61 $data['title'] = $data['title'].'-copy';
61 unset($data['id']); 62 unset($data['id']);
62 $project_id = $projectModel->insertGetId($data); 63 $project_id = $projectModel->insertGetId($data);
  64 + $hashids = new Hashids($data['from_order_id'], 13, 'abcdefghjkmnpqrstuvwxyz1234567890');
  65 + $projectModel->edit(['from_order_id'=>$hashids->encode($project_id)],['id'=>$project_id]);
63 //复制部署表 66 //复制部署表
64 $buildModel = new DeployBuild(); 67 $buildModel = new DeployBuild();
65 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first(); 68 $buildData = $buildModel::where('project_id', $this->param['project_id'])->first();
@@ -55,6 +55,8 @@ class RouteMap extends Base @@ -55,6 +55,8 @@ class RouteMap extends Base
55 public static function generateRoute($title, $source, $source_id, $project_id){ 55 public static function generateRoute($title, $source, $source_id, $project_id){
56 if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){ 56 if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
57 $title = Translate::tran($title, 'en'); 57 $title = Translate::tran($title, 'en');
  58 + }elseif (preg_match('/[а-яА-Я]/u', $title)) {
  59 + $title = Translate::tran($title, 'en');
58 } 60 }
59 $i=1; 61 $i=1;
60 $sign = generateRoute($title); 62 $sign = generateRoute($title);
@@ -67,7 +67,6 @@ class AmazonS3Service @@ -67,7 +67,6 @@ class AmazonS3Service
67 public function syncImageFiles($files) 67 public function syncImageFiles($files)
68 { 68 {
69 $file_content = curl_c($files,false); 69 $file_content = curl_c($files,false);
70 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($file_content, true) . PHP_EOL, FILE_APPEND);  
71 $key = str_replace_url($files); 70 $key = str_replace_url($files);
72 try { 71 try {
73 $result = $this->s3->putObject([ 72 $result = $this->s3->putObject([
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/2/19
  6 + * Time: 15:46
  7 + */
  8 +namespace App\Services;
  9 +
  10 +class CreateHtmlService
  11 +{
  12 + public function __construct(){}
  13 +
  14 + /**
  15 + * 返回最终需要的HTML
  16 + * @return string
  17 + */
  18 + public function getHtml($project, $route, $lang = [], $page = 0)
  19 + {
  20 + // 获取页面信息
  21 + $page_info = $this->getInfoByRoute($route);
  22 +
  23 + // 根据项目和路由信息返回的结果确定当前页面使用5.0还是6.0的页面;
  24 + if ($project && $page_info) {
  25 + $html = $this->getHtmlV6($page_info['master_lang'], $lang = [], $page = 0);
  26 + } else {
  27 + $html = $this->getHtmlV5();
  28 + }
  29 + return $html;
  30 + }
  31 +
  32 + /**
  33 + * 返回5.0页面最终HTML
  34 + * @return string
  35 + */
  36 + public function getHtmlV5()
  37 + {
  38 + $html = '';
  39 + return $html;
  40 + }
  41 +
  42 + /**
  43 + * 返回6.0页面最终HTML
  44 + * @return mixed
  45 + */
  46 + public function getHtmlV6($master_lang, $lang = [], $page = 0)
  47 + {
  48 + // 初始化后续需要渲染页面需要的数据 路由、主语种、tdk、嵌入等信息
  49 +
  50 + $origin_html = $this->originHtml();
  51 + $html = $this->renderData($origin_html, $page);
  52 + $html = $this->plugHead($html);
  53 + $html = $this->processFinal($html);
  54 + /** ... 调用其他方法, 直至返回完整的正确的HTML */
  55 + return $html;
  56 + }
  57 +
  58 + /**
  59 + * 根据路由信息 返回 路由属性及详细信息
  60 + * @param string $route
  61 + * @return array
  62 + */
  63 + public function getInfoByRoute($route)
  64 + {
  65 + // TODO 获取详情需要通过路由查下路由信息, 以及数据信息, 要处理特殊几个路由: top-search、products、news、blog, 这几个如果存在就用查下的信息, 如果不存在要初始化信息
  66 + return [];
  67 + }
  68 +
  69 + /**
  70 + * 获取可视化HTML
  71 + * @return string
  72 + */
  73 + public function originHtml()
  74 + {
  75 + $html = '根据路由查询数据库,并拼装HTML';
  76 + return $html;
  77 + }
  78 +
  79 + /**
  80 + * 补充其他信息
  81 + * TDK mate信息等
  82 + * @param $html
  83 + * @return mixed
  84 + */
  85 + public function plugHead($html)
  86 + {
  87 + /** 渲染tdk信息、 mate信息、 嵌入信息、 图标信息*/
  88 + return $html;
  89 + }
  90 +
  91 + /**
  92 + * 处理最终信息
  93 + * 处理标签、最后代码标识、特殊规则或者字符等
  94 + * @param string $html
  95 + * @return string
  96 + */
  97 + public function processFinal($html)
  98 + {
  99 + return $html;
  100 + }
  101 +
  102 + /**
  103 + * 渲染页面数据
  104 + * @param string $html
  105 + * @return string
  106 + */
  107 + public function renderData($html, $page)
  108 + {
  109 + /**
  110 + * 根据可视化HTML中关键词渲染数据
  111 + * 这个方法还需要进行拆分, 这个功能内容应该会比较多
  112 + * 并且还会根据路由信息和分页信息不同, 渲染不同数据, 只要针对列表页面
  113 + */
  114 + return $html;
  115 + }
  116 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :GeneratePageService.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/2/19 15:54
  8 + */
  9 +
  10 +namespace App\Services;
  11 +
  12 +use App\Models\CustomModule\CustomModule;
  13 +use App\Models\CustomModule\CustomModuleCategory;
  14 +use App\Models\CustomModule\CustomModuleContent;
  15 +use App\Models\Project\Project;
  16 +use App\Models\RouteMap\RouteMap;
  17 +use App\Models\Template\BTemplate;
  18 +use App\Models\Template\BTemplateCommon;
  19 +use App\Models\Template\BTemplateMain;
  20 +use App\Models\Template\Setting;
  21 +use App\Models\Template\Template;
  22 +use App\Models\Template\TemplateTypeMain;
  23 +use Illuminate\Support\Facades\DB;
  24 +
  25 +class GeneratePageService
  26 +{
  27 + protected $route;
  28 +
  29 + protected $param;
  30 +
  31 + protected $project_id = 0;
  32 + public function __construct(){
  33 + $this->param = request()->all();
  34 + $this->route = $this->param['route'];
  35 + $this->project_id = $this->param['project_id'];
  36 + }
  37 +
  38 + /**
  39 + * @remark :生成单页数据
  40 + * @name :generateHtml
  41 + * @author :lyh
  42 + * @method :post
  43 + * @time :2024/2/19 16:57
  44 + */
  45 + public function generateHtml(){
  46 + ProjectServer::useProject($this->project_id);
  47 + $routeMapModel = new RouteMap();
  48 + $routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);
  49 + if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){
  50 + //页面管理单独处理
  51 + }else{
  52 + $this->handleParam($routeInfo);
  53 + $this->getTemplateHtml();
  54 + }
  55 + DB::disconnect('custom_mysql');
  56 + return true;
  57 + }
  58 +
  59 + /**
  60 + * @remark :生成页面参数处理
  61 + * @name :generateHtml
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2024/2/19 16:36
  65 + */
  66 + public function handleParam($routeInfo){
  67 + switch ($routeInfo['source']){
  68 + case RouteMap::SOURCE_PRODUCT:
  69 + $this->param['source'] = BTemplate::SOURCE_PRODUCT;
  70 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  71 + break;
  72 + case RouteMap::SOURCE_PRODUCT_CATE:
  73 + $this->param['source'] = BTemplate::SOURCE_PRODUCT;
  74 + $this->param['is_list'] = BTemplate::IS_LIST;
  75 + break;
  76 + case RouteMap::SOURCE_BLOG:
  77 + $this->param['source'] = BTemplate::SOURCE_BLOG;
  78 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  79 + break;
  80 + case RouteMap::SOURCE_BLOG_CATE:
  81 + $this->param['source'] = BTemplate::SOURCE_BLOG;
  82 + $this->param['is_list'] = BTemplate::IS_LIST;
  83 + break;
  84 + case RouteMap::SOURCE_NEWS:
  85 + $this->param['source'] = BTemplate::SOURCE_NEWS;
  86 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  87 + break;
  88 + case RouteMap::SOURCE_NEWS_CATE:
  89 + $this->param['source'] = BTemplate::SOURCE_NEWS;
  90 + $this->param['is_list'] = BTemplate::IS_LIST;
  91 + break;
  92 + case RouteMap::SOURCE_MODULE:
  93 + $this->param['is_custom'] = BTemplate::IS_CUSTOM;
  94 + //TODO::获取对应模块数据
  95 + $moduleModel = new CustomModuleContent();
  96 + $moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
  97 + $this->param['source'] = $moduleInfo['id'] ?? 0;
  98 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  99 + break;
  100 + case RouteMap::SOURCE_MODULE_CATE:
  101 + $this->param['is_custom'] = BTemplate::IS_CUSTOM;
  102 + //TODO::获取对应模块数据
  103 + $moduleModel = new CustomModuleCategory();
  104 + $moduleInfo = $moduleModel->read(['id'=>$routeInfo['source_id']],['module_id']);
  105 + $this->param['source'] = $moduleInfo['id'] ?? 0;
  106 + $this->param['is_list'] = BTemplate::IS_LIST;
  107 + break;
  108 + default:
  109 + $this->param['source'] = BTemplate::SOURCE_HOME;
  110 + $this->param['is_list'] = BTemplate::IS_DETAIL;
  111 + break;
  112 + return true;
  113 + }
  114 + }
  115 +
  116 + /**
  117 + * @notes: 请简要描述方法功能
  118 + * @param array $data
  119 + * @return array
  120 + */
  121 + public function success($data = [])
  122 + {
  123 + return $data;
  124 + }
  125 +
  126 + /**
  127 + * @remark :获取html
  128 + * @name :getTemplateHtml
  129 + * @author :lyh
  130 + * @method :post
  131 + */
  132 + public function getTemplateHtml(){
  133 + $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
  134 + $is_list = $this->param['is_list'] ?? 0;//是否为列表页
  135 + $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
  136 + $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
  137 + if($templateInfo === false){
  138 + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
  139 + $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
  140 + if($html !== false){
  141 + return $this->success($html);
  142 + }
  143 + }
  144 + //非定制初始中间部分
  145 + $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
  146 + }else{
  147 + if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
  148 + return $this->getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list);
  149 + }
  150 + $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
  151 + }
  152 + $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
  153 + $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
  154 + $html = $this->getHeadFooter($html);
  155 + $result = ['html'=>$html,'template_id'=>$template_id];
  156 + return $this->success($result);
  157 + }
  158 +
  159 + /**
  160 + * @remark :获取整个html代码
  161 + * @name :getCustomizeAllHtml
  162 + * @author :lyh
  163 + * @method :post
  164 + * @time :2024/1/10 14:15
  165 + */
  166 + public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
  167 + if($is_custom == BTemplate::IS_CUSTOM){
  168 + $commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
  169 + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
  170 + }else{
  171 + $type = $this->getCustomizedType($this->param['source'],$is_list);
  172 + $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
  173 + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
  174 + }
  175 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  176 + }
  177 +
  178 + /**
  179 + * @remark :获取装修详情
  180 + * @name :webTemplateInfo
  181 + * @author :lyh
  182 + * @method :post
  183 + * @time :2024/1/10 13:43
  184 + */
  185 + public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
  186 + $templateInfo = $this->model->read([
  187 + 'template_id'=>$template_id, 'source'=>$source,
  188 + 'project_id'=>$this->user['project_id'], 'source_id'=>$source_id,
  189 + 'is_custom'=>$is_custom, 'is_list'=>$is_list
  190 + ]);
  191 + return $this->success($templateInfo);
  192 + }
  193 +
  194 + /**
  195 + * @remark :定制页面获取html
  196 + * @name :customizedReturnHtml
  197 + * @author :lyh
  198 + * @method :post
  199 + * @time :2024/1/10 13:46
  200 + */
  201 + public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){
  202 + //TODO::扩展模块定制单独处理
  203 + if($is_custom == BTemplate::IS_CUSTOM){
  204 + $customModuleModel = new CustomModule();
  205 + $info = $customModuleModel->read(['id'=>$source]);
  206 + if($info === false){
  207 + $this->fail('当前扩展模块不存在或已被删除');
  208 + }
  209 + //扩展模块定制
  210 + if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
  211 + $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
  212 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  213 + }
  214 + if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
  215 + $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
  216 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  217 + }
  218 + return false;
  219 + }
  220 + //TODO::默认模块定制
  221 + $html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html
  222 + if(!empty($html)){
  223 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  224 + }
  225 + return false;
  226 + }
  227 +
  228 + /**
  229 + * @remark :扩展模块定制html
  230 + * @name :customModuleInfo
  231 + * @author :lyh
  232 + * @method :post
  233 + * @time :2024/1/10 9:20
  234 + */
  235 + public function customModuleCustomizeHtml($source,$is_list,$is_custom){
  236 + $bTemplateMainModel = new BTemplateMain();
  237 + //TODO::获取初始代码
  238 + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
  239 + if($customHtmlInfo === false){
  240 + $this->fail('定制页面,请先上传代码块');
  241 + }
  242 + $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
  243 + if($commonInfo !== false){
  244 + $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
  245 + }
  246 + return $customHtmlInfo['main_html'];
  247 + }
  248 +
  249 + /**
  250 + * @remark :获取中间部分的html
  251 + * @name :getMAinHtml
  252 + * @author :lyh
  253 + * @method :post
  254 + * @time :2023/12/27 15:00
  255 + */
  256 + public function getMAinHtml($type,$is_custom,$is_list){
  257 + //获取设置的默认中间部分
  258 + $bTemplateMainModel = new BTemplateMain();
  259 + $mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]);
  260 + if($mainInfo === false){
  261 + $main_html = $this->getInitModule($type,$is_custom,$is_list);
  262 + $main_css = "<style id='globalsojs-styles'></style>";
  263 + }else{
  264 + $main_html = $mainInfo['main_html'];
  265 + $main_css = $mainInfo['main_css'];
  266 + }
  267 + return ['main_html'=>$main_html,'main_css'=>$main_css];
  268 + }
  269 +
  270 + /**
  271 + * @remark :默认复合页数据
  272 + * @name :getProductModule
  273 + * @author :lyh
  274 + * @method :post
  275 + * @time :2023/7/27 15:08
  276 + */
  277 + public function getInitModule($type,$is_custom,$is_list){
  278 + if($is_custom == BTemplate::IS_CUSTOM) {
  279 + $type = BTemplate::SOURCE_CUSTOM;
  280 + }
  281 + $mainModel = new TemplateTypeMain();
  282 + $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
  283 + return $info['main_html'];
  284 + }
  285 +
  286 + /**
  287 + * @remark :返回整个html截取代码
  288 + * @name :handleAllHtml
  289 + * @author :lyh
  290 + * @method :post
  291 + * @time :2023/12/13 15:39
  292 + */
  293 + public function handleAllHtml($commonInfo,$html){
  294 + if(!empty($commonInfo)){
  295 + $html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
  296 + $html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
  297 + $html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
  298 + $html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
  299 + }
  300 + return $html;
  301 + }
  302 +
  303 + /**
  304 + * @remark :页面是否为定制页面获取初始代码
  305 + * @name :watchProjectIsCustomized
  306 + * @author :lyh
  307 + * @method :post
  308 + * @time :2023/12/13 10:55
  309 + */
  310 + public function isCustomizedPage($source,$is_list,$is_custom)
  311 + {
  312 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
  313 + //查看当前页面是否定制,是否开启可视化
  314 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  315 + if (in_array($type, $page_array)) {//是定制界面
  316 + //TODO::获取初始代码
  317 + $bTemplateMainModel = new BTemplateMain();
  318 + $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
  319 + if($customHtmlInfo === false){
  320 + $this->fail('定制页面,请先上传代码块');
  321 + }
  322 + $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
  323 + if($commonInfo !== false){
  324 + $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
  325 + }
  326 + return $customHtmlInfo['main_html'];
  327 + }
  328 + return false;
  329 + }
  330 +
  331 + /**
  332 + * @remark :定制项目获取头部底部
  333 + * @name :getCustomizedCommonHtml
  334 + * @author :lyh
  335 + * @method :post
  336 + * @time :2023/12/29 13:13
  337 + */
  338 + public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
  339 + $data = [
  340 + 'template_id' => 0,
  341 + 'project_id' => $this->user['project_id'],
  342 + 'type'=>$type,
  343 + 'is_custom'=>$is_custom,
  344 + 'is_list'=>$is_list
  345 + ];
  346 + $commonTemplateModel = new BTemplateCommon();
  347 + return $commonTemplateModel->read($data);
  348 + }
  349 +
  350 + /**
  351 + * @remark :定制页面头部类型---根据source获取type类型
  352 + * @name :getType
  353 + * @author :lyh
  354 + * @method :post
  355 + * @time :2023/11/16 11:20
  356 + */
  357 + public function getCustomizedType($source,$is_list){
  358 + $type = BTemplate::TYPE_HOME;
  359 + if($source == BTemplate::SOURCE_PRODUCT){
  360 + if($is_list == BTemplate::IS_LIST){
  361 + $type = BTemplate::TYPE_PRODUCT_LIST;
  362 + }else{
  363 + $type = BTemplate::TYPE_PRODUCT_DETAIL;
  364 + }
  365 + }
  366 + if($source == BTemplate::SOURCE_BLOG){
  367 + if($is_list == BTemplate::IS_LIST){
  368 + $type = BTemplate::TYPE_BLOG_LIST;
  369 + }else{
  370 + $type = BTemplate::TYPE_BLOG_DETAIL;
  371 + }
  372 + }
  373 + if($source == BTemplate::SOURCE_NEWS){
  374 + if($is_list == BTemplate::IS_LIST){
  375 + $type = BTemplate::TYPE_NEWS_LIST;
  376 + }else{
  377 + $type = BTemplate::TYPE_NEWS_DETAIL;
  378 + }
  379 + }
  380 + return $type;
  381 + }
  382 +
  383 + /**
  384 + * @remark :获取当前项目设置的模版
  385 + * @name :getSettingTemplate
  386 + * @author :lyh
  387 + * @method :post
  388 + * @time :2023/12/13 10:48
  389 + */
  390 + public function getSettingTemplate($source,$is_list,$is_custom){
  391 + $template_id = 0;
  392 + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
  393 + if($is_custom == BTemplate::IS_CUSTOM){
  394 + $customModuleModel = new CustomModule();
  395 + $info = $customModuleModel->read(['id'=>$source]);
  396 + if($info === false){
  397 + return false;
  398 + }
  399 + if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){
  400 + return $this->success($template_id);
  401 + }
  402 + if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){
  403 + return $this->success($template_id);
  404 + }
  405 + }else{
  406 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
  407 + //查看当前页面是否定制,是否开启可视化
  408 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  409 + if (in_array($type, $page_array)) {//是定制界面
  410 + return $this->success($template_id);
  411 + }
  412 + }
  413 + }
  414 + $bSettingModel = new Setting();
  415 + $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
  416 + if($info === false){
  417 + $this->fail('请先选择模版');
  418 + }
  419 + $template_id = $info['template_id'];
  420 + return $this->success($template_id);
  421 + }
  422 +
  423 + /**
  424 + * @remark :根据类型获取公共头和底
  425 + * @name :getCommonPage
  426 + * @author :lyh
  427 + * @method :post
  428 + * @time :2023/10/21 16:55
  429 + */
  430 + public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
  431 + $type = $this->getType($source,$is_list,$is_custom);
  432 + $data = [
  433 + 'template_id' => $template_id,
  434 + 'project_id' => $this->user['project_id'],
  435 + 'type'=>$type,
  436 + 'is_custom'=>0,
  437 + ];
  438 + $commonTemplateModel = new BTemplateCommon();
  439 + $commonInfo = $commonTemplateModel->read($data);
  440 + if($commonInfo === false){
  441 + $data['type'] = BTemplate::SOURCE_HOME;
  442 + $commonInfo = $commonTemplateModel->read($data);
  443 + }
  444 + return $this->success($commonInfo);
  445 + }
  446 +
  447 +}
@@ -380,6 +380,7 @@ Route::group([], function () { @@ -380,6 +380,7 @@ Route::group([], function () {
380 Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect'); 380 Route::any('/collect', [Aside\Collect\CollectController::class, 'index'])->name('admin.collect');
381 //同步询盘 381 //同步询盘
382 Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry'); 382 Route::any('/sync_inquiry', [Aside\Com\IndexController::class, 'sync_inquiry'])->name('admin.sync_inquiry');
  383 + Route::any('/getKeywordImage', [Aside\Com\IndexController::class, 'getKeywordImage'])->name('admin.getKeywordImage');
383 }); 384 });
384 385
385 386
@@ -19,6 +19,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -19,6 +19,7 @@ Route::middleware(['bloginauth'])->group(function () {
19 Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project'); 19 Route::any('/get_project', [\App\Http\Controllers\Bside\BCom\ComController::class, 'get_project'])->name('get_project');
20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken'); 20 Route::any('/generateToken', [\App\Http\Controllers\Bside\BCom\ComController::class, 'generateToken'])->name('generateToken');
21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink'); 21 Route::any('/getLink', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getLink'])->name('getLink');
  22 + Route::any('/getMobileProject', [\App\Http\Controllers\Bside\BCom\ComController::class, 'getMobileProject'])->name('getMobileProject');
22 //用户相关路由 23 //用户相关路由
23 Route::prefix('user')->group(function () { 24 Route::prefix('user')->group(function () {
24 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists'); 25 Route::any('/', [\App\Http\Controllers\Bside\User\UserController::class, 'lists'])->name('user_lists');
@@ -495,6 +496,12 @@ Route::middleware(['bloginauth'])->group(function () { @@ -495,6 +496,12 @@ Route::middleware(['bloginauth'])->group(function () {
495 Route::any('/save', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'save'])->name('rating_save'); 496 Route::any('/save', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'save'])->name('rating_save');
496 Route::any('/code', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'verificationCode'])->name('rating_code'); 497 Route::any('/code', [\App\Http\Controllers\Bside\Scoring\RatingController::class, 'verificationCode'])->name('rating_code');
497 }); 498 });
  499 +
  500 + //月报表
  501 + Route::prefix('month_report')->group(function () {
  502 + Route::any('/month', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'getMonth'])->name('month_report_getMonth');
  503 + Route::any('/read', [\App\Http\Controllers\Bside\BCom\MonthReportController::class, 'monthReportInfo'])->name('month_report_read');
  504 + });
498 }); 505 });
499 //无需登录验证的路由组 506 //无需登录验证的路由组
500 Route::group([], function () { 507 Route::group([], function () {