//退货单表
DROP TABLE IF EXISTS `nju`.`tb_salereturn`;
CREATE TABLE `nju`.`tb_salereturn` (
`salereturnid` varchar(36) NOT NULL,
`saleorderid` varchar(36) NOT NULL,
`reason` varchar(100) default NULL,
`total` double NOT NULL,
`createdatetime` datetime NOT NULL,
`paytype` varchar(45) NOT NULL,
`returncashier` varchar(45) NOT NULL,
PRIMARY KEY (`salereturnid`),
UNIQUE KEY `salereturnid` (`salereturnid`),
KEY `saleorderid` (`saleorderid`),
CONSTRAINT `tb_salereturn_ibfk_1` FOREIGN KEY (`saleorderid`) REFERENCES `tb_saleorder` (`saleorderid`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
//退货单明细表
DROP TABLE IF EXISTS `nju`.`tb_salereturnitem`;
CREATE TABLE `nju`.`tb_salereturnitem` (
`id` int(11) NOT NULL auto_increment,
`salereturnid` varchar(36) NOT NULL,
`goodsid` char(30) NOT NULL,
`number` int(11) NOT NULL,
`price` double NOT NULL,
PRIMARY KEY (`id`),
KEY `salereturnid` (`salereturnid`),
KEY `goodsid` (`goodsid`),
CONSTRAINT `tb_salereturnitem_ibfk_1` FOREIGN KEY (`salereturnid`) REFERENCES `tb_salereturn` (`salereturnid`),
CONSTRAINT `tb_salereturnitem_ibfk_2` FOREIGN KEY (`goodsid`) REFERENCES `tb_saleorderitem` (`goodsid`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=gbk;
//订单表
DROP TABLE IF EXISTS `nju`.`tb_saleorder`;
CREATE TABLE `nju`.`tb_saleorder` (
`saleorderid` varchar(36) NOT NULL,
`customerid` char(11) NOT NULL,
`salestime` datetime NOT NULL,
`operateperson` char(50) NOT NULL,
`total` double NOT NULL,
`isPay` int(10) unsigned default NULL, //标识是否付款
`isReturn` int(11) unsigned default NULL, //标识是否已经进行退货操作
PRIMARY KEY (`saleorderid`),
UNIQUE KEY `saleorderid` (`saleorderid`),
KEY `customerid` USING BTREE (`customerid`),
CONSTRAINT `tb_saleorder_ibfk_1` FOREIGN KEY (`customerid`) REFERENCES `tb_customer` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=gbk;
//订单明细表
DROP TABLE IF EXISTS `nju`.`tb_saleorderitem`;
CREATE TABLE `nju`.`tb_saleorderitem` (
`id` int(11) NOT NULL auto_increment,
`saleorderid` varchar(36) NOT NULL,
`goodsid` char(11) NOT NULL,
`number` int(11) NOT NULL,
`price` double NOT NULL,
PRIMARY KEY (`id`),
KEY `saleorderid` (`saleorderid`),
KEY `goodsid` (`goodsid`),
CONSTRAINT `saleorderitem_ibfk_1` FOREIGN KEY (`saleorderid`) REFERENCES `tb_saleorder` (`saleorderid`),
CONSTRAINT `saleorderitem_ibfk_2` FOREIGN KEY (`goodsid`) REFERENCES `tb_goods` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=115 DEFAULT CHARSET=gbk;
还有商品信息表、会员信息表、商品库存表等在退货过程中需要获取相关信息。