作者 Your Name
... ... @@ -76,7 +76,7 @@ class Count extends Command
//服务达标天数
$arr['compliance_day'] = $v['finish_remain_day'];
//剩余服务时常
$arr['service_day'] = $v['remain_day'] - 1;
$arr['service_day'] = ($v['remain_day'] - 1) < 0 ? 0: $v['remain_day'] - 1;
//项目id
$arr['project_id'] = $v['project_id'];
$arr['created_at'] = date('Y-m-d H:i:s');
... ... @@ -86,7 +86,14 @@ class Count extends Command
if($arr === false){
$data[] = $v['test_domain'];
}
//查询当天数据是否存在 存在则更新
$countModel = new \App\Models\HomeCount\Count();
$info = $countModel->read(['date'=>$arr['date'],'project_id'=>$v['id']]);
if($info === false){
DB::table('gl_count')->insert($arr);
}else{
$countModel->edit($arr,['id'=>$info['id']]);
}
Log::channel('day_count')->error('日期:'.$arr['created_at'].'success: ' .$v['test_domain']);
}
}
... ...