/*
* @Author: fm453
* @Date:   2021-09-11 08:43:17
 * @Last modified by:   fm453
 * @Last modified time: 2022-10-19T10:45:43+08:00
*/

-- 数据库： ancheng
CREATE TABLE `ac_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 '缩略图',
  `cw_phone` char(11) 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;

-- ALTER TABLE `ac_plat`
-- ADD COLUMN `cw_phone` char(11) CHARACTER SET utf8 COMMENT '财务手机号';

CREATE TABLE `ac_car`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `mid` int(11) NOT NULL COMMENT '关联会员ID',
  `owner_id` int(11) NOT NULL COMMENT '对应车主ID',
  `car_no` char(50) NOT NULL COMMENT '车牌号外显',
  `num_frame` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '车架号',
  `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 '备注',
  `brand_id` int(11) NOT NULL  DEFAULT 0 COMMENT '品牌ID',
  `series_id` int(11) NOT NULL  DEFAULT 0 COMMENT '车型ID',
  `title` char(50) 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_p`(`num_p`) USING BTREE COMMENT '省份',
  INDEX `num_left`(`num_left`) USING BTREE COMMENT '车牌尾号',
  INDEX `owner_id`(`owner_id`) USING BTREE COMMENT '车主ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '客户车辆记录' ROW_FORMAT = COMPRESSED;

-- ALTER TABLE `ac_car`
-- ADD COLUMN `brand_id` int(11) NOT NULL  DEFAULT 0 COMMENT '品牌ID',
-- ADD COLUMN `series_id` int(11) NOT NULL  DEFAULT 0 COMMENT '车型ID',
-- ADD COLUMN `title` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '车型名称';
-- ALTER TABLE `ac_car` 
-- ADD COLUMN `car_no` char(50) NOT NULL COMMENT '车牌号外显' AFTER `owner_id`;

CREATE TABLE `ac_car_brand`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `title` char(50) 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 `ac_car_series`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `brand_id` int(11) NOT NULL COMMENT '品牌ID',
  `title` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '名称',
  `params` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '参数JSON化',
  `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 `brand_id`(`brand_id`) USING BTREE COMMENT '品牌ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '车型系列' ROW_FORMAT = COMPRESSED;

CREATE TABLE `ac_car_owner`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `mid` int(11) NOT NULL COMMENT '关联会员ID',
  `nickname` varchar(32) CHARACTER SET utf8 COMMENT '车主姓名',
  `level` int(11) NOT NULL COMMENT '网点评级',
  `score` int(11) NOT NULL COMMENT '点评分数',
  `gender` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '性别1男2女',
  `last_send` int(11) NOT NULL COMMENT '上次发车时间',
  `last_contact` int(11) NOT NULL COMMENT '上次业务联系时间',
  `total_fee` int(11) NOT NULL COMMENT '总消费额',
  `store_id` int(11) NOT NULL COMMENT '来源门店ID',
  `employee_id` int(11) NOT NULL COMMENT '来源员工ID',
  `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;

ALTER TABLE `ac_car_owner`
ADD COLUMN `nickname` varchar(32) CHARACTER SET utf8 COMMENT '车主姓名' AFTER `mid`;

/*
type  板车类型；0自有板车；1外援板；
 */
CREATE TABLE `ac_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 '数据创建时间',
  `max_cars` int(2) NOT NULL  DEFAULT 8 COMMENT '最大载量',  /*8位板就是8*/
  `type` int(2) DEFAULT 0 COMMENT '板车类型',
  `order_by` int(11) NOT NULL  DEFAULT 0 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;

-- ALTER TABLE `ac_truck`
-- ADD COLUMN `max_cars` int(2) NOT NULL  DEFAULT 8 COMMENT '最大载量';
-- ALTER TABLE `ac_truck`
-- ADD COLUMN `type` int(2) DEFAULT 0 COMMENT '板车类型';
-- ALTER TABLE `ac_truck`
-- ADD COLUMN `order_by` int(11) NOT NULL  DEFAULT 0 COMMENT '排序';

CREATE TABLE `ac_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 `ac_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 `ac_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 '手机',
  `idcard` char(18) COMMENT '身份证号',
  `update_at` bigint(11) NOT NULL COMMENT '数据更新时间',
  `create_at` bigint(11) NOT NULL COMMENT '数据创建时间',
  `order_by` int(11) NOT NULL  DEFAULT 0 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;

-- ALTER TABLE `ac_driver`
-- ADD COLUMN `idcard` char(18) COMMENT '身份证号';
-- ALTER TABLE `ac_driver`
-- ADD COLUMN `order_by` int(11) NOT NULL  DEFAULT 0 COMMENT '排序';

CREATE TABLE `ac_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 '数据创建时间',
  `order_by` int(11) NOT NULL  DEFAULT 0 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 `ac_store`
-- ADD COLUMN `nav` char(150) COMMENT '地图导航说明' AFTER `addr`;
-- ALTER TABLE `ac_store`
-- ADD COLUMN `order_by` int(11) NOT NULL  DEFAULT 0 COMMENT '排序';

CREATE TABLE `ac_employee`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `store_id` int(11) NOT NULL 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 '数据创建时间',
  `order_by` int(11) NOT NULL  DEFAULT 0 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;
-- ALTER TABLE `ac_employee`
-- ADD COLUMN `order_by` int(11) NOT NULL  DEFAULT 0 COMMENT '排序';

CREATE TABLE `ac_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 `ac_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 `ac_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` bigint(11) NOT NULL COMMENT '签约日期',
  `signer` char(20) COMMENT '委托人',
  `weituo` int(11) NOT NULL COMMENT '委托人ID',
  `wtdw` 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 '总费用',
  `income` int(11) COMMENT '实际所得(分)',
  `expense` 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` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '更多验车照片',
  `videos` varchar(1000) COMMENT '验车视频',

  `checker` char(20) 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 '是否结佣',
  `not_insurance` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '不买保险',
  `is_cwqr` tinyint(1) NOT NULL DEFAULT 0 COMMENT '财务是否确认',
  `is_turnover` 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 '未结佣金',

  `employee_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联员工',
  `create_by` int(11) UNSIGNED 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',
  INDEX `store_id`(`store_id`) USING BTREE COMMENT '门店'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '托运合同单' ROW_FORMAT = COMPRESSED;

-- ALTER TABLE `ac_order`
-- ADD COLUMN `employee_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联员工' AFTER `deleted`,
-- ADD COLUMN `create_by` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人员' AFTER `employee_id`;
-- ALTER TABLE `ac_order`
-- ADD COLUMN `not_insurance` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '不买保险' AFTER `create_by`;
-- ALTER TABLE `ac_order`
-- ADD COLUMN `income` int(11) DEFAULT 0 COMMENT '实际所得';
-- ALTER TABLE `ac_order`
-- ADD COLUMN `expense` int(11) DEFAULT 0 COMMENT '总成本';
-- ALTER TABLE `ac_order`
-- ADD COLUMN `no_driving_lisence` tinyint(1) NOT NULL DEFAULT 0 COMMENT '行驶证不随车',
-- ADD COLUMN `driving_lisence` char(255) COMMENT '行驶证照';
-- ALTER TABLE `ac_order`
-- ADD COLUMN `is_cwqr` tinyint(1) NOT NULL DEFAULT 0 COMMENT '财务是否确认';
-- ALTER TABLE `ac_order`
-- ADD COLUMN `bind_id` int(11) DEFAULT 0 COMMENT '介绍人ID';
-- ALTER TABLE `ac_order`
-- ADD COLUMN `weituo` int(11) NOT NULL COMMENT '委托人ID',
-- ADD COLUMN `wtdw` char(20) COMMENT '委托单位';
-- ALTER TABLE `ac_order`
-- ADD COLUMN `is_turnover` tinyint(1) NOT NULL DEFAULT 0 COMMENT '交车补单';
-- ALTER TABLE `ac_order`
-- ADD COLUMN`checker` char(20) COMMENT '验车人';

CREATE TABLE `ac_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 '始发日期',
  `from_city` char(20) 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 '抵达日期',
  `end_store` int(11) NOT NULL COMMENT '目的地网点ID',
  `end_city` char(20) NOT NULL 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;
-- ALTER TABLE `ac_truck_online`
-- ADD COLUMN `end_store` int(11) NOT NULL COMMENT '目的地网点ID',
-- ADD COLUMN `end_city` char(20) NOT NULL COMMENT '目的城市';
-- ALTER TABLE `ac_truck_online`
-- ADD COLUMN `from_city` char(20) NOT NULL COMMENT '起运城市';

CREATE TABLE `ac_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',
  `car_id` int(11) NOT NULL COMMENT '客车ID',
  `from_time` int(11)  COMMENT '车辆起运时间',
  `from_store` int(11) NOT NULL COMMENT '起运网点ID',
  `from_city` char(20) NOT NULL COMMENT '起运城市',
  `to_time` int(11)  COMMENT '车辆交付时间',
  `to_store` int(11) NOT NULL COMMENT '交付网点ID',
  `to_city` char(20) NOT NULL 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;
-- ALTER TABLE `ac_truck_cars`
-- ADD COLUMN `car_id` int(11) NOT NULL COMMENT '客车ID';
-- ALTER TABLE `ac_truck_cars`
-- ADD COLUMN `to_store` int(11) NOT NULL COMMENT '交付网点ID',
-- ADD COLUMN `to_city` char(20) NOT NULL COMMENT '交付城市';
-- ALTER TABLE `ac_truck_cars`
-- ADD COLUMN `from_time` int(11)  COMMENT '车辆起运时间',
-- ADD COLUMN `from_store` int(11) NOT NULL COMMENT '起运网点ID',
-- ADD COLUMN `from_city` char(20) NOT NULL COMMENT '起运城市';

CREATE TABLE `ac_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 `ac_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 '市',
  `addr` char(255) COMMENT '详址',
  `longt` char(20) NOT NULL COMMENT '经度',
  `lat` char(20) NOT NULL COMMENT '纬度',
  `orderby` int(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`),
  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;
-- ALTER TABLE `ac_truck_route`
-- ADD COLUMN `addr` char(255) COMMENT '详址' AFTER `deleted`,
-- ADD COLUMN `longt` char(20) COMMENT '经度' AFTER `addr`,
-- ADD COLUMN `lat` char(20) COMMENT '纬度' AFTER `longt`,
-- COMMENT = '板车轨迹';
-- ALTER TABLE `ac_truck_route`
-- ADD COLUMN `orderby` int(4) COMMENT '排序' AFTER `lat`;

CREATE TABLE `ac_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 '收款人',
  `logs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `thumbs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '凭证截图',
  `cwlogs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '财务操作日志',
  `pay_at` bigint(11) NOT NULL COMMENT '支付时间',
  `create_by` int(11) COMMENT '创建者工号',
  `chonghong_id` int(11) NOT NULL COMMENT '冲红单ID',
  `is_chonghong` tinyint(1) 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`),
  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;
-- ALTER TABLE `ac_fee_order`
-- ADD COLUMN `pay_at` bigint(11) NOT NULL COMMENT '支付时间';
-- ALTER TABLE `ac_fee_order`
-- ADD COLUMN `create_by` int(11) COMMENT '创建者工号';
-- ALTER TABLE `ac_fee_order`
-- ADD COLUMN `cwlogs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '财务操作日志';
-- ALTER TABLE `ac_fee_order`
-- ADD COLUMN `chonghong_id` int(11) NOT NULL COMMENT '冲红单ID';
-- ALTER TABLE `ac_fee_order`
-- ADD COLUMN `is_chonghong` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否冲红';
-- ALTER TABLE `ac_fee_order`
-- ADD COLUMN `thumbs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '凭证截图';

CREATE TABLE `ac_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 '收款人',
  `logs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `thumbs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '凭证截图',
  `cwlogs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '财务操作日志',
  `pay_at` bigint(11) NOT NULL COMMENT '支付时间',
  `create_by` int(11) COMMENT '创建者工号',
  `chonghong_id` int(11) NOT NULL COMMENT '冲红单ID',
  `is_chongchong` tinyint(1) 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`),
  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;
-- ALTER TABLE `ac_fee_driver`
-- ADD COLUMN `pay_at` bigint(11) NOT NULL COMMENT '支付时间';
-- ALTER TABLE `ac_fee_driver`
-- ADD COLUMN `create_by` int(11) COMMENT '创建者工号';
-- ALTER TABLE `ac_fee_driver`
-- ADD COLUMN `cwlogs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '财务操作日志';
-- ALTER TABLE `ac_fee_driver`
-- ADD COLUMN `chonghong_id` int(11) NOT NULL COMMENT '冲红单ID';
-- ALTER TABLE `ac_fee_driver`
-- ADD COLUMN `is_chonghong` tinyint(1) NOT NULL  DEFAULT 0 COMMENT '是否冲红';
-- ALTER TABLE `ac_fee_driver`
-- ADD COLUMN `thumbs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '凭证截图';

CREATE TABLE `ac_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 `ac_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;

/*2020-08-23*/
CREATE TABLE `ac_contact`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `company` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '单位',
  `name` char(10) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '姓名',
  `mobile` char(15) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '手机',
  `idcard` char(18) 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;

/*2020-08-25*/
CREATE TABLE `ac_weituoren`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `company` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '单位名称',
  `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;
-- ALTER TABLE `ac_weituoren`
-- ADD COLUMN `orderby` int(4) COMMENT '排序' AFTER `mobile`;
-- 
/*2020-08-01*/
CREATE TABLE `ac_albums`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `mid` int(11) NOT NULL COMMENT '关联会员ID',
  `uid` int(11) NOT NULL COMMENT '关联管理员ID',
  `car_num` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '车架号/车牌',
  `car_title` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '车型名称',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `mem_name` char(50) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '关联客户名称',
  `phone1_1` char(11) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '关联手机号(发车人)',
  `phone1_2` char(11) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '关联手机号(发车人)',
  `phone2_1` char(11) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '关联手机号(收车人)',
  `phone2_2` char(11) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '关联手机号(收车人)',
  `total_num` bigint(11) NOT NULL COMMENT '照片数量',
  `total_size` bigint(11) NOT NULL COMMENT '占用空间大小(byte)',
  `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 `car_num`(`car_num`) USING BTREE COMMENT '车牌/车架号'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '车辆验视照图库' ROW_FORMAT = COMPRESSED;

-- ALTER TABLE `ctms`.`ac_albums` 
-- ADD COLUMN `order_sn` varchar(32) NULL COMMENT '运单SN' AFTER `deleted`;
/*
v0 商品车验车
v1 首发网点验车
v2 中转网点验车
v99 到达网点验车
*/
CREATE TABLE `ac_album_version`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `mid` int(11) NOT NULL COMMENT '关联会员ID',
  `uid` int(11) NOT NULL COMMENT '关联管理员ID',
  `album_id` int(11) NOT NULL COMMENT '关联相册ID',
  `remark` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '备注',
  `uphone` char(11) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '关联手机号(拍验人)',
  `version` int(4) NOT NULL DEFAULT 1 COMMENT '版本/批次0,1,2,99',
  `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 `version`(`version`) USING BTREE COMMENT '版本号'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '车辆验视照相册版本' ROW_FORMAT = COMPRESSED;

/*
t0 外观
t1 内饰物品
t2 钥匙
t3 合同单
t4 验车单
t5 其他
*/
CREATE TABLE `ac_album_pics`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `mid` int(11) NOT NULL COMMENT '关联会员ID',
  `uid` int(11) NOT NULL COMMENT '关联管理员ID',
  `album_id` int(11) NOT NULL COMMENT '关联相册ID',
  `vid` int(11) NOT NULL COMMENT '关联相册版本号ID',
  `type` tinyint(2) NOT NULL COMMENT '图片类型',
  `link` char(255) 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 `album_id`(`album_id`) USING BTREE COMMENT '相册ID'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '车辆验视照' ROW_FORMAT = COMPRESSED;

/*2021-09-11*/
CREATE TABLE `ac_fans_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;

/*2022-05-10*/
CREATE TABLE `ac_order_deliver`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `order_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` bigint(11) NOT NULL COMMENT '交车日期',
  `signer` char(20) COMMENT '委托人',
  `weituo` int(11) NOT NULL COMMENT '委托人ID',
  `wtdw` 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 '总费用',
  `fee_minus` int(11) COMMENT '质损',
  `income` int(11) COMMENT '实际所得(分)',
  `expense` 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_pay` char(255) COMMENT '收款图',
  `thumb_paper` char(255) COMMENT '交车单证',
  `thumbs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '更多交车照片',
  `videos` varchar(1000) 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 '是否结佣',
  `not_insurance` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '不买保险',
  `is_cwqr` tinyint(1) NOT NULL DEFAULT 0 COMMENT '财务是否确认',

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

  `employee_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联员工',
  `create_by` int(11) UNSIGNED 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',
  INDEX `store_id`(`store_id`) USING BTREE COMMENT '门店'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '交车单' ROW_FORMAT = COMPRESSED;

CREATE TABLE `ac_order_pickup`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) NOT NULL COMMENT '平台ID',
  `order_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 '始发城市',
  `start_address` char(255) COMMENT '提车地址',
  `aim_province` char(20) COMMENT '目标省',
  `aim_city` char(20) COMMENT '目标城市',
  `aim_address` char(255) COMMENT '送车地址',

  `do_date` bigint(11) NOT NULL COMMENT '提车日期',
  `doer` char(20) COMMENT '提车人',
  `doer_idcard` char(16) COMMENT '提车人身份证号',
  `doer_phone` char(11) COMMENT '提车人手机号',
  `doer_remark` char(500) COMMENT '提车人备注',

  `sender_name` char(20) COMMENT '对接人',
  `sender_mobiles` char(20) COMMENT '对接人手机号',

  `fee_pickup` int(11) COMMENT '提车费',
  `fee_extra` int(11) COMMENT '其他额外费用',

  `pay_send` int(11) COMMENT '提车时付费',

  `thumb_pay` char(255) COMMENT '收款图',
  `thumbs` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '更多照片',
  `videos` varchar(1000) 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 '是否结佣',
  `is_cwqr` tinyint(1) NOT NULL DEFAULT 0 COMMENT '财务是否确认',

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

  `employee_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联员工',
  `create_by` int(11) UNSIGNED 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',
  INDEX `store_id`(`store_id`) USING BTREE COMMENT '门店'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '提车单' ROW_FORMAT = COMPRESSED;

CREATE TABLE `ac_order_rescue`  (
  `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 '始发城市',
  `start_address` char(255) COMMENT '始发地址',
  `aim_province` char(20) COMMENT '目标省',
  `aim_city` char(20) COMMENT '目标城市',
  `aim_address` char(255) COMMENT '目标地址',
  `start_time` bigint(11) NOT NULL COMMENT '启运时间',

  `sign_date` bigint(11) NOT NULL COMMENT '签约日期',
  `signer` char(20) COMMENT '委托人',
  `weituo` int(11) NOT NULL COMMENT '委托人ID',
  `wtdw` 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 '接车人手机号',

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

  `fee_insurance` int(11) COMMENT '保险费',
  `fee_truck` int(11) COMMENT '运费',
  `fee_extra` int(11) COMMENT '其他额外费用',
  `fee_total` int(11) COMMENT '总费用',
  `income` int(11) COMMENT '实际所得(分)',
  `expense` 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` text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '更多验车照片',
  `videos` varchar(1000) COMMENT '验车视频',

  `checker` char(20) 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 '是否结佣',
  `not_insurance` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT '不买保险',
  `is_cwqr` tinyint(1) NOT NULL DEFAULT 0 COMMENT '财务是否确认',

  `stat_km` int(11) COMMENT '路线公里数',

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

  `employee_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联员工',
  `create_by` int(11) UNSIGNED 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',
  INDEX `store_id`(`store_id`) USING BTREE COMMENT '门店'
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '救援板运单' ROW_FORMAT = COMPRESSED;

/*2024.07.13*/
ALTER TABLE `ac_order_pre`
    ADD COLUMN `car_title` varchar(255) NULL COMMENT '品牌车型' AFTER `car`,
    ADD COLUMN `car_no` varchar(20) NOT NULL COMMENT '车牌号' AFTER `car_title`;
ALTER TABLE `ac_order_pre`
    ADD COLUMN `date` bigint NULL COMMENT '计划日期' AFTER `aim_city`;
ALTER TABLE `ac_order_pre`
    ADD COLUMN `from_uid` int NOT NULL COMMENT '来源用户ID' AFTER `from_mid`;
ALTER TABLE `ac_order_pre`
    ADD COLUMN `car_value` int NULL COMMENT '车辆价值' AFTER `car_no`;
ALTER TABLE `ac_order_pre`
    ADD COLUMN `employee_id` int NOT NULL COMMENT '关联员工ID' AFTER `store_id`;
ALTER TABLE `ac_order_pre`
    MODIFY COLUMN `from_mobile` char(11) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL COMMENT '客资电话' AFTER `from_uid`,
    MODIFY COLUMN `car_no` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NULL COMMENT '车牌号' AFTER `car_title`;

/*2024.07.16*/
CREATE TABLE `ac_news_cat`  (
    `id` int NOT NULL AUTO_INCREMENT,
    `pid` int NOT NULL DEFAULT 0,
    `pcat_id` int NOT NULL DEFAULT 0 COMMENT '父级分类ID',
    `title` varchar(255) NOT NULL COMMENT '分类标题',
    `orderby` int NOT NULL DEFAULT 0 COMMENT '排序',
    `des` varchar(20) NULL COMMENT '简写',
    `is_show` bigint NOT NULL DEFAULT 1 COMMENT '是否显示',
    `deleted` int NOT NULL DEFAULT 0 COMMENT '是否删除',
    `create_at` bigint NULL COMMENT '创建时间',
    `update_at` bigint NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
) COMMENT = '文章分类表';

CREATE TABLE `ac_news`  (
    `id` int NOT NULL AUTO_INCREMENT,
    `pid` int NOT NULL DEFAULT 0,
    `cid` int NOT NULL DEFAULT 0 COMMENT '分类ID',
    `title` varchar(255) NOT NULL COMMENT '标题',
    `orderby` int NOT NULL DEFAULT 0 COMMENT '排序',
    `des` varchar(255) NULL COMMENT '简述',
    `content` text NULL COMMENT '内容',
    `viewed` int NULL COMMENT '浏览次数',
    `liked` int NULL COMMENT '喜欢次数',
    `reading` int NULL COMMENT '在看人数',
    `is_show` bigint NOT NULL DEFAULT 1 COMMENT '是否显示',
    `deleted` int NOT NULL DEFAULT 0 COMMENT '是否删除',
    `create_at` bigint NULL COMMENT '创建时间',
    `update_at` bigint NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
) COMMENT = '文章表';

CREATE TABLE `ac_notice`  (
    `id` int NOT NULL AUTO_INCREMENT,
    `pid` int NOT NULL DEFAULT 0,
    `title` varchar(255) NOT NULL COMMENT '通知标题',
    `content` text NULL COMMENT '内容',
    `is_show` int NOT NULL DEFAULT 1 COMMENT '是否显示',
    `deleted` int ZEROFILL NOT NULL COMMENT '是否删除',
    `create_at` bigint NULL COMMENT '创建时间',
    `update_at` bigint NULL COMMENT '更新时间',
    PRIMARY KEY (`id`)
) COMMENT = '通知表';

-- 2024.07.29
ALTER TABLE `ac_order` 
ADD COLUMN `sn` varchar(16) NULL COMMENT '唯一SN' AFTER `id`;
ALTER TABLE `ac_order_pre` 
ADD COLUMN `sn` varchar(16) NULL COMMENT '唯一SN' AFTER `id`;

-- 2024.08.04
ALTER TABLE `ac_news`
MODIFY COLUMN `content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '内容' AFTER `des`;