|
|
CREATE TABLE `banners` (
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
|
`img_url` varchar(400) DEFAULT NULL COMMENT 'banner图url',
|
|
|
`title` varchar(64) DEFAULT NULL COMMENT '标题',
|
|
|
`type` varchar(32) DEFAULT NULL COMMENT '栏目类型',
|
|
|
`link_url` varchar(255) DEFAULT NULL COMMENT '点击banner跳转到url',
|
|
|
`remark` varchar(255) DEFAULT NULL COMMENT '备注',
|
|
|
`sort` int DEFAULT NULL COMMENT '显示顺序',
|
|
|
`status` tinyint(1) not null default '0' COMMENT 'banner状态(0启用 1禁用)',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='banner';
|
|
|
|
|
|
CREATE TABLE `users` (
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
|
`mobile` varchar(20) not NULL COMMENT '手机号',
|
|
|
`nickname` varchar(32) not NULL default '' COMMENT '昵称',
|
|
|
`user_type` tinyint(1) not null default 1 COMMENT '账号类型:1-主账号/2-子账号',
|
|
|
`master_user_id` varchar(32) not null default 0 COMMENT '主账号ID',
|
|
|
`password_hash` varchar(64) not NULL COMMENT '登录密码',
|
|
|
`payment_password_hash` varchar(64) not NULL default '' COMMENT '支付密码',
|
|
|
`balance` decimal(10,2) not null default '0.00' COMMENT '账号余额',
|
|
|
`profit` decimal(10,2) not null default '0.00' COMMENT '收益',
|
|
|
`status` tinyint(1) not null default 1 COMMENT '账号状体(1启用)',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
|
|
|
|
|
|
CREATE TABLE `user_balances` (
|
|
|
`user_id` int(11) NOT NULL COMMENT '用户ID',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`user_id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户余额表';
|
|
|
|
|
|
CREATE TABLE `payments` (
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
|
`user_id` int(11) NOT NULL COMMENT '用户ID',
|
|
|
`order_no` varchar(32) not NULL default '' COMMENT '订单号',
|
|
|
`amount` tinyint(1) not null default 1 COMMENT '账号类型:1-主账号/2-子账号',
|
|
|
`status` tinyint(1) not null default 1 COMMENT '账号状体(1启用)',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
|
|
|
|
|
|
CREATE TABLE `orders` (
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
|
`user_id` int(11) NOT NULL COMMENT '用户ID',
|
|
|
`order_no` varchar(32) not NULL default '' COMMENT '订单号',
|
|
|
`amount` decimal(10, 2) not null default 1 COMMENT '订单金额',
|
|
|
`status` tinyint(1) not null default 1 COMMENT '账号状体(1启用)',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
|
|
|
|
|
|
CREATE TABLE `order_products` (
|
|
|
`order_product_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
|
`user_id` int(11) NOT NULL COMMENT '用户ID',
|
|
|
`order_no` varchar(32) not NULL default '' COMMENT '订单号',
|
|
|
`product_id` int(11) NOT NULL COMMENT '产品ID',
|
|
|
`num` int(11) NOT NULL COMMENT '商品数量',
|
|
|
`price` decimal(10, 2) not null default 1 COMMENT '商品单价',
|
|
|
`amount` decimal(10, 2) not null default 1 COMMENT '商品总金额',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单商品表';
|
|
|
|
|
|
CREATE TABLE `products` (
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
|
`name` varchar(255) NOT NULL COMMENT '名称',
|
|
|
`description` text default null COMMENT '描述',
|
|
|
`price` decimal(10, 2) not null default '0.00' COMMENT '价格',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品表';
|
|
|
|
|
|
CREATE TABLE `profits` (
|
|
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
|
|
`date` date NOT NULL COMMENT '日期',
|
|
|
`product_id` int(11) not default COMMENT '产品ID',
|
|
|
`amount` tinyint(1) not null default 1 COMMENT '账号类型:1-主账号/2-子账号',
|
|
|
`status` tinyint(1) not null default 1 COMMENT '账号状体(1启用)',
|
|
|
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
|
|
|
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
|
|
|
PRIMARY KEY (`id`) USING BTREE
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='收益表';
|