|
...
|
...
|
@@ -64,6 +64,8 @@ class MonthProjectCount extends Command |
|
|
|
$list = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
|
|
|
|
->groupBy('month')->get()->toArray();
|
|
|
|
var_dump($list);
|
|
|
|
die();
|
|
|
|
foreach ($list as $k=>$v){
|
|
|
|
$arr = [];
|
|
|
|
$v = (array)$v;
|
|
...
|
...
|
@@ -88,13 +90,6 @@ class MonthProjectCount extends Command |
|
|
|
}else{
|
|
|
|
$arr['total'] = $res['data']['count'] + ($previousInfo['total'] ?? 0);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//获取上一个的count
|
|
|
|
$previousMonth = date('Y-m', strtotime($v['month'] . ' -1 month'));
|
|
|
|
$previousInfo = $monthCountModel->read(['month'=>$previousMonth,'project_id'=>$project_id]);
|
|
|
|
if($previousInfo !== false){
|
|
|
|
$arr['total'] = $previousInfo['total'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取当月的其他询盘
|
|
|
|
$arr['total'] += InquiryFormData::getCount([$start.' 00:00:00',$end.' 00:00:00']);
|
|
...
|
...
|
@@ -199,5 +194,30 @@ 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) {
|
|
|
|
return Carbon::createFromFormat('Y-m', $date);
|
|
|
|
}, $dates);
|
|
|
|
// 排序日期,确保列表按时间顺序排列
|
|
|
|
usort($carbonDates, function($a, $b) {
|
|
|
|
return $a->gt($b);
|
|
|
|
});
|
|
|
|
// 用于存储完整日期的数组
|
|
|
|
$completeDates = [];
|
|
|
|
// 遍历日期列表,补齐中间缺失的月份
|
|
|
|
for ($i = 0; $i < count($carbonDates) - 1; $i++) {
|
|
|
|
$current = $carbonDates[$i];
|
|
|
|
$next = $carbonDates[$i + 1];
|
|
|
|
// 将当前月份加入完整日期数组
|
|
|
|
array_push($completeDates, $current->format('Y-m'));
|
|
|
|
// 循环补齐中间缺失的月份
|
|
|
|
while ($current->addMonth()->lt($next)) {
|
|
|
|
array_push($completeDates, $current->format('Y-m'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 加入最后一个月份
|
|
|
|
array_push($completeDates, $carbonDates[count($carbonDates) - 1]->format('Y-m'));
|
|
|
|
return $completeDates;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|