prepare("SELECT id, status FROM food_merchants WHERE id=? LIMIT 1"); $st->execute([$merchantId]); $merchant = $st->fetch(); if (!$merchant) jsonError('Merchant not found', 404); if ($merchant['status'] !== 'pending_approval') jsonError('Merchant is not pending approval', 409); $newStatus = $action === 'approve' ? 'active' : 'rejected'; $food_con->prepare( "UPDATE food_merchants SET status=?, approved_by=?, approved_at=NOW() WHERE id=?" )->execute([$newStatus, $food_admin_id, $merchantId]); jsonSuccess(['merchant_id' => $merchantId, 'status' => $newStatus]);