$date=date('Y-m-d 23:59:59');
$res=DB::table('explor_agent_income_log')
->select(DB::raw('SUM(money) as count'),
DB::raw("FROM_UNIXTIME(create_time,'%m.%d') as time"))
->where('agent_pid',$agent_pid)
->where('is_agent',1)
->where('settlement',1)
->whereBetween('create_time',[$firstDay,$lastDay])
->orderBy('create_time','asc')
->groupBy('time')->get()->toArray();
$allDay=date("t",strtotime($date));
$count = array_column($res,'count');
$estimate_income=array_sum($count);
$time = array_column($res,'time');
$combine = array_combine($time,$count);
for($i=1;$i<=$allDay;$i++){
if($i<10){
$day = date('m.'.'0'.$i);
}else{
$day = date('m.'.$i);
}
$count=$combine[$day]??0;
$thirty_total[] = [
$day=>$count,
];
}
$result['income']=$thirty_total;
PHP输出整月数据
最新推荐文章于 2023-02-08 14:03:05 发布