You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
6.0 KiB
MySQL

8 months ago
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',
7 months ago
`payment_no` varchar(32) not NULL default '' COMMENT '支付单号',
`amount` DECIMAL(10,2) not null default '0.00' COMMENT '支付金额',
`open_id` VARCHAR(32) not null default '' COMMENT '用户openid',
`status` tinyint(1) not null default 0 COMMENT '支付状态0未支付1支付成功2支付失败',
`error_message` varchar(255) not null default '' COMMENT '失败原因',
8 months ago
`created_at` timestamp not null default current_timestamp COMMENT '创建时间',
`updated_at` timestamp not null default current_timestamp COMMENT '最后更新时间',
PRIMARY KEY (`id`) USING BTREE
7 months ago
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='支付表';
8 months ago
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` (
7 months ago
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
8 months ago
`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='收益表';
7 months ago
CREATE TABLE `admins` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`username` varchar(20) not NULL COMMENT '手机号',
`nickname` varchar(32) not NULL default '' COMMENT '昵称',
`password_hash` varchar(64) not NULL 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='管理员表';