Merge remote-tracking branch 'origin/master' into zhl
正在显示
8 个修改的文件
包含
285 行增加
和
19 行删除
| 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\DayCount; | ||
| 11 | + | ||
| 12 | +use App\Models\Project\Project; | ||
| 13 | +use App\Models\Visit\Visit; | ||
| 14 | +use App\Services\ProjectServer; | ||
| 15 | +use Illuminate\Console\Command; | ||
| 16 | +use Illuminate\Support\Facades\DB; | ||
| 17 | +use App\Models\HomeCount\Count; | ||
| 18 | + | ||
| 19 | +class UpgradeProjectCount extends Command | ||
| 20 | +{ | ||
| 21 | + /** | ||
| 22 | + * The name and signature of the console command. | ||
| 23 | + * | ||
| 24 | + * @var string | ||
| 25 | + */ | ||
| 26 | + protected $signature = 'upgrade_count'; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * The console command description. | ||
| 30 | + * | ||
| 31 | + * @var string | ||
| 32 | + */ | ||
| 33 | + protected $description = '升级项目统计'; | ||
| 34 | + | ||
| 35 | + public function handle(){ | ||
| 36 | + ProjectServer::useProject(439); | ||
| 37 | + $this->count(); | ||
| 38 | + DB::disconnect('custom_mysql'); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * @remark :日统计记录 | ||
| 43 | + * @name :count | ||
| 44 | + * @author :lyh | ||
| 45 | + * @method :post | ||
| 46 | + * @time :2024/1/8 9:05 | ||
| 47 | + */ | ||
| 48 | + public function count(){ | ||
| 49 | + $list = DB::connection('custom_mysql')->table('gl_customer_visit')->select('updated_date') | ||
| 50 | + ->groupBy('updated_date')->get()->toArray(); | ||
| 51 | + $project = new Project(); | ||
| 52 | + $projectInfo = $project->read(['id'=>439]); | ||
| 53 | + if(!empty($list)){ | ||
| 54 | + $arr = []; | ||
| 55 | + foreach ($list as $k=>$v){ | ||
| 56 | + $v = (array)$v; | ||
| 57 | + echo date('Y-m-d H:i:s') . '时间:'.$v['updated_date'] . PHP_EOL; | ||
| 58 | + $count = new Count(); | ||
| 59 | + $arr['project_id'] = 439; | ||
| 60 | + $arr['date'] = $v['updated_date']; | ||
| 61 | + $arr['pv_num'] = $this->pv_num($v['updated_date']); | ||
| 62 | + $arr['ip_num'] = $this->ip_num($v['updated_date']); | ||
| 63 | + $arr['inquiry_num'] = $this->inquiry_num($v['updated_date']); | ||
| 64 | + //服务达标天数 | ||
| 65 | + $arr['compliance_day'] = $projectInfo['finish_remain_day']; | ||
| 66 | + //剩余服务时常 | ||
| 67 | + $arr['service_day'] = $projectInfo['remain_day']; | ||
| 68 | + $arr['country'] = '{"也门": 4, "印度": 3, "埃及": 4, "巴西": 1, "约旦": 2, "美国": 3, "伊拉克": 4, "利比亚": 2, "墨西哥": 5, "摩洛哥": 8, "新加坡": 1, "突尼斯": 3, "巴勒斯坦": 2, "巴基斯坦": 1, "罗马尼亚": 1, "非洲地区": 2, "马来西亚": 5, "印度尼西亚": 2, "沙特阿拉伯": 3, "阿尔及利亚": 2}'; | ||
| 69 | + //查询当天数据是否存在 存在则更新 | ||
| 70 | + $info = $count->read(['date'=>$v['updated_date']]); | ||
| 71 | + if($info === false){ | ||
| 72 | + $arr['created_at'] = $v['updated_date'].' 01:00:00'; | ||
| 73 | + $arr['updated_at'] = $v['updated_date'].' 01:00:00'; | ||
| 74 | + $count->insert($arr); | ||
| 75 | + }else{ | ||
| 76 | + $count->edit($arr,['id'=>$info['id']]); | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * @remark :询盘数量 | ||
| 85 | + * @name :inquiry_num | ||
| 86 | + * @author :lyh | ||
| 87 | + * @method :post | ||
| 88 | + * @time :2024/1/8 9:24 | ||
| 89 | + */ | ||
| 90 | + public function inquiry_num($day){ | ||
| 91 | + $count = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->where('is_inquiry',1)->count(); | ||
| 92 | + return $count; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + /** | ||
| 96 | + * @name :(统计pv)pv_num | ||
| 97 | + * @author :lyh | ||
| 98 | + * @method :post | ||
| 99 | + * @time :2023/6/14 15:40 | ||
| 100 | + */ | ||
| 101 | + public function pv_num($day){ | ||
| 102 | + $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count(); | ||
| 103 | + return $pv; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * @name :(统计ip)ip_num | ||
| 108 | + * @author :lyh | ||
| 109 | + * @method :post | ||
| 110 | + * @time :2023/6/14 15:40 | ||
| 111 | + */ | ||
| 112 | + public function ip_num($day){ | ||
| 113 | + $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->count(); | ||
| 114 | + return $ip; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + | ||
| 119 | +} |
| 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\HomeCount\MonthCount; | ||
| 14 | +use App\Models\Project\Project; | ||
| 15 | +use App\Models\Visit\Visit; | ||
| 16 | +use App\Services\ProjectServer; | ||
| 17 | +use Illuminate\Console\Command; | ||
| 18 | +use Illuminate\Support\Facades\DB; | ||
| 19 | +use App\Models\HomeCount\Count; | ||
| 20 | + | ||
| 21 | +class UpgradeProjectCount extends Command | ||
| 22 | +{ | ||
| 23 | + /** | ||
| 24 | + * The name and signature of the console command. | ||
| 25 | + * | ||
| 26 | + * @var string | ||
| 27 | + */ | ||
| 28 | + protected $signature = 'upgrade_month_count'; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * The console command description. | ||
| 32 | + * | ||
| 33 | + * @var string | ||
| 34 | + */ | ||
| 35 | + protected $description = '升级项目统计'; | ||
| 36 | + | ||
| 37 | + public function handle(){ | ||
| 38 | + ProjectServer::useProject(439); | ||
| 39 | + $this->count(); | ||
| 40 | + DB::disconnect('custom_mysql'); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * @remark :日统计记录 | ||
| 45 | + * @name :count | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2024/1/8 9:05 | ||
| 49 | + */ | ||
| 50 | + public function count(){ | ||
| 51 | + $list = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 52 | + ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month')) | ||
| 53 | + ->groupBy('month')->get()->toArray(); | ||
| 54 | + foreach ($list as $k=>$v){ | ||
| 55 | + $v = (array)$v; | ||
| 56 | + $monthCountModel = new MonthCount(); | ||
| 57 | + $info = $monthCountModel->read(['month'=>$v['month']]); | ||
| 58 | + // 获取当月开始时间 | ||
| 59 | + $start = date('Y-m-01', strtotime($v['month'])); | ||
| 60 | + // 获取当月结束时间 | ||
| 61 | + $end = date('Y-m-t', strtotime($v['month'])); | ||
| 62 | + $arr['project_id'] = 439; | ||
| 63 | + $inquiry_list = (new FormGlobalsoApi())->getInquiryList('www.cnzyl.com','',1,100000000); | ||
| 64 | + //总数 | ||
| 65 | + $arr['total'] = $inquiry_list['data']['total'] ?? 0; | ||
| 66 | + $arr['month'] = $v['month']; | ||
| 67 | + $arr['country'] = '{"\u5c3c\u65e5\u5229\u4e9a":1,"\u5370\u5ea6\u5c3c\u897f\u4e9a":1,"\u4f0a\u6717":1}'; | ||
| 68 | + $arr = $this->pv_ip($arr,$start,$end); | ||
| 69 | + $arr = $this->sourceCount($arr,$start,$end); | ||
| 70 | + if($info === false){ | ||
| 71 | + $selectedDate = $start; | ||
| 72 | + $firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month")); | ||
| 73 | + $arr['created_at'] = $firstDayOfNextMonth; | ||
| 74 | + $arr['updated_at'] = $firstDayOfNextMonth; | ||
| 75 | + $monthCountModel->insert($arr); | ||
| 76 | + }else{ | ||
| 77 | + $monthCountModel->edit($arr,['id'=>$info['id']]); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * @remark :本月询盘总量 | ||
| 85 | + * @name :month_total | ||
| 86 | + * @author :lyh | ||
| 87 | + * @method :post | ||
| 88 | + * @time :2024/1/8 11:02 | ||
| 89 | + */ | ||
| 90 | + public function pv_ip(&$arr,$start,$end){ | ||
| 91 | + $pv_ip = DB::table('gl_count') | ||
| 92 | + ->where(['project_id'=>439]) | ||
| 93 | + ->where('date','>=',$start.' 00:00:00') | ||
| 94 | + ->where('date','<=',$end.' 23:59:59') | ||
| 95 | + ->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')) | ||
| 96 | + ->first(); | ||
| 97 | + $arr['pv'] = $pv_ip->pv_num; | ||
| 98 | + $arr['ip'] = $pv_ip->ip_num; | ||
| 99 | + $arr['month_total'] = $pv_ip->inquiry_num; | ||
| 100 | + if($arr['ip'] != 0){ | ||
| 101 | + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2); | ||
| 102 | + } | ||
| 103 | + return $arr; | ||
| 104 | + } | ||
| 105 | + /** | ||
| 106 | + * @remark :来源访问前8 | ||
| 107 | + * @name :sourceCount | ||
| 108 | + * @author :lyh | ||
| 109 | + * @method :post | ||
| 110 | + * @time :2023/6/30 16:14 | ||
| 111 | + */ | ||
| 112 | + public function sourceCount(&$arr,$startTime,$endTime){ | ||
| 113 | + //访问来源前10 | ||
| 114 | + $source = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 115 | + ->select('referrer_url', DB::raw('COUNT(*) as count')) | ||
| 116 | + ->groupBy('referrer_url') | ||
| 117 | + ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 118 | + ->orderByDesc('count')->limit(10)->get()->toArray(); | ||
| 119 | + $arr['source'] = json_encode($source); | ||
| 120 | + //访问国家前15 | ||
| 121 | + $source_country = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 122 | + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) | ||
| 123 | + ->groupBy('country') | ||
| 124 | + ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 125 | + ->orderBy('ip','desc')->limit(15)->get()->toArray(); | ||
| 126 | + $arr['source_country'] = json_encode($source_country); | ||
| 127 | + //受访界面前15 | ||
| 128 | + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 129 | + ->select('url',DB::raw('COUNT(*) as num')) | ||
| 130 | + ->orderBy('num','desc') | ||
| 131 | + ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 132 | + ->groupBy('url') | ||
| 133 | + ->limit(15)->get()->toArray(); | ||
| 134 | + $arr['referrer_url'] = json_encode($referrer_url); | ||
| 135 | + //访问端口 | ||
| 136 | + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit') | ||
| 137 | + ->select('device_port',DB::raw('COUNT(*) as num')) | ||
| 138 | + ->orderBy('num','desc') | ||
| 139 | + ->whereBetween('updated_date', [$startTime,$endTime]) | ||
| 140 | + ->groupBy('device_port') | ||
| 141 | + ->limit(15)->get()->toArray(); | ||
| 142 | + $arr['referrer_port'] = json_encode($referrer_port); | ||
| 143 | + return $arr; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | +} |
| @@ -51,14 +51,15 @@ class UpdateRoute extends Command | @@ -51,14 +51,15 @@ class UpdateRoute extends Command | ||
| 51 | */ | 51 | */ |
| 52 | public function handle(){ | 52 | public function handle(){ |
| 53 | $projectModel = new Project(); | 53 | $projectModel = new Project(); |
| 54 | - $list = $projectModel->list(['id'=>290]); | 54 | + $list = $projectModel->list(['id'=>51]); |
| 55 | foreach ($list as $v){ | 55 | foreach ($list as $v){ |
| 56 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 56 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| 57 | ProjectServer::useProject($v['id']); | 57 | ProjectServer::useProject($v['id']); |
| 58 | // $this->getProduct(); | 58 | // $this->getProduct(); |
| 59 | - $this->setProductKeyword(); | 59 | +// $this->setProductKeyword(); |
| 60 | // $this->getRouteMap(); | 60 | // $this->getRouteMap(); |
| 61 | // $this->getProductCategory(); | 61 | // $this->getProductCategory(); |
| 62 | + $this->delRouteMap(); | ||
| 62 | DB::disconnect('custom_mysql'); | 63 | DB::disconnect('custom_mysql'); |
| 63 | } | 64 | } |
| 64 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 65 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| @@ -225,4 +226,11 @@ class UpdateRoute extends Command | @@ -225,4 +226,11 @@ class UpdateRoute extends Command | ||
| 225 | return true; | 226 | return true; |
| 226 | } | 227 | } |
| 227 | 228 | ||
| 229 | + public function delRouteMap(){ | ||
| 230 | + $productKeywordModel = new Keyword(); | ||
| 231 | + $list = $productKeywordModel->list(); | ||
| 232 | + foreach ($list as $k=>$v){ | ||
| 233 | + RouteMap::setRoute($v['route'],'product_keyword',$v['id'],51); | ||
| 234 | + } | ||
| 235 | + } | ||
| 228 | } | 236 | } |
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | 3 | ||
| 4 | namespace App\Helper; | 4 | namespace App\Helper; |
| 5 | 5 | ||
| 6 | +use App\Models\Project\Project; | ||
| 6 | use App\Utils\HttpUtils; | 7 | use App\Utils\HttpUtils; |
| 7 | use GuzzleHttp\Exception\GuzzleException; | 8 | use GuzzleHttp\Exception\GuzzleException; |
| 8 | 9 | ||
| @@ -51,6 +52,8 @@ class FormGlobalsoApi | @@ -51,6 +52,8 @@ class FormGlobalsoApi | ||
| 51 | */ | 52 | */ |
| 52 | public function getInquiryList($domain, $search = '', $page = 1, $page_size = 20) | 53 | public function getInquiryList($domain, $search = '', $page = 1, $page_size = 20) |
| 53 | { | 54 | { |
| 55 | + $project = Project::getProjectByDomain($domain); | ||
| 56 | + $is_upgrade = $project['is_upgrade'] ??0; | ||
| 54 | $api_url = $this->url . '/api/external-interface/6a1bd159b1fd60af'; | 57 | $api_url = $this->url . '/api/external-interface/6a1bd159b1fd60af'; |
| 55 | 58 | ||
| 56 | $params = [ | 59 | $params = [ |
| @@ -58,7 +61,7 @@ class FormGlobalsoApi | @@ -58,7 +61,7 @@ class FormGlobalsoApi | ||
| 58 | 'domain' => $domain, | 61 | 'domain' => $domain, |
| 59 | 'limit' => $page_size, | 62 | 'limit' => $page_size, |
| 60 | 'page' => $page, | 63 | 'page' => $page, |
| 61 | - 'source' => '1,3' //来源类型 新项目用1,3 | 64 | + 'source' => $is_upgrade ? '1,2,3,4' : '1,3' //来源类型 新项目用1,3 |
| 62 | ]; | 65 | ]; |
| 63 | if($search){ | 66 | if($search){ |
| 64 | $params['name'] = $search; | 67 | $params['name'] = $search; |
| @@ -114,7 +114,7 @@ class KeywordController extends BaseController | @@ -114,7 +114,7 @@ class KeywordController extends BaseController | ||
| 114 | 'title.max' => '批量操作不能超过1000条数据' | 114 | 'title.max' => '批量操作不能超过1000条数据' |
| 115 | ]); | 115 | ]); |
| 116 | $logic->batchAdd(); | 116 | $logic->batchAdd(); |
| 117 | - $this->response('success'); | 117 | + $this->response('路由生成中,请稍后刷新查看'); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | /** | 120 | /** |
| @@ -154,7 +154,6 @@ class KeywordLogic extends BaseLogic | @@ -154,7 +154,6 @@ class KeywordLogic extends BaseLogic | ||
| 154 | $param['title'] = $v; | 154 | $param['title'] = $v; |
| 155 | $id = $this->model->insertGetId($param); | 155 | $id = $this->model->insertGetId($param); |
| 156 | $route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 156 | $route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 157 | -// $this->curlDelRoute(['new_route'=>$route]); | ||
| 158 | $this->model->edit(['route'=>$route],['id'=>$id]); | 157 | $this->model->edit(['route'=>$route],['id'=>$id]); |
| 159 | } | 158 | } |
| 160 | } | 159 | } |
| @@ -12,7 +12,7 @@ class NoticeLog extends Model | @@ -12,7 +12,7 @@ class NoticeLog extends Model | ||
| 12 | const TYPE_PROJECT = 'project'; | 12 | const TYPE_PROJECT = 'project'; |
| 13 | const TYPE_RANK_DATA = 'rank_data'; | 13 | const TYPE_RANK_DATA = 'rank_data'; |
| 14 | const TYPE_INIT_PROJECT = 'init_project'; | 14 | const TYPE_INIT_PROJECT = 'init_project'; |
| 15 | - | 15 | + const TYPE_INIT_KEYWORD = 'init_keyword'; |
| 16 | const STATUS_PENDING = 0; | 16 | const STATUS_PENDING = 0; |
| 17 | const STATUS_SUCCESS = 1; | 17 | const STATUS_SUCCESS = 1; |
| 18 | const STATUS_FAIL = 2; | 18 | const STATUS_FAIL = 2; |
| @@ -284,24 +284,15 @@ class Project extends Base | @@ -284,24 +284,15 @@ class Project extends Base | ||
| 284 | */ | 284 | */ |
| 285 | public static function getProjectByDomain($domain) | 285 | public static function getProjectByDomain($domain) |
| 286 | { | 286 | { |
| 287 | - $cache_key = 'project_' . $domain; | ||
| 288 | - $data = Cache::get($cache_key); | ||
| 289 | - if (!$data) { | 287 | + $domain = parse_url($domain); |
| 288 | + $domain = $domain['host'] ?? $domain; | ||
| 290 | //是否测试域名 | 289 | //是否测试域名 |
| 291 | $project_id = DeployBuild::where('test_domain', $domain)->value('project_id'); | 290 | $project_id = DeployBuild::where('test_domain', $domain)->value('project_id'); |
| 292 | //是否正式域名 | 291 | //是否正式域名 |
| 293 | if (!$project_id) { | 292 | if (!$project_id) { |
| 294 | - $project_id = DeployOptimize::where('domain', $domain)->value('project_id'); | 293 | + $project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id'); |
| 295 | } | 294 | } |
| 296 | - if (!$project_id) { | ||
| 297 | - return []; | ||
| 298 | - } | ||
| 299 | - $data = self::find($project_id); | ||
| 300 | - if ($data) { | ||
| 301 | - Cache::put($cache_key, $data); | ||
| 302 | - } | ||
| 303 | - } | ||
| 304 | - return $data; | 295 | + return self::find($project_id ?: 0); |
| 305 | } | 296 | } |
| 306 | 297 | ||
| 307 | /** | 298 | /** |
-
请 注册 或 登录 后发表评论