43 lines
1.1 KiB
SQL
43 lines
1.1 KiB
SQL
DROP PROCEDURE IF EXISTS floranet.order_put;
|
|
|
|
DELIMITER $$
|
|
$$
|
|
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON)
|
|
READS SQL DATA
|
|
BEGIN
|
|
/**
|
|
* Get and process an order
|
|
*
|
|
* @param vOrder Data of the order
|
|
*
|
|
* Customer data: <customerName>, <email>, <customerPhone>
|
|
*
|
|
* Item data: <catalogueFk>, <message>
|
|
*
|
|
* Delivery data: <deliveryName>, <address>, <deliveryPhone>
|
|
*
|
|
*/
|
|
INSERT IGNORE INTO `order`(
|
|
catalogueFk,
|
|
customerName,
|
|
email,
|
|
customerPhone,
|
|
message,
|
|
deliveryName,
|
|
address,
|
|
deliveryPhone
|
|
)
|
|
VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')),
|
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')),
|
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')),
|
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')),
|
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')),
|
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')),
|
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')),
|
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone'))
|
|
);
|
|
|
|
SELECT LAST_INSERT_ID() orderFk;
|
|
END$$
|
|
DELIMITER ;
|