|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @remark :
|
|
|
|
* @name :UpgradeProjectCount.php
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/8 9:03
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Console\Commands\DayCount;
|
|
|
|
|
|
|
|
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_count';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = '升级项目统计';
|
|
|
|
|
|
|
|
public function handle(){
|
|
|
|
$projectModel = new Project();
|
|
|
|
$list = $projectModel->list(['is_upgrade'=>1,'delete_status'=>0]);
|
|
|
|
foreach ($list as $v) {
|
|
|
|
ProjectServer::useProject($v['id']);
|
|
|
|
$this->count($v['id']);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :日统计记录
|
|
|
|
* @name :count
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/8 9:05
|
|
|
|
*/
|
|
|
|
public function count($project_id){
|
|
|
|
$list = DB::connection('custom_mysql')->table('gl_customer_visit')->select('updated_date')
|
|
|
|
->groupBy('updated_date')->get()->toArray();
|
|
|
|
$project = new Project();
|
|
|
|
$projectInfo = $project->read(['id'=>$project_id]);
|
|
|
|
if(!empty($list)){
|
|
|
|
$arr = [];
|
|
|
|
foreach ($list as $k=>$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;
|
|
|
|
$arr['date'] = $v['updated_date'];
|
|
|
|
$arr['pv_num'] = $this->pv_num($v['updated_date']);
|
|
|
|
$arr['ip_num'] = $this->ip_num($v['updated_date']);
|
|
|
|
$arr['inquiry_num'] = $this->inquiry_num($v['updated_date']);
|
|
|
|
//服务达标天数
|
|
|
|
$arr['compliance_day'] = $projectInfo['finish_remain_day'];
|
|
|
|
//剩余服务时常
|
|
|
|
$arr['service_day'] = $projectInfo['remain_day'];
|
|
|
|
$arr['country'] = json_encode([]);
|
|
|
|
//查询当天数据是否存在 存在则更新
|
|
|
|
$info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]);
|
|
|
|
if($info === false){
|
|
|
|
$arr['created_at'] = $v['updated_date'].' 01:00:00';
|
|
|
|
$arr['updated_at'] = $v['updated_date'].' 01:00:00';
|
|
|
|
$count->insert($arr);
|
|
|
|
}else{
|
|
|
|
$count->edit($arr,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :询盘数量
|
|
|
|
* @name :inquiry_num
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/8 9:24
|
|
|
|
*/
|
|
|
|
public function inquiry_num($day){
|
|
|
|
$count = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->where('is_inquiry',1)->count();
|
|
|
|
return $count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(统计pv)pv_num
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/14 15:40
|
|
|
|
*/
|
|
|
|
public function pv_num($day){
|
|
|
|
//$pv = DB::connection('custom_mysql')->table('gl_customer_visit_item')->whereDate('updated_date', $day)->count();
|
|
|
|
$pv = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->sum('depth');
|
|
|
|
return $pv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(统计ip)ip_num
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/14 15:40
|
|
|
|
*/
|
|
|
|
public function ip_num($day){
|
|
|
|
$ip = DB::connection('custom_mysql')->table('gl_customer_visit')->whereDate('updated_date', $day)->count();
|
|
|
|
return $ip;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|