{{wikiTitle}}
数据库结构说明
复制链接
编辑文档
CRMEB PRO 数据库结构说明
概述
CRMEB PRO 使用 MySQL 5.7/8.0 数据库,默认表前缀为 eb_,字符集使用 utf8mb4。本文档详细说明数据库设计规范和主要数据表结构。
数据库配置
配置文件位置
- 主配置:
config/database.php - 环境配置:
.env
环境变量配置示例
[DATABASE]
DRIVER = mysql
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = crmeb_pro
USERNAME = root
PASSWORD = your_password
HOSTPORT = 3306
CHARSET = utf8mb4
PREFIX = eb_
DEBUG = true
数据库配置说明
// config/database.php
return [
'default' => env('DATABASE_DRIVER', 'mysql'),
'auto_timestamp' => 'timestamp', // 自动写入时间戳
'datetime_format' => 'Y-m-d H:i:s', // 时间格式
'connections' => [
'mysql' => [
'type' => 'mysql',
'hostname' => env('DATABASE_HOSTNAME', '127.0.0.1'),
'database' => env('DATABASE_DATABASE', ''),
'username' => env('DATABASE_USERNAME', 'root'),
'password' => env('DATABASE_PASSWORD', ''),
'hostport' => env('DATABASE_HOSTPORT', '3306'),
'charset' => 'utf8mb4',
'prefix' => env('DATABASE_PREFIX', 'eb_'),
'break_reconnect' => true, // 断线重连
],
],
// 分页配置
'page' => [
'pageKey' => 'page',
'limitKey' => 'limit',
'limitMax' => 200,
'defaultLimit' => 10,
]
];
数据表命名规范
| 规范 | 说明 | 示例 |
|---|---|---|
| 前缀 | 统一使用 eb_ |
eb_user |
| 命名 | 小写字母+下划线 | eb_store_order |
| 模块标识 | 模块名作为前缀 | eb_store_*, eb_user_* |
| 关联表 | 主表_从表 | eb_store_order_cart_info |
核心数据表结构
用户模块
eb_user - 用户主表
CREATE TABLE `eb_user` (
`uid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户id',
`account` varchar(32) DEFAULT '' COMMENT '用户账号',
`pwd` varchar(255) DEFAULT '' COMMENT '用户密码',
`real_name` varchar(25) DEFAULT '' COMMENT '真实姓名',
`birthday` int(11) DEFAULT '0' COMMENT '生日',
`card_id` varchar(20) DEFAULT '' COMMENT '身份证号',
`mark` varchar(255) DEFAULT '' COMMENT '用户备注',
`nickname` varchar(64) DEFAULT '' COMMENT '用户昵称',
`avatar` varchar(256) DEFAULT '' COMMENT '用户头像',
`phone` char(15) DEFAULT NULL COMMENT '手机号码',
`add_time` int(11) DEFAULT '0' COMMENT '添加时间',
`add_ip` varchar(16) DEFAULT '' COMMENT '添加ip',
`last_time` int(11) DEFAULT '0' COMMENT '最后登录时间',
`last_ip` varchar(16) DEFAULT '' COMMENT '最后登录ip',
`now_money` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '用户余额',
`brokerage_price` decimal(10,2) DEFAULT '0.00' COMMENT '佣金金额',
`integral` int(10) unsigned DEFAULT '0' COMMENT '用户积分',
`exp` int(10) unsigned DEFAULT '0' COMMENT '经验值',
`sign_num` int(11) DEFAULT '0' COMMENT '连续签到天数',
`status` tinyint(1) DEFAULT '1' COMMENT '状态 0:禁用 1:正常',
`level` tinyint(2) unsigned DEFAULT '0' COMMENT '等级',
`spread_uid` int(10) unsigned DEFAULT '0' COMMENT '推广人id',
`spread_time` int(11) DEFAULT '0' COMMENT '推广人关联时间',
`user_type` varchar(32) DEFAULT '' COMMENT '用户类型',
`is_promoter` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为推广员',
`pay_count` int(10) unsigned DEFAULT '0' COMMENT '支付次数',
`spread_count` int(10) unsigned DEFAULT '0' COMMENT '推广人数',
`clean_time` int(11) DEFAULT '0' COMMENT '清理时间',
`delete_time` int(11) DEFAULT NULL COMMENT '注销时间',
PRIMARY KEY (`uid`),
KEY `account` (`account`),
KEY `phone` (`phone`),
KEY `spread_uid` (`spread_uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
eb_user_address - 用户地址表
CREATE TABLE `eb_user_address` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户地址id',
`uid` int(10) unsigned NOT NULL COMMENT '用户id',
`real_name` varchar(32) NOT NULL DEFAULT '' COMMENT '收货人姓名',
`phone` varchar(16) NOT NULL DEFAULT '' COMMENT '收货人电话',
`province` varchar(64) NOT NULL DEFAULT '' COMMENT '省',
`city` varchar(64) NOT NULL DEFAULT '' COMMENT '市',
`city_id` int(11) NOT NULL DEFAULT '0' COMMENT '城市id',
`district` varchar(64) NOT NULL DEFAULT '' COMMENT '区',
`street` varchar(64) DEFAULT '' COMMENT '街道',
`detail` varchar(256) NOT NULL DEFAULT '' COMMENT '详细地址',
`post_code` varchar(20) NOT NULL DEFAULT '' COMMENT '邮编',
`longitude` varchar(16) NOT NULL DEFAULT '0' COMMENT '经度',
`latitude` varchar(16) NOT NULL DEFAULT '0' COMMENT '纬度',
`is_default` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否默认',
`is_del` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `is_default` (`is_default`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户地址表';
eb_user_bill - 用户账单表
CREATE TABLE `eb_user_bill` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户账单id',
`uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户uid',
`link_id` varchar(32) NOT NULL DEFAULT '0' COMMENT '关联id',
`pm` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0支出1获得',
`title` varchar(64) NOT NULL DEFAULT '' COMMENT '账单标题',
`category` varchar(64) NOT NULL DEFAULT '' COMMENT '分类:now_money余额,bindJingfen',
`type` varchar(64) NOT NULL DEFAULT '' COMMENT '类型',
`number` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '金额',
`balance` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '剩余',
`mark` varchar(512) NOT NULL DEFAULT '' COMMENT '备注',
`add_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 0:待确认 1:有效 -1:无效',
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `category` (`category`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户账单表';
商品模块
eb_store_product - 商品主表
CREATE TABLE `eb_store_product` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '商品id',
`mer_id` int(10) unsigned DEFAULT '0' COMMENT '商户id',
`image` varchar(256) NOT NULL COMMENT '商品图片',
`recommend_image` varchar(256) DEFAULT '' COMMENT '推荐图',
`slider_image` varchar(2048) NOT NULL COMMENT '轮播图',
`store_name` varchar(128) NOT NULL COMMENT '商品名称',
`store_info` varchar(256) NOT NULL COMMENT '商品简介',
`keyword` varchar(256) NOT NULL COMMENT '关键字',
`bar_code` varchar(15) DEFAULT '' COMMENT '商品条码',
`cate_id` varchar(64) NOT NULL COMMENT '分类id',
`price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商品价格',
`vip_price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '会员价',
`ot_price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '市场价',
`postage` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '邮费',
`unit_name` varchar(32) DEFAULT '' COMMENT '单位名',
`sort` smallint(5) unsigned DEFAULT '0' COMMENT '排序',
`sales` int(10) unsigned DEFAULT '0' COMMENT '销量',
`stock` int(10) unsigned DEFAULT '0' COMMENT '库存',
`is_show` tinyint(1) DEFAULT '1' COMMENT '状态 0:下架 1:上架',
`is_hot` tinyint(1) DEFAULT '0' COMMENT '热卖',
`is_benefit` tinyint(1) DEFAULT '0' COMMENT '促销',
`is_best` tinyint(1) DEFAULT '0' COMMENT '精品',
`is_new` tinyint(1) DEFAULT '0' COMMENT '新品',
`is_postage` tinyint(1) unsigned DEFAULT '0' COMMENT '是否包邮',
`is_del` tinyint(1) unsigned DEFAULT '0' COMMENT '是否删除',
`is_verify` tinyint(1) DEFAULT '0' COMMENT '是否审核',
`give_integral` int(10) unsigned DEFAULT '0' COMMENT '赠送积分',
`cost` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '成本价',
`ficti` int(10) unsigned DEFAULT '0' COMMENT '虚拟销量',
`browse` int(10) unsigned DEFAULT '0' COMMENT '浏览量',
`code_path` varchar(256) DEFAULT '' COMMENT '商品二维码',
`temp_id` int(10) unsigned DEFAULT '0' COMMENT '运费模板id',
`spec_type` tinyint(1) DEFAULT '0' COMMENT '规格 0:单 1:多',
`description` longtext COMMENT '商品详情',
`add_time` int(11) DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
KEY `cate_id` (`cate_id`),
KEY `is_show` (`is_show`),
KEY `is_del` (`is_del`),
KEY `sort` (`sort`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品表';
eb_store_product_attr - 商品属性表
CREATE TABLE `eb_store_product_attr` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品ID',
`attr_name` varchar(32) NOT NULL COMMENT '属性名',
`attr_values` varchar(256) NOT NULL COMMENT '属性值',
`type` tinyint(1) DEFAULT '0' COMMENT '活动类型 0:商品 1:秒杀 2:砍价 3:拼团',
PRIMARY KEY (`id`),
KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品属性表';
eb_store_product_attr_value - 商品属性值表
CREATE TABLE `eb_store_product_attr_value` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`product_id` int(10) unsigned NOT NULL COMMENT '商品ID',
`suk` varchar(128) NOT NULL COMMENT '商品属性索引值',
`stock` int(10) unsigned NOT NULL COMMENT '属性对应的库存',
`sales` int(10) unsigned DEFAULT '0' COMMENT '销量',
`price` decimal(10,2) unsigned NOT NULL COMMENT '属性金额',
`image` varchar(256) DEFAULT '' COMMENT '图片',
`cost` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '成本价',
`bar_code` varchar(50) DEFAULT '' COMMENT '商品条码',
`ot_price` decimal(10,2) DEFAULT '0.00' COMMENT '原价',
`weight` decimal(10,2) DEFAULT '0.00' COMMENT '重量',
`volume` decimal(10,2) DEFAULT '0.00' COMMENT '体积',
`brokerage` decimal(10,2) DEFAULT '0.00' COMMENT '一级返佣',
`brokerage_two` decimal(10,2) DEFAULT '0.00' COMMENT '二级返佣',
`type` tinyint(1) DEFAULT '0' COMMENT '类型',
`quota` int(10) DEFAULT '0' COMMENT '活动限购',
`quota_show` int(10) DEFAULT '0' COMMENT '显示限购',
`unique` varchar(32) DEFAULT '' COMMENT '唯一值',
PRIMARY KEY (`id`),
KEY `product_id` (`product_id`),
KEY `unique` (`unique`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品属性值表';
eb_store_category - 商品分类表
CREATE TABLE `eb_store_category` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父id',
`cate_name` varchar(100) NOT NULL COMMENT '分类名称',
`sort` int(10) unsigned DEFAULT '0' COMMENT '排序',
`pic` varchar(256) DEFAULT '' COMMENT '图标',
`is_show` tinyint(1) DEFAULT '1' COMMENT '是否显示',
`add_time` int(11) DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
KEY `pid` (`pid`),
KEY `is_show` (`is_show`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品分类表';
订单模块
eb_store_order - 订单主表
CREATE TABLE `eb_store_order` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '订单ID',
`order_id` varchar(32) NOT NULL COMMENT '订单号',
`uid` int(10) unsigned NOT NULL COMMENT '用户id',
`real_name` varchar(32) NOT NULL DEFAULT '' COMMENT '收货人姓名',
`user_phone` varchar(18) NOT NULL DEFAULT '' COMMENT '收货人电话',
`user_address` varchar(256) NOT NULL DEFAULT '' COMMENT '收货地址',
`cart_id` varchar(256) NOT NULL DEFAULT '[]' COMMENT '购物车id',
`freight_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '运费',
`total_num` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品总数',
`total_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商品总价',
`total_postage` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '邮费',
`pay_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '实际支付金额',
`pay_postage` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '支付邮费',
`deduction_price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '抵扣金额',
`coupon_id` int(10) unsigned DEFAULT '0' COMMENT '优惠券id',
`coupon_price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '优惠券金额',
`paid` tinyint(1) unsigned DEFAULT '0' COMMENT '支付状态',
`pay_time` int(10) unsigned DEFAULT NULL COMMENT '支付时间',
`pay_type` varchar(32) NOT NULL DEFAULT '' COMMENT '支付方式',
`add_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '订单状态',
`refund_status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '退款状态',
`refund_reason_wap_img` varchar(512) DEFAULT NULL COMMENT '退款图片',
`refund_reason_wap_explain` varchar(256) DEFAULT NULL COMMENT '退款用户说明',
`refund_reason_time` int(10) unsigned DEFAULT NULL COMMENT '退款时间',
`refund_reason_wap` varchar(256) DEFAULT '' COMMENT '前台退款原因',
`refund_reason` varchar(256) DEFAULT '' COMMENT '不退款理由',
`refund_price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '退款金额',
`delivery_sn` varchar(100) DEFAULT '' COMMENT '快递单号',
`delivery_name` varchar(64) DEFAULT '' COMMENT '快递名称',
`delivery_type` varchar(32) DEFAULT '' COMMENT '发货类型',
`delivery_id` varchar(64) DEFAULT '' COMMENT '快递id',
`gain_integral` int(10) unsigned DEFAULT '0' COMMENT '获得积分',
`use_integral` int(10) unsigned DEFAULT '0' COMMENT '使用积分',
`back_integral` int(10) unsigned DEFAULT '0' COMMENT '退回积分',
`mark` varchar(512) NOT NULL DEFAULT '' COMMENT '用户备注',
`is_del` tinyint(1) unsigned DEFAULT '0' COMMENT '是否删除',
`unique` varchar(32) DEFAULT '' COMMENT '唯一id',
`remark` varchar(512) DEFAULT '' COMMENT '管理员备注',
`mer_id` int(10) unsigned DEFAULT '0' COMMENT '商户id',
`is_system_del` tinyint(1) DEFAULT '0' COMMENT '系统删除',
`shipping_type` tinyint(1) DEFAULT '1' COMMENT '配送方式 1:快递 2:自提',
`store_id` int(10) DEFAULT '0' COMMENT '门店id',
`pink_id` int(10) unsigned DEFAULT '0' COMMENT '拼团id',
`cost` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '成本价',
`verify_code` varchar(50) DEFAULT '' COMMENT '核销码',
`is_channel` tinyint(1) unsigned DEFAULT '0' COMMENT '来源',
PRIMARY KEY (`id`),
UNIQUE KEY `order_id` (`order_id`),
KEY `uid` (`uid`),
KEY `add_time` (`add_time`),
KEY `paid` (`paid`),
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
eb_store_order_cart_info - 订单商品信息表
CREATE TABLE `eb_store_order_cart_info` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`oid` int(10) unsigned NOT NULL COMMENT '订单id',
`uid` int(10) unsigned DEFAULT '0' COMMENT '用户id',
`cart_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '购物车id',
`product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品ID',
`cart_info` text NOT NULL COMMENT '购物车信息',
`cart_num` int(10) unsigned DEFAULT '0' COMMENT '购买数量',
`unique` varchar(32) DEFAULT '' COMMENT '唯一值',
`is_pay` tinyint(1) DEFAULT '0' COMMENT '是否支付',
`is_refund` tinyint(1) DEFAULT '0' COMMENT '是否退款',
`is_gift` tinyint(1) DEFAULT '0' COMMENT '是否赠品',
PRIMARY KEY (`id`),
KEY `oid` (`oid`),
KEY `uid` (`uid`),
KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单购物详情表';
eb_store_order_status - 订单状态表
CREATE TABLE `eb_store_order_status` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`oid` int(10) unsigned NOT NULL COMMENT '订单id',
`change_type` varchar(32) NOT NULL COMMENT '操作类型',
`change_message` varchar(256) NOT NULL COMMENT '操作备注',
`change_time` int(10) unsigned NOT NULL COMMENT '操作时间',
PRIMARY KEY (`id`),
KEY `oid` (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单状态表';
购物车模块
eb_store_cart - 购物车表
CREATE TABLE `eb_store_cart` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '购物车ID',
`uid` int(10) unsigned NOT NULL COMMENT '用户ID',
`type` varchar(32) NOT NULL DEFAULT 'product' COMMENT '类型',
`product_id` int(10) unsigned NOT NULL COMMENT '商品ID',
`product_attr_unique` varchar(32) NOT NULL DEFAULT '' COMMENT '属性唯一值',
`cart_num` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '商品数量',
`add_time` int(10) unsigned NOT NULL COMMENT '添加时间',
`is_pay` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否支付',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`is_new` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否为立即购买',
`combination_id` int(10) unsigned DEFAULT '0' COMMENT '拼团ID',
`seckill_id` int(10) unsigned DEFAULT '0' COMMENT '秒杀ID',
`bargain_id` int(10) unsigned DEFAULT '0' COMMENT '砍价ID',
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `product_id` (`product_id`),
KEY `is_pay` (`is_pay`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='购物车表';
优惠券模块
eb_store_coupon - 优惠券表
CREATE TABLE `eb_store_coupon` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '优惠券ID',
`title` varchar(64) NOT NULL DEFAULT '' COMMENT '优惠券名称',
`integral` int(10) unsigned DEFAULT '0' COMMENT '兑换消耗积分',
`coupon_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '优惠券面值',
`use_min_price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '使用门槛',
`coupon_time` int(10) unsigned DEFAULT '0' COMMENT '优惠券有效期(天)',
`sort` int(10) unsigned DEFAULT '0' COMMENT '排序',
`status` tinyint(1) unsigned DEFAULT '0' COMMENT '状态 0:关闭 1:开启',
`add_time` int(10) unsigned DEFAULT '0' COMMENT '添加时间',
`is_del` tinyint(1) unsigned DEFAULT '0' COMMENT '是否删除',
`is_permanent` tinyint(1) DEFAULT '0' COMMENT '是否永久有效',
`type` tinyint(1) DEFAULT '0' COMMENT '类型',
PRIMARY KEY (`id`),
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='优惠券表';
eb_store_coupon_user - 用户优惠券表
CREATE TABLE `eb_store_coupon_user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '优惠券ID',
`uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`coupon_title` varchar(64) NOT NULL DEFAULT '' COMMENT '优惠券名称',
`coupon_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '优惠券面值',
`use_min_price` decimal(10,2) unsigned DEFAULT '0.00' COMMENT '使用门槛',
`add_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '领取时间',
`end_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '过期时间',
`use_time` int(10) unsigned DEFAULT '0' COMMENT '使用时间',
`type` varchar(32) NOT NULL DEFAULT 'send' COMMENT '获取方式',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态 0:未使用 1:已使用 2:已过期',
`is_fail` tinyint(1) unsigned DEFAULT '0' COMMENT '是否作废',
PRIMARY KEY (`id`),
KEY `uid` (`uid`),
KEY `cid` (`cid`),
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户优惠券表';
系统模块
eb_system_admin - 管理员表
CREATE TABLE `eb_system_admin` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '后台管理员表ID',
`account` varchar(32) NOT NULL COMMENT '管理员账号',
`pwd` varchar(255) NOT NULL COMMENT '管理员密码',
`real_name` varchar(16) NOT NULL DEFAULT '' COMMENT '管理员姓名',
`roles` varchar(128) NOT NULL DEFAULT '' COMMENT '角色id',
`last_ip` varchar(16) DEFAULT '' COMMENT '最后登录ip',
`last_time` int(10) unsigned DEFAULT '0' COMMENT '最后登录时间',
`add_time` int(10) unsigned DEFAULT '0' COMMENT '添加时间',
`login_count` int(10) unsigned DEFAULT '0' COMMENT '登录次数',
`level` tinyint(3) unsigned DEFAULT '1' COMMENT '等级',
`status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态 0:禁用 1:启用',
`is_del` tinyint(1) unsigned DEFAULT '0' COMMENT '是否删除',
`head_pic` varchar(256) DEFAULT '' COMMENT '头像',
PRIMARY KEY (`id`),
UNIQUE KEY `account` (`account`),
KEY `status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='后台管理员表';
eb_system_role - 角色表
CREATE TABLE `eb_system_role` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '角色id',
`role_name` varchar(32) NOT NULL COMMENT '角色名称',
`rules` text NOT NULL COMMENT '权限id',
`level` tinyint(3) unsigned DEFAULT '0' COMMENT '级别',
`status` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
eb_system_menus - 菜单表
CREATE TABLE `eb_system_menus` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '菜单ID',
`pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '父级id',
`icon` varchar(16) NOT NULL DEFAULT '' COMMENT '图标',
`menu_name` varchar(32) NOT NULL DEFAULT '' COMMENT '菜单名',
`module` varchar(32) NOT NULL DEFAULT '' COMMENT '模块名',
`controller` varchar(64) NOT NULL DEFAULT '' COMMENT '控制器',
`action` varchar(32) NOT NULL DEFAULT '' COMMENT '方法名',
`api_url` varchar(100) DEFAULT '' COMMENT '接口地址',
`methods` varchar(255) DEFAULT '' COMMENT '请求方式',
`params` varchar(128) NOT NULL DEFAULT '[]' COMMENT '参数',
`sort` int(10) unsigned DEFAULT '0' COMMENT '排序',
`is_show` tinyint(1) unsigned DEFAULT '1' COMMENT '是否显示',
`is_show_path` tinyint(1) DEFAULT '0' COMMENT '是否显示路径',
`access` tinyint(1) unsigned DEFAULT '1' COMMENT '是否需要权限',
`menu_path` varchar(255) DEFAULT '' COMMENT '路径',
`path` varchar(255) DEFAULT '' COMMENT 'vue路径',
`auth_type` tinyint(1) DEFAULT '1' COMMENT '权限类型',
`header` varchar(10) DEFAULT '' COMMENT '头部',
`is_header` tinyint(1) DEFAULT '0' COMMENT '是否头部',
`unique_auth` varchar(255) DEFAULT '' COMMENT '唯一标识',
`is_del` tinyint(1) DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`),
KEY `pid` (`pid`),
KEY `is_show` (`is_show`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='菜单表';
eb_system_config - 系统配置表
CREATE TABLE `eb_system_config` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '配置id',
`menu_name` varchar(255) NOT NULL COMMENT '字段名称',
`type` varchar(255) NOT NULL COMMENT '类型',
`input_type` varchar(20) DEFAULT 'input' COMMENT '表单类型',
`config_tab_id` int(10) unsigned NOT NULL COMMENT '配置分类id',
`parameter` varchar(255) DEFAULT '' COMMENT '规则',
`upload_type` tinyint(1) unsigned DEFAULT '1' COMMENT '上传类型',
`required` varchar(255) DEFAULT '' COMMENT '规则',
`width` int(10) unsigned DEFAULT '0' COMMENT '宽度',
`high` int(10) unsigned DEFAULT '0' COMMENT '高度',
`value` text COMMENT '值',
`info` varchar(255) NOT NULL COMMENT '配置名称',
`desc` varchar(255) DEFAULT '' COMMENT '配置说明',
`sort` int(10) unsigned DEFAULT '0' COMMENT '排序',
`status` tinyint(1) unsigned DEFAULT '0' COMMENT '是否隐藏',
PRIMARY KEY (`id`),
KEY `menu_name` (`menu_name`),
KEY `config_tab_id` (`config_tab_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统配置表';
表关系说明
用户相关
eb_user (用户主表)
├── eb_user_address (用户地址)
├── eb_user_bill (用户账单)
├── eb_user_extract (用户提现)
├── eb_user_recharge (用户充值)
├── eb_user_sign (用户签到)
├── eb_user_level (用户等级)
└── eb_store_coupon_user (用户优惠券)
商品相关
eb_store_product (商品主表)
├── eb_store_product_attr (商品属性)
├── eb_store_product_attr_value (商品属性值)
├── eb_store_product_reply (商品评价)
├── eb_store_product_cate (商品分类关联)
└── eb_store_product_relation (商品收藏/浏览)
订单相关
eb_store_order (订单主表)
├── eb_store_order_cart_info (订单商品)
├── eb_store_order_status (订单状态)
├── eb_store_order_refund (订单退款)
└── eb_store_order_invoice (订单发票)
索引设计原则
- 主键索引: 所有表都有自增主键
- 外键索引: 关联字段添加索引(如 uid, product_id, oid)
- 状态索引: 状态字段添加索引(如 status, is_show, is_del)
- 时间索引: 常用时间筛选字段添加索引(如 add_time, pay_time)
- 唯一索引: 唯一字段添加唯一索引(如 order_id, account)
常用查询示例
获取用户订单列表
// DAO层查询
$this->model->where('uid', $uid)
->where('is_del', 0)
->where('is_system_del', 0)
->order('add_time desc')
->select();
商品列表查询
// 带条件的商品查询
$this->model->where('is_show', 1)
->where('is_del', 0)
->when($cateId, function($query) use ($cateId) {
$query->whereIn('cate_id', $cateId);
})
->order('sort desc, id desc')
->select();
分销模块
eb_agent_level - 分销员等级表
CREATE TABLE `eb_agent_level` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '等级名称',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '背景图',
`color` varchar(32) NOT NULL DEFAULT '' COMMENT '字体颜色',
`one_brokerage` smallint(5) NOT NULL DEFAULT '0' COMMENT '一级分拥比例',
`two_brokerage` smallint(5) NOT NULL DEFAULT '0' COMMENT '二级分拥比例',
`grade` smallint(5) NOT NULL DEFAULT '0' COMMENT '等级',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
KEY `status` (`status`,`is_del`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分销员等级表';
eb_agent_level_task - 分销员等级任务表
CREATE TABLE `eb_agent_level_task` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`level_id` int(10) NOT NULL DEFAULT '0' COMMENT '分销等级id',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '任务名称',
`type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '任务类型',
`number` int(10) NOT NULL DEFAULT '0' COMMENT '任务限定数',
`desc` varchar(255) NOT NULL DEFAULT '' COMMENT '任务描述',
`is_must` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否必须达成 0:其一 1:所有',
`sort` smallint(5) NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分销员等级任务表';
文章模块
eb_article - 文章管理表
CREATE TABLE `eb_article` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '文章管理ID',
`cid` varchar(255) NOT NULL DEFAULT '1' COMMENT '分类id',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '文章标题',
`author` varchar(255) NOT NULL DEFAULT '' COMMENT '文章作者',
`image_input` varchar(255) NOT NULL DEFAULT '' COMMENT '文章图片',
`synopsis` varchar(255) NOT NULL DEFAULT '' COMMENT '文章简介',
`visit` varchar(255) NOT NULL DEFAULT '0' COMMENT '浏览次数',
`likes` int(10) NOT NULL DEFAULT '0' COMMENT '点赞量',
`sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`url` varchar(255) NOT NULL DEFAULT '' COMMENT '原文链接',
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态',
`add_time` varchar(255) NOT NULL DEFAULT '' COMMENT '添加时间',
`hide` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否隐藏',
`is_hot` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否热门',
`is_banner` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否轮播图',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章管理表';
eb_article_category - 文章分类表
CREATE TABLE `eb_article_category` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '文章分类id',
`pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '文章分类标题',
`intr` varchar(255) NOT NULL DEFAULT '' COMMENT '文章分类简介',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '文章分类图片',
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态',
`sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`is_del` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` varchar(255) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章分类表';
直播模块
eb_live_anchor - 直播主播表
CREATE TABLE `eb_live_anchor` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '主播名称',
`cover_img` varchar(255) NOT NULL DEFAULT '' COMMENT '主播图像',
`wechat` varchar(50) NOT NULL DEFAULT '' COMMENT '主播微信号',
`phone` varchar(32) NOT NULL DEFAULT '' COMMENT '手机号',
`is_show` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否显示',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='直播主播表';
eb_live_room - 直播间表
CREATE TABLE `eb_live_room` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`room_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '直播间 id',
`name` varchar(32) NOT NULL DEFAULT '' COMMENT '直播间名字',
`cover_img` varchar(255) NOT NULL DEFAULT '' COMMENT '背景图',
`start_time` int(10) NOT NULL DEFAULT '0' COMMENT '直播计划开始时间',
`end_time` int(10) NOT NULL DEFAULT '0' COMMENT '直播计划结束时间',
`anchor_name` varchar(50) NOT NULL DEFAULT '' COMMENT '主播昵称',
`type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '直播间类型 1:推流 0:手机直播',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态',
`live_status` smallint(5) unsigned NOT NULL DEFAULT '102' COMMENT '直播状态',
`is_show` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '是否显示',
`is_del` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='直播间表';
抽奖模块
eb_luck_lottery - 抽奖活动表
CREATE TABLE `eb_luck_lottery` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '抽奖类型 1:九宫格 2:大转盘 3:九宫格升级版 4:幸运翻牌',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '抽奖活动名称',
`desc` varchar(255) NOT NULL DEFAULT '' COMMENT '活动描述',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '活动背景图',
`factor` tinyint(1) NOT NULL DEFAULT '1' COMMENT '抽奖消耗 1:积分 2:余额 3:下单支付成功 4:订单评价',
`factor_num` smallint(5) NOT NULL DEFAULT '10' COMMENT '获取一次抽奖的条件数量',
`prize_num` smallint(5) NOT NULL DEFAULT '0' COMMENT '奖品数量',
`start_time` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
`end_time` int(11) NOT NULL DEFAULT '0' COMMENT '结束时间',
`lottery_num` smallint(5) NOT NULL DEFAULT '1' COMMENT '抽奖次数',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='抽奖活动表';
eb_luck_prize - 抽奖活动奖品表
CREATE TABLE `eb_luck_prize` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '奖品主键id',
`type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '奖品类型 1:未中奖 2:积分 3:余额 4:红包 5:优惠券 6:站内商品',
`lottery_id` int(10) NOT NULL DEFAULT '0' COMMENT '抽奖活动id',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '奖品名称',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '奖品图片',
`chance` smallint(5) NOT NULL DEFAULT '10' COMMENT '中奖基数',
`percent` float NOT NULL DEFAULT '0' COMMENT '中奖概率',
`total` smallint(5) NOT NULL DEFAULT '1' COMMENT '奖品数量',
`coupon_id` int(10) NOT NULL DEFAULT '0' COMMENT '关联优惠券id',
`product_id` int(10) NOT NULL DEFAULT '0' COMMENT '关联商品id',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`),
KEY `lottery_id` (`lottery_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='抽奖活动奖品表';
会员模块
eb_member_ship - 会员类型表
CREATE TABLE `eb_member_ship` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` varchar(20) NOT NULL DEFAULT 'month' COMMENT '会员类别 month:月卡 quarter:季卡 year:年卡 ever:永久 free:免费',
`title` varchar(200) NOT NULL DEFAULT '' COMMENT '会员名称',
`vip_day` int(10) NOT NULL DEFAULT '0' COMMENT '会员时间(天)',
`price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '原价',
`pre_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '优惠后价格',
`sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
`is_del` int(2) NOT NULL DEFAULT '0' COMMENT '删除',
`add_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员类型';
eb_member_right - 会员权益表
CREATE TABLE `eb_member_right` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`right_type` varchar(100) NOT NULL DEFAULT '' COMMENT '权益类别',
`title` varchar(200) NOT NULL DEFAULT '' COMMENT '权益名称',
`show_title` varchar(255) NOT NULL DEFAULT '' COMMENT '显示权益名称',
`image` varchar(200) NOT NULL DEFAULT '' COMMENT '权益图标',
`explain` varchar(1024) NOT NULL DEFAULT '' COMMENT '权益介绍',
`number` int(2) NOT NULL DEFAULT '1' COMMENT '规则数字',
`sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '0:禁用 1:启用',
`add_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`,`right_type`),
KEY `type` (`right_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员权益';
营销活动模块
eb_store_bargain - 砍价表
CREATE TABLE `eb_store_bargain` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '砍价商品ID',
`product_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联商品ID',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '砍价活动名称',
`image` varchar(150) NOT NULL DEFAULT '' COMMENT '砍价活动图片',
`stock` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '库存',
`sales` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '销量',
`start_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '砍价开启时间',
`stop_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '砍价结束时间',
`price` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '砍价金额',
`min_price` decimal(12,2) unsigned DEFAULT '0.00' COMMENT '砍价商品最低价',
`bargain_max_price` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '用户每次砍价的最大金额',
`bargain_min_price` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '用户每次砍价的最小金额',
`bargain_num` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '用户帮砍的次数',
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '砍价状态',
`is_del` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`quota` int(10) NOT NULL DEFAULT '0' COMMENT '限购总数',
PRIMARY KEY (`id`),
KEY `is_del` (`is_del`,`status`,`product_id`,`start_time`,`stop_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='砍价表';
eb_store_combination - 拼团商品表
CREATE TABLE `eb_store_combination` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品id',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '推荐图',
`images` varchar(2000) NOT NULL DEFAULT '' COMMENT '轮播图',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '活动标题',
`people` int(2) unsigned NOT NULL DEFAULT '0' COMMENT '参团人数',
`info` varchar(255) NOT NULL DEFAULT '' COMMENT '简介',
`price` decimal(10,2) unsigned NOT NULL DEFAULT '0' COMMENT '价格',
`sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`sales` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '销量',
`stock` int(10) NOT NULL DEFAULT '0' COMMENT '库存',
`is_show` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '商品状态',
`is_del` tinyint(1) unsigned NOT NULL DEFAULT '0',
`start_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '拼团开始时间',
`stop_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '拼团结束时间',
`effective_time` int(11) NOT NULL DEFAULT '0' COMMENT '拼团订单有效时间',
`virtual` int(11) NOT NULL DEFAULT '100' COMMENT '虚拟成团百分比',
`quota` int(10) NOT NULL DEFAULT '0' COMMENT '限购总数',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='拼团商品表';
eb_store_seckill - 秒杀商品表
CREATE TABLE `eb_store_seckill` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '商品秒杀商品表id',
`activity_id` int(10) NOT NULL DEFAULT '0' COMMENT '活动ID',
`product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品id',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '推荐图',
`images` varchar(2000) NOT NULL DEFAULT '' COMMENT '轮播图',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '活动标题',
`info` varchar(255) NOT NULL DEFAULT '' COMMENT '简介',
`price` decimal(10,2) unsigned NOT NULL DEFAULT '0' COMMENT '价格',
`cost` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '成本',
`ot_price` decimal(10,2) unsigned NOT NULL DEFAULT '0' COMMENT '原价',
`sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`stock` int(10) NOT NULL DEFAULT '0' COMMENT '库存',
`sales` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '销量',
`start_time` varchar(128) NOT NULL DEFAULT '' COMMENT '开始时间',
`stop_time` varchar(128) NOT NULL DEFAULT '' COMMENT '结束时间',
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '商品状态',
`is_del` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '删除',
`num` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '最多秒杀几个',
`quota` int(10) NOT NULL DEFAULT '0' COMMENT '限购总数',
`once_num` int(11) NOT NULL DEFAULT '0' COMMENT '单次购买个数',
PRIMARY KEY (`id`),
KEY `product_id` (`product_id`),
KEY `is_del` (`is_del`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品秒杀商品表';
积分商城模块
eb_store_integral - 积分商品表
CREATE TABLE `eb_store_integral` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '积分商品ID',
`image` varchar(256) NOT NULL DEFAULT '' COMMENT '商品图片',
`product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品id',
`images` varchar(2000) NOT NULL DEFAULT '' COMMENT '轮播图',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '活动标题',
`price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
`integral` int(12) NOT NULL DEFAULT '0' COMMENT '积分价格',
`sort` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`sales` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '销量',
`stock` int(10) NOT NULL DEFAULT '0' COMMENT '库存',
`is_show` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '商品状态',
`is_del` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '删除',
`num` int(11) NOT NULL DEFAULT '0' COMMENT '最多积分几个',
`quota` int(10) NOT NULL DEFAULT '0' COMMENT '限购总数',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='积分商品表';
门店模块
eb_system_store - 门店自提表
CREATE TABLE `eb_system_store` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '' COMMENT '门店名称',
`introduction` varchar(1000) NOT NULL DEFAULT '' COMMENT '简介',
`phone` char(25) NOT NULL DEFAULT '' COMMENT '手机号码',
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '省市区',
`province` int(10) NOT NULL DEFAULT '0' COMMENT '省ID',
`city` int(10) NOT NULL DEFAULT '0' COMMENT '市ID',
`area` int(10) NOT NULL DEFAULT '0' COMMENT '区ID',
`detailed_address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '门店logo',
`latitude` char(25) NOT NULL DEFAULT '' COMMENT '纬度',
`longitude` char(25) NOT NULL DEFAULT '' COMMENT '经度',
`valid_time` varchar(100) NOT NULL DEFAULT '' COMMENT '核销有效日期',
`day_time` varchar(100) NOT NULL DEFAULT '' COMMENT '每日营业开关时间',
`add_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
`is_show` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否显示',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`is_store` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否到店自提',
PRIMARY KEY (`id`),
KEY `phone` (`phone`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='门店自提';
eb_system_store_staff - 门店店员表
CREATE TABLE `eb_system_store_staff` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`store_id` int(11) NOT NULL DEFAULT '0' COMMENT '门店id',
`uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '微信用户id',
`account` varchar(50) NOT NULL DEFAULT '' COMMENT '账号',
`pwd` varchar(100) NOT NULL DEFAULT '' COMMENT '密码',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '店员头像',
`staff_name` varchar(64) NOT NULL DEFAULT '' COMMENT '店员名称',
`phone` char(15) NOT NULL DEFAULT '' COMMENT '手机号码',
`roles` varchar(255) DEFAULT '' COMMENT '管理权限',
`verify_status` tinyint(2) NOT NULL DEFAULT '0' COMMENT '核销开关',
`is_admin` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是管理员',
`is_manager` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是店长',
`is_cashier` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否收银员',
`status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '状态',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='门店店员表';
供应商模块
eb_system_supplier - 供应商表
CREATE TABLE `eb_system_supplier` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`admin_id` int(10) NOT NULL DEFAULT '0' COMMENT '管理员ID',
`supplier_name` varchar(50) NOT NULL DEFAULT '' COMMENT '供应商名称',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '联系人姓名',
`phone` char(15) NOT NULL DEFAULT '' COMMENT '联系电话',
`email` varchar(50) NOT NULL DEFAULT '' COMMENT '邮箱',
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '省市区',
`detailed_address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
`bank_code` varchar(32) NOT NULL DEFAULT '0' COMMENT '银行卡',
`bank_address` varchar(256) NOT NULL DEFAULT '' COMMENT '开户地址',
`sort` int(10) NOT NULL DEFAULT '0' COMMENT '排序',
`is_show` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 0关闭 1开启',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
`add_time` int(10) NOT NULL DEFAULT '0' COMMENT '添加时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='供应商表';
客服模块
eb_store_service - 客服表
CREATE TABLE `eb_store_service` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '客服id',
`mer_id` int(11) NOT NULL DEFAULT '0' COMMENT '商户id',
`uid` int(11) NOT NULL DEFAULT '0' COMMENT '客服uid',
`online` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否在线',
`account` varchar(255) NOT NULL DEFAULT '' COMMENT '账号',
`password` varchar(255) NOT NULL DEFAULT '' COMMENT '密码',
`avatar` varchar(250) NOT NULL DEFAULT '' COMMENT '客服头像',
`nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '代理名称',
`phone` varchar(20) NOT NULL DEFAULT '' COMMENT '客服电话',
`add_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
`status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '客服状态',
`notify` int(2) NOT NULL DEFAULT '0' COMMENT '订单通知',
`is_del` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除',
PRIMARY KEY (`id`),
KEY `uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客服表';
扩展表关系说明
分销相关
eb_agent_level (分销员等级)
└── eb_agent_level_task (等级任务)
└── eb_agent_level_task_record (任务完成记录)
直播相关
eb_live_room (直播间)
├── eb_live_anchor (主播)
├── eb_live_goods (直播商品)
└── eb_live_room_goods (直播间商品关联)
抽奖相关
eb_luck_lottery (抽奖活动)
├── eb_luck_prize (奖品)
└── eb_luck_lottery_record (抽奖记录)
会员相关
eb_member_ship (会员类型)
eb_member_right (会员权益)
eb_member_card (会员卡)
└── eb_member_card_batch (会员卡批次)
eb_other_order (会员购买记录)
营销活动相关
eb_store_bargain (砍价活动)
├── eb_store_bargain_user (用户参与砍价)
└── eb_store_bargain_user_help (砍价帮助记录)
eb_store_combination (拼团商品)
└── eb_store_pink (拼团记录)
eb_store_seckill (秒杀商品)
└── eb_store_seckill_time (秒杀时间段)
└── eb_store_activity (活动配置)
eb_store_promotions (优惠活动)
└── eb_store_promotions_auxiliary (优惠活动辅助)
eb_store_discounts (优惠套餐)
└── eb_store_discounts_products (套餐商品)
门店/供应商相关
eb_system_store (门店)
└── eb_system_store_staff (店员)
eb_system_supplier (供应商)
├── eb_supplier_flowing_water (供应商流水)
├── eb_supplier_transactions (供应商交易)
└── eb_supplier_extract (供应商提现)
企业微信模块
eb_work_client - 企业微信客户表
CREATE TABLE `eb_work_client` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`corp_id` varchar(18) NOT NULL DEFAULT '' COMMENT '企业微信id',
`external_userid` varchar(64) NOT NULL DEFAULT '' COMMENT '外部联系人的userid',
`uid` int(11) NOT NULL DEFAULT '0' COMMENT '商城用户uid',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '外部联系人的名称',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '外部联系人头像',
`type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1微信用户 2企业微信用户',
`gender` tinyint(1) NOT NULL DEFAULT '0' COMMENT '性别 0未知 1男 2女',
`unionid` varchar(64) NOT NULL DEFAULT '' COMMENT '开放平台唯一身份标识',
`corp_name` varchar(50) NOT NULL DEFAULT '' COMMENT '外部联系人所在企业简称',
`create_time` int(11) NOT NULL DEFAULT '0',
`delete_time` int(11) DEFAULT NULL COMMENT '删除时间戳',
PRIMARY KEY (`id`),
KEY `external_userid` (`external_userid`),
KEY `uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='企业微信客户';
eb_work_member - 企业微信成员表
CREATE TABLE `eb_work_member` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`corp_id` varchar(18) NOT NULL DEFAULT '' COMMENT '企业微信id',
`userid` varchar(64) NOT NULL DEFAULT '' COMMENT '成员UserID',
`uid` int(11) NOT NULL DEFAULT '0' COMMENT '商城uid',
`name` varchar(64) NOT NULL DEFAULT '' COMMENT '成员名称',
`position` varchar(50) NOT NULL DEFAULT '' COMMENT '职务信息',
`mobile` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号码',
`gender` tinyint(1) NOT NULL DEFAULT '0' COMMENT '性别 0未定义 1男 2女',
`email` varchar(50) NOT NULL DEFAULT '' COMMENT '邮箱',
`avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '头像url',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '激活状态 1已激活 2已禁用 4未激活 5退出企业',
`qr_code` varchar(255) NOT NULL DEFAULT '' COMMENT '员工个人二维码',
`create_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `userid` (`userid`),
KEY `corp_id` (`corp_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='企业微信成员';
eb_work_group_chat - 企业微信群表
CREATE TABLE `eb_work_group_chat` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`corp_id` varchar(18) NOT NULL DEFAULT '' COMMENT '企业ID',
`chat_id` varchar(40) NOT NULL DEFAULT '' COMMENT '客户群ID',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '群名',
`owner` varchar(64) NOT NULL DEFAULT '' COMMENT '群主ID',
`group_create_time` int(11) NOT NULL DEFAULT '0' COMMENT '群创建时间',
`notice` varchar(255) NOT NULL DEFAULT '' COMMENT '群公告',
`member_num` int(11) NOT NULL DEFAULT '0' COMMENT '群人数',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '跟进状态 0正常 1离职 2继承中 3继承完成',
`create_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `corp_id` (`corp_id`,`chat_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='企业微信群';
eb_work_welcome - 企业微信欢迎语表
CREATE TABLE `eb_work_welcome` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0通用 1指定员工',
`content` text COMMENT '消息内容',
`attachments` text COMMENT '欢迎语消息体',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
`create_time` int(11) NOT NULL DEFAULT '0',
`delete_time` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='企业微信欢迎语';
礼品卡模块
eb_card_gift - 礼品卡表
CREATE TABLE `eb_card_gift` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '礼品卡类型 1储值卡 2兑换卡',
`name` varchar(64) NOT NULL DEFAULT '' COMMENT '礼品卡名称',
`batch_id` int NOT NULL DEFAULT '0' COMMENT '关联卡密批次',
`total_num` int NOT NULL DEFAULT '0' COMMENT '总数量',
`used_num` int NOT NULL DEFAULT '0' COMMENT '已使用数量',
`instructions` text COMMENT '使用须知',
`cover_image` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图',
`valid_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '有效期类型 1永久 2固定日期',
`start_time` int NOT NULL DEFAULT '0' COMMENT '开始时间',
`end_time` int NOT NULL DEFAULT '0' COMMENT '结束时间',
`status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 0禁用 1启用',
`balance` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '储值金额',
`exchange_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '兑换类型 1固定打包 2任选N件',
`is_del` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='礼品卡表';
eb_card_code - 卡密表
CREATE TABLE `eb_card_code` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`card_number` varchar(64) NOT NULL DEFAULT '' COMMENT '卡号',
`card_pwd` varchar(255) NOT NULL DEFAULT '' COMMENT '卡密',
`uid` int NOT NULL DEFAULT '0' COMMENT '用户UID',
`type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '卡密类型 0储值卡 1兑换卡',
`card_id` int NOT NULL DEFAULT '0' COMMENT '关联礼品卡ID',
`batch_id` int NOT NULL DEFAULT '0' COMMENT '关联卡密批次ID',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态 0未使用 1已使用 2已分配 3已过期',
`active_time` int NOT NULL DEFAULT '0' COMMENT '激活时间',
`end_time` int NOT NULL DEFAULT '0' COMMENT '到期时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_card_number` (`card_number`),
KEY `idx_uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='卡密表';
eb_card_batch - 卡次表
CREATE TABLE `eb_card_batch` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`name` varchar(64) NOT NULL DEFAULT '' COMMENT '卡次名称',
`card_prefix` varchar(64) NOT NULL DEFAULT '' COMMENT '卡号前缀',
`card_suffix` varchar(64) NOT NULL DEFAULT '' COMMENT '卡号后缀',
`prefix` varchar(64) NOT NULL COMMENT '卡号前缀+后缀',
`total_num` int NOT NULL DEFAULT '0' COMMENT '总数量',
`used_num` int NOT NULL DEFAULT '0' COMMENT '使用数量',
`add_time` int NOT NULL DEFAULT '0' COMMENT '创建时间',
`is_del` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='卡次表';
运费模板模块
eb_shipping_templates - 运费模板表
CREATE TABLE `eb_shipping_templates` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
`type` tinyint(2) NOT NULL DEFAULT '0' COMMENT '所属 0平台 1门店 2供应商',
`relation_id` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
`name` varchar(255) NOT NULL DEFAULT '' COMMENT '模板名称',
`group` tinyint(1) NOT NULL DEFAULT '1' COMMENT '计费方式 1按件数 2按重量 3按体积',
`appoint` tinyint(1) NOT NULL DEFAULT '0' COMMENT '指定包邮',
`no_delivery` tinyint(1) NOT NULL DEFAULT '0' COMMENT '指定不送达',
`sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
`add_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运费模板表';
eb_shipping_templates_region - 运费模板区域表
CREATE TABLE `eb_shipping_templates_region` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
`province_id` int(11) NOT NULL DEFAULT '0' COMMENT '省ID',
`temp_id` int(11) NOT NULL DEFAULT '0' COMMENT '模板ID',
`city_id` int(11) NOT NULL DEFAULT '0' COMMENT '城市ID',
`first` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '首件',
`first_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '首件运费',
`continue` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '续件',
`continue_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '续件运费',
`group` tinyint(1) NOT NULL DEFAULT '1' COMMENT '计费方式',
`uniqid` varchar(32) NOT NULL DEFAULT '' COMMENT '分组唯一值',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='运费模板区域表';
社区模块
eb_community - 社区帖子表
CREATE TABLE `eb_community` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '类型 0平台 1门店 2用户',
`relation_id` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
`content_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '内容类型 1图文 2视频',
`title` varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
`image` varchar(255) NOT NULL DEFAULT '' COMMENT '封面图',
`video_url` varchar(255) NOT NULL DEFAULT '' COMMENT '视频地址',
`slider_image` text COMMENT '图集',
`content` longtext COMMENT '内容详情',
`topic_id` longtext COMMENT '关联话题ids',
`product_id` longtext COMMENT '关联商品ids',
`like_num` int(10) NOT NULL DEFAULT '0' COMMENT '点赞数量',
`collect_num` int(10) NOT NULL DEFAULT '0' COMMENT '收藏数量',
`play_num` int(10) NOT NULL DEFAULT '0' COMMENT '浏览播放数量',
`comment_num` int(10) NOT NULL DEFAULT '0' COMMENT '评论数量',
`is_verify` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态 -2强制下架 -1未通过 0未审核 1通过',
`is_del` tinyint(1) NOT NULL DEFAULT '0',
`add_time` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='社区帖子表';
eb_community_topic - 社区话题表
CREATE TABLE `eb_community_topic` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '' COMMENT '话题名称',
`icon` varchar(128) NOT NULL DEFAULT '' COMMENT '图标',
`sort` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
`is_recommend` tinyint(11) NOT NULL DEFAULT '0' COMMENT '推荐',
`type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型 1后台 2用户',
`use_num` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '使用次数',
`view_num` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '浏览量',
`status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '状态',
`is_del` tinyint(2) NOT NULL DEFAULT '0',
`add_time` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='社区话题';
eb_community_comment - 社区评价回复表
CREATE TABLE `eb_community_comment` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '类型 0平台 1门店 2用户 3虚拟',
`uid` int(11) NOT NULL DEFAULT '0' COMMENT '关联id',
`reply_id` int(11) NOT NULL DEFAULT '0' COMMENT '帖子评论id',
`community_id` int(11) NOT NULL DEFAULT '0' COMMENT '社区内容id',
`content` varchar(1000) NOT NULL DEFAULT '' COMMENT '评论内容',
`like_num` int(11) NOT NULL DEFAULT '0' COMMENT '点赞数量',
`is_verify` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态',
`is_del` tinyint(1) NOT NULL DEFAULT '0',
`add_time` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `community_id` (`community_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='社区评价回复表';
其他扩展模块
eb_store_newcomer - 新人专享商品表
CREATE TABLE `eb_store_newcomer` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`type` tinyint(2) NOT NULL DEFAULT '0' COMMENT '所属 0平台 1门店 2供应商',
`product_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '商品id',
`product_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '商品类型',
`relation_id` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
`price` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '商品价格',
`ot_price` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '市场价',
`sales` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '销量',
`is_del` tinyint(1) NOT NULL DEFAULT '0',
`add_time` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='新人专享商品';
eb_store_delivery_order - 配送订单表
CREATE TABLE `eb_store_delivery_order` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`type` tinyint(2) NOT NULL DEFAULT '0' COMMENT '所属 0平台 1门店 2供应商',
`relation_id` int(10) NOT NULL DEFAULT '0' COMMENT '关联ID',
`oid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '订单ID',
`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`station_type` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '平台类型',
`order_id` varchar(32) NOT NULL DEFAULT '' COMMENT '订单号',
`delivery_no` varchar(255) NOT NULL DEFAULT '' COMMENT '配送方订单号',
`from_address` varchar(255) NOT NULL DEFAULT '' COMMENT '起始位置',
`to_address` varchar(255) NOT NULL DEFAULT '' COMMENT '结束位置',
`distance` float NOT NULL DEFAULT '0' COMMENT '配送距离',
`fee` decimal(8,2) NOT NULL DEFAULT '0.00' COMMENT '配送费',
`status` int(11) NOT NULL DEFAULT '0' COMMENT '状态 -1取消 2待取货 3配送中 4已完成',
`add_time` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='发货配送订单';
eb_channel_merchant - 采购商表
CREATE TABLE `eb_channel_merchant` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '渠道商ID',
`uid` int NOT NULL DEFAULT '0' COMMENT '关联用户ID',
`channel_name` varchar(100) NOT NULL DEFAULT '' COMMENT '渠道商名称',
`real_name` varchar(50) NOT NULL DEFAULT '' COMMENT '联系人',
`phone` varchar(20) NOT NULL DEFAULT '' COMMENT '联系电话',
`province` varchar(100) NOT NULL DEFAULT '' COMMENT '省份城市区县',
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
`verify_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '审核状态 0待审核 1通过 2未通过',
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态 0关闭 1开启',
`order_count` int NOT NULL DEFAULT '0' COMMENT '订单数量',
`order_price` decimal(12,2) NOT NULL DEFAULT '0.00' COMMENT '订单金额',
`is_del` tinyint(1) NOT NULL DEFAULT '0',
`add_time` int NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='采购商表';
扩展表关系说明(补充)
企业微信相关
eb_work_member (企业成员)
├── eb_work_client (企业客户)
│ └── eb_work_client_follow (客户跟踪)
│ └── eb_work_client_follow_tags (跟踪标签)
├── eb_work_department (部门)
│ └── eb_work_member_relation (成员部门关联)
└── eb_work_group_chat (企业群)
└── eb_work_group_chat_member (群成员)
eb_work_group_template (群发模板)
└── eb_work_group_msg_task (群发任务)
└── eb_work_group_msg_send_result (发送结果)
eb_work_moment (朋友圈)
└── eb_work_moment_send_result (发送结果)
eb_work_welcome (欢迎语)
└── eb_work_welcome_relation (欢迎语关联)
礼品卡相关
eb_card_batch (卡次批次)
└── eb_card_code (卡密)
└── eb_card_gift (礼品卡)
├── eb_card_gift_auxiliary (礼品卡商品)
└── eb_card_gift_record (操作记录)
社区相关
eb_community (社区帖子)
├── eb_community_topic (话题)
├── eb_community_comment (评论)
├── eb_community_relevance (关联关系)
└── eb_community_user (社区用户)
└── eb_community_record (社区记录)
运费模板相关
eb_shipping_templates (运费模板)
├── eb_shipping_templates_region (区域运费)
├── eb_shipping_templates_free (包邮设置)
└── eb_shipping_templates_no_delivery (不送达设置)
数据库维护建议
- 定期备份: 使用系统自带的数据库备份功能
- 表优化: 定期执行
OPTIMIZE TABLE优化表 - 索引维护: 定期检查慢查询并优化索引
- 数据清理: 定期清理过期数据(如日志、临时数据)
注意事项
- 表前缀统一:所有数据表使用
eb_前缀,修改表前缀需要同步更新database.php配置 - 字符集选择:所有表统一使用
utf8mb4字符集,支持 emoji 表情存储 - 软删除字段:大部分业务表使用
is_del字段做软删除,避免直接物理删除数据 - 时间字段:创建时间
add_time和更新时间update_time使用 INT 类型存储时间戳 - 金额字段:所有金额字段使用 DECIMAL(10,2) 类型,避免浮点数精度问题
- 外键约束:系统未使用数据库外键约束,关联关系在应用层维护,便于分库分表扩展
- 索引设计:高频查询字段必须建立索引,联合索引注意字段顺序遵循最左前缀原则
- 大字段分离:商品描述等大文本字段单独存储在
_description表中,减小主表体积 - 状态字段:状态字段(如
status、is_show)使用 TINYINT 类型,0/1 表示不同状态
常见问题
Q: 新增数据表应该放在哪里执行?
A: 开发环境可以直接执行 SQL,生产环境建议通过版本升级脚本执行,或使用public/install/sql/目录下的升级文件Q: 如何修改表前缀?
A: 修改config/database.php中的prefix配置项,同时需要手动重命名数据库中的所有表Q: 数据库字段如何与 Model 对应?
A: ThinkPHP 会自动将下划线命名转换为驼峰命名,如add_time在模型中可以用$model->add_time或$model->addTime访问Q: 为什么订单表设计了多个关联表?
A: 订单业务复杂,拆分为主表(eb_store_order)、详情表(eb_store_order_cart_info)、状态表(eb_store_order_status)等,便于维护和查询优化Q: 如何处理数据库迁移和版本升级?
A: 使用public/install/sql/目录下的版本升级 SQL 文件,按版本号顺序执行升级脚本Q: 数据表数据量大时如何优化查询?
A: 1) 确保查询字段有索引;2) 使用 EXPLAIN 分析查询计划;3) 考虑分表或归档历史数据;4) 使用缓存减少数据库访问
评论({{cateWiki.comment_num}})
最新
最早
{{cateWiki.page_view_num}}人看过该文档
评论(0)
最新
最早
251人看过
登录/注册
即可发表评论
{{item.user ? item.user.nickname : ''}}
(自评)
{{item.content}}
搜索结果
为您找到{{wikiCount}}条结果
{{item.page_view_num}}
{{item.like ? item.like.like_num : 0}}
{{item.comment ? item.comment.comment_num : 0}}
位置:
{{path.name}}
{{(i+1) == getCataloguePathData(item.catalogue).length ? '':'/'}}
