where('status', 3) ->get(); foreach ($order as $item) { if ($item->invite_user_id) { $inviter = User::find($item->invite_user_id); if (!$inviter) continue; $inviter->commission_balance = $inviter->commission_balance + $item->commission_balance; if ($inviter->save()) { $item->commission_status = 1; $item->save(); } } } } }