作者 刘锟

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

... ... @@ -34,8 +34,9 @@ class UpgradeCount extends Command
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]);
$list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0,'id'=>['<=',550]]);
foreach ($list as $v) {
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->count($v['id']);
DB::disconnect('custom_mysql');
... ... @@ -58,10 +59,10 @@ class UpgradeCount extends Command
if(!empty($list)){
$arr = [];
foreach ($list as $k=>$v){
$v = (array)$v;
if($v['updated_date'] == date('Y-m-d')){
continue;
}
$v = (array)$v;
echo date('Y-m-d H:i:s') . '时间:'.$v['updated_date'] . PHP_EOL;
$count = new Count();
$arr['project_id'] = $project_id;
... ...
<?php
/**
* @remark :
* @name :UpgradeProjectCount.php
* @author :lyh
* @method :post
* @time :2024/1/8 9:03
*/
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Com\UpdateOldInfo;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\MonthCount;
use App\Models\Project\Project;
use App\Models\Visit\Visit;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use App\Models\HomeCount\Count;
class UpgradeCount extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'upgrade_month_count';
/**
* The console command description.
*
* @var string
*/
protected $description = '升级项目统计-月统计';
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0,'id'=>['<=',456]]);
foreach ($list as $v) {
$oldModel = new UpdateOldInfo();
$info = $oldModel->read(['project_id' => $v['id']]);
if ($info !== false) {
$url = $info['old_domain_online'];
}else{
continue;
}
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
$this->count($v['id'], $url);
DB::disconnect('custom_mysql');
}
}
/**
* @remark :日统计记录
* @name :count
* @author :lyh
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
$list = DB::connection('custom_mysql')->table('gl_customer_visit')
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
->groupBy('month')->get()->toArray();
foreach ($list as $k=>$v){
$v = (array)$v;
if($v['month'] == date('Y-m')){
continue;
}
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
// 获取当月开始时间
$start = date('Y-m-01', strtotime($v['month']));
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
// $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
$arr['month_total'] = $res['data']['count'];
//获取上一个的count
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
}else{
$arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
}
}
if(isset($res['data']['data'])){
$arr['country'] = json_encode($res['data']['data']);
}
$arr['month'] = $v['month'];
$arr = $this->pv_ip($arr,$start,$end,$project_id);
$arr = $this->sourceCount($arr,$start,$end);
if($info === false){
$selectedDate = $start;
$firstDayOfNextMonth = date('Y-m-01 01:00:00', strtotime("$selectedDate +1 month"));
$arr['created_at'] = $firstDayOfNextMonth;
$arr['updated_at'] = $firstDayOfNextMonth;
// echo date('Y-m-d H:i:s') . '数据:'.json_encode($arr) . PHP_EOL;
$monthCountModel->insert($arr);
}else{
$monthCountModel->edit($arr,['id'=>$info['id']]);
}
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
/**
* @remark :本月询盘总量
* @name :month_total
* @author :lyh
* @method :post
* @time :2024/1/8 11:02
*/
public function pv_ip(&$arr,$start,$end,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$start.' 00:00:00')
->where('date','<=',$end.' 23:59:59')
->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'))
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
if($arr['ip'] != 0){
$arr['rate'] = round((($arr['month_total'] ?? 0) / $arr['ip']) * 10,2);
}
return $arr;
}
/**
* @remark :来源访问前8
* @name :sourceCount
* @author :lyh
* @method :post
* @time :2023/6/30 16:14
*/
public function sourceCount(&$arr,$startTime,$endTime){
//访问来源前10
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')
->whereBetween('updated_date', [$startTime,$endTime])
->orderByDesc('count')->limit(10)->get()->toArray();
$arr['source'] = json_encode($source);
//访问国家前15
$source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')
->whereBetween('updated_date', [$startTime,$endTime])
->orderBy('ip','desc')->limit(15)->get()->toArray();
$arr['source_country'] = json_encode($source_country);
//受访界面前15
$referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('url',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('url')
->limit(15)->get()->toArray();
$arr['referrer_url'] = json_encode($referrer_url);
//访问端口
$referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('device_port',DB::raw('COUNT(*) as num'))
->orderBy('num','desc')
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('device_port')
->limit(15)->get()->toArray();
$arr['referrer_port'] = json_encode($referrer_port);
return $arr;
}
public function inquiry($url,$month){
$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;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
}
... ...
... ... @@ -55,7 +55,7 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>264]);
$list = $projectModel->list(['id'=>358]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
... ...
... ... @@ -7,13 +7,16 @@ use App\Helper\Common;
use App\Helper\Gpt;
use App\Helper\Translate;
use App\Models\Ai\AiCommand;
use App\Models\Domain\DomainInfo;
use App\Models\Mail\Mail;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\ProjectUpdateTdk;
use App\Models\User\User;
use App\Models\WebSetting\WebLanguage;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
... ... @@ -149,6 +152,8 @@ class UpdateSeoTdk extends Command
try {
$this->project = ProjectServer::useProject($project_id);
$this->seo_tdk($project_id, $task->id);
//TODO::通知C端更新所有界面
$this->sendNotify($project_id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
echo date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
... ... @@ -158,7 +163,30 @@ class UpdateSeoTdk extends Command
echo date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
}
}
public function sendNotify($project_id)
{
//获取当前项目的域名
$domainModel = new DomainInfo();
$domainInfo = $domainModel->read(['project_id'=>$project_id]);
if($domainInfo === false){
//获取测试域名
$deployBuildModel = new DeployBuild();
$buildInfo = $deployBuildModel->read(['project_id'=>$project_id]);
$this->param['domain'] = $buildInfo['test_domain'];
}else{
$this->param['domain'] = 'https://'.$domainInfo['domain'].'/';
}
$url = $this->param['domain'].'api/update_page/';
$param = [
'project_id' => $project_id,
'type' => 1,
'route' => 1,
'url' => [],
'language'=> [],
];
http_post($url, json_encode($param));
echo '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
}
public function seo_tdk($project_id, $task_id)
{
... ...
... ... @@ -149,7 +149,7 @@ class WebTrafficRussia extends Command
* 概率值
* @var int[]
*/
protected $sjjg = [360, 640];//访问间隔占比 访问|不访问 比非俄语站降一
protected $sjjg = [360, 640];//访问间隔占比 访问|不访问 比非俄语站降一
//访问页面类型占比 产品详情页、单页|产品分类页
protected $ymzb = [
'urls_cats' => 700,
... ...
... ... @@ -53,7 +53,7 @@ class WebTrafficRussiaSpecial extends Command
}
protected $projects = [
969 => 30,
969 => 60,
];
/**
... ... @@ -289,7 +289,7 @@ class WebTrafficRussiaSpecial extends Command
'referrer_url' => $this->getReferer($ips[$project_key]['ip_area'], $project['lang']),
'user_agent' => $project['user_agent'],
];
Log::channel('traffic')->info('ru_traffic project_id:' . $project['project_id'], $data);
Log::channel('traffic')->info('ru_traffic_special project_id:' . $project['project_id'], $data);
$promises[] = $client->postAsync($project['domain'] . 'api/traffic_visit', ['form_params' => $data]);
}
... ...
... ... @@ -33,6 +33,7 @@ class OptimizeController extends BaseController
public function lists(Project $project){
$query = $project->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id')
->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id')
->leftJoin('gl_domain_info', 'gl_project.id', '=', 'gl_domain_info.project_id')
->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id')
->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id');
$query = $this->searchParam($query)->orderByRaw("FIELD(gl_project.level, '2') DESC")
... ... @@ -131,8 +132,10 @@ class OptimizeController extends BaseController
$item['plan'] = Project::planMap()[$item['plan']];
$item['created_at'] = date('Y年m月d日', strtotime($item['cooperate_date']));
$item['autologin_code'] = getAutoLoginCode($item['id']);
$domainModel = new DomainInfo();
$item['domain'] = !empty($item['domain']) ? $domainModel->getDomain($item['domain']) : '';
$item['domain'] = 'https://'.$item['domain'].'/';
if(!empty($item['domain']) && $item['amp_status'] == 1){
$item['amp_domain'] = str_replace('www','m',$item['domain']);
}
$item['product_num'] = $data['product'] ?? 0;
$item['keyword_num'] = $item['key'] ?? 0;
$item['autologin_code'] = getAutoLoginCode($item['id']);
... ... @@ -186,11 +189,12 @@ class OptimizeController extends BaseController
'gl_project_deploy_optimize.tech_mid AS optimize_tech_mid',
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.tech_leader AS tech_leader',
'gl_project_deploy_optimize.domain AS domain',
'gl_project_deploy_optimize.quality_mid AS quality_mid',
'gl_project_deploy_optimize.design_mid AS design_mid',
'gl_project_deploy_optimize.start_date AS start_date',
'gl_project_deploy_optimize.backlink AS backlink',
'gl_domain_info.amp_status AS amp_status',
'gl_domain_info.domain AS domain',
];
return $select;
}
... ... @@ -246,8 +250,8 @@ class OptimizeController extends BaseController
if(isset($this->map['domain']) && !empty($this->map['domain'])){
$parsedUrl = parse_url($this->map['domain']);
$this->map['domain'] = $parsedUrl['host'] ?? $this->map['domain'];
$ids = DomainInfo::where('domain', 'like', '%'.$this->map['domain'].'%')->pluck('id')->toArray();
$query = $query->whereIn('gl_project_deploy_optimize.domain', $ids);
// $ids = DomainInfo::where('domain', 'like', '%'.$this->map['domain'].'%')->pluck('id')->toArray();
$query = $query->where('gl_domain_info.domain', 'like' ,'%'.$this->map['domain'].'%');
}
if(isset($this->map['test_domain']) && !empty($this->map['test_domain'])){
$query = $query->where('gl_project_deploy_build.test_domain','like','%'.$this->map['test_domain'].'%');
... ...
... ... @@ -397,7 +397,7 @@ class ProjectLogic extends BaseLogic
$info = $this->model->read(['id'=>$param['id']]);
if($info['delete_status'] == 0){
//删除原始项目
$this->edit(['delete_status' => 1], ['id' => $param['id']]);
$this->edit(['delete_status' => 1,'type'=>$param['type']], ['id' => $param['id']]);
//添加到续费单
$data = [
'title' => '【续费单】' . $param['title'],
... ... @@ -411,8 +411,8 @@ class ProjectLogic extends BaseLogic
'service_duration' => $param['deploy_build']['service_duration'],
'plan' => $param['deploy_build']['plan'],
'amount' => $param['payment']['amount'],
'contract' => json_encode($param['payment']['contract']),
'bill' => json_encode($param['payment']['bill']),
'contract' => json_encode($param['payment']['contract'] ?? []),
'bill' => json_encode($param['payment']['bill'] ?? []),
];
$renewModel = new ProjectRenew();
$renewModel->add($data);
... ...
... ... @@ -58,6 +58,25 @@ class SyncSubmitTaskService
/**
* 特殊处理项目 去掉来源url的全部参数
*/
public function handle_referer($referer){
$url = [
'www.shphe.ru',
'www.mainpaper.ru',
'www.jinbiao.ru',
'www.gyhockey.ru',
];
if(Str::contains($referer, $url)){
$referer = pathinfo($referer,PATHINFO_DIRNAME);
}
return $referer;
}
/**
* 询盘
* @param $data
* @return bool
... ... @@ -75,6 +94,8 @@ class SyncSubmitTaskService
$form_id = InquiryForm::getFromId($data['data']);
$data['referer'] = $this->handle_referer($data['referer']);
InquiryFormData::saveData($form_id, $data['domain'], $data['ip'], $data['country'], $data['referer'], $data['user_agent'], $data['submit_at'], $data['data']);
//转化询盘
... ... @@ -102,7 +123,7 @@ class SyncSubmitTaskService
$referrer_url = $url_arr['scheme'] . '://' . $url_arr['host'] . '/';
}
}
$visit_data['referrer_url'] = $referrer_url;
$visit_data['referrer_url'] = $this->handle_referer($referrer_url);
$visit_data['device_port'] = $data['data']['device_port']??'';
$visit_data['url'] = $data['data']['url']??'';
$visit_data['domain'] = $data['domain']??'';
... ...
... ... @@ -14,8 +14,8 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/editPassword', [Aside\Com\IndexController::class, 'editPassword'])->name('admin.editPassword.white');
Route::get('/logout', [Aside\LoginController::class, 'logout'])->name('admin.logout.white');
Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
Route::get('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
Route::get('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
//会员相关
Route::prefix('user')->group(function () {
... ...