|
...
|
...
|
@@ -2,30 +2,24 @@ |
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use App\Http\Logic\Aside\Project\DomainInfoLogic;
|
|
|
|
use App\Models\Com\UpdateNotify;
|
|
|
|
use App\Models\Devops\DevopsTask as DevopsTaskModel;
|
|
|
|
use App\Models\Devops\DevopsTaskLog;
|
|
|
|
|
|
|
|
|
|
|
|
use App\Helper\FormGlobalsoApi;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\File\File;
|
|
|
|
use App\Models\File\Image;
|
|
|
|
use App\Models\Product\CategoryRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\HomeCount\Count;
|
|
|
|
use App\Models\Inquiry\InquiryFormData;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Template\BCustomTemplate;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Database\QueryException;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use mysql_xdevapi\Exception;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 测试
|
|
|
|
* Class Traffic
|
|
|
|
* Class Test
|
|
|
|
* @package App\Console\Commands
|
|
|
|
* @author zbj
|
|
|
|
* @date 2023/5/18
|
|
|
|
* @date 2023/4/25
|
|
|
|
*/
|
|
|
|
class Test extends Command
|
|
|
|
{
|
|
...
|
...
|
@@ -41,7 +35,7 @@ class Test extends Command |
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '测试';
|
|
|
|
protected $description = '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
...
|
...
|
@@ -58,52 +52,70 @@ class Test extends Command |
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$domains = DB::table('gl_customer_visit')->groupBy('domain')->select('domain')->pluck('domain')->toArray();
|
|
|
|
foreach($domains as $domain){
|
|
|
|
if(!Str::contains($domain, 'globalso.site')){
|
|
|
|
$this->sync($domain);
|
|
|
|
$projects = Project::all();
|
|
|
|
foreach ($projects as $project){
|
|
|
|
echo "project " . $project->id;
|
|
|
|
if(!ProjectServer::useProject($project->id)){
|
|
|
|
echo '未配置数据库' . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$test_domain = $project->deploy_build['test_domain'];
|
|
|
|
$domainInfo = new DomainInfo();
|
|
|
|
$info = $domainInfo->read(['id'=>$project->deploy_optimize['domain']]);
|
|
|
|
if($info !== false){
|
|
|
|
$test_domain = $info['domain'];
|
|
|
|
}
|
|
|
|
|
|
|
|
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']);
|
|
|
|
$v->inquiry_num = $arr['inquiry_num'];
|
|
|
|
$v->country = $arr['country'];
|
|
|
|
$v->save();
|
|
|
|
echo $v['date'] . ':' . $v->pv_num .':'. $v->ip_num . PHP_EOL;
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
echo '保存失败' . $e->getMessage() . PHP_EOL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "finish";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sync($domain){
|
|
|
|
echo date('Y-m-d H:i:s') . "同步项目{$domain}" . PHP_EOL;
|
|
|
|
if(!Str::startsWith($domain,'www.')){
|
|
|
|
$domain = 'www.'.$domain;
|
|
|
|
}
|
|
|
|
$project_id = DomainInfo::where('domain', $domain)->value('project_id');
|
|
|
|
if(!$project_id){
|
|
|
|
echo date('Y-m-d H:i:s') . "项目{$domain}不存在" . PHP_EOL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(!ProjectServer::useProject($project_id)){
|
|
|
|
echo date('Y-m-d H:i:s') . "项目{$domain}数据库配置无效" . PHP_EOL;
|
|
|
|
return true;
|
|
|
|
public function inquiry($arr,$domain,$project_id){
|
|
|
|
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
|
|
|
|
if($inquiry_list['status'] == 400){
|
|
|
|
$arr['inquiry_num'] = 0;
|
|
|
|
$countryArr = [];
|
|
|
|
}else{
|
|
|
|
$arr['inquiry_num'] = $inquiry_list['data']['total'];
|
|
|
|
//询盘国家统计
|
|
|
|
$countryData = $inquiry_list['data']['data'];
|
|
|
|
$countryArr = [];
|
|
|
|
foreach ($countryData as $v1){
|
|
|
|
if(isset($countryArr[$v1['country']])){
|
|
|
|
$countryArr[$v1['country']]++;
|
|
|
|
}else{
|
|
|
|
$countryArr[$v1['country']] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$visit = 0;
|
|
|
|
$visit_item = 0;
|
|
|
|
$list = DB::table('gl_customer_visit')->whereIn('domain', [$domain, str_replace('www.','',$domain)])->get();
|
|
|
|
foreach ($list as $v){
|
|
|
|
$v = (array) $v;
|
|
|
|
|
|
|
|
$items = DB::table('gl_customer_visit_item')->where('customer_visit_id', $v['id'])->get();
|
|
|
|
|
|
|
|
unset($v['id']);
|
|
|
|
$id = DB::connection('custom_mysql')->table('gl_customer_visit')->insertGetId($v);
|
|
|
|
|
|
|
|
$visit++;
|
|
|
|
|
|
|
|
$data = [];
|
|
|
|
foreach ($items as $item){
|
|
|
|
$item = (array) $item;
|
|
|
|
unset($item['id']);
|
|
|
|
$item['customer_visit_id'] = $id;
|
|
|
|
$data[] = $item;
|
|
|
|
$visit_item++;
|
|
|
|
//加上其他询盘
|
|
|
|
$arr['inquiry_num'] += InquiryFormData::getCount();
|
|
|
|
$countryData = InquiryFormData::getCountryCount();
|
|
|
|
foreach ($countryData as $v1){
|
|
|
|
if(isset($countryArr[$v1['country']])){
|
|
|
|
$countryArr[$v1['country']] += $v1['count'];
|
|
|
|
}else{
|
|
|
|
$countryArr[$v1['country']] = $v1['count'];
|
|
|
|
}
|
|
|
|
DB::connection('custom_mysql')->table('gl_customer_visit_item')->insert($data);
|
|
|
|
}
|
|
|
|
echo date('Y-m-d H:i:s') . "visit:{$visit};item:{$visit_item}" . PHP_EOL;exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
arsort($countryArr);
|
|
|
|
$top20 = array_slice($countryArr, 0, 20, true);
|
|
|
|
$arr['country'] = json_encode($top20);
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|