|
|
|
|
@ -409,23 +409,37 @@ class WorkMainController extends Controller
|
|
|
|
|
//开单统计
|
|
|
|
|
public function CountMakeList(){
|
|
|
|
|
$searchInfo = request('searchInfo');
|
|
|
|
|
$list = DB::table('s_list')
|
|
|
|
|
// 基础查询
|
|
|
|
|
$baseQuery = DB::table('s_list')
|
|
|
|
|
->where(['s_list.is_del' => 0, 's_list.is_nullify' => 0]);
|
|
|
|
|
if(isset($searchInfo['dateRange'])){
|
|
|
|
|
$list=$list->whereBetween('s_list.created_at', $searchInfo['dateRange']);
|
|
|
|
|
}
|
|
|
|
|
//开单总量
|
|
|
|
|
$count=$list;
|
|
|
|
|
$count=$count->count();
|
|
|
|
|
//按月开单量统计
|
|
|
|
|
$MonthCountList=$list;
|
|
|
|
|
$MonthCountList=$MonthCountList
|
|
|
|
|
->select(DB::raw('DATE_FORMAT(s_list.reservation_date, "%Y-%m") as month'), DB::raw('count(*) as count'))
|
|
|
|
|
->groupBy(DB::raw('DATE_FORMAT(s_list.reservation_date, "%Y-%m")'))->get();
|
|
|
|
|
//预约总量
|
|
|
|
|
$appointmentCount=$list;
|
|
|
|
|
$appointmentCount=$appointmentCount->where(['s_list.list_status'=>2])->count();
|
|
|
|
|
return \Yz::Return(true, '操作成功', ['MonthCountList'=>$MonthCountList,'Count'=>$count,'AppointmentCount'=>$appointmentCount]);
|
|
|
|
|
|
|
|
|
|
// 日期范围条件(如果有)
|
|
|
|
|
if(isset($searchInfo['dateRange']) && !empty($searchInfo['dateRange'])){
|
|
|
|
|
$startDate = $searchInfo['dateRange'][0] . ' 00:00:00';
|
|
|
|
|
$endDate = $searchInfo['dateRange'][1] . ' 23:59:59';
|
|
|
|
|
$baseQuery->whereBetween('s_list.created_at', [$startDate, $endDate]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 开单总量:克隆基础查询
|
|
|
|
|
$count = clone $baseQuery;
|
|
|
|
|
$count = $count->count();
|
|
|
|
|
|
|
|
|
|
// 按月开单量:克隆基础查询
|
|
|
|
|
$MonthCountList = clone $baseQuery;
|
|
|
|
|
$MonthCountList = $MonthCountList
|
|
|
|
|
->select(DB::raw('DATE_FORMAT(s_list.created_at, "%Y-%m") as month'), DB::raw('count(*) as count'))
|
|
|
|
|
->groupBy(DB::raw('DATE_FORMAT(s_list.created_at, "%Y-%m")'))
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
// 预约总量:克隆基础查询并添加条件
|
|
|
|
|
$appointmentCount = clone $baseQuery;
|
|
|
|
|
$appointmentCount = $appointmentCount->whereIn('s_list.list_status',[1,2,3])->count();
|
|
|
|
|
|
|
|
|
|
return \Yz::Return(true, '操作成功', [
|
|
|
|
|
'MonthCountList' => $MonthCountList,
|
|
|
|
|
'Count' => $count,
|
|
|
|
|
'AppointmentCount' => $appointmentCount
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|