# SQL
```
-- 生活服务分类表
CREATE TABLE `o2o_category`(
`id` int(11) unsigned NOT NULL auto_increment,
`name` VARCHAR(50) NOT NULL default '' ,
`parent_id` int(10) unsigned NOT NULL default 0,
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
KEY parent_id(`parent_id`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 城市表
CREATE TABLE `o2o_city`(
`id` int(11) unsigned NOT NULL auto_increment,
`name` VARCHAR(50) NOT NULL default '' ,
`uname` VARCHAR(50) NOT NULL default '' ,
`parent_id` int(10) unsigned NOT NULL default 0,
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
KEY parent_id(`parent_id`),
UNIQUE KEY uname(`uname`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 商圈表
CREATE TABLE `o2o_area`(
`id` int(11) unsigned NOT NULL auto_increment,
`name` VARCHAR(50) NOT NULL default '' ,
`city_id` int(11) unsigned NOT NULL default 0,
`parent_id` int(10) unsigned NOT NULL default 0,
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
KEY parent_id(`parent_id`),
KEY city_id(`city_id`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 商户表
CREATE TABLE `o2o_bis`(
`id` int(11) unsigned NOT NULL auto_increment,
`name` VARCHAR(50) NOT NULL default '' ,
`email` VARCHAR(50) NOT NULL default '' ,
`logo` VARCHAR(255) NOT NULL default '' ,
`licence_logo` VARCHAR(255) NOT NULL default '' ,
`description` text NOT NULL,
`city_id` int(11) unsigned NOT NULL default 0,
`city_path` varchar(50) NOT NULL default '' ,
`bank_info` varchar(50) NOT NULL default '' ,
`money` decimal(20,2) NOT NULL default '0.00',
`bank_name` varchar(50) NOT NULL default '' ,
`bank_user` varchar(50) NOT NULL default '' ,
`faren` varchar(20) NOT NULL default '' ,
`faren_tel` varchar(20) NOT NULL default '' ,
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
KEY city_id(`city_id`),
KEY name(`name`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 商户账号表
CREATE TABLE `o2o_bis_account`(
`id` int(11) unsigned NOT NULL auto_increment,
`username` VARCHAR(50) NOT NULL default '' ,
`password` char(32) NOT NULL default '' ,
`code` varchar(10) NOT NULL default '' ,
`bis_id` int(11) unsigned NOT NULL default 0,
`last_login_ip` VARCHAR(20) NOT NULL default '',
`last_login_time` int(11) unsigned NOT NULL default 0,
`is_main` tinyint(1) unsigned NOT NULL default 0,
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
KEY bis_id(`bis_id`),
KEY username(`username`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 商户门店表
CREATE TABLE `o2o_bis_location`(
`id` int(11) unsigned NOT NULL auto_increment,
`name` VARCHAR(50) NOT NULL default '' ,
`logo` VARCHAR(255) NOT NULL default '' ,
`address` VARCHAR(255) NOT NULL default '' ,
`tel` VARCHAR(20) NOT NULL default '' ,
`contact` VARCHAR(20) NOT NULL default '' ,
`xpoint` VARCHAR(20) NOT NULL default '',
`ypoint` VARCHAR(20) NOT NULL default '',
`bis_id` int(11) unsigned NOT NULL default 0,
`open_time` int(11) unsigned NOT NULL default 0,
`content` text NOT NULL ,
`is_main` tinyint(1) unsigned NOT NULL default 0,
`api_address` VARCHAR(255) NOT NULL default '' ,
`city_id` int(11) unsigned NOT NULL default 0,
`city_path` varchar(50) NOT NULL default '' ,
`category_id` int(11 ) unsigned NOT NULL default 0,
`category_path` VARCHAR(50) NOT NULL default '',
`bank_info` varchar(50) NOT NULL default '' ,
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
KEY city_id(`city_id`),
KEY bis_id(`bis_id`),
KEY category_id(`category_id`),
KEY name(`name`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 团购商品表
CREATE TABLE `o2o_deal`(
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '',
`category_id` int(11) NOT NULL default 0,
`se_category_id` int(11) NOT NULL default 0,
`bis_id` int(11) NOT NULL default 0,
`location_ids` VARCHAR(100) NOT NULL default '',
`image` VARCHAR(200) NOT NULL default '',
`description` text NOT NULL ,
`start_time` int(11) NOT NULL default 0,
`end_time` int(11) NOT NULL default 0,
`origin_price` decimal(20,2) NOT NULL default '0.00',
`current_price` decimal(20,2) NOT NULL default '0.00',
`city_id` int(11 ) NOT NULL default 0,
`buy_count` int(11 ) NOT NULL default 0,
`total_count` int(11 ) NOT NULL default 0,
`coupons_begin_time` int(11) NOT NULL default 0,
`coupons_end_time` int(11) NOT NULL default 0,
`xpoint` VARCHAR(20) NOT NULL default '',
`ypoint` VARCHAR(20) NOT NULL default '',
`bis_account_id` int(10) NOT NULL default 0,
`balance_price` decimal(20,2) NOT NULL default '0.00',
`notes` text not NULL ,
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
KEY category_id(`category_id`),
KEY se_category_id(`se_category_id`),
KEY city_id(`city_id`),
KEY start_time(`start_time`),
KEY end_time(`end_time`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 用户表
CREATE TABLE `o2o_user`(
`id` int(11) unsigned NOT NULL auto_increment,
`username` VARCHAR(20) NOT NULL default '',
`password` char(32) NOT NULL default '' ,
`code` varchar(10) NOT NULL default '' ,
`last_login_ip` VARCHAR(20) NOT NULL default '',
`last_login_time` int(11) unsigned NOT NULL default 0,
`email` varchar(30) NOT NULL default '',
`mobile` varchar(20) NOT NULL default '',
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
UNIQUE KEY username(`username`),
UNIQUE KEY email(`email`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 推荐位表
CREATE TABLE `o2o_featured`(
`id` int(11) unsigned NOT NULL auto_increment,
`type` tinyint(1) NOT NULL default 0,
`title` VARCHAR(30) NOT NULL default '',
`image` VARCHAR(255) NOT NULL default '',
`url` VARCHAR(255) NOT NULL default '',
`description` VARCHAR(255) NOT NULL default '',
`listorder` int(8) unsigned NOT NULL default 0,
`status` tinyint(1) NOT NULL default 0,
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`)
)ENGINE=InnoDB AUTO_INCREMENT=1 default CHARSET=utf8;
-- 订单表
CREATE TABLE `o2o_order`(
`id` int(11) unsigned NOT NULL auto_increment,
`out_trade_no` VARCHAR(100) NOT NULL DEFAULT '',
`transaction_id` VARCHAR(100) NOT NULL DEFAULT '',
`user_id` int(11) NOT NULL DEFAULT 0,
`username` VARCHAR(50) NOT NULL DEFAULT '',
`pay_time` VARCHAR(20) NOT NULL DEFAULT '',
`payment_id` tinyint(1) NOT NULL DEFAULT 1,
`deal_id` int(11) NOT NULL default 0,
`deal_count` int(11) NOT NULL default 0,
`pay_status` tinyint(1) NOT NULL DEFAULT 0,
`total_price` decimal(20,2) NOT NULL DEFAULT '0.00',
`pay_amount` decimal(20,2) NOT NULL DEFAULT '0.00',
`status` tinyint(1) NOT NULL DEFAULT 1,
`referer` VARCHAR(255) NOT NULL DEFAULT '',
`create_time` int(11) unsigned NOT NULL default 0,
`update_time` int(11) unsigned NOT NULL default 0,
PRIMARY KEY (`id`),
UNIQUE `out_trade_no`(`out_trade_no`),
key user_id(`user_id`),
key create_time(`create_time` )
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
```