作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -149,6 +149,7 @@ class CountProject extends Command @@ -149,6 +149,7 @@ class CountProject extends Command
149 if($inquiry_list == false){ 149 if($inquiry_list == false){
150 return false; 150 return false;
151 } 151 }
  152 + echo date('Y-m-d H:i:s') . '拉取询盘状态:' .json_encode($inquiry_list) . PHP_EOL;
152 if($inquiry_list['status'] == self::STATUS_ERROR){ 153 if($inquiry_list['status'] == self::STATUS_ERROR){
153 $arr['inquiry_num'] = 0; 154 $arr['inquiry_num'] = 0;
154 $countryArr = []; 155 $countryArr = [];
@@ -35,6 +35,7 @@ use App\Models\Template\BTemplateCom; @@ -35,6 +35,7 @@ use App\Models\Template\BTemplateCom;
35 use App\Services\AmazonS3Service; 35 use App\Services\AmazonS3Service;
36 use App\Services\ProjectServer; 36 use App\Services\ProjectServer;
37 use App\Utils\EncryptUtils; 37 use App\Utils\EncryptUtils;
  38 +use GuzzleHttp\Exception\GuzzleException;
38 use Illuminate\Console\Command; 39 use Illuminate\Console\Command;
39 use Illuminate\Support\Facades\DB; 40 use Illuminate\Support\Facades\DB;
40 use Illuminate\Support\Facades\Schema; 41 use Illuminate\Support\Facades\Schema;
@@ -56,6 +57,20 @@ class Demo extends Command @@ -56,6 +57,20 @@ class Demo extends Command
56 */ 57 */
57 protected $description = 'demo'; 58 protected $description = 'demo';
58 59
  60 + public function handle(){
  61 + $domain = "https://www.xawellauto.com/";
  62 + $token = md5($domain.date("Y-m-d"));
  63 + $url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
  64 + try {
  65 + $res = http_get($url,['charset=utf-8']);
  66 + } catch (\Exception | GuzzleException $e) {
  67 + errorLog('提交询盘信息失败', $domain, $e);
  68 + return false;
  69 + }
  70 + echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
  71 + return true;
  72 + }
  73 +
59 // public function handle(){ 74 // public function handle(){
60 // $projectModel = new Project(); 75 // $projectModel = new Project();
61 // $list = $projectModel->list(['id'=>503]); 76 // $list = $projectModel->list(['id'=>503]);
@@ -89,26 +104,26 @@ class Demo extends Command @@ -89,26 +104,26 @@ class Demo extends Command
89 // DB::disconnect('custom_mysql'); 104 // DB::disconnect('custom_mysql');
90 // } 105 // }
91 // } 106 // }
92 - public function handle(){  
93 - ProjectServer::useProject(503);  
94 - $newsCate = new NewsCategory();  
95 - $newsList = $newsCate->list();  
96 - foreach ($newsList as $v){  
97 - $data = [  
98 - 'name'=>$v['name'],  
99 - 'status'=>0,  
100 - 'sort'=>$v['sort'],  
101 - 'pid'=>$v['pid'],  
102 - 'route'=>$v['alias'],  
103 - 'project_id'=>503,  
104 - 'operator_id'=>$v['operator_id'],  
105 - 'create_id'=>1101,  
106 - 'module_id'=>10,  
107 - ];  
108 - $moduleCateModel = new CustomModuleCategory();  
109 - $id = $moduleCateModel->addReturnId($data);  
110 - RouteMap::setRoute($v['alias'],RouteMap::SOURCE_MODULE_CATE,$id,503);  
111 - }  
112 - DB::disconnect('custom_mysql');  
113 - } 107 +// public function handle(){
  108 +// ProjectServer::useProject(503);
  109 +// $newsCate = new NewsCategory();
  110 +// $newsList = $newsCate->list();
  111 +// foreach ($newsList as $v){
  112 +// $data = [
  113 +// 'name'=>$v['name'],
  114 +// 'status'=>0,
  115 +// 'sort'=>$v['sort'],
  116 +// 'pid'=>$v['pid'],
  117 +// 'route'=>$v['alias'],
  118 +// 'project_id'=>503,
  119 +// 'operator_id'=>$v['operator_id'],
  120 +// 'create_id'=>1101,
  121 +// 'module_id'=>10,
  122 +// ];
  123 +// $moduleCateModel = new CustomModuleCategory();
  124 +// $id = $moduleCateModel->addReturnId($data);
  125 +// RouteMap::setRoute($v['alias'],RouteMap::SOURCE_MODULE_CATE,$id,503);
  126 +// }
  127 +// DB::disconnect('custom_mysql');
  128 +// }
114 } 129 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :SyncTimeFiles.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/14 14:23
  8 + */
  9 +
  10 +namespace App\Console\Commands\Test;
  11 +
  12 +use App\Models\File\ErrorFile;
  13 +use App\Models\File\File;
  14 +use Illuminate\Console\Command;
  15 +
  16 +class SyncTimeFiles extends Command
  17 +{
  18 + /**
  19 + * The name and signature of the console command.
  20 + *
  21 + * @var string
  22 + */
  23 + protected $signature = 'sync_videos';
  24 +
  25 + /**
  26 + * The console command description.
  27 + *
  28 + * @var string
  29 + */
  30 + protected $description = '按时间同步图片与文件';
  31 +
  32 + public function handle()
  33 + {
  34 + $fileModel = new File();
  35 + $start = '2024-08-10 00:00:00';
  36 + $end = date('Y-m-d H:i:s');
  37 + $lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
  38 + foreach ($lists as $v){
  39 + $path = $v['path'];
  40 + $this->param['name'] = basename($path);
  41 + $this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
  42 + $file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
  43 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
  44 + echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
  45 + $code = shell_exec($cmd);
  46 + if(200 != (int)$code){
  47 + echo date('Y-m-d H:i:s') . ' | 错误状态:' . $code . PHP_EOL;
  48 +// $errorFileModel = new ErrorFile();
  49 +// $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
  50 + }
  51 + echo date('Y-m-d H:i:s') . ' | ok:' . $code . PHP_EOL;
  52 + }
  53 + return true;
  54 + }
  55 +
  56 + /**
  57 + * @remark :获取图片文件链接
  58 + * @name :getUrl
  59 + * @author :lyh
  60 + * @method :post
  61 + * @time :2024/5/22 11:53
  62 + */
  63 + public function getUrl($path,$storage_type,$location){
  64 + if(is_array($path)){
  65 + $url =[];
  66 + foreach ($path as $v){
  67 + $url[] = $this->getUrl($v,$storage_type,$location);
  68 + }
  69 + }else{
  70 + if(empty($path)){
  71 + return '';
  72 + }
  73 + if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
  74 + return $path;
  75 + }
  76 + if(substr($path,0,2) == '//'){
  77 + return 'https:'.$path;
  78 + }
  79 + if($location == 0){
  80 + $cos = config('filesystems.disks.cos');
  81 + $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
  82 + $url = $cosCdn.$path;
  83 + }else{
  84 + $s3 = config('filesystems.disks.s3');
  85 + $cdn = $s3['cdn'];
  86 + $url = $cdn.$path;
  87 + }
  88 + }
  89 + return $url;
  90 + }
  91 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :SyncVideo.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/14 13:50
  8 + */
  9 +
  10 +namespace App\Console\Commands\Test;
  11 +
  12 +use App\Models\File\ErrorFile;
  13 +use Illuminate\Console\Command;
  14 +
  15 +class SyncVideo extends Command
  16 +{
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'sync_video {path}';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '同步图片与文件';
  30 + public function handle()
  31 + {
  32 + $path = $this->argument('path');
  33 + $this->param['name'] = basename($path);
  34 + $this->param['path'] = str_replace('/'.$this->param['name'],'',$path);
  35 + $file_path = $this->getUrl($this->param['path'].'/'.$this->param['name'], 0,0);
  36 + $cmd = 'curl -F "file_path='.$file_path.'" -F "save_path=/www/wwwroot/cos'.$this->param['path'].'" https://v6-file.globalso.com/upload.php';
  37 + echo date('Y-m-d H:i:s') . ' | ' . $cmd . PHP_EOL;
  38 + $code = shell_exec($cmd);
  39 + if(200 != (int)$code){
  40 + $errorFileModel = new ErrorFile();
  41 + $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
  42 + }
  43 + return true;
  44 + }
  45 +
  46 + /**
  47 + * @remark :获取图片文件链接
  48 + * @name :getUrl
  49 + * @author :lyh
  50 + * @method :post
  51 + * @time :2024/5/22 11:53
  52 + */
  53 + public function getUrl($path,$storage_type,$location){
  54 + if(is_array($path)){
  55 + $url =[];
  56 + foreach ($path as $v){
  57 + $url[] = $this->getUrl($v,$storage_type,$location);
  58 + }
  59 + }else{
  60 + if(empty($path)){
  61 + return '';
  62 + }
  63 + if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
  64 + return $path;
  65 + }
  66 + if(substr($path,0,2) == '//'){
  67 + return 'https:'.$path;
  68 + }
  69 + if($location == 0){
  70 + $cos = config('filesystems.disks.cos');
  71 + $cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
  72 + $url = $cosCdn.$path;
  73 + }else{
  74 + $s3 = config('filesystems.disks.s3');
  75 + $cdn = $s3['cdn'];
  76 + $url = $cdn.$path;
  77 + }
  78 + }
  79 + return $url;
  80 + }
  81 +}
@@ -15,6 +15,7 @@ class Kernel extends ConsoleKernel @@ -15,6 +15,7 @@ class Kernel extends ConsoleKernel
15 */ 15 */
16 protected function schedule(Schedule $schedule) 16 protected function schedule(Schedule $schedule)
17 { 17 {
  18 + $schedule->command('sync_file')->everyThirtyMinutes()->withoutOverlapping(1);//每半小时执行同步
18 // 每日更新最新模块 19 // 每日更新最新模块
19 $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块 20 $schedule->command('template_label')->dailyAt('01:00')->withoutOverlapping(1);//最新模块
20 $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块 21 $schedule->command('popular_template_label')->dailyAt('01:30')->withoutOverlapping(1);//热门模块
@@ -32,8 +32,22 @@ class LogFormatterFactory @@ -32,8 +32,22 @@ class LogFormatterFactory
32 $path = date('Y-m', $time) . '/' . date('d', $time) . '_' . $suffix . '.log'; 32 $path = date('Y-m', $time) . '/' . date('d', $time) . '_' . $suffix . '.log';
33 $path = 'logs/' . $config['prefix'] . '/' . $path; 33 $path = 'logs/' . $config['prefix'] . '/' . $path;
34 $path = storage_path($path); 34 $path = storage_path($path);
  35 +
  36 + try {
  37 + if (!file_exists($path)) {
  38 + $directory = pathinfo($path, PATHINFO_DIRNAME);
  39 + if(!file_exists($directory)){
  40 + mkdir($directory, 0644, true);
  41 + chown($directory, 'www');
  42 + }
  43 + touch($path);
  44 + chown($path, 'www');
  45 + }
  46 + }catch (\Throwable $exception){}
  47 +
35 $handler = new StreamHandler($path, $level, false); 48 $handler = new StreamHandler($path, $level, false);
36 $handler->setFormatter(new LineFormatter(null, 'Y-m-d H:i:s', false, true)); 49 $handler->setFormatter(new LineFormatter(null, 'Y-m-d H:i:s', false, true));
  50 +
37 return $handler; 51 return $handler;
38 } 52 }
39 53
@@ -70,7 +70,7 @@ class FormGlobalsoApi @@ -70,7 +70,7 @@ class FormGlobalsoApi
70 $res = HttpUtils::get($api_url, $params); 70 $res = HttpUtils::get($api_url, $params);
71 $res = Arr::s2a($res); 71 $res = Arr::s2a($res);
72 } catch (\Exception | GuzzleException $e) { 72 } catch (\Exception | GuzzleException $e) {
73 - errorLog('询盘列表', $params, $e); 73 + errorLog('询盘列表'.$api_url, $params, $e);
74 return false; 74 return false;
75 } 75 }
76 return $res; 76 return $res;
@@ -155,5 +155,24 @@ class FormGlobalsoApi @@ -155,5 +155,24 @@ class FormGlobalsoApi
155 return $res; 155 return $res;
156 } 156 }
157 157
158 - 158 + /**
  159 + * @remark :获取当前项目所有询盘及询盘国家
  160 + * @name :getInquiryAll
  161 + * @author :lyh
  162 + * @method :post
  163 + * @time :2024/8/15 14:16
  164 + */
  165 + public function getInquiryAll($domain){
  166 + $domain = 'https://'.$domain.'/';
  167 + $token = md5($domain.date("Y-m-d"));
  168 + $url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
  169 + try {
  170 + $res = http_get($url,['charset=utf-8']);
  171 + } catch (\Exception | GuzzleException $e) {
  172 + errorLog('提交询盘信息失败', $domain, $e);
  173 + return false;
  174 + }
  175 + echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
  176 + return $res;
  177 + }
159 } 178 }
@@ -88,9 +88,7 @@ class AyrReleaseController extends BaseController @@ -88,9 +88,7 @@ class AyrReleaseController extends BaseController
88 } 88 }
89 //发送请求发布社交文章 89 //发送请求发布社交文章
90 $res = $ayrShare->post_send_msg($param,$share_info['profile_key']); 90 $res = $ayrShare->post_send_msg($param,$share_info['profile_key']);
91 - if($res){  
92 - $ayrReleaseLogic->release_add($res);  
93 - } 91 + $res = $ayrReleaseLogic->release_add($res);
94 //保存返回的内容 92 //保存返回的内容
95 $this->response('success',Code::SUCCESS,json_decode($res)); 93 $this->response('success',Code::SUCCESS,json_decode($res));
96 } 94 }
@@ -346,22 +346,42 @@ class ProductController extends BaseController @@ -346,22 +346,42 @@ class ProductController extends BaseController
346 return []; 346 return [];
347 } 347 }
348 $extendInfoModel = new ExtendInfo(); 348 $extendInfoModel = new ExtendInfo();
  349 + $infoList = $extendInfoModel->list(['product_id'=>$product_id],'created_at');
349 foreach ($list as $k=>$v){ 350 foreach ($list as $k=>$v){
350 - $info = $extendInfoModel->read(['key'=>$v['key'],'product_id'=>$product_id]);  
351 - if($info == false){ 351 + foreach ($infoList as $values){
  352 + if($v['key'] == $values['key']){
  353 + $v = $this->setTypValues($v,$values);
  354 + break;
  355 + }
  356 + }
  357 + $list[$k] = $v;
  358 + }
  359 + $list = $this->handleExtentList($list);
  360 + return $list;
  361 + }
  362 +
  363 + /**
  364 + * @remark :处理详情数据(初始化)
  365 + * @name :handleList
  366 + * @author :lyh
  367 + * @method :post
  368 + * @time :2024/8/14 18:26
  369 + */
  370 + public function handleExtentList($list){
  371 + foreach ($list as $k => $v){
352 if($v['type'] == 3 || $v['type'] == 4){ 372 if($v['type'] == 3 || $v['type'] == 4){
  373 + if(!isset($v['values'])){
353 $v['values'] = []; 374 $v['values'] = [];
  375 + }
354 }else{ 376 }else{
  377 + if(!isset($v['values'])){
355 $v['values'] = ''; 378 $v['values'] = '';
356 } 379 }
357 - }else{  
358 - $v = $this->setTypValues($v,$info);  
359 } 380 }
360 $list[$k] = $v; 381 $list[$k] = $v;
361 } 382 }
362 - return $list; 383 + return $this->success($list);
363 } 384 }
364 -  
365 /** 385 /**
366 * @remark :扩展字段根据type返回类型 386 * @remark :扩展字段根据type返回类型
367 * @name :setTypValues 387 * @name :setTypValues
@@ -50,11 +50,12 @@ class AyrReleaseLogic extends BaseLogic @@ -50,11 +50,12 @@ class AyrReleaseLogic extends BaseLogic
50 $this->model->add($this->param); 50 $this->model->add($this->param);
51 }else{ 51 }else{
52 $result_data = json_decode($this->param['result_data']); 52 $result_data = json_decode($this->param['result_data']);
53 - if(isset($result_data['status']) && $result_data['status'] == 'success'){ 53 + if(isset($result_data->status) && $result_data->status == 'success'){
54 $this->model->edit($this->param,['id'=>$info['id']]); 54 $this->model->edit($this->param,['id'=>$info['id']]);
  55 + return $this->param['result_data'];
55 } 56 }
56 } 57 }
57 - return $this->success(); 58 + return $this->param['result_data'];
58 } 59 }
59 /** 60 /**
60 * @name :(上传第三方图片参数处理)get_param 61 * @name :(上传第三方图片参数处理)get_param
@@ -261,6 +261,8 @@ class TranslateLogic extends BaseLogic @@ -261,6 +261,8 @@ class TranslateLogic extends BaseLogic
261 foreach ($this->param['data'] as $k => $v){ 261 foreach ($this->param['data'] as $k => $v){
262 if(!empty($v) && is_array($v)){ 262 if(!empty($v) && is_array($v)){
263 foreach ($v as $text => $translate){ 263 foreach ($v as $text => $translate){
  264 + $text = str_replace(['%22', '%', '+'], ['"', '%', '+'], $text);
  265 + $translate = str_replace(['%22', '%', '+'], ['"', '%', '+'], $translate);
264 $data[$text] = $translate; 266 $data[$text] = $translate;
265 } 267 }
266 } 268 }
@@ -109,6 +109,7 @@ class InquiryFormData extends Base @@ -109,6 +109,7 @@ class InquiryFormData extends Base
109 */ 109 */
110 public static function getCount($submit_at = []){ 110 public static function getCount($submit_at = []){
111 return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id') 111 return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
  112 + ->where('gl_inquiry_form.is_default', 0)
112 ->when($submit_at, function ($query, $submit_at) { 113 ->when($submit_at, function ($query, $submit_at) {
113 $query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]); 114 $query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
114 }) 115 })
@@ -122,6 +123,7 @@ class InquiryFormData extends Base @@ -122,6 +123,7 @@ class InquiryFormData extends Base
122 */ 123 */
123 public static function getCountryCount($submit_at = []){ 124 public static function getCountryCount($submit_at = []){
124 return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id') 125 return self::leftjoin('gl_inquiry_form', 'gl_inquiry_form.id', '=', 'gl_inquiry_form_data.form_id')
  126 + ->where('gl_inquiry_form.is_default', 0)
125 ->when($submit_at, function ($query, $submit_at) { 127 ->when($submit_at, function ($query, $submit_at) {
126 $query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]); 128 $query->whereBetween('submit_at',[$submit_at[0], $submit_at[1]]);
127 }) 129 })