etrade_order_v1.0.7_dengwei.sql
2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
USE dili_etrade;
DROP TABLE IF EXISTS `order_leave_out`;
CREATE TABLE `order_leave_out` (
`id` bigint NOT NULL AUTO_INCREMENT,
`code` varchar(50) NOT NULL DEFAULT '' COMMENT '出门单编码',
`customer_id` bigint NOT NULL COMMENT '客户id',
`market_id` bigint NOT NULL COMMENT '市场id',
`state` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '状态(0:撤销 1:未验票 2:已验票 3:已过期)',
`deleted` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '删除(0已删除 1未删除)',
`version` int unsigned NOT NULL DEFAULT '1' COMMENT '版本号',
`auditor_id` bigint DEFAULT NULL COMMENT '审核人id',
`audit_result` varchar(255) DEFAULT '' COMMENT '审核结果',
`auditor_name` varchar(50) DEFAULT NULL COMMENT '审核人名称',
`audit_time` datetime DEFAULT NULL COMMENT '审核时间',
`expire_time` datetime DEFAULT NULL COMMENT '过期时间',
`creator_id` bigint NOT NULL COMMENT '创建人id',
`creator_name` varchar(50) NOT NULL DEFAULT '' COMMENT '创建人名称',
`created_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`modifier_name` varchar(50) DEFAULT '' COMMENT '修改人名称',
`modified_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
KEY `idx_code` (`code`) USING BTREE COMMENT '出门单号',
KEY `idx_create_time` (`created_time`) USING BTREE COMMENT '创建时间',
KEY `idx_autime` (`audit_time`) USING BTREE COMMENT '审核时间',
KEY `idx_customer` (`customer_id`) USING BTREE COMMENT '客户id'
) ENGINE=InnoDB COMMENT='订单-出门单基本信息';
DROP TABLE IF EXISTS `order_leave_out_detail`;
CREATE TABLE `order_leave_out_detail` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`leave_out_id` bigint NOT NULL COMMENT '出门单主键id',
`order_id` bigint NOT NULL COMMENT '订单id',
`order_code` varchar(50) NOT NULL DEFAULT '' COMMENT '订单编码',
`order_goods_id` bigint NOT NULL COMMENT '订单商品主键id',
`order_project_id` bigint NOT NULL COMMENT '关联商品主键id',
`repeal` bigint unsigned NOT NULL DEFAULT '0' COMMENT '撤销(0正常 1...撤销)',
PRIMARY KEY (`id`),
UNIQUE KEY `unq_order_good` (`order_id`,`order_goods_id`,`repeal`) USING BTREE COMMENT '订单+商品唯一索引',
KEY `idx_out_id` (`leave_out_id`) USING BTREE COMMENT '出门单id'
) ENGINE=InnoDB COMMENT='订单-出门单关联订单(1:N)';
-- dili_etrade 电子交易结算
ALTER TABLE `dili_etrade`.`order`
DROP INDEX `buyer`,
ADD INDEX `buyer`(`buyer_id`, `pay_time`) USING BTREE COMMENT '买家查询';