-- ============================================
-- Cartzilla Shop - Seed Data
-- ============================================
-- Date de test pentru magazinul online Cartzilla
-- Versiune: 2.0
-- Data: 2024
-- ============================================
-- Parolă pentru toți utilizatorii și adminii: "password"
-- Hash: $2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi
-- ============================================

-- ============================================
-- 1. ADMINISTRATORI
-- ============================================
INSERT INTO `admins` (`username`, `email`, `password`, `role`) VALUES
('admin', 'admin@cartzilla-shop.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'super_admin'),
('manager', 'manager@cartzilla-shop.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'admin')
ON DUPLICATE KEY UPDATE `username`=`username`;

-- ============================================
-- 2. CATEGORII
-- ============================================
-- Categorii principale
INSERT INTO `categories` (`name`, `slug`, `description`, `image`, `banner_image`, `is_active`, `sort_order`, `parent_id`) VALUES
('Electronice', 'electronice', 'Produse electronice și gadget-uri', NULL, NULL, 1, 1, NULL),
('Fashion', 'fashion', 'Modă și accesorii', NULL, NULL, 1, 2, NULL),
('Casa & Grădină', 'casa-gradina', 'Produse pentru casă și grădină', NULL, NULL, 1, 3, NULL),
('Sport & Outdoor', 'sport-outdoor', 'Echipament sport și outdoor', NULL, NULL, 1, 4, NULL),
('Auto & Moto', 'auto-moto', 'Accesorii auto și moto', NULL, NULL, 1, 5, NULL)
ON DUPLICATE KEY UPDATE `name`=`name`;

-- Subcategorii Electronice
SET @cat_electronice = (SELECT id FROM categories WHERE slug = 'electronice');
INSERT INTO `categories` (`name`, `slug`, `description`, `image`, `is_active`, `sort_order`, `parent_id`) VALUES
('Telefoane', 'telefoane', 'Telefoane mobile și accesorii', NULL, 1, 1, @cat_electronice),
('Laptopuri', 'laptopuri', 'Laptopuri și calculatoare', NULL, 1, 2, @cat_electronice),
('Tablete', 'tablete', 'Tablete și iPad-uri', NULL, 1, 3, @cat_electronice),
('Accesorii', 'accesorii', 'Accesorii electronice', NULL, 1, 4, @cat_electronice),
('TV & Audio', 'tv-audio', 'Televizoare și echipamente audio', NULL, 1, 5, @cat_electronice),
('Smartwatch', 'smartwatch', 'Ceasuri inteligente', NULL, 1, 6, @cat_electronice)
ON DUPLICATE KEY UPDATE `name`=`name`;

-- ============================================
-- 3. FURNIZORI
-- ============================================
INSERT INTO `suppliers` (`name`, `contact_person`, `email`, `phone`, `address`) VALUES
('TechSupplier SRL', 'Ion Popescu', 'contact@techsupplier.ro', '0721234567', 'București, Str. Exemplu, Nr. 1'),
('ElectroDist SRL', 'Maria Ionescu', 'contact@electrodist.ro', '0722345678', 'Cluj-Napoca, Str. Test, Nr. 2'),
('GadgetPro SRL', 'Gheorghe Georgescu', 'contact@gadgetpro.ro', '0723456789', 'Timișoara, Str. Demo, Nr. 3'),
('FashionLine SRL', 'Ana Dumitrescu', 'contact@fashionline.ro', '0724567890', 'Iași, Str. Moda, Nr. 4')
ON DUPLICATE KEY UPDATE `name`=`name`;

-- ============================================
-- 4. GRUPURI B2B
-- ============================================
INSERT INTO `b2b_groups` (`name`, `discount_percent`, `description`, `is_active`) VALUES
('Clienți Business', 10.00, 'Grup pentru clienți business cu discount de 10%', 1),
('Distribuitori', 20.00, 'Grup pentru distribuitori cu discount de 20%', 1),
('Parteneri Premium', 15.00, 'Grup pentru parteneri premium cu discount de 15%', 1),
('Revânzători', 25.00, 'Grup pentru revânzători cu discount de 25%', 1)
ON DUPLICATE KEY UPDATE `name`=`name`;

-- ============================================
-- 5. PRODUSE
-- ============================================
SET @cat_telefoane = (SELECT id FROM categories WHERE slug = 'telefoane');
SET @cat_laptopuri = (SELECT id FROM categories WHERE slug = 'laptopuri');
SET @cat_tablete = (SELECT id FROM categories WHERE slug = 'tablete');
SET @cat_accesorii = (SELECT id FROM categories WHERE slug = 'accesorii');
SET @cat_tv_audio = (SELECT id FROM categories WHERE slug = 'tv-audio');
SET @cat_smartwatch = (SELECT id FROM categories WHERE slug = 'smartwatch');

INSERT INTO `products` (`name`, `slug`, `sku`, `price`, `sale_price`, `stock_quantity`, `category_id`, `description`, `short_description`, `image`, `is_active`, `is_gift`, `is_featured`, `featured_order`, `supplier_id`) VALUES
-- Telefoane
('iPhone 15 Pro 256GB', 'iphone-15-pro-256gb', 'IPH15P256', 5999.00, 5499.00, 15, @cat_telefoane, 'iPhone 15 Pro cu ecran Super Retina XDR de 6.1 inci, procesor A17 Pro, sistem de cameră Pro cu 3 camere de 48MP, rezistență la apă IP68.', 'iPhone 15 Pro 256GB - Titanium Natural', '/assets/img/shop/electronics/thumbs/01.png', 1, 0, 1, 1, 1),
('Samsung Galaxy S24 Ultra', 'samsung-galaxy-s24-ultra', 'SGS24U256', 6499.00, NULL, 12, @cat_telefoane, 'Samsung Galaxy S24 Ultra cu ecran Dynamic AMOLED 2X de 6.8 inci, procesor Snapdragon 8 Gen 3, cameră de 200MP, S Pen inclus.', 'Samsung Galaxy S24 Ultra 256GB', '/assets/img/shop/electronics/thumbs/02.png', 1, 0, 1, 2, 1),
('Xiaomi Redmi Note 13 Pro', 'xiaomi-redmi-note-13-pro', 'XMRN13P', 1499.00, 1299.00, 25, @cat_telefoane, 'Xiaomi Redmi Note 13 Pro cu ecran AMOLED 6.67 inch, procesor MediaTek Dimensity 7200 Ultra, cameră 200MP, baterie 5100mAh.', 'Redmi Note 13 Pro 256GB', '/assets/img/shop/electronics/thumbs/12.png', 1, 0, 0, 0, 1),
('Google Pixel 8 Pro', 'google-pixel-8-pro', 'GPX8P', 4999.00, 4499.00, 10, @cat_telefoane, 'Google Pixel 8 Pro cu ecran LTPO OLED de 6.7 inci, procesor Google Tensor G3, cameră 50MP, Android 14.', 'Google Pixel 8 Pro 128GB', '/assets/img/shop/electronics/thumbs/13.png', 1, 0, 0, 0, 1),
-- Laptopuri
('MacBook Pro 14" M3', 'macbook-pro-14-m3', 'MBP14M3', 9999.00, 9499.00, 8, @cat_laptopuri, 'MacBook Pro 14 inch cu procesor Apple M3, 18GB RAM, 512GB SSD, ecran Liquid Retina XDR, autonomie până la 18 ore.', 'MacBook Pro 14" M3 512GB', '/assets/img/shop/electronics/thumbs/03.png', 1, 0, 1, 3, 2),
('Dell XPS 15', 'dell-xps-15', 'DLLXPS15', 7999.00, 7499.00, 6, @cat_laptopuri, 'Dell XPS 15 cu procesor Intel Core i7-13700H, 16GB RAM, 512GB SSD, ecran OLED 15.6 inch 3.5K, NVIDIA RTX 4050.', 'Dell XPS 15 i7 16GB 512GB', '/assets/img/shop/electronics/thumbs/05.png', 1, 0, 0, 0, 2),
('ASUS ROG Strix G16', 'asus-rog-strix-g16', 'ASUSROGG16', 6999.00, NULL, 5, @cat_laptopuri, 'ASUS ROG Strix G16 cu procesor Intel Core i7-13650HX, 16GB RAM, 1TB SSD, ecran 16 inch FHD 165Hz, NVIDIA RTX 4060.', 'ASUS ROG Strix G16 i7 RTX 4060', '/assets/img/shop/electronics/thumbs/14.png', 1, 0, 0, 0, 2),
-- Tablete
('iPad Pro 12.9" M2', 'ipad-pro-12-9-m2', 'IPADP129M2', 6999.00, NULL, 12, @cat_tablete, 'iPad Pro 12.9 inch cu procesor Apple M2, 256GB, ecran Liquid Retina XDR, suport pentru Apple Pencil 2, autonomie până la 10 ore.', 'iPad Pro 12.9" M2 256GB', '/assets/img/shop/electronics/thumbs/04.png', 1, 0, 0, 0, 2),
('Samsung Galaxy Tab S9 Ultra', 'samsung-galaxy-tab-s9-ultra', 'SGTABS9U', 5999.00, 5499.00, 8, @cat_tablete, 'Samsung Galaxy Tab S9 Ultra cu ecran Dynamic AMOLED 2X de 14.6 inci, procesor Snapdragon 8 Gen 2, S Pen inclus, rezistență la apă IP68.', 'Galaxy Tab S9 Ultra 256GB', '/assets/img/shop/electronics/thumbs/15.png', 1, 0, 0, 0, 1),
-- Accesorii
('AirPods Pro 2', 'airpods-pro-2', 'APDPRO2', 1499.00, 1299.00, 30, @cat_accesorii, 'AirPods Pro 2 cu cancelare activă a zgomotului, audio spațial, rezistență la apă IPX4, autonomie până la 6 ore, cazul cu încărcare wireless.', 'AirPods Pro 2 - Alb', '/assets/img/shop/electronics/thumbs/06.png', 1, 1, 0, 0, 3),
('Sony WH-1000XM5', 'sony-wh-1000xm5', 'SNYWH1000XM5', 2299.00, 1999.00, 18, @cat_accesorii, 'Căști Sony WH-1000XM5 cu cancelare activă a zgomotului, audio Hi-Res, autonomie 30h, încărcare rapidă 3 minute = 3 ore.', 'Sony WH-1000XM5 - Negru', '/assets/img/shop/electronics/thumbs/09.png', 1, 0, 0, 0, 3),
('Logitech MX Master 3S', 'logitech-mx-master-3s', 'LGTMXM3S', 699.00, NULL, 35, @cat_accesorii, 'Mouse wireless Logitech MX Master 3S cu tracking precis Darkfield 8K DPI, 7 butoane programabile, autonomie 70 zile, încărcare USB-C.', 'Logitech MX Master 3S', '/assets/img/shop/electronics/thumbs/10.png', 1, 0, 0, 0, 3),
('Apple Magic Keyboard', 'apple-magic-keyboard', 'APLMK', 899.00, NULL, 20, @cat_accesorii, 'Tastatură wireless Apple Magic Keyboard cu layout QWERTY, baterie recarregabilă, conectare Bluetooth, design minimalist.', 'Apple Magic Keyboard - Alb', '/assets/img/shop/electronics/thumbs/16.png', 1, 0, 0, 0, 3),
-- Smartwatch
('Apple Watch Series 9', 'apple-watch-series-9', 'AW9', 2299.00, 1999.00, 22, @cat_smartwatch, 'Apple Watch Series 9 cu ecran Always-On Retina de 45mm, monitorizare sănătate avansată, GPS, rezistență la apă 50m, autonomie 18h.', 'Apple Watch Series 9 45mm', '/assets/img/shop/electronics/thumbs/08.png', 1, 0, 0, 0, 3),
('Samsung Galaxy Watch 6', 'samsung-galaxy-watch-6', 'SGW6', 1799.00, NULL, 20, @cat_smartwatch, 'Samsung Galaxy Watch 6 cu ecran AMOLED de 44mm, monitorizare sănătate, GPS, rezistență la apă 5ATM, autonomie 40h.', 'Galaxy Watch 6 44mm', '/assets/img/shop/electronics/thumbs/07.png', 1, 0, 0, 0, 3),
-- TV & Audio
('Samsung 4K Smart TV 55"', 'samsung-4k-smart-tv-55', 'SMTV55', 3999.00, 3499.00, 8, @cat_tv_audio, 'Televizor Samsung 4K Smart TV 55 inch, HDR10+, Smart Hub, compatibil cu Alexa și Google Assistant, procesor Crystal 4K.', 'Samsung 4K Smart TV 55" QLED', '/assets/img/shop/electronics/thumbs/11.png', 1, 0, 0, 0, 1),
('LG OLED 65" C3', 'lg-oled-65-c3', 'LGOLED65C3', 6999.00, 6499.00, 5, @cat_tv_audio, 'Televizor LG OLED 65 inch C3, 4K HDR, procesor α9 Gen6 AI, webOS 23, Dolby Vision IQ, compatibil cu Google Assistant.', 'LG OLED 65" C3', '/assets/img/shop/electronics/thumbs/17.png', 1, 0, 0, 0, 1)
ON DUPLICATE KEY UPDATE `name`=`name`;

-- Actualizează banner_product_id pentru categorii (folosind produse featured)
UPDATE `categories` SET `banner_product_id` = (SELECT id FROM products WHERE slug = 'iphone-15-pro-256gb' LIMIT 1) WHERE slug = 'telefoane';
UPDATE `categories` SET `banner_product_id` = (SELECT id FROM products WHERE slug = 'macbook-pro-14-m3' LIMIT 1) WHERE slug = 'laptopuri';

-- ============================================
-- 6. UTILIZATORI
-- ============================================
INSERT INTO `users` (`first_name`, `last_name`, `email`, `password`, `phone`, `cnp`, `company_name`, `cui`, `reg_com`, `bank_account`, `default_order_type`, `loyalty_points`) VALUES
('Ion', 'Popescu', 'ion.popescu@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', '0721234567', NULL, NULL, NULL, NULL, NULL, 'physical', 500),
('Maria', 'Ionescu', 'maria.ionescu@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', '0722345678', NULL, NULL, NULL, NULL, NULL, 'physical', 1200),
('Gheorghe', 'Georgescu', 'gheorghe.georgescu@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', '0723456789', '1234567890123', 'TechBusiness SRL', 'RO12345678', 'J40/1234/2020', 'RO12BANK123456789', 'legal', 2500),
('Ana', 'Marinescu', 'ana.marinescu@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', '0724567890', NULL, NULL, NULL, NULL, NULL, 'physical', 800),
('Petru', 'Constantinescu', 'petru.constantinescu@example.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', '0725678901', '2345678901234', 'ElectroDist SRL', 'RO23456789', 'J12/5678/2021', 'RO34BANK234567890', 'legal', 3500)
ON DUPLICATE KEY UPDATE `email`=`email`;

-- Asociază utilizatori la grupuri B2B
INSERT INTO `b2b_group_users` (`user_id`, `b2b_group_id`) VALUES
(2, 1), -- Maria Ionescu -> Clienți Business
(3, 2), -- Gheorghe Georgescu -> Distribuitori
(5, 3)  -- Petru Constantinescu -> Parteneri Premium
ON DUPLICATE KEY UPDATE `b2b_group_id`=`b2b_group_id`;

-- ============================================
-- 7. ADRESE
-- ============================================
INSERT INTO `addresses` (`user_id`, `first_name`, `last_name`, `email`, `phone`, `company_name`, `cui`, `reg_com`, `country`, `county`, `city`, `postcode`, `address_line1`, `address_line2`, `is_default`) VALUES
(1, 'Ion', 'Popescu', 'ion.popescu@example.com', '0721234567', NULL, NULL, NULL, 'România', 'București', 'București', '010101', 'Str. Exemplu, Nr. 1, Bl. A, Sc. 1, Ap. 1', NULL, 1),
(2, 'Maria', 'Ionescu', 'maria.ionescu@example.com', '0722345678', NULL, NULL, NULL, 'România', 'Cluj', 'Cluj-Napoca', '400001', 'Str. Test, Nr. 2', NULL, 1),
(3, 'Gheorghe', 'Georgescu', 'gheorghe.georgescu@example.com', '0723456789', 'TechBusiness SRL', 'RO12345678', 'J40/1234/2020', 'România', 'Timiș', 'Timișoara', '300001', 'Str. Demo, Nr. 3', NULL, 1),
(4, 'Ana', 'Marinescu', 'ana.marinescu@example.com', '0724567890', NULL, NULL, NULL, 'România', 'Iași', 'Iași', '700001', 'Bd. Independenței, Nr. 10', NULL, 1),
(5, 'Petru', 'Constantinescu', 'petru.constantinescu@example.com', '0725678901', 'ElectroDist SRL', 'RO23456789', 'J12/5678/2021', 'România', 'Constanța', 'Constanța', '900001', 'Str. Portului, Nr. 5', NULL, 1)
ON DUPLICATE KEY UPDATE `address_line1`=`address_line1`;

-- ============================================
-- 8. CUPOANE
-- ============================================
INSERT INTO `coupons` (`code`, `discount_type`, `discount_value`, `min_order_value`, `max_discount`, `usage_limit`, `used_count`, `valid_from`, `valid_until`, `is_active`) VALUES
('WELCOME10', 'percentage', 10.00, 100.00, NULL, 100, 0, NOW(), DATE_ADD(NOW(), INTERVAL 1 YEAR), 1),
('SAVE50', 'fixed', 50.00, 200.00, NULL, 50, 0, NOW(), DATE_ADD(NOW(), INTERVAL 6 MONTH), 1),
('FREESHIP', 'free_shipping', 0, 300.00, NULL, 200, 0, NOW(), DATE_ADD(NOW(), INTERVAL 1 YEAR), 1),
('BLACKFRIDAY25', 'percentage', 25.00, 500.00, 500.00, 1000, 0, NOW(), DATE_ADD(NOW(), INTERVAL 1 YEAR), 1),
('SUMMER15', 'percentage', 15.00, 150.00, NULL, 500, 0, NOW(), DATE_ADD(NOW(), INTERVAL 6 MONTH), 1)
ON DUPLICATE KEY UPDATE `code`=`code`;

-- ============================================
-- 9. REGULI PRODUSE CADOU
-- ============================================
SET @prod_iphone = (SELECT id FROM products WHERE slug = 'iphone-15-pro-256gb');
SET @prod_macbook = (SELECT id FROM products WHERE slug = 'macbook-pro-14-m3');
SET @prod_airpods = (SELECT id FROM products WHERE slug = 'airpods-pro-2');

INSERT INTO `gift_products` (`buy_product_id`, `buy_quantity`, `gift_product_id`, `gift_quantity`, `min_order_value`, `is_active`) VALUES
(@prod_iphone, 1, @prod_airpods, 1, 5000.00, 1), -- Cumpără iPhone 15 Pro, primești AirPods Pro 2
(@prod_macbook, 1, @prod_airpods, 1, 9000.00, 1)  -- Cumpără MacBook Pro, primești AirPods Pro 2
ON DUPLICATE KEY UPDATE `is_active`=`is_active`;

-- ============================================
-- 10. COMENZI (pentru testare)
-- ============================================
SET @addr1 = (SELECT id FROM addresses WHERE user_id = 1 LIMIT 1);
SET @addr2 = (SELECT id FROM addresses WHERE user_id = 2 LIMIT 1);
SET @addr3 = (SELECT id FROM addresses WHERE user_id = 3 LIMIT 1);

INSERT INTO `orders` (`order_number`, `user_id`, `order_type`, `billing_address_id`, `shipping_address_id`, `subtotal`, `discount`, `shipping_cost`, `total`, `payment_method`, `payment_status`, `order_status`, `coupon_code`, `loyalty_points_used`, `notes`, `created_at`) VALUES
('ORD-2024-001', 1, 'physical', @addr1, @addr1, 1299.00, 0.00, 0.00, 1299.00, 'cash_on_delivery', 'paid', 'delivered', NULL, 0, NULL, DATE_SUB(NOW(), INTERVAL 10 DAY)),
('ORD-2024-002', 2, 'physical', @addr2, @addr2, 5999.00, 0.00, 0.00, 5999.00, 'card', 'paid', 'shipped', NULL, 0, NULL, DATE_SUB(NOW(), INTERVAL 5 DAY)),
('ORD-2024-003', 3, 'legal', @addr3, @addr3, 9999.00, 999.90, 0.00, 8999.10, 'bank_transfer', 'paid', 'processing', 'WELCOME10', 0, NULL, DATE_SUB(NOW(), INTERVAL 2 DAY)),
('ORD-2024-004', 1, 'physical', @addr1, @addr1, 2299.00, 0.00, 0.00, 2299.00, 'card', 'pending', 'pending', NULL, 0, NULL, DATE_SUB(NOW(), INTERVAL 1 DAY))
ON DUPLICATE KEY UPDATE `order_number`=`order_number`;

-- Articole comandă
SET @order1 = (SELECT id FROM orders WHERE order_number = 'ORD-2024-001');
SET @order2 = (SELECT id FROM orders WHERE order_number = 'ORD-2024-002');
SET @order3 = (SELECT id FROM orders WHERE order_number = 'ORD-2024-003');
SET @order4 = (SELECT id FROM orders WHERE order_number = 'ORD-2024-004');

INSERT INTO `order_items` (`order_id`, `product_id`, `product_name`, `quantity`, `price`, `subtotal`, `is_gift`) VALUES
(@order1, @prod_airpods, 'AirPods Pro 2 - Alb', 1, 1299.00, 1299.00, 0),
(@order2, (SELECT id FROM products WHERE slug = 'ipad-pro-12-9-m2'), 'iPad Pro 12.9" M2 256GB', 1, 5999.00, 5999.00, 0),
(@order3, @prod_macbook, 'MacBook Pro 14" M3 512GB', 1, 9999.00, 9999.00, 0),
(@order4, (SELECT id FROM products WHERE slug = 'apple-watch-series-9'), 'Apple Watch Series 9 45mm', 1, 2299.00, 2299.00, 0)
ON DUPLICATE KEY UPDATE `quantity`=`quantity`;

-- ============================================
-- 11. RECENZII
-- ============================================
INSERT INTO `reviews` (`user_id`, `product_id`, `order_id`, `rating`, `title`, `comment`, `is_approved`) VALUES
(1, @prod_iphone, NULL, 5, 'Excelent telefon!', 'Telefonul este foarte bun, camerele sunt excelente și performanța este impecabilă. Recomand cu căldură!', 1),
(2, @prod_macbook, @order2, 5, 'MacBook perfect', 'Laptopul este rapid, ecranul este minunat și bateria ține mult. Foarte mulțumită de achiziție!', 1),
(1, @prod_airpods, @order1, 4, 'Bune căști', 'Căștile sunt bune, cancelarea zgomotului funcționează bine. Singurul minus este prețul puțin ridicat.', 1),
(2, (SELECT id FROM products WHERE slug = 'apple-watch-series-9'), NULL, 5, 'Apple Watch excelent', 'Ceasul este perfect pentru monitorizarea sănătății și notificările. Recomand cu căldură!', 1),
(3, @prod_macbook, @order3, 5, 'Excelent pentru business', 'Laptopul este perfect pentru lucru, performanță excelentă și design profesional.', 1)
ON DUPLICATE KEY UPDATE `rating`=`rating`;

-- ============================================
-- 12. LISTĂ DE DORINȚE
-- ============================================
INSERT INTO `wishlist` (`user_id`, `product_id`) VALUES
(1, (SELECT id FROM products WHERE slug = 'samsung-galaxy-s24-ultra')),
(1, (SELECT id FROM products WHERE slug = 'ipad-pro-12-9-m2')),
(2, @prod_iphone),
(2, @prod_macbook),
(3, (SELECT id FROM products WHERE slug = 'samsung-4k-smart-tv-55')),
(4, (SELECT id FROM products WHERE slug = 'apple-watch-series-9'))
ON DUPLICATE KEY UPDATE `user_id`=`user_id`;

-- ============================================
-- 13. PUNCTE LOIALITATE
-- ============================================
INSERT INTO `loyalty_points` (`user_id`, `points`, `type`, `order_id`, `description`) VALUES
(1, 1299, 'earned', @order1, 'Puncte câștigate din comandă ORD-2024-001'),
(2, 5999, 'earned', @order2, 'Puncte câștigate din comandă ORD-2024-002'),
(3, 9999, 'earned', @order3, 'Puncte câștigate din comandă ORD-2024-003'),
(1, 2299, 'earned', @order4, 'Puncte câștigate din comandă ORD-2024-004')
ON DUPLICATE KEY UPDATE `points`=`points`;

-- ============================================
-- 14. COȘURI (pentru testare coșuri abandonate)
-- ============================================
INSERT INTO `cart` (`user_id`, `session_id`, `created_at`, `updated_at`) VALUES
(1, NULL, DATE_SUB(NOW(), INTERVAL 2 DAY), DATE_SUB(NOW(), INTERVAL 2 DAY)),
(NULL, 'test_session_123', DATE_SUB(NOW(), INTERVAL 1 DAY), DATE_SUB(NOW(), INTERVAL 1 DAY)),
(4, NULL, DATE_SUB(NOW(), INTERVAL 3 HOUR), DATE_SUB(NOW(), INTERVAL 3 HOUR))
ON DUPLICATE KEY UPDATE `updated_at`=`updated_at`;

-- Articole coș
SET @cart1 = (SELECT id FROM cart WHERE user_id = 1 ORDER BY created_at DESC LIMIT 1);
SET @cart2 = (SELECT id FROM cart WHERE session_id = 'test_session_123' LIMIT 1);
SET @cart3 = (SELECT id FROM cart WHERE user_id = 4 ORDER BY created_at DESC LIMIT 1);

INSERT INTO `cart_items` (`cart_id`, `product_id`, `quantity`, `price_at_add`) VALUES
(@cart1, @prod_iphone, 1, 5499.00),
(@cart1, @prod_airpods, 1, 1299.00),
(@cart2, (SELECT id FROM products WHERE slug = 'samsung-galaxy-s24-ultra'), 1, 6499.00),
(@cart3, (SELECT id FROM products WHERE slug = 'apple-watch-series-9'), 1, 1999.00)
ON DUPLICATE KEY UPDATE `quantity`=`quantity`;

-- ============================================
-- END OF SEED DATA
-- ============================================
