作者 lyh

gxdemo脚本

... ... @@ -71,26 +71,23 @@ class MonthProjectCount extends Command
$data[] = $v->month;
}
$list = $this->fillMissingMonths($data);
var_dump($list);
die();
foreach ($list as $k=>$v){
foreach ($list as $v){
$arr = [];
$v = (array)$v;
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['month'=>$v['month'],'project_id'=>$project_id]);
$info = $monthCountModel->read(['month'=>$v,'project_id'=>$project_id]);
// 获取当月开始时间
$start = date('Y-m-01', strtotime($v['month']));
$start = date('Y-m-01', strtotime($v));
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$end = date('Y-m-t', strtotime($v));
$arr['project_id'] = $project_id;
$res = $this->inquiry($url,$v['month']);
echo date('Y-m-d H:i:s') . '月份:'.$v['month']. PHP_EOL;
$res = $this->inquiry($url,$v);
echo date('Y-m-d H:i:s') . '月份:'.$v. PHP_EOL;
$arr['total'] = $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'));
$previousMonth = date('Y-m', strtotime($v . ' -1 month'));
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
if($previousInfo === false){
$arr['total'] = $arr['month_total'];
... ... @@ -114,7 +111,7 @@ class MonthProjectCount extends Command
}
}
$arr['country'] = json_encode($country);
$arr['month'] = $v['month'];
$arr['month'] = $v;
$arr = $this->pv_ip($arr,$start,$end,$project_id);
$arr = $this->sourceCount($arr,$start,$end);
if($info === false){
... ... @@ -201,6 +198,8 @@ class MonthProjectCount extends Command
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
}
public function fillMissingMonths($dates) {
// 将字符串日期转换为 Carbon 对象
$carbonDates = array_map(function($date) {
... ...