作者 赵彬吉
@@ -11,6 +11,7 @@ namespace App\Console\Commands\Geo; @@ -11,6 +11,7 @@ namespace App\Console\Commands\Geo;
11 11
12 use App\Models\Geo\GeoQuestionLog; 12 use App\Models\Geo\GeoQuestionLog;
13 use App\Models\Geo\GeoQuestionResult; 13 use App\Models\Geo\GeoQuestionResult;
  14 +use App\Models\Project\Project;
14 use Illuminate\Console\Command; 15 use Illuminate\Console\Command;
15 use Illuminate\Support\Carbon; 16 use Illuminate\Support\Carbon;
16 use App\Models\Geo\GeoCount as GeoCountModel; 17 use App\Models\Geo\GeoCount as GeoCountModel;
@@ -61,18 +62,26 @@ class GeoCount extends Command @@ -61,18 +62,26 @@ class GeoCount extends Command
61 if(empty($project_id)){ 62 if(empty($project_id)){
62 return true; 63 return true;
63 } 64 }
  65 + $projectModel = new Project();
  66 + $geo_qualify_day = $projectModel->getValue(['id'=>$project_id],['geo_qualify_day']);
64 $geoQuestionResModel = new GeoQuestionResult(); 67 $geoQuestionResModel = new GeoQuestionResult();
65 $platforms = ['gemini','openai','deepseek','poe','perplexity','google_ai_overview','openai-not-network','claude']; 68 $platforms = ['gemini','openai','deepseek','poe','perplexity','google_ai_overview','openai-not-network','claude'];
66 foreach ($project_id as $item){ 69 foreach ($project_id as $item){
67 $this->output('执行的项目ID----'.$item); 70 $this->output('执行的项目ID----'.$item);
68 //收录总数 71 //收录总数
69 $total = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]); 72 $total = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]);
  73 + $qualify_total = $geoQuestionResModel->counts(['platform'=>['in',['openai', 'gemini','google_ai_overview']],'project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]);
  74 + if($qualify_total > $geo_qualify_day){
  75 + $is_qualify = 1;
  76 + }
70 $data = [ 77 $data = [
71 'project_id' => $item, 78 'project_id' => $item,
72 'date' => $date, 79 'date' => $date,
73 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 80 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
74 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), 81 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
75 'total'=>$total,//收录总数 82 'total'=>$total,//收录总数
  83 + 'is_qualify'=>$is_qualify,
  84 + 'qualify_total'=>$qualify_total
76 ]; 85 ];
77 foreach ($platforms as $platform){ 86 foreach ($platforms as $platform){
78 if($platform == 'openai-not-network'){ 87 if($platform == 'openai-not-network'){
@@ -11,6 +11,7 @@ namespace App\Console\Commands\Geo; @@ -11,6 +11,7 @@ namespace App\Console\Commands\Geo;
11 11
12 use App\Models\Geo\GeoQuestionLog; 12 use App\Models\Geo\GeoQuestionLog;
13 use App\Models\Geo\GeoQuestionResult; 13 use App\Models\Geo\GeoQuestionResult;
  14 +use App\Models\Project\Project;
14 use Illuminate\Console\Command; 15 use Illuminate\Console\Command;
15 use Illuminate\Support\Carbon; 16 use Illuminate\Support\Carbon;
16 use App\Models\Geo\GeoCount as GeoCountModel; 17 use App\Models\Geo\GeoCount as GeoCountModel;
@@ -65,18 +66,26 @@ class GeoCountAll extends Command @@ -65,18 +66,26 @@ class GeoCountAll extends Command
65 if(empty($project_id)){ 66 if(empty($project_id)){
66 return true; 67 return true;
67 } 68 }
  69 + $projectModel = new Project();
  70 + $geo_qualify_day = $projectModel->getValue(['id'=>$project_id],['geo_qualify_day']);
68 $geoQuestionResModel = new GeoQuestionLog(); 71 $geoQuestionResModel = new GeoQuestionLog();
69 $platforms = ['gemini','openai','deepseek','poe','perplexity','google_ai_overview','openai-not-network','claude']; 72 $platforms = ['gemini','openai','deepseek','poe','perplexity','google_ai_overview','openai-not-network','claude'];
70 foreach ($project_id as $item){ 73 foreach ($project_id as $item){
71 $this->output('执行的项目ID----'.$item); 74 $this->output('执行的项目ID----'.$item);
72 //收录总数 75 //收录总数
73 $total = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]); 76 $total = $geoQuestionResModel->counts(['project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]);
  77 + $qualify_total = $geoQuestionResModel->counts(['platform'=>['in',['openai', 'gemini','google_ai_overview']],'project_id' => $item,'hit'=>['!=',0],'created_at' => ['between',[$start,$end]]]);
  78 + if($total > $geo_qualify_day){
  79 + $is_qualify = 1;
  80 + }
74 $data = [ 81 $data = [
75 'project_id' => $item, 82 'project_id' => $item,
76 'date' => $date, 83 'date' => $date,
77 'created_at' => Carbon::now()->format('Y-m-d H:i:s'), 84 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
78 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'), 85 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
79 'total'=>$total,//收录总数 86 'total'=>$total,//收录总数
  87 + 'is_qualify'=>$is_qualify,
  88 + 'qualify_total'=>$qualify_total
80 ]; 89 ];
81 foreach ($platforms as $platform){ 90 foreach ($platforms as $platform){
82 if($platform == 'openai-not-network'){ 91 if($platform == 'openai-not-network'){
@@ -33,11 +33,11 @@ class SyncImage extends Command @@ -33,11 +33,11 @@ class SyncImage extends Command
33 33
34 34
35 public function handle(){ 35 public function handle(){
36 - $str = $this->getProjectConfig(4636); 36 + $str = $this->getProjectConfig(2123);
37 $imageModel = new Image(); 37 $imageModel = new Image();
38 -// $strImage = '/upload/p/4240/image_other/2025-09/picture-18-copy-3.jpg,/upload/p/4240/image_other/2025-09/picture-17-copy-2.jpg,/upload/p/4240/image_other/2025-09/picture-16-copy-2.jpg,/upload/p/4240/image_other/2025-09/picture-12-copy-3.jpg,/upload/p/4240/image_other/2025-09/picture-5-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-6-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-10-copy-2.jpg,/upload/p/4240/image_other/2025-09/picture-11-copy-2.jpg,/upload/p/4240/image_other/2025-09/4-1.jpg,/upload/p/4240/image_other/2025-09/picture-18-copy-2.jpg,/upload/p/4240/image_other/2025-09/picture-16-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-17-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-15-copy-2.jpg,/upload/p/4240/image_other/2025-09/picture-13-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-14-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-12-copy-2.jpg,/upload/p/4240/image_other/2025-09/picture-10-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-11-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-20-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-18-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-19-copy-1.jpg,/upload/p/4240/image_other/2025-09/image-1-copy.jpg,/upload/p/4240/image_other/2025-09/image-2-copy.jpg,/upload/p/4240/image_other/2025-09/picture-3-copy.jpg,/upload/p/4240/image_other/2025-09/picture-6-copy.jpg,/upload/p/4240/image_other/2025-09/picture-4-copy.jpg,/upload/p/4240/image_other/2025-09/picture-5-copy.jpg,/upload/p/4240/image_other/2025-09/picture-9-copy.jpg,/upload/p/4240/image_other/2025-09/picture-7-copy.jpg,/upload/p/4240/image_other/2025-09/picture-8-copy.jpg,/upload/p/4240/image_other/2025-09/picture-15-copy-1.jpg,/upload/p/4240/image_other/2025-09/picture-14-copy.jpg,/upload/p/4240/image_other/2025-09/picture-13-copy.jpg,/upload/p/4240/image_other/2025-09/picture-12-copy-1.jpg,/upload/p/4240/image_other/2025-08/picture-44-copy.jpg,/upload/p/4240/image_other/2025-08/45.jpg,/upload/p/4240/image_other/2025-09/picture-10-copy.jpg,/upload/p/4240/image_other/2025-09/picture-11-copy.jpg,/upload/p/4240/image_other/2025-08/43.jpg,/upload/p/4240/image_other/2025-08/42.jpg,/upload/p/4240/image_other/2025-08/picture-38-copy.jpg,/upload/p/4240/image_other/2025-08/picture-37-copy.jpg,/upload/p/4240/image_other/2025-08/picture-36-copy.jpg,/upload/p/4240/image_other/2025-08/picture-35-copy-1.jpg,/upload/p/4240/image_other/2025-08/picture-30-copy.jpg,/upload/p/4240/image_other/2025-08/29.jpg,/upload/p/4240/image_other/2025-08/28-1.jpg,/upload/p/4240/image_other/2025-08/27-1.jpg,/upload/p/4240/image_other/2025-08/picture-23-copy.jpg,/upload/p/4240/image_other/2025-08/22-1.jpg,/upload/p/4240/image_other/2025-08/21.jpg,/upload/p/4240/image_other/2025-08/17.jpg,/upload/p/4240/image_other/2025-08/16.jpg,/upload/p/4240/image_other/2025-08/picture-15-copy.jpg,/upload/p/4240/image_other/2025-08/11-2.jpg,/upload/p/4240/image_other/2025-08/10-1.jpg,/upload/p/4240/image_other/2025-08/picture-6.jpg,/upload/p/4240/image_other/2025-08/picture-5.jpg,/upload/p/4240/image_other/2025-08/picture-4.jpg,/upload/p/4240/image_other/2025-08/api-standard-welded-pipe.jpg,/upload/p/4240/image_other/2025-08/gb-standard-welded-pipe.jpg,/upload/p/4240/image_other/2025-08/gost-standard-welded-pipe.jpg,/upload/p/4240/image_other/2025-08/jis-standard-welded-pipe.jpg,/upload/p/4240/image_other/2025-08/asmeastm-welded-pipe.jpg,/upload/p/4240/image_other/2025-08/en-standard-welded-pipe.jpg,/upload/p/4240/image_other/2025-08/api-corrosion-resistant-alloy-cra-pipe.jpg,/upload/p/4240/image_other/2025-08/nickel-alloy-seamless-pipe.jpg,/upload/p/4240/image_other/2025-08/duplexsuper-duplex-seamless-pipe.jpg,/upload/p/4240/image_other/2025-08/super-austenitic-seamless-pipe.jpg,/upload/p/4240/image_other/2025-08/austenitic-stainless-steel-seamless-pipe.jpg,/upload/p/4240/image_other/2025-08/thick-zinc-coated-pipe.jpg,/upload/p/4240/image_other/2025-08/galvanized-fbe-pipe.jpg,/upload/p/4240/image_other/2025-08/electro-galvanized-pipe.jpg,/upload/p/4240/image_other/2025-08/hot-dip-galvanized-pipe.jpg,/upload/p/4240/image_other/2025-08/q235-galvanized-pipe.jpg,/upload/p/4240/image_other/2025-08/q195-galvanized-pipe.jpg,/upload/p/4240/image_other/2025-08/bare-ssaw-steel-pipe.jpg,/upload/p/4240/image_other/2025-08/fbe-coated-ssaw-steel-pipe.jpg,/upload/p/4240/image_other/2025-08/x52-ssaw-steel-pipe.jpg,/upload/p/4240/image_other/2025-08/q235b-ssaw-steel-pipe.jpg,/upload/p/4240/image_other/2025-08/low-alloy-steel-erw-pipe.jpg,/upload/p/4240/image_other/2025-08/carbon-steel-erw-pipe.jpg,/upload/p/4240/image_other/2025-08/black-carbon-steel-pipe.jpg,/upload/p/4240/image_other/2025-08/picture-19-copy.jpg,/upload/p/4240/image_other/2025-08/hydrogen-energy-skid.jpg';  
39 - $lists = $imageModel->selectField(['project_id'=>4636],'path');  
40 -// $lists = explode(',',$strImage); 38 + $strImage = '/upload/p/2123/image_other/2025-10/1-361.jpg,/upload/p/2123/image_other/2025-10/3-255.jpg,/upload/p/2123/image_other/2025-10/4-237.jpg,/upload/p/2123/image_other/2025-10/5-104.jpg,/upload/p/2123/image_other/2025-10/6-53.jpg,/upload/p/2123/image_other/2025-10/7-31.jpg,/upload/p/2123/image_other/2025-10/8-27.jpg,/upload/p/2123/image_other/2025-10/5-105.jpg';
  39 +// $lists = $imageModel->selectField(['project_id'=>4636],'path');
  40 + $lists = explode(',',$strImage);
41 $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 41 $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名
42 foreach ($lists as $v){ 42 foreach ($lists as $v){
43 $url = $domain . $v.'?'.$str; 43 $url = $domain . $v.'?'.$str;
@@ -49,7 +49,120 @@ class Temp extends Command @@ -49,7 +49,120 @@ class Temp extends Command
49 49
50 public function handle() 50 public function handle()
51 { 51 {
52 - $this->inquiryAiCheck(17259, 27468); 52 +
  53 + }
  54 +
  55 + /**
  56 + * 4301项目特殊产品数据导入
  57 + * @return bool
  58 + * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  59 + * @author Akun
  60 + * @date 2025/10/21 10:11
  61 + */
  62 + public function specialImport4301()
  63 + {
  64 + $file_url = 'D:\work\特维整理后表格.csv';
  65 + $project_id = 4301;
  66 + $img_path = '/upload/p/' . $project_id . '/image_product/2025-10/';
  67 +
  68 + $is_gbk = 0;
  69 + $file_code_type = $this->get_code_type($file_url);
  70 + if ($file_code_type === false) {
  71 + $this->output('import fail, error: 文件编码格式错误');
  72 + return true;
  73 + } elseif ($file_code_type === 'GBK') {
  74 + $is_gbk = 1;
  75 + setlocale(LC_ALL, 'zh_CN');
  76 + }
  77 +
  78 + //读取csv文件
  79 + $line_of_text = [];
  80 + try {
  81 + $opts = [
  82 + 'http' => [
  83 + 'method' => 'GET',
  84 + 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
  85 + ],
  86 + 'ssl' => [
  87 + 'verify_peer' => false,
  88 + 'verify_peer_name' => false
  89 + ]
  90 + ];
  91 + $file_handle = fopen($file_url, 'r', null, stream_context_create($opts));
  92 + while (!feof($file_handle)) {
  93 + $line_of_text[] = fgetcsv($file_handle, 0, ',');
  94 + }
  95 + fclose($file_handle);
  96 + } catch (\Exception $e) {
  97 + $this->output('import fail, error: ' . $e->getMessage());
  98 + return true;
  99 + }
  100 +
  101 + $new_csv = [];
  102 + if (count($line_of_text) > 1) {
  103 + foreach ($line_of_text as $k => $v) {
  104 + if ($k > 0 && isset($v[0]) && $v[0]) {
  105 +
  106 + if ($is_gbk) {
  107 + foreach ($v as $kk => $vv) {
  108 + $v[$kk] = mb_convert_encoding($vv, 'utf-8', 'gbk');
  109 + }
  110 + }
  111 +
  112 + $images = glob('D:\work\特维产品图\TW24\\' . $v[8] . '*');
  113 + $new_images = [];
  114 + foreach ($images as $img) {
  115 + $img_arr = explode('\\', $img);
  116 + $new_images[] = getImageUrl($img_path . end($img_arr), 1);
  117 + }
  118 + $new_csv[] = [
  119 + $this->special2str($v[0]),
  120 + $v[1],
  121 + $v[2],
  122 + $v[3],
  123 + Arr::a2s([
  124 + 'Number' => $v[8],
  125 + 'Price' => $v[9],
  126 + 'Unit' => $v[10],
  127 + 'Packaging' => $v[11],
  128 + 'Length' => $v[12],
  129 + 'Width' => $v[13],
  130 + 'Height' => $v[14],
  131 + 'Box Length' => $v[15],
  132 + 'Box Width' => $v[16],
  133 + 'Box Height' => $v[17],
  134 + 'Material Volume' => $v[18],
  135 + 'Volume' => $v[19],
  136 + 'Box Number' => $v[20],
  137 + 'Weight' => $v[21],
  138 + 'Product Weight' => $v[22],
  139 + 'Category' => $v[23],
  140 + 'Color' => $v[24],
  141 + 'Minimum Order Quantity' => $v[25],
  142 + ]),
  143 + $v[5],
  144 + $v[6],
  145 + implode('^v6sp$', $new_images)
  146 + ];
  147 + }
  148 + }
  149 + }
  150 +
  151 + $map = ['产品标题', '自定义路由', '分类(支持多级,用 ^v6sp$ 分割)', '关键词(支持多个,用 ^v6sp$分割)', '参数(json格式)', '短描述', '产品描述', '产品图片集(支持多张,用 ^v6sp$ 分割)'];
  152 + //生成文件,发送到客户端
  153 + if ($new_csv) {
  154 + $table = new BatchExportService($project_id . '_products_need_import');
  155 + $file = $table->head($map)->data($new_csv)->save();
  156 + if (!$file) {
  157 + $this->output('文件生成失败,请重试');
  158 + } else {
  159 + $this->output('export success');
  160 + }
  161 + } else {
  162 + $this->output('no data');
  163 + }
  164 +
  165 + return true;
53 } 166 }
54 167
55 /** 168 /**
@@ -159,7 +272,7 @@ class Temp extends Command @@ -159,7 +272,7 @@ class Temp extends Command
159 * @author Akun 272 * @author Akun
160 * @date 2025/06/05 10:47 273 * @date 2025/06/05 10:47
161 */ 274 */
162 - public function specialImport() 275 + public function specialImport3531()
163 { 276 {
164 $file_url = 'https://ecdn6.globalso.com/upload/p/3531/file/2025-07/www-cninfo-com-cn_news_v1-2.csv'; 277 $file_url = 'https://ecdn6.globalso.com/upload/p/3531/file/2025-07/www-cninfo-com-cn_news_v1-2.csv';
165 $domain = 'static.cninfo.com.cn'; 278 $domain = 'static.cninfo.com.cn';
@@ -123,10 +123,6 @@ class ProjectLogic extends BaseLogic @@ -123,10 +123,6 @@ class ProjectLogic extends BaseLogic
123 $info['collect_test_domain'] = $info['is_upgrade'] ? CollectLog::getCollectTestDomain($id) : ''; 123 $info['collect_test_domain'] = $info['is_upgrade'] ? CollectLog::getCollectTestDomain($id) : '';
124 //获取项目所属行业 124 //获取项目所属行业
125 $info['deploy_optimize']['industry'] = ProjectIndustryRelated::where('project_id', $id)->pluck('industry_id')->toArray(); 125 $info['deploy_optimize']['industry'] = ProjectIndustryRelated::where('project_id', $id)->pluck('industry_id')->toArray();
126 - $questionModel = new GeoQuestionResult();  
127 - $info['question_qualify_count'] = $questionModel->where('project_id', $id)  
128 - ->where('hit','!=',0)->whereIn('platform',['openai', 'gemini','google_ai_overview'])  
129 - ->count();  
130 return $this->success($info); 126 return $this->success($info);
131 } 127 }
132 128
@@ -101,6 +101,10 @@ class CountLogic extends BaseLogic @@ -101,6 +101,10 @@ class CountLogic extends BaseLogic
101 * @time :2023/5/24 14:03 101 * @time :2023/5/24 14:03
102 */ 102 */
103 public function keyword_data_count(){ 103 public function keyword_data_count(){
  104 + $version = $this->project['version'] ?? '';
  105 + if(!empty($version) && $version != '7.5'){
  106 +
  107 + }
104 $yesterday = date('Y-m-d'); 108 $yesterday = date('Y-m-d');
105 $rankDataModel = new RankDataModel(); 109 $rankDataModel = new RankDataModel();
106 $param = [ 110 $param = [
@@ -93,7 +93,7 @@ class ProductLogic extends BaseLogic @@ -93,7 +93,7 @@ class ProductLogic extends BaseLogic
93 $route = $param['route']; 93 $route = $param['route'];
94 $is_upgrade = $param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0 94 $is_upgrade = $param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
95 $six_read = $param['six_read'] ?? 0;//是否按6.0显示 95 $six_read = $param['six_read'] ?? 0;//是否按6.0显示
96 - if($six_read == 0 && $is_upgrade == 1){ 96 + if($six_read == 1 && $is_upgrade == 1){
97 unset($param['route']); 97 unset($param['route']);
98 }else{ 98 }else{
99 $param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']); 99 $param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_PRODUCT, $this->param['id'], $this->user['project_id']);