作者 刘锟

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

1 -<?php  
2 -  
3 -namespace App\Console\Commands\MonthlyCount;  
4 -  
5 -use App\Helper\FormGlobalsoApi;  
6 -use App\Models\Domain\DomainInfo;  
7 -use App\Models\Inquiry\InquiryFormData;  
8 -use App\Models\Project\Project;  
9 -use App\Services\ProjectServer;  
10 -use Carbon\Carbon;  
11 -use Illuminate\Console\Command;  
12 -use Illuminate\Support\Facades\DB;  
13 -use Illuminate\Support\Facades\Log;  
14 -  
15 -class InquiryMonthlyCount extends Command  
16 -{  
17 - const STATUS_ERROR = 400;  
18 - public $error = 0;  
19 - /**  
20 - * The name and signature of the console command.  
21 - *  
22 - * @var string  
23 - */  
24 - protected $signature = 'month_count';  
25 -  
26 - /**  
27 - * The console command description.  
28 - *  
29 - * @var string  
30 - */  
31 - protected $description = '询盘月报告统计';  
32 -  
33 - /**  
34 - * @remark :询盘月报告  
35 - * @name :handle  
36 - * @author :lyh  
37 - * @method :post  
38 - * @time :2023/6/30 9:32  
39 - */  
40 - public function handle(){  
41 - $list = DB::table('gl_project')->where('gl_project.extend_type','=',0)  
42 - ->where('gl_project.type','!=',0)  
43 - ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')  
44 - ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')  
45 - ->select($this->selectParam())->get()->toArray();  
46 - // 获取上个月的开始时间  
47 - $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();  
48 - // 获取上个月的结束时间  
49 - $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();  
50 - $domainInfo = new DomainInfo();  
51 - foreach ($list as $value){  
52 - $value = (array)$value;  
53 - if($value['type'] == Project::TYPE_ZERO){  
54 - continue;  
55 - }  
56 - if(!empty($value['domain'])){  
57 - $info = $domainInfo->read(['id'=>$value['domain']]);  
58 - if($info !== false){  
59 - $value['test_domain'] = $info['domain'];  
60 - }  
61 - }  
62 - $arr = [];  
63 - //按月统计询盘记录  
64 - $arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain'],$value['project_id']);  
65 - $arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);  
66 - ProjectServer::useProject($value['project_id']);  
67 - $arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);  
68 - DB::disconnect('custom_mysql');  
69 - $arr['created_at'] = date('Y-m-d H:i:s');  
70 - $arr['updated_at'] = date('Y-m-d H:i:s');  
71 - $arr['project_id'] = $value['project_id'];  
72 - // 获取当前日期时间  
73 - $arr['month'] = Carbon::now()->subMonth()->format('Y-m');  
74 - try {  
75 - DB::table('gl_month_count')->insert($arr);  
76 - Log::channel('month_count')->error('success:project_id .'.$arr['project_id']);  
77 - }catch (\Exception $e){  
78 - Log::channel('month_count')->error('month_count:error ' . $e->getMessage());  
79 - }  
80 - }  
81 - return true;  
82 - }  
83 -  
84 - /**  
85 - * @param $domain  
86 - * @param $project_id  
87 - * @remark :询盘按月统计  
88 - * @name :inquiryCount  
89 - * @author :lyh  
90 - * @method :post  
91 - * @time :2023/6/30 14:29  
92 - */  
93 - public function inquiryCount(&$arr,&$startTime,&$endTime,$domain,$project_id){  
94 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);  
95 - //总数  
96 - $arr['total'] = $inquiry_list['data']['total'] ?? 0;  
97 - //数据详情  
98 - $data = $inquiry_list['data']['data'] ?? 0;  
99 - $arr['month_total'] = 0;  
100 - $countryArr = [];  
101 - $arr['country'] = "";  
102 - if(!empty($data)){  
103 - foreach ($data as $v){  
104 - if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){  
105 - $arr['month_total']++;  
106 - if(isset($countryArr[$v['country']])){  
107 - $countryArr[$v['country']]++;  
108 - }else{  
109 - $countryArr[$v['country']] = 1;  
110 - }  
111 - }  
112 - }  
113 - }  
114 - //加上其他询盘  
115 - ProjectServer::useProject($project_id);  
116 - $arr['total'] += InquiryFormData::count();  
117 - $arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);  
118 - $countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);  
119 - foreach ($countryData as $v1){  
120 - if(isset($countryArr[$v1['country']])){  
121 - $countryArr[$v1['country']] += $v1['count'];  
122 - }else{  
123 - $countryArr[$v1['country']] = $v1['count'];  
124 - }  
125 - }  
126 -  
127 - arsort($countryArr);  
128 - $top20 = array_slice($countryArr, 0, 15, true);  
129 - $arr['country'] = json_encode($top20);  
130 - return $arr;  
131 - }  
132 -  
133 - /**  
134 - * @remark :流量统计  
135 - * @name :flowCount  
136 - * @author :lyh  
137 - * @method :post  
138 - * @time :2023/6/30 14:31  
139 - */  
140 - public function flowCount(&$arr,&$startTime,&$endTime,$project_id){  
141 - $pv_ip = DB::table('gl_count')  
142 - ->where(['project_id'=>$project_id])  
143 - ->where('date','>=',$startTime.' 00:00:00')  
144 - ->where('date','<=',$endTime.' 23:59:59')  
145 - ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))  
146 - ->first();  
147 - $arr['pv'] = $pv_ip->pv_num;  
148 - $arr['ip'] = $pv_ip->ip_num;  
149 - if($arr['ip'] != 0){  
150 - $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2);  
151 - }  
152 - return $arr;  
153 - }  
154 -  
155 - /**  
156 - * @remark :来源访问前8  
157 - * @name :sourceCount  
158 - * @author :lyh  
159 - * @method :post  
160 - * @time :2023/6/30 16:14  
161 - */  
162 - public function sourceCount(&$arr,$domain,$startTime,$endTime){  
163 - //访问来源前10  
164 - $source = DB::connection('custom_mysql')->table('gl_customer_visit')  
165 - ->select('referrer_url', DB::raw('COUNT(*) as count'))  
166 - ->groupBy('referrer_url')  
167 - ->whereBetween('updated_date', [$startTime,$endTime])  
168 - ->orderByDesc('count')->limit(10)->get()->toArray();  
169 - $arr['source'] = json_encode($source);  
170 - //访问国家前15  
171 - $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')  
172 - ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))  
173 - ->groupBy('country')  
174 - ->whereBetween('updated_date', [$startTime,$endTime])  
175 - ->orderBy('ip','desc')->limit(15)->get()->toArray();  
176 - $arr['source_country'] = json_encode($source_country);  
177 - //受访界面前15  
178 - $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')  
179 - ->select('url',DB::raw('COUNT(*) as num'))  
180 - ->orderBy('num','desc')  
181 - ->whereBetween('updated_date', [$startTime,$endTime])  
182 - ->groupBy('url')  
183 - ->limit(15)->get()->toArray();  
184 - $arr['referrer_url'] = json_encode($referrer_url);  
185 - //访问端口  
186 - $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')  
187 - ->select('device_port',DB::raw('COUNT(*) as num'))  
188 - ->orderBy('num','desc')  
189 - ->whereBetween('updated_date', [$startTime,$endTime])  
190 - ->groupBy('device_port')  
191 - ->limit(15)->get()->toArray();  
192 - $arr['referrer_port'] = json_encode($referrer_port);  
193 - return $arr;  
194 - }  
195 -  
196 - /**  
197 - * @name :(查询参数设置)selectParam  
198 - * @author :lyh  
199 - * @method :post  
200 - * @time :2023/6/14 15:00  
201 - */  
202 - public function selectParam(){  
203 - $select = [  
204 - 'gl_project.id AS id',  
205 - 'gl_project.type AS type',  
206 - 'gl_project.extend_type AS extend_type',  
207 - 'gl_project_deploy_build.test_domain AS test_domain',  
208 - 'gl_project_deploy_optimize.domain AS domain',  
209 - 'gl_project_deploy_build.project_id AS project_id',  
210 - 'gl_project.cooperate_date AS cooperate_date',  
211 - 'gl_project_deploy_build.service_duration AS service_duration',  
212 - ];  
213 - return $select;  
214 - }  
215 -}  
  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\Models\Com\UpdateOldInfo;
  13 +use App\Models\Domain\DomainInfo;
  14 +use App\Models\Project\Project;
  15 +use App\Services\ProjectServer;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Support\Facades\DB;
  18 +use App\Models\HomeCount\MonthCount AS MonthCountModel;
  19 +
  20 +class MonthCount extends Command
  21 +{
  22 + /**
  23 + * The name and signature of the console command.
  24 + *
  25 + * @var string
  26 + */
  27 + protected $signature = 'month_counts';
  28 +
  29 + /**
  30 + * The console command description.
  31 + *
  32 + * @var string
  33 + */
  34 + protected $description = '每天生成月统计记录';
  35 +
  36 + public function handle(){
  37 + $list = DB::table('gl_project')->where('gl_project.extend_type','=',0)
  38 + ->where('gl_project.type','!=',0)
  39 + ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
  40 + ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
  41 + ->select($this->selectParam())->get()->toArray();
  42 + foreach ($list as $v) {
  43 + $v = (array)$v;
  44 + if($v['type'] == Project::TYPE_ZERO){
  45 + continue;
  46 + }
  47 + if($v['is_upgrade'] == 1){
  48 + $oldModel = new UpdateOldInfo();
  49 + $info = $oldModel->read(['project_id' => $v['id']]);
  50 + if ($info !== false) {
  51 + $url = $info['old_domain_online'];
  52 + }else{
  53 + continue;
  54 + }
  55 + }else{
  56 + $domainInfo = new DomainInfo();
  57 + if(!empty($v['domain'])){
  58 + $info = $domainInfo->read(['id'=>$v['domain']]);
  59 + if($info !== false){
  60 + $url = $info['domain'];
  61 + }
  62 + }else{
  63 + $url = $v['test_domain'];
  64 + }
  65 + }
  66 + ProjectServer::useProject($v['id']);
  67 + echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
  68 + $this->count($v['id'], $url);
  69 + DB::disconnect('custom_mysql');
  70 + }
  71 + }
  72 +
  73 + /**
  74 + * @name :(查询参数设置)selectParam
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2023/6/14 15:00
  78 + */
  79 + public function selectParam(){
  80 + $select = [
  81 + 'gl_project.id AS id',
  82 + 'gl_project.type AS type',
  83 + 'gl_project.extend_type AS extend_type',
  84 + 'gl_project_deploy_build.test_domain AS test_domain',
  85 + 'gl_project.is_upgrade AS is_upgrade',
  86 + 'gl_project_deploy_optimize.domain AS domain',
  87 + 'gl_project_deploy_build.project_id AS project_id',
  88 + 'gl_project.cooperate_date AS cooperate_date',
  89 + 'gl_project_deploy_build.service_duration AS service_duration',
  90 + ];
  91 + return $select;
  92 + }
  93 + /**
  94 + * @remark :日统计记录
  95 + * @name :count
  96 + * @author :lyh
  97 + * @method :post
  98 + * @time :2024/1/8 9:05
  99 + */
  100 + 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']);
  110 +// $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']);
  125 + }
  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);
  136 + }else{
  137 + $monthCountModel->edit($arr,['id'=>$info['id']]);
  138 + }
  139 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  140 + }
  141 +
  142 + /**
  143 + * @remark :本月询盘总量
  144 + * @name :month_total
  145 + * @author :lyh
  146 + * @method :post
  147 + * @time :2024/1/8 11:02
  148 + */
  149 + public function pv_ip(&$arr,$start,$end,$project_id){
  150 + $pv_ip = DB::table('gl_count')
  151 + ->where(['project_id'=>$project_id])
  152 + ->where('date','>=',$start.' 00:00:00')
  153 + ->where('date','<=',$end.' 23:59:59')
  154 + ->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'))
  155 + ->first();
  156 + $arr['pv'] = $pv_ip->pv_num;
  157 + $arr['ip'] = $pv_ip->ip_num;
  158 + if($arr['ip'] != 0){
  159 + $arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2);
  160 + }
  161 + return $arr;
  162 + }
  163 + /**
  164 + * @remark :来源访问前8
  165 + * @name :sourceCount
  166 + * @author :lyh
  167 + * @method :post
  168 + * @time :2023/6/30 16:14
  169 + */
  170 + public function sourceCount(&$arr,$startTime,$endTime){
  171 + //访问来源前10
  172 + $source = DB::connection('custom_mysql')->table('gl_customer_visit')
  173 + ->select('referrer_url', DB::raw('COUNT(*) as count'))
  174 + ->groupBy('referrer_url')
  175 + ->whereBetween('updated_date', [$startTime,$endTime])
  176 + ->orderByDesc('count')->limit(10)->get()->toArray();
  177 + $arr['source'] = json_encode($source);
  178 + //访问国家前15
  179 + $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
  180 + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
  181 + ->groupBy('country')
  182 + ->whereBetween('updated_date', [$startTime,$endTime])
  183 + ->orderBy('ip','desc')->limit(15)->get()->toArray();
  184 + $arr['source_country'] = json_encode($source_country);
  185 + //受访界面前15
  186 + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
  187 + ->select('url',DB::raw('COUNT(*) as num'))
  188 + ->orderBy('num','desc')
  189 + ->whereBetween('updated_date', [$startTime,$endTime])
  190 + ->groupBy('url')
  191 + ->limit(15)->get()->toArray();
  192 + $arr['referrer_url'] = json_encode($referrer_url);
  193 + //访问端口
  194 + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
  195 + ->select('device_port',DB::raw('COUNT(*) as num'))
  196 + ->orderBy('num','desc')
  197 + ->whereBetween('updated_date', [$startTime,$endTime])
  198 + ->groupBy('device_port')
  199 + ->limit(15)->get()->toArray();
  200 + $arr['referrer_port'] = json_encode($referrer_port);
  201 + return $arr;
  202 + }
  203 +
  204 + public function inquiry($url,$month){
  205 + $url = 'https://'.$url.'/';
  206 + $token = md5($url.date("Y-m-d"));
  207 + $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;
  208 + $res = http_get($url,['charset=utf-8']);
  209 + echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
  210 + return $res;
  211 + }
  212 +
  213 +}
@@ -51,19 +51,12 @@ class RecommendedSuppliers extends Command @@ -51,19 +51,12 @@ class RecommendedSuppliers extends Command
51 { 51 {
52 $projectModel = new DeployBuild(); 52 $projectModel = new DeployBuild();
53 $project_list = $projectModel->list(['is_supplier'=>1]);//TODO::已开启推荐供应商 53 $project_list = $projectModel->list(['is_supplier'=>1]);//TODO::已开启推荐供应商
54 - foreach ($project_list as $k => $v){ 54 + foreach ($project_list as $v){
55 echo date('Y-m-d H:i:s') . 'project_id:'.$v['project_id'] . PHP_EOL; 55 echo date('Y-m-d H:i:s') . 'project_id:'.$v['project_id'] . PHP_EOL;
56 ProjectServer::useProject($v['project_id']); 56 ProjectServer::useProject($v['project_id']);
57 - $info = Keyword::inRandomOrder()->first();  
58 - if(empty($info)){  
59 - continue;  
60 - }  
61 - $keywordInfo = $this->getPurchaser($info->title,$v['project_id']);  
62 - if($keywordInfo !== false){  
63 - continue;  
64 - } 57 + $title = $this->getKeywords($v['project_id']);
65 echo date('Y-m-d H:i:s') . '开始:'.$v['project_id'] . PHP_EOL; 58 echo date('Y-m-d H:i:s') . '开始:'.$v['project_id'] . PHP_EOL;
66 - $this->savePurchaser($v['project_id'],$info->title); 59 + $this->savePurchaser($v['project_id'],$title);
67 DB::disconnect('custom_mysql'); 60 DB::disconnect('custom_mysql');
68 } 61 }
69 return true; 62 return true;
@@ -107,11 +100,30 @@ class RecommendedSuppliers extends Command @@ -107,11 +100,30 @@ class RecommendedSuppliers extends Command
107 $purchaserModel = new Purchaser(); 100 $purchaserModel = new Purchaser();
108 $purchaserModel->add($saveData); 101 $purchaserModel->add($saveData);
109 $this->savePurchaserInfo($project_id,$keyword,$res['data']); 102 $this->savePurchaserInfo($project_id,$keyword,$res['data']);
  103 + }else{
  104 + $title = $this->getKeywords($project_id);
  105 + $this->savePurchaser($project_id,$title);
110 } 106 }
111 return true; 107 return true;
112 } 108 }
113 109
114 /** 110 /**
  111 + * @remark :取关键词
  112 + * @name :getKeywords
  113 + * @author :lyh
  114 + * @method :post
  115 + * @time :2024/7/1 18:07
  116 + */
  117 + public function getKeywords($project_id){
  118 + $info = Keyword::inRandomOrder()->first();
  119 + $keywordInfo = $this->getPurchaser($info->title,$project_id);
  120 + if($keywordInfo !== false){
  121 + $this->getKeywords($project_id);
  122 + }
  123 + return $info->title;
  124 + }
  125 +
  126 + /**
115 * @remark :保存供应商详情 127 * @remark :保存供应商详情
116 * @name :savePurchaserInfo 128 * @name :savePurchaserInfo
117 * @author :lyh 129 * @author :lyh
@@ -50,7 +50,7 @@ class UpdateProductCategory extends Command @@ -50,7 +50,7 @@ class UpdateProductCategory extends Command
50 public function handle(){ 50 public function handle(){
51 //获取所有项目 51 //获取所有项目
52 $projectModel = new Project(); 52 $projectModel = new Project();
53 - $list = $projectModel->list(['id'=>['!=',[1515]],'type'=>['!=',0]],'id',['id']); 53 + $list = $projectModel->list(['id'=>978],'id',['id']);
54 echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL; 54 echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL;
55 try { 55 try {
56 foreach ($list as $v) { 56 foreach ($list as $v) {
@@ -278,7 +278,7 @@ class LoginController extends BaseController @@ -278,7 +278,7 @@ class LoginController extends BaseController
278 ]; 278 ];
279 }else{ 279 }else{
280 //有from_order_id, 找到对应的项目并登录主账号 280 //有from_order_id, 找到对应的项目并登录主账号
281 - $project = (new Project())->read(['from_order_id'=>$arr['from_order_id']]); 281 + $project = (new Project())->read(['from_order_id'=>$arr['from_order_id'], 'delete_status' => Project::IS_DEL_FALSE]);
282 if(!$project){ 282 if(!$project){
283 $this->response('项目不存在,请联系管理员',Code::USER_ERROR); 283 $this->response('项目不存在,请联系管理员',Code::USER_ERROR);
284 } 284 }
@@ -77,7 +77,7 @@ class SuppliersController extends BaseController @@ -77,7 +77,7 @@ class SuppliersController extends BaseController
77 if(isset($res['status_code']) && $res['status_code'] != 200){ 77 if(isset($res['status_code']) && $res['status_code'] != 200){
78 $this->response($res['message'],Code::SYSTEM_ERROR); 78 $this->response($res['message'],Code::SYSTEM_ERROR);
79 } 79 }
80 - return $this->success($res['data']); 80 + return $this->success($res['data'] ?? []);
81 } 81 }
82 /** 82 /**
83 * @remark :按名字搜索公司 83 * @remark :按名字搜索公司
@@ -30,7 +30,6 @@ class MonthCountLogic extends BaseLogic @@ -30,7 +30,6 @@ class MonthCountLogic extends BaseLogic
30 */ 30 */
31 public function getCountLists($map,$order = 'created_at',$filed = ['*']){ 31 public function getCountLists($map,$order = 'created_at',$filed = ['*']){
32 $map['project_id'] = $this->user['project_id']; 32 $map['project_id'] = $this->user['project_id'];
33 - $new = $this->currentMonthCount();  
34 $lists = $this->model->list($map,$order,$filed,'desc',10); 33 $lists = $this->model->list($map,$order,$filed,'desc',10);
35 if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){ 34 if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){
36 foreach ($lists as $k => $v){ 35 foreach ($lists as $k => $v){
@@ -49,144 +48,10 @@ class MonthCountLogic extends BaseLogic @@ -49,144 +48,10 @@ class MonthCountLogic extends BaseLogic
49 $lists[$k] = $v; 48 $lists[$k] = $v;
50 } 49 }
51 } 50 }
52 - $lists['new'] = $new;  
53 return $this->success($lists); 51 return $this->success($lists);
54 } 52 }
55 53
56 /** 54 /**
57 - * @remark :获取当前月数据统计  
58 - * @name :currentMonth  
59 - * @author :lyh  
60 - * @method :post  
61 - * @time :2023/7/3 9:55  
62 - */  
63 - public function currentMonthCount(){  
64 - $startTime = Carbon::now()->startOfMonth()->toDateString();  
65 - $endTime = date('Y-m-d',time());  
66 - $arr = [];  
67 - $arr = $this->inquiryCount($arr,$startTime,$endTime,$this->user['domain']);  
68 - $arr = $this->flowCount($arr,$startTime,$endTime,$this->user['project_id']);  
69 - $arr = $this->sourceCount($arr,$startTime,$endTime,$this->user['domain']);  
70 - $arr['month'] = date('Y-m',time());  
71 - return $this->success($arr);  
72 - }  
73 - /**  
74 - * @param $domain  
75 - * @param $project_id  
76 - * @remark :询盘按月统计  
77 - * @name :inquiryCount  
78 - * @author :lyh  
79 - * @method :post  
80 - * @time :2023/6/30 14:29  
81 - */  
82 - public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){  
83 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);  
84 - if(!empty($inquiry_list)){  
85 - //总数  
86 - $arr['total'] = $inquiry_list['data']['total'] ?? 0;  
87 - //数据详情  
88 - $data = $inquiry_list['data']['data'] ?? '';  
89 - $arr['month_total'] = 0;  
90 - $countryArr = [];  
91 - if(isset($data) && !empty($data)){  
92 - foreach ($data as $v){  
93 - if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){  
94 - $arr['month_total']++;  
95 - if(isset($countryArr[$v['country']])){  
96 - $countryArr[$v['country']]++;  
97 - }else{  
98 - $countryArr[$v['country']] = 1;  
99 - }  
100 - }  
101 - }  
102 - }  
103 - }  
104 - //加上其他询盘  
105 - $arr['total'] += InquiryFormData::getCount();  
106 - $arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);  
107 - $countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);  
108 - foreach ($countryData as $v1){  
109 - if(isset($countryArr[$v1['country']])){  
110 - $countryArr[$v1['country']] += $v1['count'];  
111 - }else{  
112 - $countryArr[$v1['country']] = $v1['count'];  
113 - }  
114 - }  
115 - arsort($countryArr);  
116 - $top20 = array_slice($countryArr, 0, 15, true);  
117 - $arr['country'] = $top20;  
118 - return $arr;  
119 - }  
120 -  
121 - /**  
122 - * @remark :流量统计  
123 - * @name :flowCount  
124 - * @author :lyh  
125 - * @method :post  
126 - * @time :2023/6/30 14:31  
127 - */  
128 - public function flowCount(&$arr,&$startTime,&$endTime,$project_id){  
129 - $pv_ip = DB::table('gl_count')  
130 - ->where(['project_id'=>$project_id])  
131 - ->whereBetween('date', [$startTime,$endTime])  
132 - ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))  
133 - ->orderBy('id','desc')  
134 - ->first();  
135 - $arr['pv'] = $pv_ip->pv_num;  
136 - $arr['ip'] = $pv_ip->ip_num;  
137 - $arr['rate'] = 0;  
138 - if($arr['ip'] != 0){  
139 - $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);  
140 - }  
141 - return $arr;  
142 - }  
143 -  
144 - /**  
145 - * @remark :来源访问前8  
146 - * @name :sourceCount  
147 - * @author :lyh  
148 - * @method :post  
149 - * @time :2023/6/30 16:14  
150 - */  
151 - public function sourceCount(&$arr,$startTime,$endTime,$domain){  
152 - //访问来源前10  
153 - $source = DB::connection('custom_mysql')->table('gl_customer_visit')  
154 - ->select('referrer_url', DB::raw('COUNT(*) as count'))  
155 - ->groupBy('referrer_url')  
156 - ->where('referrer_url','!=','')  
157 - ->whereBetween('updated_date', [$startTime,$endTime])  
158 - ->orderByDesc('count')->limit(10)->get()->toArray();  
159 - $arr['source'] = $source;  
160 - //访问国家前15  
161 - $query = DB::connection('custom_mysql')->table('gl_customer_visit')  
162 - ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))  
163 - ->groupBy('country');  
164 - if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){  
165 - $query->where('country','<>','中国');  
166 - }  
167 - $source_country = $query->whereBetween('updated_date', [$startTime,$endTime])  
168 - ->orderBy('ip','desc')->limit(15)->get()->toArray();  
169 - $arr['source_country'] = $source_country;  
170 - //受访界面前15  
171 - $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')  
172 - ->select('url',DB::raw('COUNT(*) as num'))  
173 - ->orderBy('num','desc')  
174 - ->whereBetween('updated_date', [$startTime,$endTime])  
175 - ->groupBy('url')  
176 - ->limit(15)->get()->toArray();  
177 - $arr['referrer_url'] = $referrer_url;  
178 - //访问断后  
179 - $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')  
180 - ->select('device_port',DB::raw('COUNT(*) as num'))  
181 - ->orderBy('num','desc')  
182 - ->whereBetween('updated_date', [$startTime,$endTime])  
183 - ->groupBy('device_port')  
184 - ->limit(15)->get()->toArray();  
185 - $arr['referrer_port'] = $referrer_port;  
186 - return $arr;  
187 - }  
188 -  
189 - /**  
190 * @remark :根据时间获取pv,ip 55 * @remark :根据时间获取pv,ip
191 * @name :getIpPvCount 56 * @name :getIpPvCount
192 * @author :lyh 57 * @author :lyh
@@ -144,7 +144,7 @@ class KeywordLogic extends BaseLogic @@ -144,7 +144,7 @@ class KeywordLogic extends BaseLogic
144 continue; 144 continue;
145 } 145 }
146 $this->model = new Keyword(); 146 $this->model = new Keyword();
147 - $info = $this->model->read(['title'=>$v]); 147 + $info = $this->model->read(['title'=>$v],['id']);
148 if($info === false){ 148 if($info === false){
149 $param['project_id'] = $this->user['project_id']; 149 $param['project_id'] = $this->user['project_id'];
150 $param['created_at'] = date('Y-m-d H:i:s'); 150 $param['created_at'] = date('Y-m-d H:i:s');
@@ -44,7 +44,12 @@ class QueryListener @@ -44,7 +44,12 @@ class QueryListener
44 } 44 }
45 } 45 }
46 } 46 }
47 - $log = vsprintf($sql, $event->bindings); 47 + if(strpos($sql,'%Y-%m') === false){
  48 + $log = vsprintf($sql, $event->bindings);
  49 + }else{
  50 + $log = $sql;
  51 + }
  52 +
48 $log = $log.' [ RunTime:'.$event->time.'ms ] '; 53 $log = $log.' [ RunTime:'.$event->time.'ms ] ';
49 Log::debug($log); 54 Log::debug($log);
50 } 55 }
@@ -35,6 +35,9 @@ class Project extends Base @@ -35,6 +35,9 @@ class Project extends Base
35 const IS_UPGRADE_FALSE = 0; 35 const IS_UPGRADE_FALSE = 0;
36 const IS_UPGRADE_TRUE = 1; 36 const IS_UPGRADE_TRUE = 1;
37 37
  38 + const IS_DEL_FALSE = 0;
  39 + const IS_DEL_TRUE = 1;
  40 +
38 /** 41 /**
39 * 星级客户 42 * 星级客户
40 * @return string[] 43 * @return string[]