CREATE DATABASE `lvju` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
-- 数据库： lvju
CREATE TABLE `lvju`.`plat`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '平台名称',
  `thumb` char(255) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '缩略图',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `orderby` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '入驻平台' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`hotel`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `title` char(20) NOT NULL COMMENT '酒店名称',
  `province` char(10) NOT NULL COMMENT '省',
  `city` int(4) NOT NULL DEFAULT 0 COMMENT '市',
  `addr` char(100) NOT NULL COMMENT '地址',
  `longt` char(20) NOT NULL COMMENT '经度',
  `lat` char(20) NOT NULL COMMENT '纬度',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `title`(`title`) USING BTREE COMMENT '酒店'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '酒店' ROW_FORMAT = COMPRESSED;

-- ALTER TABLE `lvju`.`hotel` 
-- CHANGE COLUMN `title` `title` CHAR(20) NOT NULL COMMENT '酒店名称' ;

CREATE TABLE `lvju`.`room`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `hotel_id` int(11) NOT NULL DEFAULT 0 COMMENT '酒店ID',
  `owner_id` int(11) NOT NULL DEFAULT 0 COMMENT '对应业主ID',
  `f` int(2) NOT NULL DEFAULT 1 COMMENT '室',
  `t` int(2) NOT NULL DEFAULT 0 COMMENT '厅',
  `c` int(2) NOT NULL DEFAULT 0 COMMENT '厨房',
  `w` int(2) NOT NULL DEFAULT 1 COMMENT '卫生间',
  `b` int(2) NOT NULL DEFAULT 1 COMMENT '阳台',
  `measure` int(3) NOT NULL DEFAULT 0 COMMENT '面积(平米)',
  `type` int(2) NOT NULL DEFAULT 1 COMMENT '户型',
  `sn` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '房号',
  `title` char(20) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '房间名', 
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',

  `detail` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '详情',
  `addr` char(100) NOT NULL COMMENT '地址',
  `longt` char(20) NOT NULL COMMENT '经度',
  `lat` char(20) NOT NULL COMMENT '纬度',
  `floor` int(3) NOT NULL DEFAULT 0 COMMENT '楼层',
  `traffic` varchar(1000) NOT NULL DEFAULT '' COMMENT '交通',
  `feature` varchar(1000) NOT NULL DEFAULT '' COMMENT '特色',
  `tag` char(255) NOT NULL DEFAULT '' COMMENT '标签',
  `landscape` varchar(1000) NOT NULL DEFAULT '' COMMENT '景观',
  `thumb` char(100) NOT NULL DEFAULT '' COMMENT '缩略图',
  `album_id` int(11) NOT NULL DEFAULT 0 COMMENT '相册ID',
  `wifi` int(1) NOT NULL DEFAULT 0 COMMENT '有否WIFI',
  `swimmingpool` int(1) NOT NULL DEFAULT 0 COMMENT '有否泳池',
  `parker` int(1) NOT NULL DEFAULT 0 COMMENT '有否停车位',
  `cooking` int(1) NOT NULL DEFAULT 0 COMMENT '可否开火',
  `gas` int(1) NOT NULL DEFAULT 0 COMMENT '有否天然气',
  `signtime` bigint(11) NOT NULL COMMENT '协议签署时间',
  `signmonths` int(11) NOT NULL COMMENT '协议签署时长',
  `deadline` bigint(11) NOT NULL COMMENT '协议到期时间',
  `income` int(11) NOT NULL COMMENT '总收入(分)',
  `expense` int(11) NOT NULL COMMENT '总支出(分)',
  `surplus` int(11) NOT NULL COMMENT '总盈余(分)',

  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `hotel_id`(`hotel_id`) USING BTREE COMMENT '酒店ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '房间' ROW_FORMAT = COMPRESSED;

  -- ALTER TABLE `lvju`.`room`
  -- ADD COLUMN `detail` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '详情' AFTER `remark`,
  -- ADD COLUMN `addr` char(100) NOT NULL COMMENT '地址' AFTER `remark`,
  -- ADD COLUMN `longt` char(20) NOT NULL COMMENT '经度' AFTER `remark`,
  -- ADD COLUMN `lat` char(20) NOT NULL COMMENT '纬度' AFTER `remark`,
  -- ADD COLUMN `floor` int(3) NOT NULL DEFAULT 0 COMMENT '楼层' AFTER `remark`,
  -- ADD COLUMN `traffic` varchar(1000) NOT NULL DEFAULT '' COMMENT '交通' AFTER `remark`,
  -- ADD COLUMN `feature` varchar(1000) NOT NULL DEFAULT '' COMMENT '特色' AFTER `remark`,
  -- ADD COLUMN `tag` char(255) NOT NULL DEFAULT '' COMMENT '标签' AFTER `remark`,
  -- ADD COLUMN `landscape` varchar(1000) NOT NULL DEFAULT '' COMMENT '景观' AFTER `remark`,
  -- ADD COLUMN `thumb` char(100) NOT NULL DEFAULT 0 COMMENT '缩略图' AFTER `remark`,
  -- ADD COLUMN `album_id` int(11) NOT NULL DEFAULT 0 COMMENT '相册ID' AFTER `remark`,
  -- ADD COLUMN `wifi` int(1) NOT NULL DEFAULT 0 COMMENT '有否WIFI' AFTER `remark`,
  -- ADD COLUMN `swimmingpool` int(1) NOT NULL DEFAULT 0 COMMENT '有否泳池' AFTER `remark`,
  -- ADD COLUMN `parker` int(1) NOT NULL DEFAULT 0 COMMENT '有否停车位' AFTER `remark`,
  -- ADD COLUMN `cooking` int(1) NOT NULL DEFAULT 0 COMMENT '可否开火' AFTER `remark`,
  -- ADD COLUMN `gas` int(1) NOT NULL DEFAULT 0 COMMENT '有否天然气' AFTER `remark`,
  -- ADD COLUMN `signtime` bigint(11) NOT NULL COMMENT '协议签署时间' AFTER `remark`,
  -- ADD COLUMN `signmonths` int(11) NOT NULL COMMENT '协议签署时长' AFTER `remark`,
  -- ADD COLUMN `deadline` bigint(11) NOT NULL COMMENT '协议到期时间' AFTER `remark`,
  -- ADD COLUMN `income` int(11) NOT NULL COMMENT '总收入(分)' AFTER `remark`,
  -- ADD COLUMN `expense` int(11) NOT NULL COMMENT '总支出(分)' AFTER `remark`,
  -- ADD COLUMN `surplus` int(11) NOT NULL COMMENT '总盈余(分)' AFTER `remark`;

CREATE TABLE `lvju`.`employee`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `hotel_id` int(11) NOT NULL DEFAULT 0 COMMENT '对应酒店',
  `job_id` int(11) NOT NULL DEFAULT 0 COMMENT '岗位',
  `adminer` char(32) NOT NULL COMMENT '对应管理员',
  `name` char(20) NOT NULL COMMENT '员工姓名',
  `mobile` char(11) NOT NULL COMMENT '手机号',
  `status` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否在职',
  `gender` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '性别1男2女',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `name`(`name`) USING BTREE COMMENT '姓名'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '门店员工' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`customer`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `mid` int(11) NOT NULL COMMENT '关联会员ID',
  `hotel_id` int(11) NOT NULL DEFAULT 0 COMMENT '来源酒店ID',
  `employee_id` int(11) NOT NULL DEFAULT 0 COMMENT '来源员工ID',
  `name` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '姓名',
  `mobile` char(15) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '手机',
  `gender` tinyint(1) NOT NULL DEFAULT 0 COMMENT '性别1男2女',
  `idcard` char(18) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '身份证号',
  `passport` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '护照号',
  `country` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '中国' COMMENT '国籍',
  `last_checkin` int(11) NOT NULL DEFAULT 0 COMMENT '上次入住时间',
  `last_contact` int(11) NOT NULL DEFAULT 0 COMMENT '上次业务联系时间',
  `total_fee` int(11) NOT NULL DEFAULT 0 COMMENT '总消费额(分)',
  `money` int(11) NOT NULL DEFAULT 0 COMMENT '余额(分)',
  `jifen` int(11) NOT NULL DEFAULT 0 COMMENT '积分',
  `score` int(11) NOT NULL DEFAULT 0 COMMENT '评分',
  `province` char(10) NOT NULL COMMENT '常在省份',
  `channel` char(10) NOT NULL COMMENT '来源渠道',
  `thumb` char(80) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '用户头像',
  `birth_y` int(4) NOT NULL DEFAULT 0 COMMENT '出生年',
  `birth_m` int(2) NOT NULL DEFAULT 0 COMMENT '出生月',
  `birth_d` int(2) NOT NULL DEFAULT 0 COMMENT '出生日',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '住客' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`roomowner`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `name` char(20) NOT NULL COMMENT '姓名',
  `mobile` char(11) NOT NULL COMMENT '手机号',
  `status` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否在职',
  `gender` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '性别1男2女',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `name`(`name`) USING BTREE COMMENT '姓名'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '房间业主' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`user_ext`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `mid` int(11) NOT NULL COMMENT '关联用户ID',
  `mobile` varchar(11) NOT NULL  COMMENT '关联用户手机',
  `key` varchar(50) NOT NULL COMMENT '键名',
  `value` varchar(255) COMMENT '键值',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户扩展资料' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`contract`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `owner_id` int(11) NOT NULL DEFAULT 0 COMMENT '对应业主',
  `title` char(100) NOT NULL COMMENT '标题',
  `file` char(100) NOT NULL COMMENT '文件链接',
  `status` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否生效',
  `content` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '协议内容',
  `remark` varchar(500) COMMENT '备注',
  `sn` char(64) NOT NULL COMMENT '协议编号',
  `start` bigint(11) NOT NULL COMMENT '协议生效时间',
  `end` bigint(11) NOT NULL COMMENT '协议解除时间',
  `sgintime` bigint(11) NOT NULL COMMENT '协议签署时间',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `title`(`title`) USING BTREE COMMENT '标题'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '合约文档' ROW_FORMAT = COMPRESSED;

/*_______________*/
CREATE TABLE `lvju`.`truck`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `driver_id` int(11) NOT NULL COMMENT '司机ID',
  `driver2_id` int(11) NOT NULL COMMENT '副驾司机ID',
  `gps_id` int(11) NOT NULL COMMENT 'GPS定位器ID',
  `num_p` char(4) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '车牌_省',
  `num_area` char(2) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '车牌_区域标识字母',
  `num_left` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '车牌_剩余部分',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `num_left`(`num_left`) USING BTREE COMMENT '车牌尾号'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运载板车' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`gps`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `supplier_id` int(11) NOT NULL DEFAULT 0 COMMENT '供应商ID',
  `supplier_name` char(100) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '供应商',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '板车GPS' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`gps_route`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `longt` char(20) NOT NULL COMMENT '经度',
  `lat` char(20) NOT NULL COMMENT '纬度',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'GPS轨迹' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`driver`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `name` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '姓名',
  `mobile` char(15) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '手机', 
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `mobile`(`mobile`) USING BTREE COMMENT '手机'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '板车司机' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`store_incar`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `store_id` int(11) NOT NULL COMMENT '门店ID',
  `car_id` int(11) NOT NULL COMMENT '对应车辆ID',
  `order_id` int(11) NOT NULL COMMENT '对应合同单ID',
  `truck_id` int(11) NOT NULL COMMENT '对应板车ID',
  `fee_in` decimal(11, 2) COMMENT '运抵后关联收费',
  `fee_out` decimal(11, 2) COMMENT '运抵后关联支出',
  `payids` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '关联付款记录',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `store_id`(`store_id`) USING BTREE COMMENT '门店',
  INDEX `truck_id`(`truck_id`) USING BTREE COMMENT '板车ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运抵门店车辆记录' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`order_pre`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `store_id` int(11) NOT NULL COMMENT '门店ID',
  `from_mid` int(11) NOT NULL COMMENT '来源会员ID',
  `from_mobile` char(11) NOT NULL COMMENT '客资电话',
  `from_name` char(20) COMMENT '客资姓名',
  `from_gender` tinyint(1) NOT NULL COMMENT '客资性别',
  `price` char(255) COMMENT '报价',
  `car` varchar(1000) COMMENT '车况记录',
  `start_province` char(20) COMMENT '始发省',
  `start_city` char(20) COMMENT '始发城市',
  `start_date` char(100) COMMENT '发车时间需求',
  `aim_province` char(20) COMMENT '目标省',
  `aim_city` char(20) COMMENT '目标城市',
  `receptionist` char(20) COMMENT '接待员',
  `bind` char(20) COMMENT '介绍人',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `store_id`(`store_id`) USING BTREE COMMENT '门店',
  INDEX `from_mobile`(`from_mobile`) USING BTREE COMMENT '客资电话'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '客资询车记录' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`order`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `pre_id` int(11) NOT NULL COMMENT '客资记录ID',
  `car_id` int(11) NOT NULL COMMENT '车辆ID',
  `store_id` int(11) NOT NULL COMMENT '门店ID',
  `from_mid` int(11) NOT NULL COMMENT '来源会员ID',
  `from_bid` int(11) NOT NULL COMMENT '来源企业ID',

  `start_province` char(20) COMMENT '始发省',
  `start_city` char(20) COMMENT '始发城市',
  `aim_province` char(20) COMMENT '目标省',
  `aim_city` char(20) COMMENT '目标城市',

  `sign_date` char(100) COMMENT '签约日期',
  `signer` char(20) COMMENT '签约人',

  `sender_name` char(20) COMMENT '发车人',
  `sender_idcard` char(18) COMMENT '发车人身份证',
  `sender_mobiles` char(50) COMMENT '发车人手机号',

  `receiver_name` char(20) COMMENT '接车人',
  `receiver_idcard` char(18) COMMENT '接车人身份证',
  `receiver_mobiles` char(50) COMMENT '接车人手机号',

  `aim_address` char(255) COMMENT '送车地址',

  `car_value` int(11) COMMENT '车辆价值',

  `fee_insurance` int(11) COMMENT '保险费',
  `fee_truck` int(11) COMMENT '运费',
  `fee_deliver` int(11) COMMENT '送车费',
  `fee_pickup` int(11) COMMENT '提车费',
  `fee_urgent` int(11) COMMENT '加急费',
  `fee_extra` int(11) COMMENT '其他额外费用',
  `fee_total` int(11) COMMENT '总费用',

  `pay_send` int(11) COMMENT '发车时付费',
  `pay_send_pids` varchar(255) COMMENT '发车时付费记录',
  `pay_receive` int(11) COMMENT '接车时付费',
  `pay_receive_pids` varchar(255) COMMENT '接车时付费记录',

  `thumb_f` char(255) COMMENT '车前面照',
  `thumb_b` char(255) COMMENT '车尾面照',
  `thumb_l` char(255) COMMENT '车左面照',
  `thumb_r` char(255) COMMENT '车右面照',
  `thumbs` varchar(1000) COMMENT '更多验车照片',
  `videos` varchar(1000) COMMENT '验车视频', 

  `is_checked` tinyint(1) NOT NULL DEFAULT 0 COMMENT '验车状态',
  `is_holdon` tinyint(1) NOT NULL DEFAULT 0 COMMENT '挂起(异常)状态',
  `is_over` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否完结状态',
  `is_commission` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否结佣',
  
  `start_km` int(11) COMMENT '发车时公里数',
  `car_extra` varchar(1000) COMMENT '随车物品备注',

  `bind` char(20) COMMENT '介绍人',
  `commission` int(11)  DEFAULT 0 COMMENT '介绍佣金',
  `commission_left` int(11)  DEFAULT 0 COMMENT '未结佣金',

  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `store_id`(`store_id`) USING BTREE COMMENT '门店'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '托运合同单' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`truck_online`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `truck_id` int(11) NOT NULL COMMENT '大车ID',
  `cars` int(11) NOT NULL COMMENT '载车数量',
  `from_store` int(11) NOT NULL COMMENT '始发门店ID',
  `from_date` int(11) NOT NULL COMMENT '始发日期',
  `driver_name` char(20) COMMENT '司机姓名',
  `driver_mobiles` char(50) COMMENT '司机电话',
  `driver_idcard` char(18) COMMENT '司机身份证号',
  `truck_num` char(50) COMMENT '板车车牌号',
  `end_date` int(11)  COMMENT '抵达日期',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `from_store`(`from_store`) USING BTREE COMMENT '门店',
  INDEX `truck_id`(`truck_id`) USING BTREE COMMENT '板车'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '板车发车记录' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`truck_cars`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `online_id` int(11) NOT NULL COMMENT '板车发车记录ID',
  `order_id` int(11) NOT NULL COMMENT '托运合同单ID',
  `to_time` int(11)  COMMENT '车辆交付时间',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `online_id`(`online_id`) USING BTREE COMMENT '板车发车单'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '板车发车清单' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`order_status`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `online_id` int(11) NOT NULL COMMENT '板车发车记录ID',
  `order_id` int(11) NOT NULL COMMENT '托运合同单ID',
  `longt` char(20) COMMENT '经度',
  `lat` char(20) COMMENT '纬度',
  `province` char(20) COMMENT '省',
  `city` char(20) COMMENT '市',
  `date_start` int(11)  COMMENT '车辆起运时间',
  `date_end` int(11)  COMMENT '车辆运抵时间',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `order_id`(`order_id`) USING BTREE COMMENT '托运合同单'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '车在途状态' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`truck_route`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `truck_id` int(11) NOT NULL COMMENT '板车ID',
  `online_id` int(11) NOT NULL COMMENT '板车运单ID',
  `province` char(20) COMMENT '省',
  `city` char(20) COMMENT '市',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `online_id`(`online_id`) USING BTREE COMMENT '板车运单'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '外援板轨迹' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`fee_order`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `order_id` int(11) NOT NULL COMMENT '托运合同单ID',
  `paytype` int(4) NOT NULL COMMENT '支付方式',
  `fee` int(11) NOT NULL COMMENT '支付金额',
  `sn` char(50) COMMENT '支付流水号',
  `pay_from` char(20) COMMENT '支付人',
  `pay_to` char(20) COMMENT '收款人',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `order_id`(`order_id`) USING BTREE COMMENT '合同单'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '运单费用记录' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`fee_driver`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `online_id` int(11) NOT NULL COMMENT '板车运单ID',
  `paytype` int(4) NOT NULL COMMENT '支付方式',
  `fee` int(11) NOT NULL COMMENT '支付金额',
  `sn` char(50) COMMENT '支付流水号',
  `pay_from` char(20) COMMENT '支付人',
  `pay_to` char(20) COMMENT '收款人',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `online_id`(`online_id`) USING BTREE COMMENT '板车发车单'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '板车司机支取费用记录' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`stat`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `new_order` int(11) NOT NULL DEFAULT 0 COMMENT '新签合同',
  `total_order` int(11) NOT NULL DEFAULT 0 COMMENT '合同总数',
  `new_car` int(11) NOT NULL DEFAULT 0 COMMENT '新增客车',
  `total_car` int(11) NOT NULL DEFAULT 0 COMMENT '客车总量',
  `new_carowner` int(11) NOT NULL DEFAULT 0 COMMENT '新增业主',
  `total_carowner` int(11) NOT NULL DEFAULT 0 COMMENT '业主总数',
  `newfee_totruck` int(11) NOT NULL DEFAULT 0 COMMENT '新垫付出车款',
  `totalfee_totruck` int(11) NOT NULL DEFAULT 0 COMMENT '总垫付出车款',
  `newfee_order` int(11) NOT NULL DEFAULT 0 COMMENT '新产生合同款',
  `totalfee_order` int(11) NOT NULL DEFAULT 0 COMMENT '总产生合同款',
  `infee_order` int(11) NOT NULL DEFAULT 0 COMMENT '新收合同款',
  `totalinfee_order` int(11) NOT NULL DEFAULT 0 COMMENT '总收合同款',
  `fee_nopay` int(11) NOT NULL DEFAULT 0 COMMENT '待收合同款',
  `y` int(11) NOT NULL COMMENT '数据归属年',
  `m` int(4) NOT NULL COMMENT '数据归属月',
  `d` int(4) NOT NULL COMMENT '数据归属日',
  `w` int(4) NOT NULL COMMENT '周几',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `m`(`m`) USING BTREE COMMENT '月度统计'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '简要统计记录' ROW_FORMAT = COMPRESSED;

CREATE TABLE `lvju`.`store`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `title` char(10) NOT NULL COMMENT '门店名称',
  `province` char(20) NOT NULL COMMENT '省',
  `city` int(4) NOT NULL DEFAULT 0 COMMENT '市',
  `addr` char(100) NOT NULL COMMENT '地址',
  `longt` char(20) NOT NULL COMMENT '经度',
  `lat` char(20) NOT NULL COMMENT '纬度',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `status_code` int(4) NOT NULL  DEFAULT 0 COMMENT '状态代码',
  `deleted` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否删除',
  PRIMARY KEY (`id`),
  INDEX `pid`(`pid`) USING BTREE COMMENT '平台ID',
  INDEX `title`(`title`) USING BTREE COMMENT '门店'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '门店' ROW_FORMAT = COMPRESSED;