38 lines
807 B
MySQL
38 lines
807 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`myOrder_create`(
|
||
|
OUT vSelf INT,
|
||
|
vDelivery DATE,
|
||
|
vDeliveryMethod VARCHAR(45),
|
||
|
vAgency INT,
|
||
|
vAddress INT)
|
||
|
proc: BEGIN
|
||
|
/**
|
||
|
* Creates a new order for the current user. If passed parameters are wrong
|
||
|
* it returns an error.
|
||
|
*
|
||
|
* @param vDelivery Delivery date
|
||
|
* @param vDeliveryMethod Delivery method code
|
||
|
* @param vAgency Agency id
|
||
|
* @param vAddress Address id, @NULL for pickup
|
||
|
*/
|
||
|
DECLARE vCompany INT;
|
||
|
|
||
|
SELECT defaultCompanyFk INTO vCompany
|
||
|
FROM orderConfig;
|
||
|
|
||
|
INSERT INTO `order`
|
||
|
SET customer_id = account.myUser_getId(),
|
||
|
source_app = 'WEB',
|
||
|
company_id = vCompany;
|
||
|
|
||
|
SET vSelf = LAST_INSERT_ID();
|
||
|
CALL myOrder_configure(
|
||
|
vSelf,
|
||
|
vDelivery,
|
||
|
vDeliveryMethod,
|
||
|
vAgency,
|
||
|
vAddress
|
||
|
);
|
||
|
END$$
|
||
|
DELIMITER ;
|