mysql事件(定时任务)处理超时失效订单
MySQL事件(定时任务)
https://blog.csdn.net/pan_junbiao/article/details/86489237
UPDATE wz_mer_goods_spec as a,
(
SELECT osn,shop_id,SUM(goods_num) g_num,state,spec_id from wz_mer_goods_details join wz_mer_goods_order using(osn) WHERE state=0 GROUP BY
spec_id
) as d
SET a.surplus_num=a.surplus_num + d.g_num
WHERE a.shop_id=d.shop_id
AND a.spec_id=d.spec_id
AND TIMESTAMPDIFF(SECOND, a.create_time, NOW()) > 15;
UPDATE
wz_mer_goods_order AS order_
set
order_.state = '3'
WHERE 1 = 1
AND order_.state = '0'
AND TIMESTAMPDIFF(SECOND, order_.create_time, NOW()) > 15;
END
执行场景:
1:多-用户--同商品同规格(spec_id+mer_gid)--订单失效--同商品同规格 库存增加对应失效订单数量
2:多用户--同商品不同规格--- 订单失效--库存对应增加失效订单数量
原始库存