作者 刘锟

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

... ... @@ -82,7 +82,7 @@ class Count extends Command
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain'], $v['id']);
$arr = $this->inquiry($arr,$v['test_domain'], $v['id'] , $v['is_upgrade'] ?? 0);
if($arr === false){
continue;
}
... ... @@ -134,8 +134,8 @@ class Count extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ... @@ -175,6 +175,7 @@ class Count extends Command
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.remain_day AS remain_day',
'gl_project.finish_remain_day AS finish_remain_day',
'gl_project_deploy_build.test_domain AS test_domain',
... ...
... ... @@ -101,8 +101,8 @@ class CountAll extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ...
... ... @@ -32,7 +32,7 @@ class CountDate extends Command
*
* @var string
*/
protected $description = '统计昨日数据';
protected $description = '时间统计记录';
/**
* @name :(定时执行生成昨日数据统计)handle
... ... @@ -84,7 +84,7 @@ class CountDate extends Command
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain'], $v['id']);
$arr = $this->inquiry($arr,$v['test_domain'], $v['id'],$v['is_upgrade'] ?? 0);
if($arr === false){
continue;
}
... ... @@ -136,8 +136,8 @@ class CountDate extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ... @@ -177,6 +177,7 @@ class CountDate extends Command
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.remain_day AS remain_day',
'gl_project.finish_remain_day AS finish_remain_day',
'gl_project_deploy_build.test_domain AS test_domain',
... ...
... ... @@ -52,7 +52,7 @@ class CountProject extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id){
public function count($project_id,$is_upgrade = 0){
$list = DB::connection('custom_mysql')->table('gl_customer_visit')->select('updated_date')
->groupBy('updated_date')->get()->toArray();
$project = new Project();
... ... @@ -87,7 +87,7 @@ class CountProject extends Command
$arr['compliance_day'] = $projectInfo['finish_remain_day'];
//剩余服务时常
$arr['service_day'] = $projectInfo['remain_day'];
$arr = $this->inquiry($arr,$domain, $project_id);
$arr = $this->inquiry($arr,$domain, $project_id,$projectInfo['is_upgrade'] ?? 0);
//查询当天数据是否存在 存在则更新
$info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]);
if($info === false){
... ... @@ -144,8 +144,8 @@ class CountProject extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ...
... ... @@ -53,6 +53,7 @@ class SyncInquiry extends Command
{
while (true) {
$result = $this->getInquiry();
$this->output('新的询盘:' . count($result));
if (!$result){
//5分钟同步一次
sleep(300);
... ...
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2024/09/30
* Time: 14:01
*/
namespace App\Console\Commands\Inquiry;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Models\Inquiry\ReInquiryForm;
use App\Models\Inquiry\ReInquiryText;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
/**
* Class SyncInquiry
* @package App\Console\Commands\Inquiry
*/
class SyncInquiryText extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sync_inquiry_text';
/**
* The console command description.
*
* @var string
*/
protected $description = '同步询盘文案';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
$res = HttpUtils::get('https://fob.ai.cc/api/get_inquiry_text', ['type' => 'all']);
if($res){
$res = Arr::s2a($res);
foreach ($res as $item){
ReInquiryText::createText($item['id'], $item['title'], $item['content'], $item['status']);
}
}
}
}
... ...
... ... @@ -49,6 +49,7 @@ class postInquiry extends Command
}
// 询盘数据入库
foreach ($list as $key => $val) {
$this->output('开始执行' . $val->id);
try {
$detail = ReInquiryDetail::find($val['detail_id']);
if($val['type'] == 1){
... ... @@ -68,7 +69,11 @@ class postInquiry extends Command
}
}
}catch (\Exception $e){
Log::channel('inquiry_relay')->error('inquiry_relay handle error', [$e->getMessage(), $e->getFile(), $e->getLine()]);
$val->status = ReInquiryDetailLog::STATUS_FAIL;
$val->remark = mb_substr($e->getMessage(), 0, 200);
$val->save();
}
}
}
... ... @@ -90,6 +95,7 @@ class postInquiry extends Command
$log->save();
Log::channel('inquiry_relay')->error('inquiry_relay visit error', [$res, $detail['re_website'] . 'api/traffic_visit/',$data]);
return false;
}
}else{
//v4 v5分离项目 往测试链接推
... ... @@ -118,8 +124,12 @@ class postInquiry extends Command
$log->save();
Log::channel('inquiry_relay')->error('inquiry_relay v4|v5 visit error', [$res, $website . 'wp-admin/admin-ajax.php', $data]);
return false;
}
}
$log->status = ReInquiryDetailLog::STATUS_SUCCESS;
$log->save();
return true;
}
public function inquiry(ReInquiryDetail $detail, ReInquiryDetailLog $log){
... ... @@ -170,6 +180,8 @@ class postInquiry extends Command
return false;
}
}
$log->status = ReInquiryDetailLog::STATUS_SUCCESS;
$log->save();
return true;
}
... ...
... ... @@ -59,7 +59,7 @@ class MonthAllCount extends Command
}
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
$this->count($v['id'], $url);
$this->count($v['id'], $url ,$v['is_upgrade']);
DB::disconnect('custom_mysql');
}
}
... ... @@ -71,7 +71,7 @@ class MonthAllCount extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade = 0){
$list = DB::connection('custom_mysql')->table('gl_customer_visit')
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
->groupBy('month')->get()->toArray();
... ... @@ -85,7 +85,7 @@ class MonthAllCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month'],$is_upgrade ?? 0);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
... ...
... ... @@ -67,7 +67,7 @@ class MonthCount extends Command
}
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
$this->count($v['id'], $url);
$this->count($v['id'], $url ,$v['is_upgrade'] ?? 0);
DB::disconnect('custom_mysql');
}
}
... ... @@ -99,7 +99,7 @@ class MonthCount extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade = 0){
$arr = [];
$v = ['month'=>date('Y-m')];
$monthCountModel = new MonthCountModel();
... ... @@ -109,7 +109,7 @@ class MonthCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month'],$is_upgrade ?? 0);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
... ...
... ... @@ -67,7 +67,7 @@ class MonthCountDate extends Command
}
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
$this->count($v['id'], $url);
$this->count($v['id'], $url , $v['is_upgrade'] ?? 0);
DB::disconnect('custom_mysql');
}
}
... ... @@ -99,7 +99,7 @@ class MonthCountDate extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade){
$arr = [];
$date = $this->argument('date');
$v = ['month'=>$date];
... ... @@ -110,7 +110,7 @@ class MonthCountDate extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month'],$is_upgrade ?? 0);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
... ...
... ... @@ -49,8 +49,10 @@ class MonthProjectCount extends Command
$info = $domainModel->read(['project_id'=>$project_id]);
$url = $info['domain'];
}
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id]);
ProjectServer::useProject($project_id);
$this->count($project_id,$url);
$this->count($project_id,$url,$projectInfo['is_upgrade'] ?? 0);
DB::disconnect('custom_mysql');
}
... ... @@ -61,7 +63,7 @@ class MonthProjectCount extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade = 0){
$data = [];
$list = DB::connection('custom_mysql')->table('gl_customer_visit')
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
... ... @@ -80,7 +82,7 @@ class MonthProjectCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v ,$is_upgrade ?? 0);
echo date('Y-m-d H:i:s') . '月份:'.$v. PHP_EOL;
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
... ...
... ... @@ -2,8 +2,10 @@
namespace App\Console\Commands\RankData;
use App\Helper\QuanqiusouApi;
use App\Http\Logic\Bside\RankData\RankDataLogic;
use App\Models\Project\DeployOptimize;
use App\Models\RankData\RankData;
use Illuminate\Support\Facades\Log;
/**
... ... @@ -34,6 +36,23 @@ class IndexedPages extends BaseCommands
* @date 2023/5/11
*/
public function do(){
$api = new QuanqiusouApi();
$site_res = $api->getSiteRes();
if (!$site_res) {
Log::channel('rank_data')->error('谷歌收录数据获取失败');
}else{
foreach ($site_res as $api_no => $num){
$project_ids = DeployOptimize::where('api_no', $api_no)->pluck('project_id');
foreach ($project_ids as $project_id){
$rank_data = RankData::where('project_id', $project_id)->where('lang', '')->first();
if($rank_data){
$rank_data->indexed_pages_num = $num;
$rank_data->save();
}
}
}
}
//有排名api编号的项目
$list = DeployOptimize::where('api_no', '>', 0)->pluck('api_no', 'project_id')->toArray();
Log::channel('rank_data')->info('开始-页面收录数据-'.count($list));
... ...
... ... @@ -144,7 +144,7 @@ class Test extends Command
try {
$list = Count::where('date', '2023-12-11')->where('project_id', $project->id)->get();
foreach ($list as $v){
$arr = $this->inquiry([],$test_domain, $v['id']);
$arr = $this->inquiry([],$test_domain, $v['id'],$project->is_upgrade ?? 0);
$v->inquiry_num = $arr['inquiry_num'];
$v->country = $arr['country'];
$v->save();
... ... @@ -157,8 +157,8 @@ class Test extends Command
echo "finish";
}
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade ?? 0);
if($inquiry_list['status'] == 400){
$arr['inquiry_num'] = 0;
$countryArr = [];
... ...
... ... @@ -56,16 +56,16 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[1799]]]);
$list = $projectModel->list(['id'=>['in',[1148]]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->getProduct();
// $this->setProductKeyword();
$this->setProductKeyword();
// $this->getBlog();
// $this->setCustomRoute($v['id']);
$this->editProductAlt();
// $this->editProductAlt();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -131,6 +131,8 @@ class UpdateRoute extends Command
foreach ($lists as $v){
if(!empty($v['route'])){
echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
$route = $this->setRoute($v['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $v['project_id']);
$keywordModel->edit(['route'=>$route],['id'=>$v['id']]);
continue;
}else{
echo date('Y-m-d H:i:s') . 'route :'.$v['id'] . PHP_EOL;
... ...
... ... @@ -42,6 +42,8 @@ class Kernel extends ConsoleKernel
// 每日推送已完成视频任务项目生成对应界面
//更新AI站点数据
$schedule->command('updateAiProjects')->everyFourHours()->withoutOverlapping(1);
//每日同步询盘文案
$schedule->command('sync_inquiry_text')->dailyAt('09:00')->withoutOverlapping(1);
}
/**
... ...
... ... @@ -162,12 +162,19 @@ class FormGlobalsoApi
* @method :post
* @time :2024/8/15 14:16
*/
public function getInquiryAll($domain){
public function getInquiryAll($domain,$is_upgrade = 0){
if (!(strpos($domain, 'https://') === 0)) {
$domain = 'https://'.$domain.'/';
}
$token = md5($domain.date("Y-m-d"));
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
$data = [
'domain' => $domain,
'token' => $token,
'source'=> $is_upgrade ? '1,2,3,4' : '1,3',
'num'=>15,
];
$queryString = http_build_query($data);
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?".$queryString;
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
... ... @@ -184,10 +191,18 @@ class FormGlobalsoApi
* @method :post
* @time :2024/8/16 10:16
*/
public function getMonthInquiry($url,$month){
public function getMonthInquiry($url,$month,$is_upgrade = 0){
$url = 'https://'.$url.'/';
$token = md5($url.date("Y-m-d"));
$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;
$data = [
'domain' => $url,
'token' => $token,
'source'=> $is_upgrade ? '1,2,3,4' : '1,3',
'model' => 'month',
'sta_date'=>$month,
];
$queryString = http_build_query($data);
$url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?'.$queryString;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
... ...
... ... @@ -75,7 +75,7 @@ class OptimizationReportController extends BaseController
//关键词排名明细
$data['keywords_rank_list'] = $this->keywords_rank_list($this->param['project_id'],$projectInfo);
//pv_ip统计
$data['pv_ip'] = $this->pv_ip($domain_info['domain']);
$data['pv_ip'] = $this->pv_ip($domain_info['domain'],$projectInfo['is_upgrade']);
//30天统计
$data['count_30'] = $this->count_30_total();
//访问国家前10
... ... @@ -321,10 +321,10 @@ class OptimizationReportController extends BaseController
* @method :post
* @time :2024/3/7 16:53
*/
public function pv_ip($domain){
public function pv_ip($domain,$is_upgrade = 0){
$pv = (new VisitItem())->count();
$ip = (new Visit())->count();
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade ?? 0);
if(!empty($inquiry_list)){
$total = $inquiry_list['data']['count'] ?? 0;
}
... ...
... ... @@ -124,7 +124,8 @@ class AdsController extends BaseController
$channel = Project::where('id', $domain_info['project_id'])->value('channel');
$data = [
'is_v6' => 1,
'agent' => Channel::getChannelText($channel['user_id']??0)
'agent' => Channel::getChannelText($channel['user_id']??0),
'domain' => $domain,
];
return $this->response('success', Code::SUCCESS, $data);
}
... ... @@ -141,7 +142,8 @@ class AdsController extends BaseController
}
$data = [
'is_v6' => 0,
'agent' => $res['data']
'agent' => $res['data'],
'domain' => $domain,
];
return $this->response('success', Code::SUCCESS, $data);
}
... ...
... ... @@ -111,7 +111,7 @@ class TaskController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getTaskInfo();
return $this->response('success',Code::SUCCESS,$data);
$this->response('success',Code::SUCCESS,$data);
}
/**
... ...