作者 张关杰

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

  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 +namespace App\Console\Commands;
  4 +
  5 +use App\Http\Logic\Aside\Project\ProjectLogic;
  6 +use App\Models\Com\NoticeLog;
  7 +use App\Models\Product\Keyword;
  8 +use App\Models\Project\Project;
  9 +use App\Models\RouteMap\RouteMap;
  10 +use App\Services\ProjectServer;
  11 +use Illuminate\Console\Command;
  12 +use Illuminate\Support\Facades\DB;
  13 +
  14 +/**
  15 + * 初始化项目
  16 + * Class InitProject
  17 + * @package App\Console\Commands
  18 + * @author zbj
  19 + * @date 2023/10/8
  20 + */
  21 +class InitKeyword extends Command
  22 +{
  23 + /**
  24 + * The name and signature of the console command.
  25 + *
  26 + * @var string
  27 + */
  28 + protected $signature = 'init_keyword';
  29 +
  30 + /**
  31 + * The console command description.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $description = '批量导入关键字生成路由';
  36 +
  37 + /**
  38 + * Create a new command instance.
  39 + *
  40 + * @return void
  41 + */
  42 + public function __construct()
  43 + {
  44 + parent::__construct();
  45 + }
  46 +
  47 + /**
  48 + * @return bool
  49 + */
  50 + public function handle()
  51 + {
  52 + while (true){
  53 + $list = NoticeLog::where('type', NoticeLog::TYPE_INIT_KEYWORD)->where('status', NoticeLog::STATUS_PENDING)->get();
  54 + if(!empty($list)){
  55 + foreach ($list as $item){
  56 + echo 'start:' . $item['data']['project_id'] . PHP_EOL;
  57 + ProjectServer::useProject($item['data']['project_id']);
  58 + $keywordModel = new Keyword();
  59 + $list = $keywordModel->list(['route'=>'']);
  60 + echo 'start:' . json_encode($list) . PHP_EOL;
  61 + foreach ($list as $v){
  62 + $route = RouteMap::setRoute($v['title'],RouteMap::SOURCE_PRODUCT_KEYWORD,$v['id'],$item['data']['project_id']);
  63 + if(empty($route)){
  64 + $keywordModel->del(['id'=>$v['id']]);
  65 + continue;
  66 + }
  67 + $keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
  68 + }
  69 + $item->status = NoticeLog::STATUS_SUCCESS;
  70 + $item->save();
  71 + DB::disconnect('custom_mysql');
  72 + }
  73 + }
  74 + sleep(2);
  75 + }
  76 + }
  77 +
  78 +}
  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 +
  41 + DB::disconnect('custom_mysql');
  42 + }
  43 +
  44 + /**
  45 + * @remark :日统计记录
  46 + * @name :count
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2024/1/8 9:05
  50 + */
  51 + public function count(){
  52 + $list = DB::connection('custom_mysql')->table('gl_customer_visit')
  53 + ->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
  54 + ->groupBy('month')->get()->toArray();
  55 + foreach ($list as $k=>$v){
  56 + $v = (array)$v;
  57 + $monthCountModel = new MonthCount();
  58 + $info = $monthCountModel->read(['month'=>$v['month']]);
  59 + // 获取当月开始时间
  60 + $start = date('Y-m-01', strtotime($v['month']));
  61 + // 获取当月结束时间
  62 + $end = date('Y-m-t', strtotime($v['month']));
  63 + $arr['project_id'] = 439;
  64 + $res = $this->inquiry('www.cnzyl.com',$v['month']);
  65 + $arr['month_total'] = 0;
  66 + if(isset($res['data']['count'])){
  67 + $arr['month_total'] = $res['data']['count'];
  68 + }
  69 + if(isset($res['data']['data'])){
  70 + $arr['country'] = $res['data']['data'];
  71 + }
  72 + $arr['month'] = $v['month'];
  73 + $arr = $this->pv_ip($arr,$start,$end);
  74 + $arr = $this->sourceCount($arr,$start,$end);
  75 + if($info === false){
  76 + $selectedDate = $start;
  77 + $firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month"));
  78 + $arr['created_at'] = $firstDayOfNextMonth;
  79 + $arr['updated_at'] = $firstDayOfNextMonth;
  80 + $monthCountModel->insert($arr);
  81 + }else{
  82 + $monthCountModel->edit($arr,['id'=>$info['id']]);
  83 + }
  84 + }
  85 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  86 + }
  87 +
  88 + /**
  89 + * @remark :本月询盘总量
  90 + * @name :month_total
  91 + * @author :lyh
  92 + * @method :post
  93 + * @time :2024/1/8 11:02
  94 + */
  95 + public function pv_ip(&$arr,$start,$end){
  96 + $pv_ip = DB::table('gl_count')
  97 + ->where(['project_id'=>439])
  98 + ->where('date','>=',$start.' 00:00:00')
  99 + ->where('date','<=',$end.' 23:59:59')
  100 + ->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'))
  101 + ->first();
  102 + $arr['pv'] = $pv_ip->pv_num;
  103 + $arr['ip'] = $pv_ip->ip_num;
  104 + $arr['month_total'] = $pv_ip->inquiry_num;
  105 + if($arr['ip'] != 0){
  106 + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2);
  107 + }
  108 + return $arr;
  109 + }
  110 + /**
  111 + * @remark :来源访问前8
  112 + * @name :sourceCount
  113 + * @author :lyh
  114 + * @method :post
  115 + * @time :2023/6/30 16:14
  116 + */
  117 + public function sourceCount(&$arr,$startTime,$endTime){
  118 + //访问来源前10
  119 + $source = DB::connection('custom_mysql')->table('gl_customer_visit')
  120 + ->select('referrer_url', DB::raw('COUNT(*) as count'))
  121 + ->groupBy('referrer_url')
  122 + ->whereBetween('updated_date', [$startTime,$endTime])
  123 + ->orderByDesc('count')->limit(10)->get()->toArray();
  124 + $arr['source'] = json_encode($source);
  125 + //访问国家前15
  126 + $source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
  127 + ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
  128 + ->groupBy('country')
  129 + ->whereBetween('updated_date', [$startTime,$endTime])
  130 + ->orderBy('ip','desc')->limit(15)->get()->toArray();
  131 + $arr['source_country'] = json_encode($source_country);
  132 + //受访界面前15
  133 + $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
  134 + ->select('url',DB::raw('COUNT(*) as num'))
  135 + ->orderBy('num','desc')
  136 + ->whereBetween('updated_date', [$startTime,$endTime])
  137 + ->groupBy('url')
  138 + ->limit(15)->get()->toArray();
  139 + $arr['referrer_url'] = json_encode($referrer_url);
  140 + //访问端口
  141 + $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
  142 + ->select('device_port',DB::raw('COUNT(*) as num'))
  143 + ->orderBy('num','desc')
  144 + ->whereBetween('updated_date', [$startTime,$endTime])
  145 + ->groupBy('device_port')
  146 + ->limit(15)->get()->toArray();
  147 + $arr['referrer_port'] = json_encode($referrer_port);
  148 + return $arr;
  149 + }
  150 +
  151 + public function inquiry($url,$month){
  152 + $url = 'https://'.$url.'/';
  153 + $token = md5($url.date("Y-m-d"));
  154 + $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;
  155 + $res = http_get($url,['charset=utf-8']);
  156 + echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
  157 + return $res;
  158 + }
  159 +
  160 +}
@@ -51,7 +51,7 @@ class UpdateRoute extends Command @@ -51,7 +51,7 @@ 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'=>183]); 54 + $list = $projectModel->list(['id'=>209]);
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']);
@@ -59,6 +59,7 @@ class UpdateRoute extends Command @@ -59,6 +59,7 @@ class UpdateRoute extends Command
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'],569);
  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;
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/1/6
  6 + * Time: 17:41
  7 + */
  8 +namespace App\Http\Controllers\Api;
  9 +
  10 +use App\Models\Project\OnlineCheck;
  11 +use App\Models\Project\Project;
  12 +use Illuminate\Http\Request;
  13 +
  14 +/**
  15 + * Class PrivateController
  16 + * @package App\Http\Controllers\Api
  17 + */
  18 +class PrivateController extends BaseController
  19 +{
  20 + /**
  21 + * 优化中项目列表
  22 + * @param Request $request
  23 + * @return false|string
  24 + */
  25 + public function optimizeProjectList(Request $request)
  26 + {
  27 + $page_size = $request->input('page_size', 20);
  28 + $field = ['gl_project.id', 'gl_project.company', 'gl_project.is_upgrade', 'b.start_date', 'd.domain'];
  29 + $result = Project::select($field)->leftJoin('gl_project_deploy_optimize as b', 'gl_project.id', '=', 'b.project_id')
  30 + ->leftJoin('gl_project_online_check as c', 'gl_project.id', '=', 'c.project_id')
  31 + ->leftJoin('gl_domain_info as d', 'gl_project.id', '=', 'd.project_id')
  32 + ->where('c.qa_status', '=', OnlineCheck::STATUS_ONLINE_TRUE)
  33 + ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
  34 + ->paginate($page_size)
  35 + ->toArray();
  36 + return $this->success($result);
  37 + }
  38 +}
@@ -69,7 +69,7 @@ class OptimizeController extends BaseController @@ -69,7 +69,7 @@ class OptimizeController extends BaseController
69 if(!empty($list)){ 69 if(!empty($list)){
70 foreach ($list as $v) { 70 foreach ($list as $v) {
71 $last = Arr::last($v); 71 $last = Arr::last($v);
72 - if(isset($last['g']) && ($last['g'] == 1)){ 72 + if(isset($last['g']) && ($last['g'] == 1) && ($last['position'] <= 10) && ($last['position'] >= 1)){
73 $num = $num+1; 73 $num = $num+1;
74 } 74 }
75 } 75 }
@@ -63,6 +63,7 @@ class KeywordController extends BaseController @@ -63,6 +63,7 @@ class KeywordController extends BaseController
63 if(!empty($map['keyword_title'])){ 63 if(!empty($map['keyword_title'])){
64 $map['keyword_title'] = ['like','%'.$map['keyword_title'].'%']; 64 $map['keyword_title'] = ['like','%'.$map['keyword_title'].'%'];
65 } 65 }
  66 + $map['route'] = ['<>',''];
66 $map['project_id'] = $this->user['project_id']; 67 $map['project_id'] = $this->user['project_id'];
67 return $this->success($map); 68 return $this->success($map);
68 } 69 }
@@ -114,7 +115,7 @@ class KeywordController extends BaseController @@ -114,7 +115,7 @@ class KeywordController extends BaseController
114 'title.max' => '批量操作不能超过1000条数据' 115 'title.max' => '批量操作不能超过1000条数据'
115 ]); 116 ]);
116 $logic->batchAdd(); 117 $logic->batchAdd();
117 - $this->response('success'); 118 + $this->response('路由生成中,请稍后刷新查看');
118 } 119 }
119 120
120 /** 121 /**
@@ -7,6 +7,7 @@ use App\Helper\Arr; @@ -7,6 +7,7 @@ use App\Helper\Arr;
7 use App\Helper\Common; 7 use App\Helper\Common;
8 use App\Helper\Translate; 8 use App\Helper\Translate;
9 use App\Http\Logic\Bside\BaseLogic; 9 use App\Http\Logic\Bside\BaseLogic;
  10 +use App\Models\Com\NoticeLog;
10 use App\Models\News\News; 11 use App\Models\News\News;
11 use App\Models\Product\Keyword; 12 use App\Models\Product\Keyword;
12 use App\Models\Product\KeywordRelated; 13 use App\Models\Product\KeywordRelated;
@@ -136,10 +137,6 @@ class KeywordLogic extends BaseLogic @@ -136,10 +137,6 @@ class KeywordLogic extends BaseLogic
136 * @time :2023/8/28 14:03 137 * @time :2023/8/28 14:03
137 */ 138 */
138 public function batchAdd(){ 139 public function batchAdd(){
139 - $route_array = Translate::tran($this->param['title'], 'en');  
140 - if (empty($route_array)) {  
141 - $this->fail('路由生成失败,请稍后重试!');  
142 - }  
143 try { 140 try {
144 foreach ($this->param['title'] as $k=>$v){ 141 foreach ($this->param['title'] as $k=>$v){
145 if(empty($v)){ 142 if(empty($v)){
@@ -148,18 +145,14 @@ class KeywordLogic extends BaseLogic @@ -148,18 +145,14 @@ class KeywordLogic extends BaseLogic
148 $this->model = new Keyword(); 145 $this->model = new Keyword();
149 $info = $this->model->read(['title'=>$v]); 146 $info = $this->model->read(['title'=>$v]);
150 if($info === false){ 147 if($info === false){
151 - $route = $this->specialRouteCheck($v);  
152 $param['project_id'] = $this->user['project_id']; 148 $param['project_id'] = $this->user['project_id'];
153 $param['created_at'] = date('Y-m-d H:i:s'); 149 $param['created_at'] = date('Y-m-d H:i:s');
154 $param['updated_at'] = $param['created_at']; 150 $param['updated_at'] = $param['created_at'];
155 $param['title'] = $v; 151 $param['title'] = $v;
156 - $param['route'] = $route;  
157 - $id = $this->model->insertGetId($param);  
158 - $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);  
159 -//// $this->curlDelRoute(['new_route'=>$route]);  
160 -// $this->model->edit(['route'=>$route],['id'=>$id]); 152 + $this->model->insertGetId($param);
161 } 153 }
162 } 154 }
  155 + NoticeLog::createLog(NoticeLog::TYPE_INIT_KEYWORD, ['project_id' => $this->user['project_id']]);
163 }catch (\Exception $e){ 156 }catch (\Exception $e){
164 $this->fail('error'); 157 $this->fail('error');
165 } 158 }
@@ -175,7 +175,7 @@ class ProductLogic extends BaseLogic @@ -175,7 +175,7 @@ class ProductLogic extends BaseLogic
175 $v['values'] = json_encode($v['values']); 175 $v['values'] = json_encode($v['values']);
176 }elseif ($v['type'] == 4){ 176 }elseif ($v['type'] == 4){
177 foreach ($v['values'] as $k1=>$v1){ 177 foreach ($v['values'] as $k1=>$v1){
178 - $v1 = str_replace_url($v1); 178 + $v1['url'] = str_replace_url($v1['url']);
179 $v['values'][$k1] = $v1; 179 $v['values'][$k1] = $v1;
180 } 180 }
181 $v['values'] = json_encode($v['values']); 181 $v['values'] = json_encode($v['values']);
@@ -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;
@@ -9,4 +9,6 @@ class OnlineCheck extends Base @@ -9,4 +9,6 @@ class OnlineCheck extends Base
9 //设置关联表名 9 //设置关联表名
10 protected $table = 'gl_project_online_check'; 10 protected $table = 'gl_project_online_check';
11 11
  12 + const STATUS_ONLINE_FALSE = 0;
  13 + const STATUS_ONLINE_TRUE = 1;
12 } 14 }
@@ -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) {  
290 - //是否测试域名  
291 - $project_id = DeployBuild::where('test_domain', $domain)->value('project_id');  
292 - //是否正式域名  
293 - if (!$project_id) {  
294 - $project_id = DeployOptimize::where('domain', $domain)->value('project_id');  
295 - }  
296 - if (!$project_id) {  
297 - return [];  
298 - }  
299 - $data = self::find($project_id);  
300 - if ($data) {  
301 - Cache::put($cache_key, $data);  
302 - } 287 + $domain = parse_url($domain);
  288 + $domain = $domain['host'] ?? $domain;
  289 + //是否测试域名
  290 + $project_id = DeployBuild::where('test_domain', $domain)->value('project_id');
  291 + //是否正式域名
  292 + if (!$project_id) {
  293 + $project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id');
303 } 294 }
304 - return $data; 295 + return self::find($project_id ?: 0);
305 } 296 }
306 297
307 /** 298 /**
@@ -18,4 +18,5 @@ Route::middleware('auth:sanctum')->get('/user', function (Request $request) { @@ -18,4 +18,5 @@ Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
18 return $request->user(); 18 return $request->user();
19 }); 19 });
20 20
21 -Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit');  
  21 +Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit');
  22 +Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list');