更新统计

main
岩仔88 1 month ago
parent 72cbcfc0b5
commit 8628b78222

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

Loading…
Cancel
Save