作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -34,7 +34,7 @@ class UpgradeCount extends Command @@ -34,7 +34,7 @@ class UpgradeCount extends Command
34 34
35 public function handle(){ 35 public function handle(){
36 $projectModel = new Project(); 36 $projectModel = new Project();
37 - $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0,'id'=>['<=',985]]); 37 + $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0,'id'=>['<=',550]]);
38 foreach ($list as $v) { 38 foreach ($list as $v) {
39 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; 39 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
40 ProjectServer::useProject($v['id']); 40 ProjectServer::useProject($v['id']);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpgradeProjectCount.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/1/8 9:03
  8 + */
  9 +
  10 +namespace App\Console\Commands\MonthlyCount;
  11 +
  12 +use App\Helper\FormGlobalsoApi;
  13 +use App\Models\Com\UpdateOldInfo;
  14 +use App\Models\Domain\DomainInfo;
  15 +use App\Models\HomeCount\MonthCount;
  16 +use App\Models\Project\Project;
  17 +use App\Models\Visit\Visit;
  18 +use App\Services\ProjectServer;
  19 +use Illuminate\Console\Command;
  20 +use Illuminate\Support\Facades\DB;
  21 +use App\Models\HomeCount\Count;
  22 +
  23 +class UpgradeCount extends Command
  24 +{
  25 + /**
  26 + * The name and signature of the console command.
  27 + *
  28 + * @var string
  29 + */
  30 + protected $signature = 'upgrade_month_count';
  31 +
  32 + /**
  33 + * The console command description.
  34 + *
  35 + * @var string
  36 + */
  37 + protected $description = '升级项目统计-月统计';
  38 +
  39 + public function handle(){
  40 + $projectModel = new Project();
  41 + $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0,'id'=>['<=',456]]);
  42 + foreach ($list as $v) {
  43 + $oldModel = new UpdateOldInfo();
  44 + $info = $oldModel->read(['project_id' => $v['id']]);
  45 + if ($info !== false) {
  46 + $url = $info['old_domain_online'];
  47 + }else{
  48 + continue;
  49 + }
  50 + ProjectServer::useProject($v['id']);
  51 + echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
  52 + $this->count($v['id'], $url);
  53 + DB::disconnect('custom_mysql');
  54 + }
  55 + }
  56 +
  57 + /**
  58 + * @remark :日统计记录
  59 + * @name :count
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2024/1/8 9:05
  63 + */
  64 + public function count($project_id,$url){
  65 + $list = DB::connection('custom_mysql')->table('gl_customer_visit')
  66 + ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
  67 + ->groupBy('month')->get()->toArray();
  68 + foreach ($list as $k=>$v){
  69 + $v = (array)$v;
  70 + if($v['month'] == date('Y-m')){
  71 + continue;
  72 + }
  73 + $monthCountModel = new MonthCount();
  74 + $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
  75 + // 获取当月开始时间
  76 + $start = date('Y-m-01', strtotime($v['month']));
  77 + // 获取当月结束时间
  78 + $end = date('Y-m-t', strtotime($v['month']));
  79 + $arr['project_id'] = $project_id;
  80 + $res = $this->inquiry($url,$v['month']);
  81 +// $arr['month_total'] = 0;
  82 + if(isset($res['data']['count'])){
  83 + echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
  84 + $arr['month_total'] = $res['data']['count'];
  85 + //获取上一个的count
  86 + $previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
  87 + $previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
  88 + if($previousInfo === false){
  89 + $arr['total'] = $arr['month_total'];
  90 + }else{
  91 + $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
  92 + }
  93 + }
  94 + if(isset($res['data']['data'])){
  95 + $arr['country'] = json_encode($res['data']['data']);
  96 + }
  97 + $arr['month'] = $v['month'];
  98 + $arr = $this->pv_ip($arr,$start,$end,$project_id);
  99 + $arr = $this->sourceCount($arr,$start,$end);
  100 + if($info === false){
  101 + $selectedDate = $start;
  102 + $firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month"));
  103 + $arr['created_at'] = $firstDayOfNextMonth;
  104 + $arr['updated_at'] = $firstDayOfNextMonth;
  105 +// echo date('Y-m-d H:i:s') . '数据:'.json_encode($arr) . PHP_EOL;
  106 + $monthCountModel->insert($arr);
  107 + }else{
  108 + $monthCountModel->edit($arr,['id'=>$info['id']]);
  109 + }
  110 + }
  111 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  112 + }
  113 +
  114 + /**
  115 + * @remark :本月询盘总量
  116 + * @name :month_total
  117 + * @author :lyh
  118 + * @method :post
  119 + * @time :2024/1/8 11:02
  120 + */
  121 + public function pv_ip(&$arr,$start,$end,$project_id){
  122 + $pv_ip = DB::table('gl_count')
  123 + ->where(['project_id'=>$project_id])
  124 + ->where('date','>=',$start.' 00:00:00')
  125 + ->where('date','<=',$end.' 23:59:59')
  126 + ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'),DB::raw('SUM(inquiry_num) as inquiry_num'))
  127 + ->first();
  128 + $arr['pv'] = $pv_ip->pv_num;
  129 + $arr['ip'] = $pv_ip->ip_num;
  130 + if($arr['ip'] != 0){
  131 + $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2);
  132 + }
  133 + return $arr;
  134 + }
  135 + /**
  136 + * @remark :来源访问前8
  137 + * @name :sourceCount
  138 + * @author :lyh
  139 + * @method :post
  140 + * @time :2023/6/30 16:14
  141 + */
  142 + public function sourceCount(&$arr,$startTime,$endTime){
  143 + //访问来源前10
  144 + $source = DB::connection('custom_mysql')->table('gl_customer_visit')
  145 + ->select('referrer_url', DB::raw('COUNT(*) as count'))
  146 + ->groupBy('referrer_url')
  147 + ->whereBetween('updated_date', [$startTime,$endTime])
  148 + ->orderByDesc('count')->limit(10)->get()->toArray();
  149 + $arr['source'] = json_encode($source);
  150 + //访问国家前15
  151 + $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
  152 + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
  153 + ->groupBy('country')
  154 + ->whereBetween('updated_date', [$startTime,$endTime])
  155 + ->orderBy('ip','desc')->limit(15)->get()->toArray();
  156 + $arr['source_country'] = json_encode($source_country);
  157 + //受访界面前15
  158 + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
  159 + ->select('url',DB::raw('COUNT(*) as num'))
  160 + ->orderBy('num','desc')
  161 + ->whereBetween('updated_date', [$startTime,$endTime])
  162 + ->groupBy('url')
  163 + ->limit(15)->get()->toArray();
  164 + $arr['referrer_url'] = json_encode($referrer_url);
  165 + //访问端口
  166 + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
  167 + ->select('device_port',DB::raw('COUNT(*) as num'))
  168 + ->orderBy('num','desc')
  169 + ->whereBetween('updated_date', [$startTime,$endTime])
  170 + ->groupBy('device_port')
  171 + ->limit(15)->get()->toArray();
  172 + $arr['referrer_port'] = json_encode($referrer_port);
  173 + return $arr;
  174 + }
  175 +
  176 + public function inquiry($url,$month){
  177 + $url = 'https://'.$url.'/';
  178 + $token = md5($url.date("Y-m-d"));
  179 + $url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain='.$url.'&token='.$token.'&source=1,2,3,4&model=month&sta_date='.$month;
  180 + $res = http_get($url,['charset=utf-8']);
  181 + echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
  182 + return $res;
  183 + }
  184 +
  185 +}
@@ -55,7 +55,7 @@ class UpdateRoute extends Command @@ -55,7 +55,7 @@ class UpdateRoute extends Command
55 */ 55 */
56 public function handle(){ 56 public function handle(){
57 $projectModel = new Project(); 57 $projectModel = new Project();
58 - $list = $projectModel->list(['id'=>264]); 58 + $list = $projectModel->list(['id'=>358]);
59 $data = []; 59 $data = [];
60 foreach ($list as $v){ 60 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
@@ -7,13 +7,16 @@ use App\Helper\Common; @@ -7,13 +7,16 @@ use App\Helper\Common;
7 use App\Helper\Gpt; 7 use App\Helper\Gpt;
8 use App\Helper\Translate; 8 use App\Helper\Translate;
9 use App\Models\Ai\AiCommand; 9 use App\Models\Ai\AiCommand;
  10 +use App\Models\Domain\DomainInfo;
10 use App\Models\Mail\Mail; 11 use App\Models\Mail\Mail;
  12 +use App\Models\Project\DeployBuild;
11 use App\Models\Project\DeployOptimize; 13 use App\Models\Project\DeployOptimize;
12 use App\Models\Project\ProjectUpdateTdk; 14 use App\Models\Project\ProjectUpdateTdk;
13 use App\Models\User\User; 15 use App\Models\User\User;
14 use App\Models\WebSetting\WebLanguage; 16 use App\Models\WebSetting\WebLanguage;
15 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
16 use Illuminate\Console\Command; 18 use Illuminate\Console\Command;
  19 +use Illuminate\Http\Request;
17 use Illuminate\Support\Facades\Cache; 20 use Illuminate\Support\Facades\Cache;
18 use Illuminate\Support\Facades\DB; 21 use Illuminate\Support\Facades\DB;
19 use Illuminate\Support\Facades\Redis; 22 use Illuminate\Support\Facades\Redis;
@@ -149,6 +152,8 @@ class UpdateSeoTdk extends Command @@ -149,6 +152,8 @@ class UpdateSeoTdk extends Command
149 try { 152 try {
150 $this->project = ProjectServer::useProject($project_id); 153 $this->project = ProjectServer::useProject($project_id);
151 $this->seo_tdk($project_id, $task->id); 154 $this->seo_tdk($project_id, $task->id);
  155 + //TODO::通知C端更新所有界面
  156 + $this->sendNotify($project_id);
152 DB::disconnect('custom_mysql'); 157 DB::disconnect('custom_mysql');
153 }catch (\Exception $e){ 158 }catch (\Exception $e){
154 echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; 159 echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
@@ -158,7 +163,30 @@ class UpdateSeoTdk extends Command @@ -158,7 +163,30 @@ class UpdateSeoTdk extends Command
158 echo date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL; 163 echo date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
159 } 164 }
160 } 165 }
161 - 166 + public function sendNotify($project_id)
  167 + {
  168 + //获取当前项目的域名
  169 + $domainModel = new DomainInfo();
  170 + $domainInfo = $domainModel->read(['project_id'=>$project_id]);
  171 + if($domainInfo === false){
  172 + //获取测试域名
  173 + $deployBuildModel = new DeployBuild();
  174 + $buildInfo = $deployBuildModel->read(['project_id'=>$project_id]);
  175 + $this->param['domain'] = $buildInfo['test_domain'];
  176 + }else{
  177 + $this->param['domain'] = 'https://'.$domainInfo['domain'].'/';
  178 + }
  179 + $url = $this->param['domain'].'api/update_page/';
  180 + $param = [
  181 + 'project_id' => $project_id,
  182 + 'type' => 1,
  183 + 'route' => 1,
  184 + 'url' => [],
  185 + 'language'=> [],
  186 + ];
  187 + http_post($url, json_encode($param));
  188 + echo '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
  189 + }
162 public function seo_tdk($project_id, $task_id) 190 public function seo_tdk($project_id, $task_id)
163 { 191 {
164 192
@@ -149,7 +149,7 @@ class WebTrafficRussia extends Command @@ -149,7 +149,7 @@ class WebTrafficRussia extends Command
149 * 概率值 149 * 概率值
150 * @var int[] 150 * @var int[]
151 */ 151 */
152 - protected $sjjg = [360, 640];//访问间隔占比 访问|不访问 比非俄语站降一 152 + protected $sjjg = [360, 640];//访问间隔占比 访问|不访问 比非俄语站降一
153 //访问页面类型占比 产品详情页、单页|产品分类页 153 //访问页面类型占比 产品详情页、单页|产品分类页
154 protected $ymzb = [ 154 protected $ymzb = [
155 'urls_cats' => 700, 155 'urls_cats' => 700,
@@ -53,7 +53,7 @@ class WebTrafficRussiaSpecial extends Command @@ -53,7 +53,7 @@ class WebTrafficRussiaSpecial extends Command
53 } 53 }
54 54
55 protected $projects = [ 55 protected $projects = [
56 - 969 => 30, 56 + 969 => 60,
57 ]; 57 ];
58 58
59 /** 59 /**
@@ -289,7 +289,7 @@ class WebTrafficRussiaSpecial extends Command @@ -289,7 +289,7 @@ class WebTrafficRussiaSpecial extends Command
289 'referrer_url' => $this->getReferer($ips[$project_key]['ip_area'], $project['lang']), 289 'referrer_url' => $this->getReferer($ips[$project_key]['ip_area'], $project['lang']),
290 'user_agent' => $project['user_agent'], 290 'user_agent' => $project['user_agent'],
291 ]; 291 ];
292 - Log::channel('traffic')->info('ru_traffic project_id:' . $project['project_id'], $data); 292 + Log::channel('traffic')->info('ru_traffic_special project_id:' . $project['project_id'], $data);
293 $promises[] = $client->postAsync($project['domain'] . 'api/traffic_visit', ['form_params' => $data]); 293 $promises[] = $client->postAsync($project['domain'] . 'api/traffic_visit', ['form_params' => $data]);
294 } 294 }
295 295
@@ -58,6 +58,25 @@ class SyncSubmitTaskService @@ -58,6 +58,25 @@ class SyncSubmitTaskService
58 58
59 59
60 /** 60 /**
  61 + * 特殊处理项目 去掉来源url的全部参数
  62 + */
  63 + public function handle_referer($referer){
  64 + $url = [
  65 + 'www.shphe.ru',
  66 + 'www.mainpaper.ru',
  67 + 'www.jinbiao.ru',
  68 + 'www.gyhockey.ru',
  69 + ];
  70 +
  71 + if(Str::contains($referer, $url)){
  72 + $referer = pathinfo($referer,PATHINFO_DIRNAME);
  73 + }
  74 + return $referer;
  75 + }
  76 +
  77 +
  78 +
  79 + /**
61 * 询盘 80 * 询盘
62 * @param $data 81 * @param $data
63 * @return bool 82 * @return bool
@@ -75,6 +94,8 @@ class SyncSubmitTaskService @@ -75,6 +94,8 @@ class SyncSubmitTaskService
75 94
76 $form_id = InquiryForm::getFromId($data['data']); 95 $form_id = InquiryForm::getFromId($data['data']);
77 96
  97 + $data['referer'] = $this->handle_referer($data['referer']);
  98 +
78 InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']); 99 InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']);
79 100
80 //转化询盘 101 //转化询盘
@@ -102,7 +123,7 @@ class SyncSubmitTaskService @@ -102,7 +123,7 @@ class SyncSubmitTaskService
102 $referrer_url = $url_arr['scheme'] . '://' . $url_arr['host'] . '/'; 123 $referrer_url = $url_arr['scheme'] . '://' . $url_arr['host'] . '/';
103 } 124 }
104 } 125 }
105 - $visit_data['referrer_url'] = $referrer_url; 126 + $visit_data['referrer_url'] = $this->handle_referer($referrer_url);
106 $visit_data['device_port'] = $data['data']['device_port']??''; 127 $visit_data['device_port'] = $data['data']['device_port']??'';
107 $visit_data['url'] = $data['data']['url']??''; 128 $visit_data['url'] = $data['data']['url']??'';
108 $visit_data['domain'] = $data['domain']??''; 129 $visit_data['domain'] = $data['domain']??'';