作者 刘锟

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

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ImportCustomModule.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/12/9 11:35
  8 + */
  9 +
  10 +namespace App\Console\Commands\CustomModule;
  11 +
  12 +use App\Models\CustomModule\CustomModuleCategory;
  13 +use App\Models\CustomModule\CustomModuleContent;
  14 +use App\Models\CustomModule\CustomModuleExtentContent;
  15 +use App\Models\RouteMap\RouteMap;
  16 +use App\Services\ProjectServer;
  17 +use Illuminate\Console\Command;
  18 +use Illuminate\Support\Facades\DB;
  19 +
  20 +class ImportCustomModule extends Command
  21 +{
  22 + /**
  23 + * The name and signature of the console command.
  24 + *
  25 + * @var string
  26 + */
  27 + protected $signature = 'import_custom_module';
  28 +
  29 + /**
  30 + * The console command description.
  31 + *
  32 + * @var string
  33 + */
  34 + protected $description = 'import_custom_module';
  35 +
  36 + /**
  37 + * @remark :导入
  38 + * @name :handle
  39 + * @author :lyh
  40 + * @method :post
  41 + * @time :2024/12/9 11:36
  42 + */
  43 + public function handle(){
  44 + echo date('Y-m-d H:i:s') . 'project_id:' . PHP_EOL;
  45 + ProjectServer::useProject(2837);
  46 + $this->import_module_content();
  47 + DB::disconnect('custom_mysql');
  48 + }
  49 +
  50 + /**
  51 + * @remark :导入扩展模块 (保留)
  52 + * @name :ceshis
  53 + * @author :lyh
  54 + * @method :post
  55 + * @time :2024/12/6 17:02
  56 + */
  57 + public function import_module_content(){
  58 + $data = 'MBR10100CT,Rectifier/Schottky Barrier Rectifier,TO-220AB,100,5*2,common cathode,100,0.85,10,2500,175,-,Active,https://v6-file.globalso.com/upload/p/2837/files/MBR10100CT.pdf
  59 +MBR2060BCT,Rectifier/Schottky Barrier Rectifier,ITO-220AB,60,10*2,common cathode,150,0.75,50,5000,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/MBR2060BCT.pdf
  60 +MBR20150DCT,Rectifier/Schottky Barrier Rectifier,TO-263(D2PAK),150,10*2,common cathode,150,0.88,5,1500,175,-,Active,https://v6-file.globalso.com/upload/p/2837/files/MBR20150DCT.pdf
  61 +MUR2060CT,Rectifier/High Efficient Rectifier,TO-220AB,600,10*2,common cathode,150,1.7,1,500,150,50,Active,https://v6-file.globalso.com/upload/p/2837/files/MUR2060CT.pdf
  62 +MUR2040FCT,Rectifier/High Efficient Rectifier,ITO-220AB,400,10*2,common cathode,150,1.3,1,500,150,50,Active,https://v6-file.globalso.com/upload/p/2837/files/MUR2040FCT.pdf
  63 +DSEK20S04B,Rectifier/Ultra fast soft Recovery Rectifier,TO-252(DPAK),400,10*2,common cathode,125,1.25,2,500,175,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSEK20S04B.pdf
  64 +DSEK30S06D,Rectifier/Ultra fast soft Recovery Rectifier,TO-263(D2PAK),600,15*2,common cathode,150,1.7,2,500,175,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSEK30S06D.pdf
  65 +DSEK60H06P,Rectifier/Ultra fast soft Recovery Rectifier,TO-247AD,600,30*2,common cathode,300,1.7,5,500,175,60,Active,https://v6-file.globalso.com/upload/p/2837/files/DSEK60H06P.pdf
  66 +GBU410,Rectifier/Bridge Rectifier,GBU,1000,4,-,125,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU410.pdf
  67 +GBU1510,Rectifier/Bridge Rectifier,GBU,1000,15,-,250,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU1510.pdf
  68 +GBJ2510,Rectifier/Bridge Rectifier,GBJ,1000,25,-,300,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBJ2510.pdf
  69 +GBU1504H,Rectifier/High Efficient Bridge Rectifier,GBU,400,15,-,150,1.3,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU1504H.pdf
  70 +GBU1506H,Rectifier/High Efficient Bridge Rectifier,GBU,400,15,-,150,1.7,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBU1506H.pdf
  71 +GBJ2504H,Rectifier/High Efficient Bridge Rectifier,GBJ,600,25,-,250,1.3,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBJ2504H.pdf
  72 +GBJ2506H,Rectifier/High Efficient Bridge Rectifier,GBJ,600,25,-,250,1.7,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/GBJ2506H.pdf
  73 +1N4007,Rectifier/Standard Recovery Rectifier,DO-41,1000,1,-,50,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/1N4007.pdf
  74 +1N5399,Rectifier/Standard Recovery Rectifier,DO-15,1000,1.5,-,75,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/1N5399.pdf
  75 +1N5408,Rectifier/Standard Recovery Rectifier,DO-27,1000,3,-,100,1,1,500,150,-,Active,https://v6-file.globalso.com/upload/p/2837/files/1N5408.pdf
  76 +RS1M,Rectifier/Fast Recovery Rectifier,SMA,1000,1,-,50,1.3,1,500,150,500,Active,https://v6-file.globalso.com/upload/p/2837/files/RS1M.pdf
  77 +RS2M,Rectifier/Fast Recovery Rectifier,SMB,1000,2,-,75,1.3,1,500,150,500,Active,https://v6-file.globalso.com/upload/p/2837/files/RS2M.pdf
  78 +RS3M,Rectifier/Fast Recovery Rectifier,SMC,1000,3,-,100,1.3,1,500,150,500,Active,https://v6-file.globalso.com/upload/p/2837/files/RS3M.pdf
  79 +SF28,Rectifier/Super fast Recovery Rectifier,DO-15,600,2,-,60,1.7,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/SF28.pdf
  80 +SF56G,Rectifier/Super fast Recovery Rectifier,DO-27,400,5,-,125,1.3,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/SF56G.pdf
  81 +DSE1006,Rectifier/Super fast Recovery Rectifier,TO-220AC,600,10,Single Positive,150,1.7,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSE1006.pdf
  82 +DSE1504F,Rectifier/Super fast Recovery Rectifier,ITO-220AC,400,15,Single Positive,150,1.4,1,500,150,35,Active,https://v6-file.globalso.com/upload/p/2837/files/DSE1504F.pdf';
  83 + $array = explode("\n", $data);
  84 + foreach ($array as $values){
  85 + $array1 = explode(',',$values);
  86 + $contentData = [
  87 + 'name'=>$array1[0],
  88 + 'route'=>'',
  89 + 'project_id'=>2837,
  90 + 'operator_id'=>6393,
  91 + 'module_id'=>2,
  92 + ];
  93 + $customModuleCategoryModel = new CustomModuleCategory();
  94 + if(!empty($array1[1])){
  95 + $cate_ids = '';
  96 + $cate_arr = explode('/',$array1[1]);
  97 + echo date('Y-m-d H:i:s') . 'json_fenle:' . json_encode($cate_arr) . PHP_EOL;
  98 + foreach ($cate_arr as $cateV){
  99 + $catInfo = $customModuleCategoryModel->read(['name'=>$cateV]);
  100 + if($catInfo !== false){
  101 + $cate_ids = $cate_ids.','.$catInfo['id'];
  102 + }
  103 + }
  104 + echo date('Y-m-d H:i:s') . '处理后的fenle:' . $cate_ids . PHP_EOL;
  105 + $contentData['category_id'] = empty($cate_ids) ? '' : $cate_ids.',';
  106 + }else{
  107 + $catInfo = $customModuleCategoryModel->read(['name'=>$array1[1]]);
  108 + if($catInfo !== false){
  109 + $contentData['category_id'] = ','.$catInfo['id'].',';
  110 + }
  111 + }
  112 + $customModuleContentModel = new CustomModuleContent();
  113 + $contentId = $customModuleContentModel->addReturnId($contentData);
  114 + $route = RouteMap::setRoute($array1[0],RouteMap::SOURCE_MODULE,$contentId,2837);
  115 + $customModuleContentModel->edit(['route'=>$route],['id'=>$contentId]);
  116 + $pd_extended_field_arr = [
  117 + [
  118 + 'key'=>'pd_extended_field_1',
  119 + 'type'=>1,
  120 + 'project_id'=>2837,
  121 + 'values'=>$array1[2],
  122 + 'content_id'=>$contentId,
  123 + 'module_id'=>2,
  124 + 'created_at'=>date('Y-m-d H:i:s'),
  125 + 'updated_at'=>date('Y-m-d H:i:s'),
  126 + ],
  127 + [
  128 + 'key'=>'pd_extended_field_2',
  129 + 'type'=>1,
  130 + 'project_id'=>2837,
  131 + 'values'=>$array1[3],
  132 + 'module_id'=>2,
  133 + 'content_id'=>$contentId,
  134 + 'created_at'=>date('Y-m-d H:i:s'),
  135 + 'updated_at'=>date('Y-m-d H:i:s'),
  136 + ],
  137 + [
  138 + 'key'=>'pd_extended_field_3',
  139 + 'type'=>1,
  140 + 'project_id'=>2837,
  141 + 'values'=>$array1[4],
  142 + 'module_id'=>2,
  143 + 'content_id'=>$contentId,
  144 + 'created_at'=>date('Y-m-d H:i:s'),
  145 + 'updated_at'=>date('Y-m-d H:i:s'),
  146 + ],
  147 + [
  148 + 'key'=>'pd_extended_field_4',
  149 + 'type'=>1,
  150 + 'project_id'=>2837,
  151 + 'values'=>$array1[5],
  152 + 'module_id'=>2,
  153 + 'content_id'=>$contentId,
  154 + 'created_at'=>date('Y-m-d H:i:s'),
  155 + 'updated_at'=>date('Y-m-d H:i:s'),
  156 + ],
  157 + [
  158 + 'key'=>'pd_extended_field_5',
  159 + 'type'=>1,
  160 + 'project_id'=>2837,
  161 + 'values'=>$array1[6],
  162 + 'module_id'=>2,
  163 + 'content_id'=>$contentId,
  164 + 'created_at'=>date('Y-m-d H:i:s'),
  165 + 'updated_at'=>date('Y-m-d H:i:s'),
  166 + ],
  167 + [
  168 + 'key'=>'pd_extended_field_6',
  169 + 'type'=>1,
  170 + 'project_id'=>2837,
  171 + 'values'=>$array1[7],
  172 + 'module_id'=>2,
  173 + 'content_id'=>$contentId,
  174 + 'created_at'=>date('Y-m-d H:i:s'),
  175 + 'updated_at'=>date('Y-m-d H:i:s'),
  176 + ],
  177 + [
  178 + 'key'=>'pd_extended_field_7',
  179 + 'type'=>1,
  180 + 'project_id'=>2837,
  181 + 'values'=>$array1[8],
  182 + 'module_id'=>2,
  183 + 'content_id'=>$contentId,
  184 + 'created_at'=>date('Y-m-d H:i:s'),
  185 + 'updated_at'=>date('Y-m-d H:i:s'),
  186 + ],
  187 + [
  188 + 'key'=>'pd_extended_field_8',
  189 + 'type'=>1,
  190 + 'project_id'=>2837,
  191 + 'values'=>$array1[9],
  192 + 'module_id'=>2,
  193 + 'content_id'=>$contentId,
  194 + 'created_at'=>date('Y-m-d H:i:s'),
  195 + 'updated_at'=>date('Y-m-d H:i:s'),
  196 + ],
  197 + [
  198 + 'key'=>'pd_extended_field_9',
  199 + 'type'=>1,
  200 + 'project_id'=>2837,
  201 + 'values'=>$array1[10],
  202 + 'module_id'=>2,
  203 + 'content_id'=>$contentId,
  204 + 'created_at'=>date('Y-m-d H:i:s'),
  205 + 'updated_at'=>date('Y-m-d H:i:s'),
  206 + ],
  207 + [
  208 + 'key'=>'pd_extended_field_10',
  209 + 'type'=>1,
  210 + 'project_id'=>2837,
  211 + 'values'=>$array1[11],
  212 + 'module_id'=>2,
  213 + 'content_id'=>$contentId,
  214 + 'created_at'=>date('Y-m-d H:i:s'),
  215 + 'updated_at'=>date('Y-m-d H:i:s'),
  216 + ],
  217 + [
  218 + 'key'=>'pd_extended_field_11',
  219 + 'type'=>1,
  220 + 'project_id'=>2837,
  221 + 'values'=>$array1[12],
  222 + 'module_id'=>2,
  223 + 'content_id'=>$contentId,
  224 + 'created_at'=>date('Y-m-d H:i:s'),
  225 + 'updated_at'=>date('Y-m-d H:i:s'),
  226 + ],
  227 + [
  228 + 'key'=>'pd_extended_field_12',
  229 + 'type'=>4,
  230 + 'project_id'=>2837,
  231 + 'values'=>json_encode([['url'=>$array1[13]]]),
  232 + 'module_id'=>2,
  233 + 'content_id'=>$contentId,
  234 + 'created_at'=>date('Y-m-d H:i:s'),
  235 + 'updated_at'=>date('Y-m-d H:i:s'),
  236 + ],
  237 + ];
  238 + $extendContentModel = new CustomModuleExtentContent();
  239 + $extendContentModel->insert($pd_extended_field_arr);
  240 + }
  241 + }
  242 +
  243 +}
@@ -36,6 +36,7 @@ class RemainDay extends Command @@ -36,6 +36,7 @@ class RemainDay extends Command
36 */ 36 */
37 protected $ceaseProjectId = [ 37 protected $ceaseProjectId = [
38 354, 38 354,
  39 + 378,
39 649, 40 649,
40 1283, 41 1283,
41 2066 42 2066
@@ -204,7 +204,7 @@ class RelayInquiry extends Command @@ -204,7 +204,7 @@ class RelayInquiry extends Command
204 } 204 }
205 // 未设置对法对象 205 // 未设置对法对象
206 $target_num_arr = array_map(function ($item) { 206 $target_num_arr = array_map(function ($item) {
207 - return count($item['target']); 207 + return count($item['target']) + count($item['shop_site']) + count($item['fob_pro']);
208 }, $ad_task); 208 }, $ad_task);
209 if (!array_sum($target_num_arr)) { 209 if (!array_sum($target_num_arr)) {
210 $val->status = ReInquiryForm::STATUS_FORGO; 210 $val->status = ReInquiryForm::STATUS_FORGO;
@@ -225,6 +225,8 @@ class RelayInquiry extends Command @@ -225,6 +225,8 @@ class RelayInquiry extends Command
225 $res = false; 225 $res = false;
226 foreach ($ad_task as $task){ 226 foreach ($ad_task as $task){
227 $res += $this->relayDetail($task, $val); 227 $res += $this->relayDetail($task, $val);
  228 + $res += $this->relayShopDetail($task, $val);
  229 + $res += $this->relayFobDetail($task, $val);
228 } 230 }
229 $val->status = $res ? ReInquiryForm::STATUS_SUCCESS : ReInquiryForm::STATUS_FORGO; 231 $val->status = $res ? ReInquiryForm::STATUS_SUCCESS : ReInquiryForm::STATUS_FORGO;
230 $val->save(); 232 $val->save();
@@ -288,7 +290,10 @@ class RelayInquiry extends Command @@ -288,7 +290,10 @@ class RelayInquiry extends Command
288 public function relayDetail($task, $form) 290 public function relayDetail($task, $form)
289 { 291 {
290 $this->output('获取转发对象'); 292 $this->output('获取转发对象');
291 - 293 + if(empty($task['target'] )){
  294 + $this->output('没有独立站转发对象');
  295 + return 0;
  296 + }
292 //是否有必选的 297 //是否有必选的
293 $require_data = []; 298 $require_data = [];
294 foreach ($task['target'] as $item){ 299 foreach ($task['target'] as $item){
@@ -327,119 +332,20 @@ class RelayInquiry extends Command @@ -327,119 +332,20 @@ class RelayInquiry extends Command
327 $is_v6 = $item['is_v6']; 332 $is_v6 = $item['is_v6'];
328 $re_website = 'https://' . $domain . '/'; 333 $re_website = 'https://' . $domain . '/';
329 334
330 - $this->output('转发对象:' . $domain);  
331 - $this->output('获取转发链接');  
332 - // v6:有邮箱推送主站,没有邮箱推送AMP站;v5:仅推送有邮箱到主站  
333 - $lang = '';  
334 - if ($is_v6) {  
335 - // 获取语种, 6.0是可以确定语种的  
336 - $project = Project::getProjectByDomain($domain);  
337 - if (empty($project)) {  
338 - $this->logChannel()->info('广告任务ID:' . $task['id'] . ', 转发对象:' . $re_website . '非v6链接,转发失败;', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]);  
339 - continue;  
340 - }  
341 - $lang = WebLanguage::getLangById($project->main_lang_id ?? 1)['short'];  
342 -  
343 - // 获取访问明细和着陆页  
344 - $product_url = $this->getLinksFromSitemap($re_website . 'product_sitemap.xml');  
345 - $product_cate_url = $this->getLinksFromSitemap($re_website . 'product_category_sitemap.xml');  
346 - $keywords_url = $this->getLinksFromSitemap($re_website . 'product_keywords_sitemap.xml');  
347 - $page_url = $this->getLinksFromSitemap($re_website . 'page_sitemap.xml');  
348 - } else {  
349 - if($form->email){  
350 - //通过sitemap拿访问页面  
351 - $product_url = $this->getLinksFromSitemap($re_website . 'sitemap_post.xml');  
352 - $product_cate_url = $this->getLinksFromSitemap($re_website . 'sitemap_category.xml');  
353 - $keywords_url = $this->getLinksFromSitemap($re_website . 'sitemap_post_tag.xml');  
354 - $page_url = $this->getLinksFromSitemap($re_website . 'sitemap_page.xml');  
355 - }else{  
356 - //m站先就往contact-us着陆  
357 - $product_url = $product_cate_url = $keywords_url = [];  
358 - $page_url = [$re_website . 'contact-us/'];  
359 - }  
360 - }  
361 -  
362 - // 所有可用url  
363 - $urls = $inquiry_urls = [];  
364 - //入口url 首页30%,单页10%,聚合页60%  
365 - $type = getRandByRatio([30,10,60]);  
366 - $inlet = $re_website;  
367 - $type == 1 && $inlet = $page_url ? Arr::random($page_url) : $re_website;  
368 - $type == 2 && $inlet = $keywords_url ? Arr::random($keywords_url) : $re_website;  
369 - $urls[] = $inquiry_urls[] = $inlet;  
370 - $all_urls = array_merge($urls, $product_url, $product_cate_url, $keywords_url, $page_url);  
371 - $inquiry_urls = array_merge($urls, $product_cate_url, $keywords_url, $page_url);  
372 -  
373 - // 随机访问1-6个页面  
374 - $deep = rand(1,6);  
375 - if($deep > 2) {  
376 - $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 4 ? 4 : count($all_urls)));  
377 - $urls = array_merge($urls, $visit_urls);  
378 - }  
379 - if($deep > 1) {  
380 - // 推送着落页只能是 首页、产品分类、单页面、聚合页  
381 - if (!in_array(end($urls), $inquiry_urls)) {  
382 - $urls[] = Arr::random($inquiry_urls);  
383 - } 335 + //urls
  336 + list($urls, $lang) = $this->getUrls($is_v6, $domain, $re_website, $form, $task);
  337 + if(!$urls){
  338 + continue;
384 } 339 }
385 340
386 - $this->output('获取转发ip');  
387 - // TODO 获取IP:如果是简码,查询数据库获取对应的国家, 如果是国家使用翻译, 再转化成IP  
388 - $country = $form->country_name;  
389 - // 有国家 通过国家查询, 如果没有获取到就随机获取  
390 - $where = [];  
391 - $country && $where['ip_area'] = $country;  
392 - $ip_data = DB::table('gl_xunpan_ipdata')->where($where)->inRandomOrder()->first();  
393 - if (empty($ip_data)) {  
394 - $ip_data = DB::table('gl_xunpan_ipdata')->inRandomOrder()->first();  
395 - } 341 + //ip
  342 + $ip_data = $this->getIpData($form->country_name);
396 $ip = $ip_data->ip; 343 $ip = $ip_data->ip;
397 $country_name = $ip_data->ip_area; 344 $country_name = $ip_data->ip_area;
398 345
399 - $this->output('转发内容');  
400 - $message = $form->message;  
401 - $message_id = 0;  
402 - //开启文案替换  
403 - if ($task['is_replace_text'] == 2) {  
404 - //AI生成  
405 - $error = 0;  
406 - while ($error<3){  
407 - $message = $this->ai_send($task['ai_param'], $message);  
408 - if(!$message){  
409 - $this->output('AI文案生成失败');  
410 - $error++;  
411 - if($error==2){  
412 - $task['is_replace_text'] = 1;  
413 - $this->output('AI文案生成失败,使用文案库');  
414 - }  
415 - }else{  
416 - break;  
417 - }  
418 - }  
419 - }  
420 - if ($task['is_replace_text'] == 1 || strlen($message) <= 4) {  
421 - //配置文案库替换或者字符少于4个,直接替换文案  
422 -  
423 - $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray();  
424 - $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first();  
425 - $message = $text->content;  
426 - $message_id = $text->id;  
427 - // 获取后,使用次数+1  
428 - $text->use_time += 1;  
429 - $text->save();  
430 -  
431 - //原内容非英语,转为对应语种  
432 - if (is_numeric($form->message)) { //数字会被识别为中文  
433 - $lang = 'en';  
434 - } else {  
435 - $translateSl = Translate::translateSl($form->message);  
436 - $lang = $translateSl['texts']['sl'] ?? 'en';  
437 - }  
438 -  
439 - if ($lang != 'en' && !Str::contains($lang, 'zh')) {  
440 - $message = Translate::tran($message, $lang);  
441 - }  
442 - } 346 + //message
  347 + list($message, $message_id, $msg_lang) = $this->getMessage($task, $form->message, $domain);
  348 + $lang = $lang ?: $msg_lang;
443 349
444 $this->output('获取转发设备信息'); 350 $this->output('获取转发设备信息');
445 // 客户端 头信息 来源 351 // 客户端 头信息 来源
@@ -474,6 +380,203 @@ class RelayInquiry extends Command @@ -474,6 +380,203 @@ class RelayInquiry extends Command
474 return true; 380 return true;
475 } 381 }
476 382
  383 + public function relayShopDetail($task, $form)
  384 + {
  385 + $this->output('获取商城转发对象');
  386 +
  387 + if(empty($task['shop_site'])){
  388 + $this->output('没有商城转发对象');
  389 + return 0;
  390 + }
  391 +
  392 + foreach ($task['shop_site'] as $item) {
  393 + //手机号过滤
  394 + $phone = $form->phone;
  395 + // 推送站点
  396 + $domain = $item;
  397 + $re_website = 'https://' . $domain . '/';
  398 + $paths = ['', 'contact-us'];
  399 + $url = $re_website . $paths[array_rand($paths)];
  400 + //ip
  401 + $ip_data = $this->getIpData($form->country_name);
  402 + $ip = $ip_data->ip;
  403 + $country_name = $ip_data->ip_area;
  404 + //message
  405 + list($message, $message_id, $lang) = $this->getMessage($task, $form->message, $domain);
  406 +
  407 + $device_port = $form->email ? '1' : '2'; //1 pc 2移动端
  408 + $user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
  409 + $referrer = $this->getReferer($country_name, $lang);
  410 +
  411 + $start_time = time();
  412 + $seconds = rand(300, 3000); // 开始时间 从5-50分钟后开始
  413 + $exists = ReInquiryDetail::where('re_website', $domain)->where('email', $form->email)->first();
  414 + if($exists){
  415 + $this->output('转发站点邮件已存在');
  416 + continue;
  417 + }
  418 + $re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $domain, $country_name, $ip, $form->full_name, $form->email, $phone, $message, $message_id,
  419 + $device_port, $user_agent, $referrer, [$url], 0, date('Y-m-d H:i:s', $start_time + $seconds), ReInquiryDetail::STATUS_INIT, 2);
  420 +
  421 + ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_INQUIRY, 1, $url, date('Y-m-d H:i:s', $start_time + $seconds));
  422 + }
  423 + return true;
  424 + }
  425 +
  426 +
  427 + public function relayFobDetail($task, $form)
  428 + {
  429 + $this->output('获取FOB转发对象');
  430 +
  431 + if(empty($task['fob_pro'])){
  432 + $this->output('没有FOB转发对象');
  433 + return 0;
  434 + }
  435 +
  436 + foreach ($task['fob_pro'] as $item) {
  437 + //手机号过滤
  438 + $phone = $form->phone;
  439 + // 推送站点
  440 + $postid = $item;
  441 + //message
  442 + list($message, $message_id, $lang) = $this->getMessage($task, $form->message, $postid);
  443 +
  444 + $device_port = $form->email ? '1' : '2'; //1 pc 2移动端
  445 + $user_agent = $form->email ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua);
  446 +
  447 + $start_time = time();
  448 + $seconds = rand(300, 3000); // 开始时间 从5-50分钟后开始
  449 + $exists = ReInquiryDetail::where('re_website', $postid)->where('email', $form->email)->first();
  450 + if($exists){
  451 + $this->output('转发站点邮件已存在');
  452 + continue;
  453 + }
  454 + $re_detail = ReInquiryDetail::createInquiry($task['id'], $form->id, $postid, $country_name??'', $ip??'', $form->full_name, $form->email, $phone,
  455 + $message, $message_id, $device_port, $user_agent, $referrer??'', [$postid], 0, date('Y-m-d H:i:s', $start_time + $seconds), ReInquiryDetail::STATUS_INIT, 3);
  456 +
  457 + ReInquiryDetailLog::createInquiryLog($re_detail->id, ReInquiryDetailLog::TYPE_INQUIRY, 1, $postid, date('Y-m-d H:i:s', $start_time + $seconds));
  458 + }
  459 + return true;
  460 + }
  461 +
  462 + public function getIpData($country_name){
  463 + $this->output('获取转发ip');
  464 + $country = $country_name;
  465 + // 有国家 通过国家查询, 如果没有获取到就随机获取
  466 + $where = [];
  467 + $country && $where['ip_area'] = $country;
  468 + $ip_data = DB::table('gl_xunpan_ipdata')->where($where)->inRandomOrder()->first();
  469 + if (empty($ip_data)) {
  470 + $ip_data = DB::table('gl_xunpan_ipdata')->inRandomOrder()->first();
  471 + }
  472 + return $ip_data;
  473 + }
  474 +
  475 + public function getMessage($task, $message, $domain){
  476 + $this->output('转发内容');
  477 + $form_message = $message;
  478 + $message_id = 0;
  479 + //开启文案替换
  480 + if ($task['is_replace_text'] == 2) {
  481 + //AI生成
  482 + $error = 0;
  483 + while ($error<3){
  484 + $message = $this->ai_send($task['ai_param'], $message);
  485 + if(!$message){
  486 + $this->output('AI文案生成失败');
  487 + $error++;
  488 + if($error==2){
  489 + $task['is_replace_text'] = 1;
  490 + $this->output('AI文案生成失败,使用文案库');
  491 + }
  492 + }else{
  493 + break;
  494 + }
  495 + }
  496 + }
  497 + if ($task['is_replace_text'] == 1 || strlen($message) <= 4) {
  498 + //配置文案库替换或者字符少于4个,直接替换文案
  499 + $use_ids = ReInquiryDetail::where(['re_website' => $domain])->where('status', '<>', ReInquiryDetail::STATUS_FAIL)->pluck('text_id')->toArray();
  500 + $text = ReInquiryText::whereNotIn('id', $use_ids)->where('status', ReInquiryText::STATUS_USABLE)->inRandomOrder()->first();
  501 + $message = $text->content;
  502 + $message_id = $text->id;
  503 + // 获取后,使用次数+1
  504 + $text->use_time += 1;
  505 + $text->save();
  506 +
  507 + //原内容非英语,转为对应语种
  508 + if (is_numeric($form_message)) { //数字会被识别为中文
  509 + $lang = 'en';
  510 + } else {
  511 + $translateSl = Translate::translateSl($form_message);
  512 + $lang = $translateSl['texts']['sl'] ?? 'en';
  513 + }
  514 +
  515 + if ($lang != 'en' && !Str::contains($lang, 'zh')) {
  516 + $message = Translate::tran($message, $lang);
  517 + }
  518 + }
  519 + return [$message, $message_id, $lang??''];
  520 + }
  521 +
  522 + public function getUrls($is_v6, $domain, $re_website, $form, $task){
  523 + $this->output('转发对象:' . $domain);
  524 + $this->output('获取转发链接');
  525 + // v6:有邮箱推送主站,没有邮箱推送AMP站;v5:仅推送有邮箱到主站
  526 + $lang = '';
  527 + if ($is_v6) {
  528 + // 获取语种, 6.0是可以确定语种的
  529 + $project = Project::getProjectByDomain($domain);
  530 + if (empty($project)) {
  531 + $this->logChannel()->info('广告任务ID:' . $task['id'] . ', 转发对象:' . $re_website . '非v6链接,转发失败;', ['广告任务ID:' . $task['id'], '询盘ID:' . $form->id]);
  532 + return [[], $lang];
  533 + }
  534 + $lang = WebLanguage::getLangById($project->main_lang_id ?? 1)['short'];
  535 +
  536 + // 获取访问明细和着陆页
  537 + $product_url = $this->getLinksFromSitemap($re_website . 'product_sitemap.xml');
  538 + $product_cate_url = $this->getLinksFromSitemap($re_website . 'product_category_sitemap.xml');
  539 + $keywords_url = $this->getLinksFromSitemap($re_website . 'product_keywords_sitemap.xml');
  540 + $page_url = $this->getLinksFromSitemap($re_website . 'page_sitemap.xml');
  541 + } else {
  542 + if($form->email){
  543 + //通过sitemap拿访问页面
  544 + $product_url = $this->getLinksFromSitemap($re_website . 'sitemap_post.xml');
  545 + $product_cate_url = $this->getLinksFromSitemap($re_website . 'sitemap_category.xml');
  546 + $keywords_url = $this->getLinksFromSitemap($re_website . 'sitemap_post_tag.xml');
  547 + $page_url = $this->getLinksFromSitemap($re_website . 'sitemap_page.xml');
  548 + }else{
  549 + //m站先就往contact-us着陆
  550 + $product_url = $product_cate_url = $keywords_url = [];
  551 + $page_url = [$re_website . 'contact-us/'];
  552 + }
  553 + }
  554 +
  555 + // 所有可用url
  556 + $urls = $inquiry_urls = [];
  557 + //入口url 首页30%,单页10%,聚合页60%
  558 + $type = getRandByRatio([30,10,60]);
  559 + $inlet = $re_website;
  560 + $type == 1 && $inlet = $page_url ? Arr::random($page_url) : $re_website;
  561 + $type == 2 && $inlet = $keywords_url ? Arr::random($keywords_url) : $re_website;
  562 + $urls[] = $inquiry_urls[] = $inlet;
  563 + $all_urls = array_merge($urls, $product_url, $product_cate_url, $keywords_url, $page_url);
  564 + $inquiry_urls = array_merge($urls, $product_cate_url, $keywords_url, $page_url);
  565 +
  566 + // 随机访问1-6个页面
  567 + $deep = rand(1,6);
  568 + if($deep > 2) {
  569 + $visit_urls = Arr::random($all_urls, rand(1, count($all_urls) > 4 ? 4 : count($all_urls)));
  570 + $urls = array_merge($urls, $visit_urls);
  571 + }
  572 + if($deep > 1) {
  573 + // 推送着落页只能是 首页、产品分类、单页面、聚合页
  574 + if (!in_array(end($urls), $inquiry_urls)) {
  575 + $urls[] = Arr::random($inquiry_urls);
  576 + }
  577 + }
  578 + return [$urls, $lang];
  579 + }
477 /** 580 /**
478 * 获取待处理询盘表单 581 * 获取待处理询盘表单
479 * @param int $num 582 * @param int $num
@@ -494,7 +597,7 @@ class RelayInquiry extends Command @@ -494,7 +597,7 @@ class RelayInquiry extends Command
494 { 597 {
495 $cache_key = 'inquiry_ads_tasks'; 598 $cache_key = 'inquiry_ads_tasks';
496 $ads = Cache::get($cache_key, function () use ($cache_key) { 599 $ads = Cache::get($cache_key, function () use ($cache_key) {
497 - $ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target', 'is_replace_text', 'ai_param']); 600 + $ads = ReInquiryTask::where(['status' => ReInquiryTask::STATUS_OPEN])->get(['id', 'ad_id', 'num', 'target', 'is_replace_text', 'ai_param', 'shop_site', 'fob_pro']);
498 $array = []; 601 $array = [];
499 foreach ($ads as $key=>$val) { 602 foreach ($ads as $key=>$val) {
500 $ad_ids = explode(',', $val['ad_id']); 603 $ad_ids = explode(',', $val['ad_id']);
@@ -158,60 +158,26 @@ class postInquiry extends Command @@ -158,60 +158,26 @@ class postInquiry extends Command
158 } 158 }
159 159
160 public function inquiry(ReInquiryDetail $detail, ReInquiryDetailLog $log){ 160 public function inquiry(ReInquiryDetail $detail, ReInquiryDetailLog $log){
161 - $website = 'https://' . $detail['re_website'] . '/';  
162 - // v6  
163 - if($detail['is_v6']) {  
164 - $data = [  
165 - 'name' => $detail['name'],  
166 - 'phone' => $detail['phone'],  
167 - 'message' => $detail['message'],  
168 - 'submit_ip' => $detail['ip'],  
169 - 'refer' => $log->url,  
170 - ];  
171 - if($detail->email){  
172 - $data['email'] = $detail->email;  
173 - }else{  
174 - $data['__amp_source_origin'] = trim($website, '/');  
175 - }  
176 -  
177 - $res = Http::withoutVerifying()->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd/', $data)->json();  
178 - if(empty($res['code']) || $res['code'] != 200){  
179 - $log->status = ReInquiryDetailLog::STATUS_FAIL;  
180 - $log->remark = mb_substr($res['message'] ?? '', 0, 200);  
181 - $log->save();  
182 -  
183 - Log::channel('inquiry_relay')->error('inquiry_relay v6 inquiry error', [$res, $website . 'api/inquiryQd/', $data]);  
184 - return false; 161 + $res = false;
  162 + if ($detail['type'] == 1) {
  163 + // v6
  164 + if ($detail['is_v6']) {
  165 + $res = $this->v6Inquiry($detail, $log);
  166 + } else {
  167 + $res = $this->v5Inquiry($detail, $log);
185 } 168 }
186 - }else{  
187 - $data = [  
188 - 'name' => $detail['name'],  
189 - 'phone' => $detail['phone'],  
190 - 'message' => $detail['message'],  
191 - 'email' => $detail['email'],  
192 - 'ip' => $detail['ip'],  
193 - 'token' => md5($log->url . $detail['name'] . $detail['ip'] . date("Y-m-d")),  
194 - 'refer' => $log->url,  
195 - 'submit_time' => date('Y-m-d H:i:s'),  
196 - 'source' => 5,  
197 - ];  
198 -  
199 - $result = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data);  
200 - $res = $result->json();  
201 - //兼容接口返回格式  
202 - if(!empty($res['data'][0]['status'])){  
203 - $res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;  
204 - !empty($res['data'][0]['msg']) && $res['message'] = $res['data'][0]['msg'];  
205 - }  
206 - if(empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200,300])){  
207 - $log->status = ReInquiryDetailLog::STATUS_FAIL;  
208 - $log->remark = mb_substr($res['message'] ?? '', 0, 200);  
209 - $log->save(); 169 + } elseif ($detail['type'] == 2) {
  170 + //商城询盘
  171 + $res = $this->ShopInquiry($detail, $log);
  172 + } elseif ($detail['type'] == 3) {
  173 + //Fob询盘
  174 + $res = $this->FobInquiry($detail, $log);
  175 + }
210 176
211 - Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]);  
212 - return false;  
213 - } 177 + if(!$res){
  178 + return false;
214 } 179 }
  180 +
215 $log->status = ReInquiryDetailLog::STATUS_SUCCESS; 181 $log->status = ReInquiryDetailLog::STATUS_SUCCESS;
216 $log->save(); 182 $log->save();
217 183
@@ -221,6 +187,102 @@ class postInquiry extends Command @@ -221,6 +187,102 @@ class postInquiry extends Command
221 return true; 187 return true;
222 } 188 }
223 189
  190 + public function v6Inquiry($detail, $log){
  191 + $website = 'https://' . $detail['re_website'] . '/';
  192 + $data = [
  193 + 'name' => $detail['name'],
  194 + 'phone' => $detail['phone'],
  195 + 'message' => $detail['message'],
  196 + 'submit_ip' => $detail['ip'],
  197 + 'refer' => $log->url,
  198 + ];
  199 + if ($detail->email) {
  200 + $data['email'] = $detail->email;
  201 + } else {
  202 + $data['__amp_source_origin'] = trim($website, '/');
  203 + }
  204 + $res = Http::withoutVerifying()->withHeaders(['User-Agent' => $detail['user_agent']])->post($website . 'api/inquiryQd/', $data)->json();
  205 + if (empty($res['code']) || $res['code'] != 200) {
  206 + $log->status = ReInquiryDetailLog::STATUS_FAIL;
  207 + $log->remark = mb_substr($res['message'] ?? '', 0, 200);
  208 + $log->save();
  209 + Log::channel('inquiry_relay')->error('inquiry_relay v6 inquiry error', [$res, $website . 'api/inquiryQd/', $data]);
  210 + return false;
  211 + }
  212 + return true;
  213 + }
  214 +
  215 + public function v5Inquiry($detail, $log){
  216 + $data = [
  217 + 'name' => $detail['name'],
  218 + 'phone' => $detail['phone'],
  219 + 'message' => $detail['message'],
  220 + 'email' => $detail['email'],
  221 + 'ip' => $detail['ip'],
  222 + 'token' => md5($log->url . $detail['name'] . $detail['ip'] . date("Y-m-d")),
  223 + 'refer' => $log->url,
  224 + 'submit_time' => date('Y-m-d H:i:s'),
  225 + 'source' => 5,
  226 + ];
  227 +
  228 + $result = Http::withoutVerifying()->post('https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data);
  229 + $res = $result->json();
  230 + //兼容接口返回格式
  231 + if (!empty($res['data'][0]['status'])) {
  232 + $res['data'][0]['code'] = $res['data'][0]['status'] == 'success' ? 200 : 400;
  233 + !empty($res['data'][0]['msg']) && $res['message'] = $res['data'][0]['msg'];
  234 + }
  235 + if (empty($res['data'][0]['code']) || !in_array($res['data'][0]['code'], [200, 300])) {
  236 + $log->status = ReInquiryDetailLog::STATUS_FAIL;
  237 + $log->remark = mb_substr($res['message'] ?? '', 0, 200);
  238 + $log->save();
  239 +
  240 + Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 inquiry error', [$result->body(), 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f', $data]);
  241 + return false;
  242 + }
  243 + return true;
  244 + }
  245 +
  246 + public function ShopInquiry($detail, $log){
  247 + $data = [
  248 + 'name' => $detail['name'],
  249 + 'email' => $detail['email'],
  250 + 'phone' => $detail['phone'],
  251 + 'message' => $detail['message'],
  252 + 'submit_ip' => $detail['ip'],
  253 + 'refer' => $log['url'],
  254 + ];
  255 + ksort($data);
  256 + $data['token'] = md5( json_encode($data, JSON_UNESCAPED_UNICODE ) . date("Y-m-d"));
  257 + $url = 'https://' . $detail['re_website'] . '/index.php?route=api/ai_inquiry/add';
  258 + $res = Http::withoutVerifying()->post($url, $data)->json();
  259 + if (empty($res['code']) || $res['code'] != 200) {
  260 + $log->status = ReInquiryDetailLog::STATUS_FAIL;
  261 + $log->remark = mb_substr($res['message'] ?? '', 0, 200);
  262 + $log->save();
  263 +
  264 + Log::channel('inquiry_relay')->error('inquiry_relay shop inquiry error', [$res, $url, $data]);
  265 + return false;
  266 + }
  267 + }
  268 +
  269 + public function FobInquiry($detail, $log){
  270 + $data = [
  271 + 'name' => $detail['name'],
  272 + 'email' => $detail['email'],
  273 + 'phone' => $detail['phone'],
  274 + 'post_id' => $log['url'],
  275 + ];
  276 + $res = Http::withoutVerifying()->post('https://fob.ai.cc/api/ad_to_scrm', $data)->json();
  277 + if (empty($res['code']) || $res['code'] != 200) {
  278 + $log->status = ReInquiryDetailLog::STATUS_FAIL;
  279 + $log->remark = mb_substr($res['message'] ?? '', 0, 200);
  280 + $log->save();
  281 +
  282 + Log::channel('inquiry_relay')->error('inquiry_relay fob inquiry error', [$res, 'https://fob.ai.cc/api/ad_to_scrm', $data]);
  283 + return false;
  284 + }
  285 + }
224 286
225 public function output($message) 287 public function output($message)
226 { 288 {
@@ -88,9 +88,9 @@ class SyncProject extends Command @@ -88,9 +88,9 @@ class SyncProject extends Command
88 if($data['data']['order_type'] == '首次'){ 88 if($data['data']['order_type'] == '首次'){
89 $this->sync($data['data'],$is_update); 89 $this->sync($data['data'],$is_update);
90 //同步aicc 90 //同步aicc
91 - if($data['data']['exclusive_aicc']){  
92 - $this->toAicc($data['data']);  
93 - } 91 +// if($data['data']['exclusive_aicc']){
  92 +// $this->toAicc($data['data']);
  93 +// }
94 //同步hagro 94 //同步hagro
95 if($data['data']['exclusive_hagro']){ 95 if($data['data']['exclusive_hagro']){
96 $this->toHagro($data['data']); 96 $this->toHagro($data['data']);
@@ -16,9 +16,11 @@ use App\Models\Com\KeywordVideoTask; @@ -16,9 +16,11 @@ use App\Models\Com\KeywordVideoTask;
16 use App\Models\Com\KeywordVideoTaskLog; 16 use App\Models\Com\KeywordVideoTaskLog;
17 use App\Models\CustomModule\CustomModuleCategory; 17 use App\Models\CustomModule\CustomModuleCategory;
18 use App\Models\CustomModule\CustomModuleContent; 18 use App\Models\CustomModule\CustomModuleContent;
  19 +use App\Models\CustomModule\CustomModuleExtentContent;
19 use App\Models\Devops\ServerConfig; 20 use App\Models\Devops\ServerConfig;
20 use App\Models\Devops\Servers; 21 use App\Models\Devops\Servers;
21 use App\Models\Devops\ServersIp; 22 use App\Models\Devops\ServersIp;
  23 +use App\Models\ExtentModule\ExtensionModuleValue;
22 use App\Models\File\File; 24 use App\Models\File\File;
23 use App\Models\File\File as FileModel; 25 use App\Models\File\File as FileModel;
24 use App\Models\File\Image; 26 use App\Models\File\Image;
@@ -62,14 +64,12 @@ class Demo extends Command @@ -62,14 +64,12 @@ class Demo extends Command
62 protected $description = 'demo'; 64 protected $description = 'demo';
63 65
64 public function handle(){ 66 public function handle(){
65 - $keywordVideoModel = new KeywordVideoTask();  
66 - $list = $keywordVideoModel->list();  
67 - foreach ($list as $v){  
68 - echo date('Y-m-d H:i:s') . 'project_id:'.$v['project_id'] . PHP_EOL;  
69 - ProjectServer::useProject($v['project_id']);  
70 - $this->getProduct(); 67 +
  68 + echo date('Y-m-d H:i:s') . 'project_id:' . PHP_EOL;
  69 + ProjectServer::useProject(2837);
  70 + $this->ceshi();
71 DB::disconnect('custom_mysql'); 71 DB::disconnect('custom_mysql');
72 - } 72 +
73 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 73 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
74 } 74 }
75 75
@@ -57,7 +57,7 @@ class UpdateRoute extends Command @@ -57,7 +57,7 @@ class UpdateRoute extends Command
57 */ 57 */
58 public function handle(){ 58 public function handle(){
59 $projectModel = new Project(); 59 $projectModel = new Project();
60 - $list = $projectModel->list(['id'=>['=',1423]]); 60 + $list = $projectModel->list(['id'=>['=',827]]);
61 $data = []; 61 $data = [];
62 foreach ($list as $v){ 62 foreach ($list as $v){
63 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 63 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
@@ -61,7 +61,7 @@ class FormGlobalsoApi @@ -61,7 +61,7 @@ class FormGlobalsoApi
61 'domain' => $domain, 61 'domain' => $domain,
62 'limit' => $page_size, 62 'limit' => $page_size,
63 'page' => $page, 63 'page' => $page,
64 - 'source' => $is_upgrade ? '1,2,3,4' : '1,3' //来源类型 新项目用1,3 64 + 'source' => $is_upgrade ? '1,2,3,4,5' : '1,3,5' //来源类型 新项目用1,3
65 ]; 65 ];
66 if($ids){ 66 if($ids){
67 $params['ids'] = implode(',', $ids); 67 $params['ids'] = implode(',', $ids);
@@ -175,7 +175,7 @@ class FormGlobalsoApi @@ -175,7 +175,7 @@ class FormGlobalsoApi
175 $data = [ 175 $data = [
176 'domain' => $domain, 176 'domain' => $domain,
177 'token' => $token, 177 'token' => $token,
178 - 'source'=> $is_upgrade ? '1,2,3,4' : '1,3', 178 + 'source'=> $is_upgrade ? '1,2,3,4,5' : '1,3,5',
179 'num'=>15, 179 'num'=>15,
180 ]; 180 ];
181 $queryString = http_build_query($data); 181 $queryString = http_build_query($data);
@@ -202,7 +202,7 @@ class FormGlobalsoApi @@ -202,7 +202,7 @@ class FormGlobalsoApi
202 $data = [ 202 $data = [
203 'domain' => $url, 203 'domain' => $url,
204 'token' => $token, 204 'token' => $token,
205 - 'source'=> $is_upgrade ? '1,2,3,4' : '1,3', 205 + 'source'=> $is_upgrade ? '1,2,3,4,5' : '1,3,5',
206 'model' => 'month', 206 'model' => 'month',
207 'sta_date'=>$month, 207 'sta_date'=>$month,
208 ]; 208 ];
@@ -23,6 +23,7 @@ use App\Utils\HttpUtils; @@ -23,6 +23,7 @@ use App\Utils\HttpUtils;
23 use GuzzleHttp\Exception\GuzzleException; 23 use GuzzleHttp\Exception\GuzzleException;
24 use Illuminate\Http\Request; 24 use Illuminate\Http\Request;
25 use Illuminate\Support\Facades\DB; 25 use Illuminate\Support\Facades\DB;
  26 +use Illuminate\Support\Facades\Http;
26 27
27 /** 28 /**
28 * Class AdsController 29 * Class AdsController
@@ -126,7 +127,9 @@ class AdsController extends BaseController @@ -126,7 +127,9 @@ class AdsController extends BaseController
126 public function setRelaySite(Request $request) 127 public function setRelaySite(Request $request)
127 { 128 {
128 $id = intval($request->input('id', 0)); 129 $id = intval($request->input('id', 0));
129 - $target = $request->input('target'); 130 + $target = $request->input('target', []);
  131 + $shop_site = $request->input('shop_site', []);
  132 + $fob_pro = $request->input('fob_pro', []);
130 $task = ReInquiryTask::find($id); 133 $task = ReInquiryTask::find($id);
131 if(!$task){ 134 if(!$task){
132 return $this->response('广告不存在!', Code::USER_ERROR, []); 135 return $this->response('广告不存在!', Code::USER_ERROR, []);
@@ -153,15 +156,42 @@ class AdsController extends BaseController @@ -153,15 +156,42 @@ class AdsController extends BaseController
153 if($is_require_num > $task->num){ 156 if($is_require_num > $task->num){
154 return $this->response('必选渠道不能大于转发数量!', Code::USER_ERROR, []); 157 return $this->response('必选渠道不能大于转发数量!', Code::USER_ERROR, []);
155 } 158 }
156 -  
157 foreach ($target as $v){ 159 foreach ($target as $v){
158 ReInquiryCount::addInquiryNum($id, $v['url'], 0); 160 ReInquiryCount::addInquiryNum($id, $v['url'], 0);
159 } 161 }
  162 +
  163 + //商城
  164 + foreach ($shop_site as &$url) {
  165 + if (empty($url)) {
  166 + return $this->response('商城网站域名不能为空!', Code::USER_ERROR, []);
  167 + }
  168 + $url = trim(str_replace(['http://', 'https://'], '', $url), '/');
  169 + $res = Http::get($url . '/index.php?route=api/ai_inquiry/add')->json();
  170 + if (!$res) {
  171 + return $this->response($url . '不是商城网站!', Code::USER_ERROR, []);
  172 + }
  173 + ReInquiryCount::addInquiryNum($id, $url, 0, 2);
  174 + }
  175 + //超级项目
  176 + foreach ($fob_pro as &$postid) {
  177 + if (empty($postid)) {
  178 + return $this->response('项目ID不能为空!', Code::USER_ERROR, []);
  179 + }
  180 + ReInquiryCount::addInquiryNum($id, $postid, 0, 3);
  181 + }
  182 +
160 $task->target = json_encode($target); 183 $task->target = json_encode($target);
  184 + $task->shop_site = json_encode($shop_site);
  185 + $task->fob_pro = json_encode($fob_pro);
161 $task->save(); 186 $task->save();
162 return $this->response('success', Code::SUCCESS, []); 187 return $this->response('success', Code::SUCCESS, []);
163 } 188 }
164 189
  190 + public function fob_projects(){
  191 + $res = ReInquiryCount::getFobProjects();
  192 + return $this->response('success', Code::SUCCESS, $res);
  193 + }
  194 +
165 /** 195 /**
166 * 验证站点5.0还是6.0, 代理商信息 196 * 验证站点5.0还是6.0, 代理商信息
167 * @param Request $request 197 * @param Request $request
@@ -12,8 +12,11 @@ namespace App\Http\Controllers\Bside; @@ -12,8 +12,11 @@ namespace App\Http\Controllers\Bside;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Logic\Bside\News\NewsLogic; 13 use App\Http\Logic\Bside\News\NewsLogic;
14 use App\Models\Channel\Channel; 14 use App\Models\Channel\Channel;
  15 +use App\Models\CustomModule\CustomModuleCategory;
15 use App\Models\CustomModule\CustomModuleContent; 16 use App\Models\CustomModule\CustomModuleContent;
  17 +use App\Models\CustomModule\CustomModuleExtentContent;
16 use App\Models\Domain\DomainInfo; 18 use App\Models\Domain\DomainInfo;
  19 +use App\Models\ExtentModule\ExtensionModuleValue;
17 use App\Models\Manage\ManageHr; 20 use App\Models\Manage\ManageHr;
18 use App\Models\Project\CountAllProject as AllProject; 21 use App\Models\Project\CountAllProject as AllProject;
19 use App\Models\Project\Project; 22 use App\Models\Project\Project;
@@ -31,139 +34,8 @@ class TestController extends BaseController @@ -31,139 +34,8 @@ class TestController extends BaseController
31 * @time :2024/11/11 14:51 34 * @time :2024/11/11 14:51
32 */ 35 */
33 public function ceshi(){ 36 public function ceshi(){
34 - $data = $this->NoSixProject();  
35 - $this->response('success',Code::SUCCESS,$data); 37 + $this->response('success',Code::SUCCESS,[]);
36 } 38 }
37 39
38 - public function NoSixProject(){  
39 - $res_data = [];  
40 -// $i = 1;  
41 -// while (true){  
42 - $url = 'https://quanqiusou.cn/extend_api/api/projects.php?page=1&pagesize=1';  
43 - $result = http_get($url);  
44 - $data = $result['data'];  
45 -// if(empty($data)){  
46 -// break;  
47 -// }  
48 -// $res_data = array_merge($res_data,$data['data']);  
49 -// $i++;  
50 -// }  
51 - return $data;  
52 - }  
53 -  
54 - public function SixProject(){  
55 - $projectModel = new Project();  
56 - $query = $projectModel->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')  
57 - ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')  
58 - ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')  
59 - ->where('gl_project.delete_status',Project::TYPE_ZERO);  
60 - $lists = $query->paginate(100000, $this->selectParam(), 'page', 1)->toArray();  
61 - $manageModel = new ManageHr();  
62 - foreach ($lists as $k => $v){  
63 - $allProjectModel = new AllProject();  
64 - $info = $allProjectModel->read(['version'=>1,'project_id'=>$v['id']],['id']);  
65 - if($info === false){  
66 - $channel = Channel::getChannelText($v['channel']['user_id'] ?? 0);  
67 - $data[] = [  
68 - 'project_id'=>$v['id'],  
69 - 'version'=>1,//代表6.0  
70 - 'is_upgrade'=>$v['is_upgrade'],  
71 - 'title'=>$v['title'],  
72 - 'company'=>$v['company'],  
73 - 'channel'=>$channel,  
74 - 'sale'=>$this->end_channel($channel),  
75 - 'join_date'=>$v['cooperate_date'],  
76 - 'online_date'=>$v['uptime'],  
77 - 'keywords_num'=>$v['key'],  
78 - 'service_num'=>$v['day'],  
79 - 'production_num'=>intval(abs(strtotime((empty($v['uptime']) ? date('Y-m-d H:i:s') : $v['uptime'])) - $v['created_at']) / 86400),  
80 - 'plan'=>Project::planMap()[$v['plan']],  
81 - 'status'=>$v['status'],  
82 - 'test_domain'=>$v['test_domain'],  
83 - 'product_domain'=>!empty($v['domain']) ? (new DomainInfo())->getDomain($v['domain']) : '',  
84 - 'project_manager'=>$manageModel->getName($v['manager_mid'] ?? ''),  
85 - 'project_group'=>$manageModel->getName($v['leader_mid'] ?? ''),  
86 - 'project_design'=>$manageModel->getName($v['designer_mid'] ?? ''),  
87 - 'project_assistant'=>$manageModel->getName($v['tech_mid'] ?? ''),  
88 - 'service_manager'=>$manageModel->getName($v['optimize_manager_mid'] ??''),  
89 - 'service_optimize'=>$manageModel->getName($v['optimize_optimist_mid'] ??''),  
90 - 'service_assistant'=>$manageModel->getName($v['optimize_assist_mid'] ??''),  
91 - 'qa'=>$manageModel->getName($v['quality_mid'] ??''),  
92 - ];  
93 - $allProjectModel->add($data);  
94 - }else{  
95 - $data_edit = [  
96 - 'title'=>$v['title'],  
97 - 'company'=>$v['company'],  
98 - 'channel'=>Channel::getChannelText($v['channel']['user_id'] ?? 0),  
99 - 'sale'=>$this->end_channel($channel),  
100 - 'join_date'=>$v['cooperate_date'],  
101 - 'online_date'=>$v['uptime'],  
102 - 'keywords_num'=>$v['key'],  
103 - 'service_num'=>$v['day'],  
104 - 'production_num'=>intval(abs(strtotime((empty($v['uptime']) ? date('Y-m-d H:i:s') : $v['uptime'])) - $v['created_at']) / 86400),  
105 - 'plan'=>Project::planMap()[$v['plan']],  
106 - 'status'=>$v['status'],  
107 - 'test_domain'=>$v['test_domain'],  
108 - 'product_domain'=>!empty($v['domain']) ? (new DomainInfo())->getDomain($v['domain']) : '',  
109 - 'project_manager'=>$manageModel->getName($v['manager_mid'] ?? ''),  
110 - 'project_group'=>$manageModel->getName($v['leader_mid'] ?? ''),  
111 - 'project_design'=>$manageModel->getName($v['designer_mid'] ?? ''),  
112 - 'project_assistant'=>$manageModel->getName($v['tech_mid'] ?? ''),  
113 - 'service_manager'=>$manageModel->getName($v['optimize_manager_mid'] ??''),  
114 - 'service_optimize'=>$manageModel->getName($v['optimize_optimist_mid'] ??''),  
115 - 'service_assistant'=>$manageModel->getName($v['optimize_assist_mid'] ??''),  
116 - 'qa'=>$manageModel->getName($v['quality_mid'] ??''),  
117 - ];  
118 - $allProjectModel->edit($data_edit,['id'=>$info['id']]);  
119 - }  
120 40
121 - }  
122 - }  
123 -  
124 - /**  
125 - * 需要查询的字段  
126 - * @return array  
127 - */  
128 - public function selectParam(){  
129 - $select = [  
130 - 'gl_project.id AS id',  
131 - 'gl_project.title AS title',  
132 - 'gl_project.channel AS channel',  
133 - 'gl_project.company AS company',  
134 - 'gl_project.type AS type',  
135 - 'gl_project.extend_type AS extend_type',  
136 - 'gl_project.uptime AS uptime',  
137 - 'gl_project.is_upgrade AS is_upgrade',  
138 - 'gl_project.created_at AS created_at',  
139 - 'gl_project.cooperate_date AS cooperate_date',  
140 - 'gl_project.site_status AS site_status',  
141 - 'gl_project_deploy_build.keyword_num AS key',  
142 - 'gl_project_deploy_build.service_duration AS day',  
143 - 'gl_project_deploy_build.is_comment AS is_comment',  
144 - 'gl_project_deploy_build.leader_mid AS leader_mid',  
145 - 'gl_project_deploy_build.manager_mid AS manager_mid',  
146 - 'gl_project_deploy_build.designer_mid AS designer_mid',  
147 - 'gl_project_deploy_build.tech_mid AS tech_mid',  
148 - 'gl_project_deploy_build.test_domain AS test_domain',  
149 - 'gl_project_deploy_build.plan AS plan',  
150 - 'gl_project_deploy_optimize.dept_id AS optimize_dept_id',  
151 - 'gl_project_deploy_optimize.manager_mid AS optimize_manager_mid',  
152 - 'gl_project_deploy_optimize.optimist_mid AS optimize_optimist_mid',  
153 - 'gl_project_deploy_optimize.assist_mid AS optimize_assist_mid',  
154 - 'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid',  
155 - 'gl_project_deploy_optimize.tech_leader AS tech_leader',  
156 - 'gl_project_deploy_optimize.domain AS domain',  
157 - 'gl_project_deploy_optimize.api_no AS api_no',  
158 - ];  
159 - return $select;  
160 - }  
161 -  
162 - public function end_channel($channel){  
163 - if(!empty($channel)){  
164 - $parts = explode("-", $channel);  
165 - return end($parts);  
166 - }  
167 - return $channel;  
168 - }  
169 } 41 }
@@ -234,8 +234,8 @@ class ImageController extends Controller @@ -234,8 +234,8 @@ class ImageController extends Controller
234 $tran_name = $tran_name[0]; 234 $tran_name = $tran_name[0];
235 } 235 }
236 $enName = generateRoute($tran_name); 236 $enName = generateRoute($tran_name);
237 - if(substr($enName, 0, 1) === '-'){  
238 - $enName = md5(uniqid().$project_id.rand(1,1000));; 237 + if(substr($enName, 0, 1) === '-' || empty($enName)){
  238 + $enName = md5(uniqid().$project_id.rand(1,1000));
239 } 239 }
240 $fileName = $enName; 240 $fileName = $enName;
241 $i=1; 241 $i=1;
@@ -360,6 +360,8 @@ class UserLoginLogic @@ -360,6 +360,8 @@ class UserLoginLogic
360 'data'=>$info 360 'data'=>$info
361 ]; 361 ];
362 } 362 }
  363 + Common::set_user_login(['user_id'=>$info['id'],'ip'=>request()->ip(),
  364 + 'project_id'=>$info['project_id'], 'type'=>2 ,'remark' => '自动登录,用户微信扫码']);
363 return $this->success($data); 365 return $this->success($data);
364 } 366 }
365 367
@@ -2,13 +2,16 @@ @@ -2,13 +2,16 @@
2 2
3 namespace App\Models\Inquiry; 3 namespace App\Models\Inquiry;
4 4
  5 +use App\Enums\Common\Code;
5 use App\Helper\Arr; 6 use App\Helper\Arr;
6 use App\Helper\QuanqiusouApi; 7 use App\Helper\QuanqiusouApi;
7 use App\Models\Base; 8 use App\Models\Base;
8 use App\Models\Domain\DomainInfo; 9 use App\Models\Domain\DomainInfo;
9 use App\Models\Project\Project; 10 use App\Models\Project\Project;
10 use App\Models\Task\TaskOwner; 11 use App\Models\Task\TaskOwner;
  12 +use App\Utils\HttpUtils;
11 use Illuminate\Database\Eloquent\Model; 13 use Illuminate\Database\Eloquent\Model;
  14 +use Illuminate\Support\Facades\Cache;
12 15
13 /** 16 /**
14 * Class ReInquiryCount 17 * Class ReInquiryCount
@@ -30,26 +33,37 @@ class ReInquiryCount extends Base @@ -30,26 +33,37 @@ class ReInquiryCount extends Base
30 * @author zbj 33 * @author zbj
31 * @date 2024/10/26 34 * @date 2024/10/26
32 */ 35 */
33 - public static function addInquiryNum($task_id, $domain, $num = 1) 36 + public static function addInquiryNum($task_id, $domain, $num = 1, $type = 1, $company = '')
34 { 37 {
35 $model = self::where('domain', $domain)->first(); 38 $model = self::where('domain', $domain)->first();
36 39
37 if (!$model) { 40 if (!$model) {
38 - //新增时获取公司名  
39 - $company = '';  
40 - $domain_info = DomainInfo::where('domain', $domain)->first();  
41 - if ($domain_info) {  
42 - $company = Project::where('id', $domain_info['project_id'])->value('company');  
43 - } else {  
44 - $res = (new QuanqiusouApi())->getV5Agent($domain);  
45 - if (!empty($res['status']) && $res['status'] == 200) {  
46 - $company = $res['company_name']; 41 + if($type == 1) {
  42 + //新增时获取公司名
  43 + $company = '';
  44 + $domain_info = DomainInfo::where('domain', $domain)->first();
  45 + if ($domain_info) {
  46 + $company = Project::where('id', $domain_info['project_id'])->value('company');
  47 + } else {
  48 + $res = (new QuanqiusouApi())->getV5Agent($domain);
  49 + if (!empty($res['status']) && $res['status'] == 200) {
  50 + $company = $res['company_name'];
  51 + }
47 } 52 }
48 } 53 }
  54 + if($type == 2){
  55 + $company = $domain;
  56 + }
  57 + if($type == 3){
  58 + $fob_list = self::getFobProjects();
  59 + $fob = collect($fob_list)->where('postid', $domain)->first();
  60 + $company = $fob['company'] . ' - ' . $fob['plan'];
  61 + }
49 62
50 $model = new self(); 63 $model = new self();
51 $model->domain = $domain; 64 $model->domain = $domain;
52 $model->company = $company; 65 $model->company = $company;
  66 + $model->type = $type;
53 } 67 }
54 $model->task_ids = $model->task_ids + [$task_id]; 68 $model->task_ids = $model->task_ids + [$task_id];
55 $model->num = $model->num + $num; 69 $model->num = $model->num + $num;
@@ -78,4 +92,15 @@ class ReInquiryCount extends Base @@ -78,4 +92,15 @@ class ReInquiryCount extends Base
78 } 92 }
79 return $tasks; 93 return $tasks;
80 } 94 }
  95 +
  96 + public static function getFobProjects(){
  97 + $cache_key = 'GET_BIND_PROJECT_LIST';
  98 + $res = Cache::get($cache_key);
  99 + if(!$res){
  100 + $res = HttpUtils::get('https://fob.ai.cc/api/get_bind_project_list', []);
  101 + $res = json_decode($res, true)['data'] ?? [];
  102 + Cache::put($cache_key, $res, 120);
  103 + }
  104 + return $res;
  105 + }
81 } 106 }
@@ -67,7 +67,7 @@ class ReInquiryDetail extends Model @@ -67,7 +67,7 @@ class ReInquiryDetail extends Model
67 * @return ReInquiryDetail 67 * @return ReInquiryDetail
68 */ 68 */
69 public static function createInquiry($task_id, $form_id, $re_website, $country, $ip, $name, $email, $phone, $message, $text_id, $device_port, 69 public static function createInquiry($task_id, $form_id, $re_website, $country, $ip, $name, $email, $phone, $message, $text_id, $device_port,
70 - $user_agent, $referrer, $urls, $is_v6, $start_at, $status = self::STATUS_INIT) 70 + $user_agent, $referrer, $urls, $is_v6, $start_at, $status = self::STATUS_INIT, $type = 1)
71 { 71 {
72 $self = new self(); 72 $self = new self();
73 $self->task_id = $task_id; 73 $self->task_id = $task_id;
@@ -88,6 +88,7 @@ class ReInquiryDetail extends Model @@ -88,6 +88,7 @@ class ReInquiryDetail extends Model
88 $self->num = count($urls) + 1; 88 $self->num = count($urls) + 1;
89 $self->start_at = $start_at; 89 $self->start_at = $start_at;
90 $self->status = $status; 90 $self->status = $status;
  91 + $self->type = $type;
91 $self->save(); 92 $self->save();
92 return $self; 93 return $self;
93 } 94 }
@@ -100,4 +101,4 @@ class ReInquiryDetail extends Model @@ -100,4 +101,4 @@ class ReInquiryDetail extends Model
100 { 101 {
101 return $this->hasMany(ReInquiryDetailLog::class, 'detail_id', 'id'); 102 return $this->hasMany(ReInquiryDetailLog::class, 'detail_id', 'id');
102 } 103 }
103 -}  
  104 +}
@@ -105,6 +105,16 @@ How Much 写成 HM', @@ -105,6 +105,16 @@ How Much 写成 HM',
105 return $value; 105 return $value;
106 } 106 }
107 107
  108 + public function getShopSiteAttribute($value)
  109 + {
  110 + return $value ? json_decode($value, true) : [];
  111 + }
  112 +
  113 + public function getFobProAttribute($value)
  114 + {
  115 + return $value ? json_decode($value, true) : [];
  116 + }
  117 +
108 public function setAiParamAttribute($value) 118 public function setAiParamAttribute($value)
109 { 119 {
110 $this->attributes['ai_param'] = Arr::a2s($value); 120 $this->attributes['ai_param'] = Arr::a2s($value);
@@ -253,6 +253,11 @@ class SyncSubmitTaskService @@ -253,6 +253,11 @@ class SyncSubmitTaskService
253 throw new InquiryFilterException('测试环境过滤'); 253 throw new InquiryFilterException('测试环境过滤');
254 } 254 }
255 255
  256 + // 访问记录过滤测试环境
  257 + if ($type == SyncSubmitTask::TYPE_INQUIRY && FALSE !== strpos($domain, 'globalso.site') && !$project->is_record_test_inquiry) {
  258 + throw new InquiryFilterException('测试环境过滤');
  259 + }
  260 +
256 if($ip == "127.0.0.1"){ 261 if($ip == "127.0.0.1"){
257 throw new InquiryFilterException('127.0.0.1过滤'); 262 throw new InquiryFilterException('127.0.0.1过滤');
258 } 263 }
@@ -496,6 +496,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -496,6 +496,7 @@ Route::middleware(['aloginauth'])->group(function () {
496 Route::any('/fb_inquiry_chart', [Aside\Task\AdsController::class, 'fbInquiryChart'])->name('admin.fb_ads_inquiry_chart'); 496 Route::any('/fb_inquiry_chart', [Aside\Task\AdsController::class, 'fbInquiryChart'])->name('admin.fb_ads_inquiry_chart');
497 Route::any('/fb_relay_detail_list', [Aside\Task\AdsController::class, 'fbRelayDetail'])->name('admin.fb_ads_relay_detail_list'); 497 Route::any('/fb_relay_detail_list', [Aside\Task\AdsController::class, 'fbRelayDetail'])->name('admin.fb_ads_relay_detail_list');
498 Route::any('/fb_relay_count', [Aside\Task\AdsController::class, 'fbRelayCount'])->name('admin.fb_relay_count'); 498 Route::any('/fb_relay_count', [Aside\Task\AdsController::class, 'fbRelayCount'])->name('admin.fb_relay_count');
  499 + Route::any('/fob_projects', [Aside\Task\AdsController::class, 'fob_projects'])->name('admin.fob_projects');
499 }); 500 });
500 501
501 //统计所有项目相关 502 //统计所有项目相关