Mysql 关掉订单存储过程应用
发布时间:2023-08-15 14:49:02 所属栏目:MySql教程 来源:
导读:本文主要给大家介绍Mysql 关闭订单存储过程应用,希望可以给大家补充和更新些知识,如有其它问题需要了解的可以持续在亿速云行业资讯里面关注我的更新文章的。
关闭订单存储过程
begin
declare done int
关闭订单存储过程
begin
declare done int
|
本文主要给大家介绍Mysql 关闭订单存储过程应用,希望可以给大家补充和更新些知识,如有其它问题需要了解的可以持续在亿速云行业资讯里面关注我的更新文章的。 关闭订单存储过程 begin declare done int default 0; declare orderid varchar(22); #声明查询订单的游标 declare cur cursor for select orders.order_id from orders where orders.order_state = 'wait_pay'; #异常处理 declare continue handler for sqlstate '02000' set done = 1; #打开游标 open cur; #遍历数据 fetch next from cur into orderid; repeat if not done then #根据订单编号查询订单的下单时间 Mysql 关闭订单存储过程应用 select orders.order_xiatime into @a from orders where order_id=orderid; #根据订单下单时间获取1天后的时间(先用一天,存储过程正常使用后改为12小时间) SELECT ADDDATE(@a, INTERVAL 24 Hour) into @b; #判断会员在1天内是否未做任何处理 if @b<now() then #自动更新订单的状态 update orders set order_state='trade_colsed',order_closetime = now() ,close_order_reason='订单关闭时间到,定时任务正常关闭' where order_id=orderid; #若有多个操作可以在这里接着些 #回收库存(调用另一个存储过程) call recoveryOfInventory(orderid); end if; end if; fetch next from cur into orderid; until done end repeat; close cur; (编辑:驾考网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
