-- 创建商家订单 INSERT INTO merchant_order (merchant_id, order_status) VALUES (2001, '未支付');

-- 创建门店 INSERT INTO store (merchant_id, store_id) VALUES (2001, 3001), (2001, 3002);

-- 创建商品 INSERT INTO product (merchant_id, product_name) VALUES (2001, '德力普5号电池'), (2001, '飞科RS-8型剃须刀');

-- 在门店上架商品 INSERT INTO store_product (store_id, product_id) VALUES (3001, 4001), (3002, 4002);

-- 用户挑选商品形成订单 INSERT INTO order (user_id, store_id, product_id, order_status) VALUES (1001, 3001, 4001, '未支付'), (1002, 3002, 4002, '未支付');

-- 用户支付订单 UPDATE order SET order_status = '已支付' WHERE user_id = 1001;

-- 商家查看订单 SELECT * FROM order WHERE store_id IN (SELECT store_id FROM store WHERE merchant_id = 2001);

-- 商家确认订单 UPDATE order SET order_status = '已确认' WHERE store_id IN (SELECT store_id FROM store WHERE merchant_id = 2001) AND order_status = '已支付';

-- 商家取消订单 UPDATE order SET order_status = '已退款' WHERE store_id IN (SELECT store_id FROM store WHERE merchant_id = 2001) AND order_status = '已支付';

SQL 示例:商家订单管理系统

原文地址: https://www.cveoy.top/t/topic/ou13 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录