作者 开飞机的舒克

优化定时任务

... ... @@ -24,16 +24,22 @@ class Crontab extends Api
{
//查询未生成的条形码
$id = db('study')->where('generate', 0)->limit(10)->column('id');
foreach ($id as $k => $v){
if (empty($id)) {
$this->error('不执行', ['status' => 0]);
}
foreach ($id as $k => $v) {
$res = str_pad($v, 8, "0", STR_PAD_LEFT);
$barpath = Resource::StudyBar($res);
db('study')
->where('id',$v)
->where('id', $v)
->update([
'barcode' => $barpath,
'unique' => $res,
'generate'=>1
'generate' => 1
]);
}
$this->success('执行成功', ['status' => 1]);
}
}
\ No newline at end of file
... ...
... ... @@ -5772,7 +5772,7 @@
</div>
<div class="col-md-6" align="right">
Generated on 2023-03-29 09:03:42 <a href="./" target="_blank">校园活动</a>
Generated on 2023-03-29 09:34:32 <a href="./" target="_blank">校园活动</a>
</div>
</div>
... ...