作者 赵彬吉

update

@@ -10,11 +10,16 @@ use App\Models\HomeCount\Count; @@ -10,11 +10,16 @@ use App\Models\HomeCount\Count;
10 use App\Models\Inquiry\InquiryFormData; 10 use App\Models\Inquiry\InquiryFormData;
11 use App\Models\Nav\BNav; 11 use App\Models\Nav\BNav;
12 use App\Models\Nav\BNavGroup; 12 use App\Models\Nav\BNavGroup;
  13 +use App\Models\Project\OnlineCheck;
13 use App\Models\Project\Project; 14 use App\Models\Project\Project;
14 use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; 15 use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel;
15 use App\Models\WebSetting\Translate as TranslateModel; 16 use App\Models\WebSetting\Translate as TranslateModel;
  17 +use App\Models\WebSetting\WebLanguage;
16 use App\Services\ProjectServer; 18 use App\Services\ProjectServer;
  19 +use Carbon\Carbon;
17 use Illuminate\Console\Command; 20 use Illuminate\Console\Command;
  21 +use Illuminate\Support\Facades\DB;
  22 +use Illuminate\Support\Facades\Redis;
18 23
19 /** 24 /**
20 * Class Test 25 * Class Test
@@ -53,6 +58,19 @@ class Test extends Command @@ -53,6 +58,19 @@ class Test extends Command
53 */ 58 */
54 public function handle() 59 public function handle()
55 { 60 {
  61 + $date = '2025-05-16';
  62 + $list = $this->getProjectList();
  63 + foreach ($list as $item){
  64 + ProjectServer::useProject($item['id']);
  65 + //pv统计
  66 + $pv_num = $this->pv_num($date);
  67 + //ip统计
  68 + $ip_num = $this->ip_num($date);
  69 +
  70 + echo $item['project_id'] . ',pv:' . $pv_num . ',ip:' . $ip_num;
  71 + }
  72 + exit;
  73 +
56 74
57 $i=0; 75 $i=0;
58 while (true){ 76 while (true){
@@ -167,4 +185,80 @@ class Test extends Command @@ -167,4 +185,80 @@ class Test extends Command
167 $arr['country'] = json_encode($top20); 185 $arr['country'] = json_encode($top20);
168 return $arr; 186 return $arr;
169 } 187 }
  188 +
  189 + protected function getProjectList($type = 1){
  190 + $ru_lang_id = WebLanguage::getIdByLang('ru');
  191 +
  192 + //推广项目
  193 + $list = Project::with('domainInfo')
  194 + ->leftJoin('gl_project_deploy_optimize as pdo', 'pdo.project_id', '=', 'gl_project.id')
  195 + ->leftJoin('gl_project_online_check as poc', 'poc.project_id', '=', 'gl_project.id')
  196 + ->where('pdo.domain', '>', 0)
  197 + ->where('poc.qa_status', OnlineCheck::STATUS_ONLINE_TRUE)
  198 + ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR])
  199 + ->where('gl_project.is_upgrade', 0) //非升级项目
  200 + ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站
  201 + ->where(function ($query) use ($type) {
  202 + if($type == 1){
  203 + //1-3个月项目
  204 + $startTime = Carbon::now()->addMonths(-4)->toDateString();
  205 + $endTime = Carbon::now()->addMonths(-1)->toDateString();
  206 + $query->whereBetween('pdo.start_date', [$startTime,$endTime]);
  207 + }elseif($type == 2){
  208 + //4-8个月项目
  209 + $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
  210 + $endTime = Carbon::now()->addMonths(-4)->endOfDay()->toDateTimeString();
  211 + $query->whereBetween('pdo.start_date', [$startTime,$endTime]);
  212 + }else{
  213 + //大于9个月项目
  214 + $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString();
  215 + $query->where('pdo.start_date', '<', $startTime);
  216 + }
  217 + })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])
  218 + ->orderBy('project_id')
  219 + ->get();
  220 + //其他地方在引流的域名
  221 + $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray();
  222 +
  223 + foreach ($list as $project) {
  224 + $lang = WebLanguage::getLangById($project['main_lang_id']??1)['short'];
  225 + if(empty($project->domainInfo['domain'])){
  226 + continue;
  227 + }
  228 + //其他地方在引流就不再引流了
  229 + if(in_array($project->domainInfo['domain'], $other)){
  230 + continue;
  231 + }
  232 + $data = [
  233 + 'project_id' => $project['project_id'],
  234 + 'domain' => 'https://' . $project->domainInfo['domain'] . '/',
  235 + 'lang' => $lang
  236 + ];
  237 +
  238 + Redis::lpush('web_traffic_fix', json_encode($data));
  239 + }
  240 + return true;
  241 + }
  242 + /**
  243 + * @name :(统计pv)pv_num
  244 + * @author :lyh
  245 + * @method :post
  246 + * @time :2023/6/14 15:40
  247 + */
  248 + public function pv_num($yesterday){
  249 + $pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->where('updated_date', $yesterday)->count();
  250 + return $pv;
  251 + }
  252 +
  253 + /**
  254 + * @name :(统计ip)ip_num
  255 + * @author :lyh
  256 + * @method :post
  257 + * @time :2023/6/14 15:40
  258 + */
  259 + public function ip_num($yesterday)
  260 + {
  261 + $ip = DB::connection('custom_mysql')->table('gl_customer_visit')->where('updated_date', $yesterday)->count();
  262 + return $ip;
  263 + }
170 } 264 }