订单号生成记录表:
drop table if exists other_order_record_sequence;
create table other_order_record_sequence(
id bigint(20) primary key auto_increment,
order_record_sequence_type varchar(5) not null comment '订单类型',
seq_date date not null comment '日期',
sequence_count int(11) not null comment '订单数',
belonged_company bigint(20) not null comment '公司id'
)engine = innodb default charset = utf8mb4 comment '单号记录表';
订单生成存储过程:
drop procedure if exists get_order_number;
DELIMITER ;;
-- order_type_ordinal订单类型标注,order_type_code订单类型在单号中的标识,company_id公司id
create procedure get_order_number(IN order_type_ordinal varchar(5),IN order_type_code varchar(5),IN company_id bigint(20));
begin
DECLARE exist_sequence int default 1;
DECLARE sequence_number int(11);
DECLARE t_error INTEGER DEFAULT 0;
DECLARE cur_sequence CURSOR FOR select sequence_count + 1 from other_or