作者 刘锟

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

@@ -5,6 +5,7 @@ namespace App\Console\Commands\DayCount; @@ -5,6 +5,7 @@ namespace App\Console\Commands\DayCount;
5 use App\Helper\Common; 5 use App\Helper\Common;
6 use App\Helper\FormGlobalsoApi; 6 use App\Helper\FormGlobalsoApi;
7 use App\Models\Domain\DomainInfo; 7 use App\Models\Domain\DomainInfo;
  8 +use App\Models\Inquiry\InquiryForm;
8 use App\Models\Inquiry\InquiryFormData; 9 use App\Models\Inquiry\InquiryFormData;
9 use App\Models\Project\DeployBuild; 10 use App\Models\Project\DeployBuild;
10 use App\Models\Project\DeployOptimize; 11 use App\Models\Project\DeployOptimize;
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -9,6 +9,8 @@ @@ -9,6 +9,8 @@
9 9
10 namespace App\Console\Commands\DayCount; 10 namespace App\Console\Commands\DayCount;
11 11
  12 +use App\Helper\FormGlobalsoApi;
  13 +use App\Models\Inquiry\InquiryFormData;
12 use App\Models\Project\Project; 14 use App\Models\Project\Project;
13 use App\Models\Visit\Visit; 15 use App\Models\Visit\Visit;
14 use App\Services\ProjectServer; 16 use App\Services\ProjectServer;
@@ -16,14 +18,15 @@ use Illuminate\Console\Command; @@ -16,14 +18,15 @@ use Illuminate\Console\Command;
16 use Illuminate\Support\Facades\DB; 18 use Illuminate\Support\Facades\DB;
17 use App\Models\HomeCount\Count; 19 use App\Models\HomeCount\Count;
18 20
19 -class UpgradeCount extends Command 21 +class CountAll extends Command
20 { 22 {
  23 +
21 /** 24 /**
22 * The name and signature of the console command. 25 * The name and signature of the console command.
23 * 26 *
24 * @var string 27 * @var string
25 */ 28 */
26 - protected $signature = 'upgrade_counts'; 29 + protected $signature = 'count_all';
27 30
28 /** 31 /**
29 * The console command description. 32 * The console command description.
@@ -34,7 +37,7 @@ class UpgradeCount extends Command @@ -34,7 +37,7 @@ class UpgradeCount extends Command
34 37
35 public function handle(){ 38 public function handle(){
36 $projectModel = new Project(); 39 $projectModel = new Project();
37 - $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]); 40 + $list = $projectModel->list(['delete_status'=>0]);
38 foreach ($list as $v) { 41 foreach ($list as $v) {
39 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; 42 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
40 ProjectServer::useProject($v['id']); 43 ProjectServer::useProject($v['id']);
@@ -90,6 +93,52 @@ class UpgradeCount extends Command @@ -90,6 +93,52 @@ class UpgradeCount extends Command
90 } 93 }
91 94
92 /** 95 /**
  96 + * @param $arr
  97 + * @param $domain
  98 + * @name :(询盘统计)inquiry
  99 + * @author :lyh
  100 + * @method :post
  101 + * @time :2023/6/14 15:44
  102 + */
  103 + public function inquiry($arr,$domain,$project_id){
  104 + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
  105 + if($inquiry_list == false){
  106 + return false;
  107 + }
  108 + if($inquiry_list['status'] == self::STATUS_ERROR){
  109 + $arr['inquiry_num'] = 0;
  110 + $countryArr = [];
  111 + }else{
  112 + $arr['inquiry_num'] = $inquiry_list['data']['total'];
  113 + //询盘国家统计
  114 + $countryData = $inquiry_list['data']['data'];
  115 + $countryArr = [];
  116 + foreach ($countryData as $v1){
  117 + if(isset($countryArr[$v1['country']])){
  118 + $countryArr[$v1['country']]++;
  119 + }else{
  120 + $countryArr[$v1['country']] = 1;
  121 + }
  122 + }
  123 + }
  124 + //加上其他询盘
  125 + ProjectServer::useProject($project_id);
  126 + $arr['inquiry_num'] += InquiryFormData::getCount();
  127 + $countryData = InquiryFormData::getCountryCount();
  128 + foreach ($countryData as $v1){
  129 + if(isset($countryArr[$v1['country']])){
  130 + $countryArr[$v1['country']] += $v1['count'];
  131 + }else{
  132 + $countryArr[$v1['country']] = $v1['count'];
  133 + }
  134 + }
  135 + arsort($countryArr);
  136 + $top20 = array_slice($countryArr, 0, 20, true);
  137 + $arr['country'] = json_encode($top20);
  138 + return $arr;
  139 + }
  140 +
  141 + /**
93 * @remark :询盘数量 142 * @remark :询盘数量
94 * @name :inquiry_num 143 * @name :inquiry_num
95 * @author :lyh 144 * @author :lyh
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -9,6 +9,10 @@ @@ -9,6 +9,10 @@
9 9
10 namespace App\Console\Commands\DayCount; 10 namespace App\Console\Commands\DayCount;
11 11
  12 +use App\Helper\FormGlobalsoApi;
  13 +use App\Models\Domain\DomainInfo;
  14 +use App\Models\Inquiry\InquiryFormData;
  15 +use App\Models\Project\DeployOptimize;
12 use App\Models\Project\Project; 16 use App\Models\Project\Project;
13 use App\Models\Visit\Visit; 17 use App\Models\Visit\Visit;
14 use App\Services\ProjectServer; 18 use App\Services\ProjectServer;
@@ -16,14 +20,16 @@ use Illuminate\Console\Command; @@ -16,14 +20,16 @@ use Illuminate\Console\Command;
16 use Illuminate\Support\Facades\DB; 20 use Illuminate\Support\Facades\DB;
17 use App\Models\HomeCount\Count; 21 use App\Models\HomeCount\Count;
18 22
19 -class UpgradeProjectCount extends Command 23 +class CountProject extends Command
20 { 24 {
  25 + const STATUS_ERROR = 400;
  26 + public $error = 0;
21 /** 27 /**
22 * The name and signature of the console command. 28 * The name and signature of the console command.
23 * 29 *
24 * @var string 30 * @var string
25 */ 31 */
26 - protected $signature = 'upgrade_count {project_id}'; 32 + protected $signature = 'count_project {project_id}';
27 33
28 /** 34 /**
29 * The console command description. 35 * The console command description.
@@ -51,6 +57,19 @@ class UpgradeProjectCount extends Command @@ -51,6 +57,19 @@ class UpgradeProjectCount extends Command
51 ->groupBy('updated_date')->get()->toArray(); 57 ->groupBy('updated_date')->get()->toArray();
52 $project = new Project(); 58 $project = new Project();
53 $projectInfo = $project->read(['id'=>$project_id]); 59 $projectInfo = $project->read(['id'=>$project_id]);
  60 + $projectOptimizeModel = new DeployOptimize();
  61 + $optimizeInfo = $projectOptimizeModel->read(['project_id'=>$project_id]);
  62 + $domain = '';
  63 + if(!empty($optimizeInfo['domain'])){
  64 + $domainInfoModel = new DomainInfo();
  65 + $domainInfo = $domainInfoModel->read(['id'=>$optimizeInfo['domain']]);
  66 + if($domainInfo !== false){
  67 + $domain = $domainInfo['domain'];
  68 + }
  69 + }
  70 + if(empty($domain)){
  71 + return false;
  72 + }
54 if(!empty($list)){ 73 if(!empty($list)){
55 $arr = []; 74 $arr = [];
56 foreach ($list as $k=>$v){ 75 foreach ($list as $k=>$v){
@@ -64,12 +83,11 @@ class UpgradeProjectCount extends Command @@ -64,12 +83,11 @@ class UpgradeProjectCount extends Command
64 $arr['date'] = $v['updated_date']; 83 $arr['date'] = $v['updated_date'];
65 $arr['pv_num'] = $this->pv_num($v['updated_date']); 84 $arr['pv_num'] = $this->pv_num($v['updated_date']);
66 $arr['ip_num'] = $this->ip_num($v['updated_date']); 85 $arr['ip_num'] = $this->ip_num($v['updated_date']);
67 - $arr['inquiry_num'] = $this->inquiry_num($v['updated_date']);  
68 //服务达标天数 86 //服务达标天数
69 $arr['compliance_day'] = $projectInfo['finish_remain_day']; 87 $arr['compliance_day'] = $projectInfo['finish_remain_day'];
70 //剩余服务时常 88 //剩余服务时常
71 $arr['service_day'] = $projectInfo['remain_day']; 89 $arr['service_day'] = $projectInfo['remain_day'];
72 - $arr['country'] = json_encode([]); 90 + $arr = $this->inquiry($arr,$domain, $project_id);
73 //查询当天数据是否存在 存在则更新 91 //查询当天数据是否存在 存在则更新
74 $info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]); 92 $info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]);
75 if($info === false){ 93 if($info === false){
@@ -103,7 +121,6 @@ class UpgradeProjectCount extends Command @@ -103,7 +121,6 @@ class UpgradeProjectCount extends Command
103 * @time :2023/6/14 15:40 121 * @time :2023/6/14 15:40
104 */ 122 */
105 public function pv_num($day){ 123 public function pv_num($day){
106 - //$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count();  
107 $pv = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->sum('depth'); 124 $pv = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->sum('depth');
108 return $pv; 125 return $pv;
109 } 126 }
@@ -119,6 +136,50 @@ class UpgradeProjectCount extends Command @@ -119,6 +136,50 @@ class UpgradeProjectCount extends Command
119 return $ip; 136 return $ip;
120 } 137 }
121 138
122 - 139 + /**
  140 + * @param $arr
  141 + * @param $domain
  142 + * @name :(询盘统计)inquiry
  143 + * @author :lyh
  144 + * @method :post
  145 + * @time :2023/6/14 15:44
  146 + */
  147 + public function inquiry($arr,$domain,$project_id){
  148 + $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
  149 + if($inquiry_list == false){
  150 + return false;
  151 + }
  152 + if($inquiry_list['status'] == self::STATUS_ERROR){
  153 + $arr['inquiry_num'] = 0;
  154 + $countryArr = [];
  155 + }else{
  156 + $arr['inquiry_num'] = $inquiry_list['data']['total'];
  157 + //询盘国家统计
  158 + $countryData = $inquiry_list['data']['data'];
  159 + $countryArr = [];
  160 + foreach ($countryData as $v1){
  161 + if(isset($countryArr[$v1['country']])){
  162 + $countryArr[$v1['country']]++;
  163 + }else{
  164 + $countryArr[$v1['country']] = 1;
  165 + }
  166 + }
  167 + }
  168 + //加上其他询盘
  169 + ProjectServer::useProject($project_id);
  170 + $arr['inquiry_num'] += InquiryFormData::getCount();
  171 + $countryData = InquiryFormData::getCountryCount();
  172 + foreach ($countryData as $v1){
  173 + if(isset($countryArr[$v1['country']])){
  174 + $countryArr[$v1['country']] += $v1['count'];
  175 + }else{
  176 + $countryArr[$v1['country']] = $v1['count'];
  177 + }
  178 + }
  179 + arsort($countryArr);
  180 + $top20 = array_slice($countryArr, 0, 20, true);
  181 + $arr['country'] = json_encode($top20);
  182 + return $arr;
  183 + }
123 184
124 } 185 }
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi; @@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi;
13 use App\Models\Com\UpdateOldInfo; 13 use App\Models\Com\UpdateOldInfo;
14 use App\Models\Domain\DomainInfo; 14 use App\Models\Domain\DomainInfo;
15 use App\Models\HomeCount\MonthCount; 15 use App\Models\HomeCount\MonthCount;
  16 +use App\Models\Inquiry\InquiryFormData;
16 use App\Models\Project\Project; 17 use App\Models\Project\Project;
17 use App\Models\Visit\Visit; 18 use App\Models\Visit\Visit;
18 use App\Services\ProjectServer; 19 use App\Services\ProjectServer;
@@ -20,14 +21,14 @@ use Illuminate\Console\Command; @@ -20,14 +21,14 @@ use Illuminate\Console\Command;
20 use Illuminate\Support\Facades\DB; 21 use Illuminate\Support\Facades\DB;
21 use App\Models\HomeCount\Count; 22 use App\Models\HomeCount\Count;
22 23
23 -class UpgradeCount extends Command 24 +class MonthAllCount extends Command
24 { 25 {
25 /** 26 /**
26 * The name and signature of the console command. 27 * The name and signature of the console command.
27 * 28 *
28 * @var string 29 * @var string
29 */ 30 */
30 - protected $signature = 'upgrade_month_counts'; 31 + protected $signature = 'month_all';
31 32
32 /** 33 /**
33 * The console command description. 34 * The console command description.
@@ -38,14 +39,23 @@ class UpgradeCount extends Command @@ -38,14 +39,23 @@ class UpgradeCount extends Command
38 39
39 public function handle(){ 40 public function handle(){
40 $projectModel = new Project(); 41 $projectModel = new Project();
41 - $list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]); 42 + $list = $projectModel->list(['delete_status'=>0]);
42 foreach ($list as $v) { 43 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']; 44 + if($v['is_upgrade'] == 1){
  45 + $oldModel = new UpdateOldInfo();
  46 + $info = $oldModel->read(['project_id' => $v['id']]);
  47 + if ($info !== false) {
  48 + $url = $info['old_domain_online'];
  49 + }else{
  50 + continue;
  51 + }
47 }else{ 52 }else{
48 - continue; 53 + $domainModel = new DomainInfo();
  54 + $info = $domainModel->read(['project_id'=>$v['id']]);
  55 + if($info === false){
  56 + continue;
  57 + }
  58 + $url = $info['domain'];
49 } 59 }
50 ProjectServer::useProject($v['id']); 60 ProjectServer::useProject($v['id']);
51 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL; 61 echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
@@ -78,7 +88,7 @@ class UpgradeCount extends Command @@ -78,7 +88,7 @@ class UpgradeCount extends Command
78 $end = date('Y-m-t', strtotime($v['month'])); 88 $end = date('Y-m-t', strtotime($v['month']));
79 $arr['project_id'] = $project_id; 89 $arr['project_id'] = $project_id;
80 $res = $this->inquiry($url,$v['month']); 90 $res = $this->inquiry($url,$v['month']);
81 -// $arr['month_total'] = 0; 91 + $arr['total'] = 0;
82 if(isset($res['data']['count'])){ 92 if(isset($res['data']['count'])){
83 echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL; 93 echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
84 $arr['month_total'] = $res['data']['count']; 94 $arr['month_total'] = $res['data']['count'];
@@ -91,9 +101,21 @@ class UpgradeCount extends Command @@ -91,9 +101,21 @@ class UpgradeCount extends Command
91 $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); 101 $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
92 } 102 }
93 } 103 }
  104 + //获取当月的其他询盘
  105 + $arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
  106 + $country = [];
94 if(isset($res['data']['data'])){ 107 if(isset($res['data']['data'])){
95 - $arr['country'] = json_encode($res['data']['data']); 108 + $country = $res['data']['data'];
  109 + }
  110 + $countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']);
  111 + foreach ($countryData as $v1){
  112 + if(isset($country[$v1['country']])){
  113 + $country[$v1['country']] += $v1['count'];
  114 + }else{
  115 + $country[$v1['country']] = $v1['count'];
  116 + }
96 } 117 }
  118 + $arr['country'] = json_encode($country);
97 $arr['month'] = $v['month']; 119 $arr['month'] = $v['month'];
98 $arr = $this->pv_ip($arr,$start,$end,$project_id); 120 $arr = $this->pv_ip($arr,$start,$end,$project_id);
99 $arr = $this->sourceCount($arr,$start,$end); 121 $arr = $this->sourceCount($arr,$start,$end);
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -11,6 +11,7 @@ namespace App\Console\Commands\MonthlyCount; @@ -11,6 +11,7 @@ namespace App\Console\Commands\MonthlyCount;
11 11
12 use App\Models\Com\UpdateOldInfo; 12 use App\Models\Com\UpdateOldInfo;
13 use App\Models\Domain\DomainInfo; 13 use App\Models\Domain\DomainInfo;
  14 +use App\Models\Inquiry\InquiryFormData;
14 use App\Models\Project\Project; 15 use App\Models\Project\Project;
15 use App\Services\ProjectServer; 16 use App\Services\ProjectServer;
16 use Illuminate\Console\Command; 17 use Illuminate\Console\Command;
@@ -98,44 +99,56 @@ class MonthCount extends Command @@ -98,44 +99,56 @@ class MonthCount extends Command
98 * @time :2024/1/8 9:05 99 * @time :2024/1/8 9:05
99 */ 100 */
100 public function count($project_id,$url){ 101 public function count($project_id,$url){
101 - $v = ['month'=>date('Y-m')];  
102 - $monthCountModel = new MonthCountModel();  
103 - $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);  
104 - // 获取当月开始时间  
105 - $start = date('Y-m-01', strtotime($v['month']));  
106 - // 获取当月结束时间  
107 - $end = date('Y-m-t', strtotime($v['month']));  
108 - $arr['project_id'] = $project_id;  
109 - $res = $this->inquiry($url,$v['month']); 102 + $v = ['month'=>date('Y-m')];
  103 + $monthCountModel = new MonthCountModel();
  104 + $info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
  105 + // 获取当月开始时间
  106 + $start = date('Y-m-01', strtotime($v['month']));
  107 + // 获取当月结束时间
  108 + $end = date('Y-m-t', strtotime($v['month']));
  109 + $arr['project_id'] = $project_id;
  110 + $res = $this->inquiry($url,$v['month']);
110 // $arr['month_total'] = 0; 111 // $arr['month_total'] = 0;
111 - if(isset($res['data']['count'])){  
112 - echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;  
113 - $arr['month_total'] = $res['data']['count'];  
114 - //获取上一个的count  
115 - $previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));  
116 - $previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);  
117 - if($previousInfo === false){  
118 - $arr['total'] = $arr['month_total'];  
119 - }else{  
120 - $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);  
121 - }  
122 - }  
123 - if(isset($res['data']['data'])){  
124 - $arr['country'] = json_encode($res['data']['data']); 112 + if(isset($res['data']['count'])){
  113 + echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
  114 + $arr['month_total'] = $res['data']['count'];
  115 + //获取上一个的count
  116 + $previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
  117 + $previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
  118 + if($previousInfo === false){
  119 + $arr['total'] = $arr['month_total'];
  120 + }else{
  121 + $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
125 } 122 }
126 - $arr['month'] = $v['month'];  
127 - $arr = $this->pv_ip($arr,$start,$end,$project_id);  
128 - $arr = $this->sourceCount($arr,$start,$end);  
129 - if($info === false){  
130 - $selectedDate = $start;  
131 - $firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month"));  
132 - $arr['created_at'] = $firstDayOfNextMonth;  
133 - $arr['updated_at'] = $firstDayOfNextMonth;  
134 -// echo date('Y-m-d H:i:s') . '数据:'.json_encode($arr) . PHP_EOL;  
135 - $monthCountModel->insert($arr); 123 + }
  124 + //获取当月的其他询盘
  125 + $arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
  126 + $country = [];
  127 + if(isset($res['data']['data'])){
  128 + $country = $res['data']['data'];
  129 + }
  130 + $countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']);
  131 + foreach ($countryData as $v1){
  132 + if(isset($country[$v1['country']])){
  133 + $country[$v1['country']] += $v1['count'];
136 }else{ 134 }else{
137 - $monthCountModel->edit($arr,['id'=>$info['id']]); 135 + $country[$v1['country']] = $v1['count'];
138 } 136 }
  137 + }
  138 + $arr['country'] = json_encode($country);
  139 + $arr['month'] = $v['month'];
  140 + $arr = $this->pv_ip($arr,$start,$end,$project_id);
  141 + $arr = $this->sourceCount($arr,$start,$end);
  142 + if($info === false){
  143 + $selectedDate = $start;
  144 + $firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month"));
  145 + $arr['created_at'] = $firstDayOfNextMonth;
  146 + $arr['updated_at'] = $firstDayOfNextMonth;
  147 +// echo date('Y-m-d H:i:s') . '数据:'.json_encode($arr) . PHP_EOL;
  148 + $monthCountModel->insert($arr);
  149 + }else{
  150 + $monthCountModel->edit($arr,['id'=>$info['id']]);
  151 + }
139 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 152 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
140 } 153 }
141 154
1 <?php 1 <?php
2 /** 2 /**
3 * @remark : 3 * @remark :
4 - * @name :UpgradeProjectCount.php 4 + * @name :CountProject.php
5 * @author :lyh 5 * @author :lyh
6 * @method :post 6 * @method :post
7 * @time :2024/1/8 9:03 7 * @time :2024/1/8 9:03
@@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi; @@ -13,6 +13,7 @@ use App\Helper\FormGlobalsoApi;
13 use App\Models\Com\UpdateOldInfo; 13 use App\Models\Com\UpdateOldInfo;
14 use App\Models\Domain\DomainInfo; 14 use App\Models\Domain\DomainInfo;
15 use App\Models\HomeCount\MonthCount; 15 use App\Models\HomeCount\MonthCount;
  16 +use App\Models\Inquiry\InquiryFormData;
16 use App\Models\Project\Project; 17 use App\Models\Project\Project;
17 use App\Models\Visit\Visit; 18 use App\Models\Visit\Visit;
18 use App\Services\ProjectServer; 19 use App\Services\ProjectServer;
@@ -20,14 +21,14 @@ use Illuminate\Console\Command; @@ -20,14 +21,14 @@ use Illuminate\Console\Command;
20 use Illuminate\Support\Facades\DB; 21 use Illuminate\Support\Facades\DB;
21 use App\Models\HomeCount\Count; 22 use App\Models\HomeCount\Count;
22 23
23 -class UpgradeProjectCount extends Command 24 +class MonthProjectCount extends Command
24 { 25 {
25 /** 26 /**
26 * The name and signature of the console command. 27 * The name and signature of the console command.
27 * 28 *
28 * @var string 29 * @var string
29 */ 30 */
30 - protected $signature = 'upgrade_month_count {project_id}'; 31 + protected $signature = 'month_project {project_id}';
31 32
32 /** 33 /**
33 * The console command description. 34 * The console command description.
@@ -89,9 +90,21 @@ class UpgradeProjectCount extends Command @@ -89,9 +90,21 @@ class UpgradeProjectCount extends Command
89 $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0); 90 $arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
90 } 91 }
91 } 92 }
  93 + //获取当月的其他询盘
  94 + $arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
  95 + $country = [];
92 if(isset($res['data']['data'])){ 96 if(isset($res['data']['data'])){
93 - $arr['country'] = json_encode($res['data']['data']); 97 + $country = $res['data']['data'];
94 } 98 }
  99 + $countryData = InquiryFormData::getCountryCount([$start.' 00:00:00',$end.' 00:00:00']);
  100 + foreach ($countryData as $v1){
  101 + if(isset($country[$v1['country']])){
  102 + $country[$v1['country']] += $v1['count'];
  103 + }else{
  104 + $country[$v1['country']] = $v1['count'];
  105 + }
  106 + }
  107 + $arr['country'] = json_encode($country);
95 $arr['month'] = $v['month']; 108 $arr['month'] = $v['month'];
96 $arr = $this->pv_ip($arr,$start,$end,$project_id); 109 $arr = $this->pv_ip($arr,$start,$end,$project_id);
97 $arr = $this->sourceCount($arr,$start,$end); 110 $arr = $this->sourceCount($arr,$start,$end);
@@ -28,23 +28,15 @@ class SyncSubmitTask extends Command @@ -28,23 +28,15 @@ class SyncSubmitTask extends Command
28 28
29 public function handle() 29 public function handle()
30 { 30 {
31 - $backup = false;  
32 while (true) { 31 while (true) {
33 - $task_id = $this->getTaskId();  
34 - if ($task_id > 2000000) {  
35 - $backup = true;  
36 - }  
37 - if (empty($task_id)) {  
38 - if ($backup) {  
39 - $this->backup();  
40 - $backup = false;  
41 - }  
42 - sleep(5); 32 + $task_id = Redis::rpop('sync_submit_task');
  33 + if(!$task_id){
  34 + sleep(3);
43 continue; 35 continue;
44 } 36 }
45 $this->output('任务' . $task_id . '开始'); 37 $this->output('任务' . $task_id . '开始');
46 $task_info = SyncSubmitTaskModel::find($task_id); 38 $task_info = SyncSubmitTaskModel::find($task_id);
47 - if (empty($task_info) || $task_info->status) { 39 + if (empty($task_info) || $task_info->status !=3) {
48 $this->output('任务不存在或者已执行'); 40 $this->output('任务不存在或者已执行');
49 continue; 41 continue;
50 } 42 }
@@ -79,29 +71,6 @@ class SyncSubmitTask extends Command @@ -79,29 +71,6 @@ class SyncSubmitTask extends Command
79 } 71 }
80 } 72 }
81 73
82 - public function getTaskId()  
83 - {  
84 - $task_id = Redis::rpop('sync_submit_task');  
85 - $lockKey = 'lock_sync_submit_task';  
86 - if (empty($task_id)) {  
87 - // 获取锁  
88 - if (Redis::setnx($lockKey, 1)) {  
89 - // 设置锁的过期时间,防止死锁  
90 - Redis::expire($lockKey, 10);  
91 - $ids = SyncSubmitTaskModel::where('status', 0)->limit(100)->pluck('id');  
92 - foreach ($ids as $id) {  
93 - Redis::lpush('sync_submit_task', $id);  
94 - }  
95 - $task_id = Redis::rpop('sync_submit_task');  
96 - Redis::del($lockKey);  
97 - } else {  
98 - // 未获取到锁  
99 - return '';  
100 - }  
101 - }  
102 - return $task_id;  
103 - }  
104 -  
105 /** 74 /**
106 * 输出处理日志 75 * 输出处理日志
107 */ 76 */
@@ -110,31 +79,4 @@ class SyncSubmitTask extends Command @@ -110,31 +79,4 @@ class SyncSubmitTask extends Command
110 echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; 79 echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
111 return true; 80 return true;
112 } 81 }
113 -  
114 - /**  
115 - * 备份数据  
116 - * @author zbj  
117 - * @date 2024/1/23  
118 - */  
119 - public function backup()  
120 - {  
121 - DB::beginTransaction();  
122 - try {  
123 - $table = (new SyncSubmitTaskModel())->getTable();  
124 - $new_table = $table . '_backup_' . date('Ymd');  
125 -  
126 - //重命名当前表  
127 - Schema::rename($table, $new_table);  
128 - //克隆表数据  
129 - DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table);  
130 -  
131 - DB::commit();  
132 -  
133 - $this->output('数据备份成功');  
134 - } catch (\Exception $e) {  
135 - $this->output('数据备份失败' . $e->getMessage());  
136 - DB::rollBack();  
137 - }  
138 - return true;  
139 - }  
140 } 82 }
  1 +<?php
  2 +
  3 +namespace App\Console\Commands\Sync;
  4 +
  5 +
  6 +use App\Exceptions\InquiryFilterException;
  7 +use App\Models\Project\Project;
  8 +use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel;
  9 +use App\Services\SyncSubmitTaskService;
  10 +use Illuminate\Console\Command;
  11 +use Illuminate\Support\Facades\Cache;
  12 +use Illuminate\Support\Facades\DB;
  13 +use Illuminate\Support\Facades\Redis;
  14 +use Illuminate\Support\Facades\Schema;
  15 +use Illuminate\Support\Str;
  16 +
  17 +/**
  18 + *
  19 + * Class SyncSubmitTask
  20 + * @package App\Console\Commands
  21 + * @author zbj
  22 + * @date 2023/11/28
  23 + */
  24 +class SyncSubmitTaskDistribution extends Command
  25 +{
  26 +
  27 + protected $signature = 'sync_submit_task_distribution';
  28 + protected $description = '询盘、访问异步任务分发';
  29 +
  30 + public function handle()
  31 + {
  32 + while (true) {
  33 + $len = Redis::llen('sync_submit_task');
  34 + if (!$len) {
  35 + $max_id = SyncSubmitTaskModel::orderBy('id', 'desc')->value('id');
  36 + if ($max_id > 2000000) {
  37 + $this->backup();
  38 + } else {
  39 + $tasks = SyncSubmitTaskModel::where('status', 0)->limit(100)->get();
  40 + foreach ($tasks as $task) {
  41 + $task->status = 3;
  42 + $task->save();
  43 + Redis::lpush('sync_submit_task', $task->id);
  44 + }
  45 + }
  46 + }
  47 + sleep(3);
  48 + }
  49 + }
  50 +
  51 + /**
  52 + * 输出处理日志
  53 + */
  54 + public function output($message): bool
  55 + {
  56 + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
  57 + return true;
  58 + }
  59 +
  60 + /**
  61 + * 备份数据
  62 + * @author zbj
  63 + * @date 2024/1/23
  64 + */
  65 + public function backup()
  66 + {
  67 + DB::beginTransaction();
  68 + try {
  69 + $table = (new SyncSubmitTaskModel())->getTable();
  70 + $new_table = $table . '_backup_' . date('Ymd');
  71 +
  72 + //重命名当前表
  73 + Schema::rename($table, $new_table);
  74 + //克隆表数据
  75 + DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table);
  76 +
  77 + //未入队的写到新表
  78 + $list = DB::table($new_table)->where('status', 0)->get();
  79 + $data = [];
  80 + foreach ($list as $task) {
  81 + $data[] = [
  82 + 'type' => $task->type,
  83 + 'data' => json_encode($task->data),
  84 + 'created_at' => $task['created_at'],
  85 + 'updated_at' => $task['updated_at'],
  86 + ];
  87 + }
  88 + $data && SyncSubmitTaskModel::insert($data);
  89 +
  90 + DB::commit();
  91 +
  92 + $this->output('数据备份成功');
  93 + } catch (\Exception $e) {
  94 + $this->output('数据备份失败' . $e->getMessage());
  95 + DB::rollBack();
  96 + }
  97 + return $new_table ?? '';
  98 + }
  99 +}
@@ -54,12 +54,13 @@ class UpdateRoute extends Command @@ -54,12 +54,13 @@ class UpdateRoute extends Command
54 */ 54 */
55 public function handle(){ 55 public function handle(){
56 $projectModel = new Project(); 56 $projectModel = new Project();
57 - $list = $projectModel->list(['id'=>['in',[1085]]]); 57 + $list = $projectModel->list(['id'=>['in',[664]]]);
58 $data = []; 58 $data = [];
59 foreach ($list as $v){ 59 foreach ($list as $v){
60 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 60 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
61 ProjectServer::useProject($v['id']); 61 ProjectServer::useProject($v['id']);
62 $this->getProduct(); 62 $this->getProduct();
  63 +// $this->setProductKeyword();
63 DB::disconnect('custom_mysql'); 64 DB::disconnect('custom_mysql');
64 } 65 }
65 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 66 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
@@ -106,19 +107,8 @@ class UpdateRoute extends Command @@ -106,19 +107,8 @@ class UpdateRoute extends Command
106 if(!empty($lists)){ 107 if(!empty($lists)){
107 foreach ($lists as $v){ 108 foreach ($lists as $v){
108 if(!empty($v['route'])){ 109 if(!empty($v['route'])){
109 -// $tag = "-tag";  
110 -// if ((substr($v['route'], -strlen($tag)) === $tag)) {  
111 -// echo date('Y-m-d H:i:s') . '拼接 :'.$v['id'] . PHP_EOL;  
112 -// $route = Translate::tran($v['route'], 'en').$tag;  
113 -// // 如果不是以 '-tag' 结尾,则拼接上 '-tag'  
114 -// $route = trim($v['route'],'-tag');  
115 -// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);  
116 -// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);  
117 -// }else{  
118 -// $route = Translate::tran($v['title'], 'en').$tag;  
119 -// $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);  
120 -// $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);  
121 -// } 110 + echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
  111 + continue;
122 }else{ 112 }else{
123 echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL; 113 echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
124 $route = Translate::tran($v['title'], 'en'); 114 $route = Translate::tran($v['title'], 'en');
@@ -128,7 +118,6 @@ class UpdateRoute extends Command @@ -128,7 +118,6 @@ class UpdateRoute extends Command
128 $keywordModel->edit(['route'=>$route],['id'=>$v['id']]); 118 $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
129 } 119 }
130 } 120 }
131 - echo date('Y-m-d H:i:s') . 'end :' . PHP_EOL;  
132 } 121 }
133 } 122 }
134 } 123 }
@@ -224,7 +213,7 @@ class UpdateRoute extends Command @@ -224,7 +213,7 @@ class UpdateRoute extends Command
224 213
225 public function getProduct(){ 214 public function getProduct(){
226 $productModel = new Product(); 215 $productModel = new Product();
227 - $lists = $productModel->list(['status'=>1]); 216 + $lists = $productModel->list(['status'=>1,'id'=>['<=',501]]);
228 if(!empty($lists)){ 217 if(!empty($lists)){
229 foreach ($lists as $v){ 218 foreach ($lists as $v){
230 if(!empty($v['route'])){ 219 if(!empty($v['route'])){
@@ -240,9 +229,10 @@ class UpdateRoute extends Command @@ -240,9 +229,10 @@ class UpdateRoute extends Command
240 // $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); 229 // $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
241 // $productModel->edit(['route'=>$route],['id'=>$v['id']]); 230 // $productModel->edit(['route'=>$route],['id'=>$v['id']]);
242 } 231 }
  232 + continue;
243 }else{ 233 }else{
244 echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL; 234 echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
245 -// $v['title'] = Translate::tran($v['title'], 'en'); 235 + $v['title'] = Translate::tran($v['title'], 'en');
246 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']); 236 $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
247 $productModel->edit(['route'=>$route],['id'=>$v['id']]); 237 $productModel->edit(['route'=>$route],['id'=>$v['id']]);
248 } 238 }
@@ -9,6 +9,7 @@ use App\Http\Logic\Bside\Product\KeywordLogic; @@ -9,6 +9,7 @@ use App\Http\Logic\Bside\Product\KeywordLogic;
9 use App\Http\Requests\Bside\Product\KeywordRequest; 9 use App\Http\Requests\Bside\Product\KeywordRequest;
10 use App\Models\Com\NoticeLog; 10 use App\Models\Com\NoticeLog;
11 use App\Models\Product\Keyword; 11 use App\Models\Product\Keyword;
  12 +use App\Models\Product\KeywordPage;
12 use App\Models\Product\KeywordRelated; 13 use App\Models\Product\KeywordRelated;
13 use App\Models\Product\Product; 14 use App\Models\Product\Product;
14 use App\Models\RouteMap\RouteMap; 15 use App\Models\RouteMap\RouteMap;
@@ -242,6 +243,20 @@ class KeywordController extends BaseController @@ -242,6 +243,20 @@ class KeywordController extends BaseController
242 * @time :2024/7/2 10:14 243 * @time :2024/7/2 10:14
243 */ 244 */
244 public function batchUpdateKeyword(){ 245 public function batchUpdateKeyword(){
245 - $noticeLogModel = new NoticeLog(); 246 + $this->request->validate([
  247 + 'text'=>'required|array',
  248 + 'update_object'=>'required|array',
  249 + 'update_method'=>'required'
  250 + ],[
  251 + 'text.required' => '文件内容不能为空',
  252 + 'update_object.required' => '更新对象不为空',
  253 + 'update_object.array' => '更新对象为数组',
  254 + 'update_method.required' => '请求方式不为空'
  255 + ]);
  256 + $keywordPageModel = new KeywordPage();
  257 + $this->param['text'] = json_encode($this->param['text']);
  258 + $this->param['update_object'] = json_encode($this->param['update_object']);
  259 + $id = $keywordPageModel->addReturnId($this->param);
  260 + $this->response('success',Code::SUCCESS,['id'=>$id]);
246 } 261 }
247 } 262 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :KeywordPage.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/7/2 15:26
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class KeywordPage extends Base
  15 +{
  16 + protected $table = 'gl_product_keyword_page';
  17 + //连接数据库
  18 + protected $connection = 'custom_mysql';
  19 +}
@@ -133,6 +133,9 @@ class SyncSubmitTaskService @@ -133,6 +133,9 @@ class SyncSubmitTaskService
133 $visit_data['updated_date'] = $data['submit_at']->toDateString(); 133 $visit_data['updated_date'] = $data['submit_at']->toDateString();
134 $visit_data['created_at'] = $data['submit_at']; 134 $visit_data['created_at'] = $data['submit_at'];
135 $visit_data['user_agent'] = $data['user_agent']; 135 $visit_data['user_agent'] = $data['user_agent'];
  136 + if(!empty($data['is_cf'])){
  137 + $visit_data['is_inquiry'] = 1;
  138 + }
136 Visit::saveData($visit_data, $date); 139 Visit::saveData($visit_data, $date);
137 140
138 return true; 141 return true;
@@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -271,6 +271,7 @@ Route::middleware(['bloginauth'])->group(function () {
271 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); 271 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
272 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel'); 272 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
273 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); 273 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
  274 + Route::any('keyword/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword');
274 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo'); 275 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
275 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled'); 276 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
276 //产品参数 277 //产品参数