# ************************************************************
# Sequel Pro SQL dump
# Version 4541
#
# http://www.sequelpro.com/
# https://github.com/sequelpro/sequelpro
#
# Host: 127.0.0.1 (MySQL 5.5.5-10.0.17-MariaDB-log)
# Database: wuliu
# Generation Time: 2016-07-29 00:54:19 +0000
# ************************************************************


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;


# Dump of table truck
# ------------------------------------------------------------
DROP TABLE IF EXISTS `truck`;

CREATE TABLE `truck` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,             /*车辆ID*/
  `name` varchar(128) COLLATE utf8_unicode_ci NOT NULL,      /*名称*/
  `type` int(4) NOT NULL,                                    /*类型－大/中/小/或货柜/拖挂等*/
  `owner_id` int(10) NOT NULL,                               /*拥有着ID*/
  `truck_no` varchar(20) COLLATE utf8_unicode_ci NOT NULL,   /*车牌号*/
  `length` float(8) NOT NULL,                                /*车长*/
  `width` float(8) NOT NULL,                                 /*车宽*/
  `height` float(8) NOT NULL,                                /*车高*/
  `truck_weight` float(8) NOT NULL,                          /*车辆自重*/
  `load_weight` float(8) NOT NULL,                           /*车辆载重*/
  `capacity` float(8) NOT NULL,                              /*容量*/
  `begin_use_date` date NOT NULL,                            /*开始使用日期*/
  `expire_date` date NOT NULL,                               /*报废日期*/
  PRIMARY KEY (`id`),
  KEY `truck_type_index` (`type`),
  KEY `truck_owner_id_index` (`owner_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


# Dump of table user
# ------------------------------------------------------------
DROP TABLE IF EXISTS `user`;

CREATE TABLE `user` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,                   /*用户ID*/
  `idcard_type` int(4) unsigned NOT NULL,                          /*证件类型*/
  `idcard_no` varchar(30) COLLATE utf8_unicode_ci NOT NULL,        /*证件号码*/
  `type` int(4) unsigned NOT NULL,                                 /*类型－托运方/承运方*/
  `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,             /*姓名*/
  `nick_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,        /*昵称*/
  `sex` varchar(4) COLLATE utf8_unicode_ci NOT NULL,               /*性别*/
  `age` int(4) unsigned NOT NULL,                                  /*年龄*/
  `phone` varchar(20) COLLATE utf8_unicode_ci NOT NULL,            /*联系电话*/
  `emergnency_phone` varchar(20) COLLATE utf8_unicode_ci NOT NULL, /*紧急联系电话*/
  `password` varchar(30) COLLATE utf8_unicode_ci NOT NULL,         /*密码*/
  `company` varchar(255) COLLATE utf8_unicode_ci NOT NULL,         /*企业名称*/
  `city` varchar(255) COLLATE utf8_unicode_ci NOT NULL,            /*城市*/
  `address` varchar(255) COLLATE utf8_unicode_ci NOT NULL,         /*地址*/
  `money_balance` float(8) NOT NULL,                               /*余额*/
  PRIMARY KEY (`id`),
  KEY `member_type_index` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

DROP TABLE IF EXISTS `message`;

CREATE TABLE `message` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,                   /*消息ID*/
  `user_id` int(10) unsigned NOT NULL,                             /*发布者ID*/
  `type` int(4) unsigned NOT NULL,                                 /*订单类型－托运/承运*/
  `detail` varchar(512) COLLATE utf8_unicode_ci NOT NULL,          /*详情*/
  `price` float(8) NOT NULL,                                       /*价格*/
  `begin_address` varchar(255) COLLATE utf8_unicode_ci NOT NULL,   /*出发地址*/
  `end_address` varchar(255) COLLATE utf8_unicode_ci NOT NULL,     /*抵达地址*/
  `midway_address` varchar(512) COLLATE utf8_unicode_ci NOT NULL,  /*途径地址*/
  `truck_id` int(10) unsigned NOT NULL,                            /*车辆ID*/
  `contact_name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,     /*随车联系人姓名*/
  `contact_phone` varchar(20) COLLATE utf8_unicode_ci NOT NULL,    /*随车联系人电话*/
  `goods_arrive_time` timestamp NULL DEFAULT NULL,                 /*货物送达时间*/
  `state` int(4) unsigned NOT NULL,                                /*订单状态*/
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

# Dump of table order
# ------------------------------------------------------------
DROP TABLE IF EXISTS `order`;

CREATE TABLE `order` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,                   /*订单ID*/
  `message_id` int(10) unsigned NOT NULL,                          /*信息ID*/
  `trade_user_id` int(10) unsigned NOT NULL,                       /*交易方ID*/
  `created_time` timestamp NULL DEFAULT NULL,                      /*订单发布时间*/
  `deal_confirm_time` timestamp NULL DEFAULT NULL,                 /*订单成交时间*/
  `goods_arrive_time` timestamp NULL DEFAULT NULL,                 /*货物送达时间*/
  `state` int(4) unsigned NOT NULL,                                /*订单状态*/
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


# Dump of table recharge_record－充值流水
# ------------------------------------------------------------
DROP TABLE IF EXISTS `recharge_record`;

CREATE TABLE `recharge_record` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,                   /*流水ID*/
  `user_id` int(10) unsigned NOT NULL,                             /*充值者ID*/
  `type` int(4) unsigned NOT NULL,                                 /*充值平台类型*/
  `amount` float(8) NOT NULL,                                      /*金额*/
  `created_time` timestamp NULL DEFAULT NULL,                      /*充值时间*/
  `state` int(4) unsigned NOT NULL,                                /*流水状态*/
  PRIMARY KEY (`id`),
  KEY `order_user_id_index` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
