作者 赵彬吉

update

... ... @@ -5,7 +5,7 @@ namespace App\Console\Commands\DayCount;
use App\Helper\Common;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
... ... @@ -146,8 +146,8 @@ class Count extends Command
//加上其他询盘
ProjectServer::useProject($project_id);
$arr['inquiry_num'] = InquiryOther::count();
$countryData = InquiryOther::select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray();
$arr['inquiry_num'] += InquiryFormData::count();
$countryData = InquiryFormData::select("country",DB::raw('COUNT(*) as count'))->groupBy('country')->get()->toArray();
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
... ...
... ... @@ -3,7 +3,7 @@
namespace App\Console\Commands;
use App\Helper\FormGlobalsoApi;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
... ... @@ -56,7 +56,7 @@ class LastInquiry extends Command
$last_time = $res['data']['data'][0] ?? '';
//其他询盘的最新时间
ProjectServer::useProject($item['id']);
$other_last_time = InquiryOther::orderBy('id', 'desc')->value('submit_time');
$other_last_time = InquiryFormData::orderBy('id', 'desc')->value('submit_time');
$last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time;
... ...
... ... @@ -4,7 +4,7 @@ namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Carbon\Carbon;
... ... @@ -107,9 +107,9 @@ class InquiryMonthlyCount extends Command
}
//加上其他询盘
ProjectServer::useProject($project_id);
$arr['total'] += InquiryOther::count();
$arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
$arr['total'] += InquiryFormData::count();
$arr['month_total'] += InquiryFormData::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryFormData::whereBetween('submit_time',[$startTime, $endTime])
->select("country",DB::raw('COUNT(*) as count'))
->groupBy('country')->get()->toArray();
foreach ($countryData as $v1){
... ...
... ... @@ -2,30 +2,21 @@
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\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\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\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 +32,7 @@ class Test extends Command
*
* @var string
*/
protected $description = '测试';
protected $description = '';
/**
* Create a new command instance.
... ... @@ -58,52 +49,48 @@ 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;
}
try {
$list = Count::where('pv_num', 0)->get();
foreach ($list as $v){
$v->pv_num = $this->pv_num($v['date']);
//ip统计
$v->ip_num = $this->ip_num($v['date']);
$v->save();
echo $v['date'] . ':' . $v->pv_num .':'. $v->ip_num . PHP_EOL;
}
public function sync($domain){
echo date('Y-m-d H:i:s') . "同步项目{$domain}" . PHP_EOL;
if(!Str::startsWith($domain,'www.')){
$domain = 'www.'.$domain;
}catch (\Exception $e){
echo '保存失败' . $e->getMessage() . PHP_EOL;
}
$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;
echo "finish";
}
$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++;
}
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;
/**
* @name :(统计pv)pv_num
* @author :lyh
* @method :post
* @time :2023/6/14 15:40
*/
public function pv_num($yesterday){
$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $yesterday)->count();
return $pv;
}
/**
* @name :(统计ip)ip_num
* @author :lyh
* @method :post
* @time :2023/6/14 15:40
*/
public function ip_num($yesterday){
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $yesterday)->count();
return $ip;
}
}
... ...
... ... @@ -6,7 +6,7 @@ use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\HomeCount\Count;
use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryOther;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\DeployOptimize;
use App\Services\ProjectServer;
use Carbon\Carbon;
... ... @@ -86,9 +86,9 @@ class MonthCountLogic extends BaseLogic
}
}
//加上其他询盘
$arr['total'] += InquiryOther::count();
$arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
$arr['total'] += InquiryFormData::count();
$arr['month_total'] += InquiryFormData::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryFormData::whereBetween('submit_time',[$startTime, $endTime])
->select("country",DB::raw('COUNT(*) as count'))
->groupBy('country')->get()->toArray();
foreach ($countryData as $v1){
... ...