where('created_at', '<=', $date) ->chunkById(100,function ($list){ foreach ($list as $item){ DB::beginTransaction(); try { //取消订单 Order::where('id',$item->{'id'})->update(['order_status'=>3]); DB::commit(); }catch (\Exception $e){ DB::rollBack(); } } }); return true; } }