-- C3 stok yarışı doğrulama
SELECT id, stock_quantity FROM products WHERE id = 17;

SELECT o.order_number, o.status, o.customer_email, o.created_at
FROM ecommerce_orders o
WHERE o.customer_email LIKE 'qa-c3-%@faunamix.test'
  AND o.created_at > UTC_TIMESTAMP() - INTERVAL 2 HOUR
ORDER BY o.id;

SELECT l.order_id, o.order_number, l.product_id, l.qty_delta, l.reason, l.note, l.created_at
FROM ecommerce_stock_ledger l
JOIN ecommerce_orders o ON o.id = l.order_id
WHERE o.customer_email LIKE 'qa-c3-%@faunamix.test'
  AND l.created_at > UTC_TIMESTAMP() - INTERVAL 2 HOUR
ORDER BY l.id;

SELECT e.order_id, o.order_number, e.from_status, e.to_status, e.source, e.note
FROM ecommerce_order_status_events e
JOIN ecommerce_orders o ON o.id = e.order_id
WHERE o.customer_email LIKE 'qa-c3-%@faunamix.test'
  AND e.created_at > UTC_TIMESTAMP() - INTERVAL 2 HOUR
ORDER BY e.id;
