Changes between Version 1 and Version 2 of UseCase007
- Timestamp:
- 05/13/26 12:07:45 (2 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UseCase007
v1 v2 15 15 {{{#!div style="text-align: justify; width: 100%;" 16 16 17 1. User selects a specific {{{Product}}} and chooses the option to add it to {{{Order}}}.17 1. User selects a specific Product and chooses the option to add it to Order. 18 18 19 2. System checks the current {{{stock}}} level of the product in the {{{Product}}}table to ensure availability.19 2. System checks the current stock level of the product in the Product table to ensure availability. 20 20 21 3. System retrieves the current {{{price}}} of the product to establish the {{{price_at_purchase}}} for the transaction. 21 {{{#!div style="margin-left: 20px;" 22 {{{ 23 SELECT stock, price 24 FROM Product 25 WHERE product_id = @selected_product_id; 26 }}} 27 }}} 22 28 23 4. System creates or identifies an active {{{Order}}} record associated with the consumer’s {{{user_id}}}.29 3. System retrieves the current price of the product to establish the price_at_purchase for the transaction. 24 30 25 5. System creates a new entry in the {{{OrderItem}}} table, linking the {{{product_id}}} to the {{{order_id}}}.31 4. System creates or identifies an active Order record associated with the consumer’s user_id. 26 32 27 6. System records the specific {{{quantity}}} requested by the {{{User}}} and saves the {{{price_at_purchase}}} to the {{{OrderItem}}} record. 33 {{{#!div style="margin-left: 20px;" 34 {{{ 35 SELECT order_id 36 FROM `Order` 37 WHERE user_id = @authenticated_user_id AND status = 'Pending'; 28 38 29 7. System updates the user's view to reflect that the item has been added to their {{{Order}}} total. 39 INSERT INTO `Order` (user_id, date_created, status, total_price) 40 VALUES (@authenticated_user_id, CURRENT_TIMESTAMP, 'Pending', 0.00); 30 41 }}} 42 }}} 43 44 5. System creates a new entry in the !OrderItem table, linking the product_id to the order_id. 45 46 6. System records the specific quantity requested by the User and saves the price_at_purchase to the OrderItem record. 47 48 {{{#!div style="margin-left: 20px;" 49 {{{ 50 INSERT INTO OrderItem (order_id, product_id, quantity, price_at_purchase) 51 VALUES (@active_order_id, @selected_product_id, @requested_quantity, @current_price) 52 ON DUPLICATE KEY UPDATE quantity = quantity + @requested_quantity; 53 }}} 54 }}} 55 56 7. System updates the user's view to reflect that the item has been added to their Order total. 57 58 {{{#!div style="margin-left: 20px;" 59 {{{ 60 SELECT SUM(quantity * price_at_purchase) AS new_total 61 FROM OrderItem 62 WHERE order_id = @active_order_id; 63 }}} 64 }}} 65 66 }}}
