/*
 Navicat Premium Dump SQL

 Source Server         : nas-postgis
 Source Server Type    : PostgreSQL
 Source Server Version : 160009 (160009)
 Source Host           : 192.168.1.31:5433
 Source Catalog        : ebike_user
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 160009 (160009)
 File Encoding         : 65001

 Date: 01/09/2025 22:10:34
*/

-- 批量创建所有序列
-- 创建 ebike_user_user_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_user_user_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;


-- 创建 ebike_user_real_info_info_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_user_real_info_info_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_order_order_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_order_order_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_order_detail_detail_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_order_detail_detail_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_payment_payment_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_payment_payment_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_refund_refund_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_refund_refund_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_fault_report_report_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_fault_report_report_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_cmd_cmd_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_cmd_cmd_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_param_param_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_param_param_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_param_value_value_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_param_value_value_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;

-- 创建 ebike_attachment_file_file_id_seq 序列
CREATE SEQUENCE IF NOT EXISTS ebike_attachment_file_file_id_seq
    START WITH 1
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9223372036854775807
    CACHE 1;


-- ----------------------------
-- Table structure for ebike_user
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_user";
CREATE TABLE "public"."ebike_user" (
           "user_id" int8 NOT NULL DEFAULT nextval('ebike_user_user_id_seq'::regclass),
           "open_id" varchar(200) COLLATE "pg_catalog"."default",
           "mobile" varchar(20) COLLATE "pg_catalog"."default",
           "password" varchar(200) COLLATE "pg_catalog"."default",
           "email" varchar(100) COLLATE "pg_catalog"."default",
           "nickname" varchar(100) COLLATE "pg_catalog"."default",
           "gender" int2,
           "birthdate" timestamp(6),
           "avatar" varchar(500) COLLATE "pg_catalog"."default",
           "last_login_time" timestamp(6),
           "user_status" int2,
           "role" varchar(100) COLLATE "pg_catalog"."default",
           "address" varchar(500) COLLATE "pg_catalog"."default",
           "user_real_name_verified" int2,
           "create_by" int8,
           "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
           "update_by" int8,
           "update_time" timestamp(6),
           "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_user"."user_id" IS '用户ID';
COMMENT ON COLUMN "public"."ebike_user"."open_id" IS '微信OPENID';
COMMENT ON COLUMN "public"."ebike_user"."mobile" IS '手机号';
COMMENT ON COLUMN "public"."ebike_user"."password" IS '密码';
COMMENT ON COLUMN "public"."ebike_user"."email" IS '邮箱';
COMMENT ON COLUMN "public"."ebike_user"."nickname" IS '昵称';
COMMENT ON COLUMN "public"."ebike_user"."gender" IS '性别 0-未知 1-男 2-女 ';
COMMENT ON COLUMN "public"."ebike_user"."birthdate" IS '生日';
COMMENT ON COLUMN "public"."ebike_user"."avatar" IS '头像';
COMMENT ON COLUMN "public"."ebike_user"."last_login_time" IS '记录用户最后一次登录的时间';
COMMENT ON COLUMN "public"."ebike_user"."user_status" IS '用户的状态，-1-注销 1-激活 2-禁用';
COMMENT ON COLUMN "public"."ebike_user"."role" IS '角色';
COMMENT ON COLUMN "public"."ebike_user"."address" IS '地址';
COMMENT ON COLUMN "public"."ebike_user"."user_real_name_verified" IS '用户是否通过实名认证 1-是 2-否';
COMMENT ON COLUMN "public"."ebike_user"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_user"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_user"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_user"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_user" IS '用户信息表';

-- ----------------------------
-- Table structure for ebike_user_real_info
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_user_real_info";
CREATE TABLE "public"."ebike_user_real_info" (
         "info_id" int8 NOT NULL DEFAULT nextval('ebike_user_real_info_info_id_seq'::regclass),
         "user_id" int8 NOT NULL,
         "user_real_name" varchar(1000) COLLATE "pg_catalog"."default",
         "user_id_card" varchar(1000) COLLATE "pg_catalog"."default",
         "id_card_front" varchar(255) COLLATE "pg_catalog"."default",
         "id_card_back" varchar(255) COLLATE "pg_catalog"."default",
         "attestation_status" int2,
         "audit_time" timestamp(6),
         "create_by" int8,
         "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
         "update_by" int8,
         "update_time" timestamp(6),
         "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_user_real_info"."info_id" IS '主键ID';
COMMENT ON COLUMN "public"."ebike_user_real_info"."user_id" IS '用户ID';
COMMENT ON COLUMN "public"."ebike_user_real_info"."user_real_name" IS '真实姓名，加密';
COMMENT ON COLUMN "public"."ebike_user_real_info"."user_id_card" IS '身份证号，加密';
COMMENT ON COLUMN "public"."ebike_user_real_info"."id_card_front" IS '身份证正面的图片链接或存储路径';
COMMENT ON COLUMN "public"."ebike_user_real_info"."id_card_back" IS '身份证背面的图片链接或存储路径';
COMMENT ON COLUMN "public"."ebike_user_real_info"."attestation_status" IS '实名认证的状态; 0-待审核、1-已认证、2-认证失败';
COMMENT ON COLUMN "public"."ebike_user_real_info"."audit_time" IS '实名认证审核的时间';
COMMENT ON COLUMN "public"."ebike_user_real_info"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_user_real_info"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_user_real_info"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_user_real_info"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_user_real_info" IS '实名认证信息';

-- ----------------------------
-- Table structure for ebike_order
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_order";
CREATE TABLE "public"."ebike_order" (
            "order_id" int8 NOT NULL DEFAULT nextval('ebike_order_order_id_seq'::regclass),
            "user_id" int8 NOT NULL,
            "operator_id" int8 NOT NULL,
            "bike_id" int8 NOT NULL,
            "bike_code" varchar(50) COLLATE "pg_catalog"."default",
            "order_type" int2 NOT NULL,
            "order_status" int2 NOT NULL,
            "total_amount" numeric(10,2) DEFAULT 0.00,
            "actual_amount" numeric(10,2) DEFAULT 0.00,
            "start_time" timestamp(6),
            "end_time" timestamp(6),
            "payment_time" timestamp(6),
            "payment_method" varchar(20) COLLATE "pg_catalog"."default",
            "coupon_ids" varchar(255) COLLATE "pg_catalog"."default",
            "discount_details" jsonb,
            "geo_hash" varchar(12) COLLATE "pg_catalog"."default",
            "start_location" point DEFAULT NULL,
            "end_location" point DEFAULT NULL,
            "cancel_time" timestamp(6),
            "temp_lock" int2,
            "create_by" int8,
            "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
            "update_by" int8,
            "update_time" timestamp(6),
            "is_deleted" bool NOT NULL DEFAULT false
);

COMMENT ON COLUMN "public"."ebike_order"."order_id" IS '主键订单Id';
COMMENT ON COLUMN "public"."ebike_order"."user_id" IS '用户ID，关联用户表';
COMMENT ON COLUMN "public"."ebike_order"."operator_id" IS '运营商id';
COMMENT ON COLUMN "public"."ebike_order"."bike_id" IS '车辆id';
COMMENT ON COLUMN "public"."ebike_order"."bike_code" IS '车辆编号';
COMMENT ON COLUMN "public"."ebike_order"."order_type" IS '订单类型：1-单次骑行 2-骑行卡购买 3-会员卡续费';
COMMENT ON COLUMN "public"."ebike_order"."order_status" IS '状态：0-进行中 1-已取消 2-待支付 3-已支付  4-退款中 5-已退款 6-退款申请中 7-退款驳回 8-退款失败';
COMMENT ON COLUMN "public"."ebike_order"."total_amount" IS '订单总金额（单位：元）';
COMMENT ON COLUMN "public"."ebike_order"."actual_amount" IS '实付金额（扣除卡券优惠后）';
COMMENT ON COLUMN "public"."ebike_order"."start_time" IS '骑行开始时间（仅骑行订单有效）';
COMMENT ON COLUMN "public"."ebike_order"."end_time" IS '骑行结束时间（仅骑行订单有效）';
COMMENT ON COLUMN "public"."ebike_order"."payment_time" IS '支付成功时间';
COMMENT ON COLUMN "public"."ebike_order"."payment_method" IS '支付方式：wechat/alipay/balance';
COMMENT ON COLUMN "public"."ebike_order"."coupon_ids" IS '使用卡券ID集合（JSON数组）';
COMMENT ON COLUMN "public"."ebike_order"."discount_details" IS '优惠明细（结构化存储，便于对账）';
COMMENT ON COLUMN "public"."ebike_order"."geo_hash" IS '地理位置GeoHash编码（用于区域优惠分析）';
COMMENT ON COLUMN "public"."ebike_order"."start_location" IS '骑行初始点';
COMMENT ON COLUMN "public"."ebike_order"."end_location" IS '骑行还车点';
COMMENT ON COLUMN "public"."ebike_order"."cancel_time" IS '取消时间';
COMMENT ON COLUMN "public"."ebike_order"."temp_lock" IS '是否临时锁车：0-未临时锁车 -1临时锁车';
COMMENT ON COLUMN "public"."ebike_order"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_order"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_order"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_order"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_order" IS '用户订单表';


-- ----------------------------
-- Table structure for ebike_order_detail
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_order_detail";
CREATE TABLE "public"."ebike_order_detail" (
        "detail_id" int8 NOT NULL DEFAULT nextval('ebike_order_detail_detail_id_seq'::regclass),
        "order_id" int8 NOT NULL,
        "operator_id" int8 NOT NULL,
        "detail_type" int2 NOT NULL,
        "detail_name" varchar(50) COLLATE "pg_catalog"."default",
        "detail_amount" numeric(10,2) NOT NULL,
        "calculation_rule" jsonb,
        "coupon_id" varchar(50) COLLATE "pg_catalog"."default",
        "create_by" int8,
        "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
        "update_by" int8,
        "update_time" timestamp(6),
        "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_order_detail"."detail_id" IS '费用项ID';
COMMENT ON COLUMN "public"."ebike_order_detail"."order_id" IS '订单ID';
COMMENT ON COLUMN "public"."ebike_order_detail"."operator_id" IS '运营商id';
COMMENT ON COLUMN "public"."ebike_order_detail"."detail_type" IS '费用类型：1-骑行时长费 2-运营区调度费用 3-停车区调度费用 4-高峰时段出行费用 5-高峰日出行费用 6-起步费用';
COMMENT ON COLUMN "public"."ebike_order_detail"."detail_name" IS '费用名称';
COMMENT ON COLUMN "public"."ebike_order_detail"."detail_amount" IS '费用金额';
COMMENT ON COLUMN "public"."ebike_order_detail"."calculation_rule" IS '计算规则（存储JSON）';
COMMENT ON COLUMN "public"."ebike_order_detail"."coupon_id" IS '关联优惠券ID';
COMMENT ON COLUMN "public"."ebike_order_detail"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_order_detail"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_order_detail"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_order_detail"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_order_detail" IS '订单费用明细表';


-- ----------------------------
-- Table structure for ebike_payment
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_payment";
CREATE TABLE "public"."ebike_payment" (
          "payment_id" int8 NOT NULL DEFAULT nextval('ebike_payment_payment_id_seq'::regclass),
          "user_id" int8 NOT NULL,
          "order_id" int8 NOT NULL,
          "operator_id" int8 NOT NULL,
          "trade_id" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
          "transaction_id" varchar(64) COLLATE "pg_catalog"."default",
          "payment_time" timestamp(6),
          "payment_method" int2 NOT NULL,
          "trade_status" int2,
          "cost_price" numeric(7,2),
          "currency" varchar(10) COLLATE "pg_catalog"."default",
          "total" numeric(7,2),
          "create_by" int8,
          "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
          "update_by" int8,
          "update_time" timestamp(6),
          "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_payment"."payment_id" IS '主键ID';
COMMENT ON COLUMN "public"."ebike_payment"."user_id" IS '用户id';
COMMENT ON COLUMN "public"."ebike_payment"."order_id" IS '骑行订单号';
COMMENT ON COLUMN "public"."ebike_payment"."operator_id" IS '运营商id';
COMMENT ON COLUMN "public"."ebike_payment"."trade_id" IS '支付交易用订单编号，重新请求时需要更新';
COMMENT ON COLUMN "public"."ebike_payment"."transaction_id" IS '微信支付订单号, 仅支付成功有';
COMMENT ON COLUMN "public"."ebike_payment"."payment_time" IS '支付成功时间';
COMMENT ON COLUMN "public"."ebike_payment"."payment_method" IS '支付方式;1-wechat 2-alipay 3-balance';
COMMENT ON COLUMN "public"."ebike_payment"."trade_status" IS '支付状态;0支付成功 1退款 2未支付 3关闭 4取消 5支付中 6支付错误 7接受';
COMMENT ON COLUMN "public"."ebike_payment"."cost_price" IS '订单原价';
COMMENT ON COLUMN "public"."ebike_payment"."currency" IS '支付货币';
COMMENT ON COLUMN "public"."ebike_payment"."total" IS '支付总金额';
COMMENT ON COLUMN "public"."ebike_payment"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_payment"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_payment"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_payment"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_payment" IS '用户订单支付记录';


-- ----------------------------
-- Table structure for ebike_refund
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_refund";
CREATE TABLE "public"."ebike_refund" (
         "refund_id" int8 NOT NULL DEFAULT nextval('ebike_refund_refund_id_seq'::regclass),
         "refund_order_id" varchar(64) COLLATE "pg_catalog"."default",
         "order_id" int8 NOT NULL,
         "operator_id" int8 NOT NULL,
         "transaction_id" varchar(64) COLLATE "pg_catalog"."default",
         "refund_time" timestamp(6),
         "refund_status" int2,
         "currency" varchar(10) COLLATE "pg_catalog"."default",
         "refund_apply" numeric(7,2),
         "refund" numeric(7,2),
         "total" numeric(7,2),
         "reason" varchar(200) COLLATE "pg_catalog"."default",
         "process_status" int2,
         "source" int2,
         "refund_method" int2,
         "remark" varchar(200) COLLATE "pg_catalog"."default",
         "process_time" timestamp(6),
         "refund_transaction_id" varchar(64) COLLATE "pg_catalog"."default",
         "review_operator" varchar(50) COLLATE "pg_catalog"."default",
         "refund_operator" varchar(50) COLLATE "pg_catalog"."default",
         "create_by" int8,
         "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
         "update_by" int8,
         "update_time" timestamp(6),
         "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_refund"."refund_id" IS '主键ID';
COMMENT ON COLUMN "public"."ebike_refund"."refund_order_id" IS '退款单号';
COMMENT ON COLUMN "public"."ebike_refund"."order_id" IS '订单号';
COMMENT ON COLUMN "public"."ebike_refund"."operator_id" IS '运营商id';
COMMENT ON COLUMN "public"."ebike_refund"."transaction_id" IS '微信支付订单号';
COMMENT ON COLUMN "public"."ebike_refund"."refund_time" IS '退款成功时间';
COMMENT ON COLUMN "public"."ebike_refund"."refund_status" IS '退款状态;0退款成功 1关闭 2退款中 3异常';
COMMENT ON COLUMN "public"."ebike_refund"."currency" IS '货币';
COMMENT ON COLUMN "public"."ebike_refund"."refund_apply" IS '申请退款金额';
COMMENT ON COLUMN "public"."ebike_refund"."refund" IS '退款金额';
COMMENT ON COLUMN "public"."ebike_refund"."total" IS '原订单金额';
COMMENT ON COLUMN "public"."ebike_refund"."reason" IS '退款原因';
COMMENT ON COLUMN "public"."ebike_refund"."process_status" IS '审核状态;0申请中 1处理中 2已处理 3已关闭';
COMMENT ON COLUMN "public"."ebike_refund"."source" IS '来源;0用户，1客服';
COMMENT ON COLUMN "public"."ebike_refund"."refund_method" IS '退款方式;0原路返回，1余额，2线下退款';
COMMENT ON COLUMN "public"."ebike_refund"."remark" IS '驳回原因/退款备注';
COMMENT ON COLUMN "public"."ebike_refund"."process_time" IS '驳回/通过时间';
COMMENT ON COLUMN "public"."ebike_refund"."refund_transaction_id" IS '退款交易流水号';
COMMENT ON COLUMN "public"."ebike_refund"."review_operator" IS '审核人';
COMMENT ON COLUMN "public"."ebike_refund"."refund_operator" IS '退款人';
COMMENT ON COLUMN "public"."ebike_refund"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_refund"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_refund"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_refund"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_refund" IS '用户订单退款记录';


-- ----------------------------
-- Table structure for ebike_fault_report
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_fault_report";
CREATE TABLE "public"."ebike_fault_report" (
            "report_id" int8 NOT NULL DEFAULT nextval('ebike_fault_report_report_id_seq'::regclass),
            "operator_id" int8 NOT NULL,
            "bike_code" varchar(50) COLLATE "pg_catalog"."default",
            "fault_part" varchar(200) COLLATE "pg_catalog"."default",
            "fault_description" varchar(400) COLLATE "pg_catalog"."default",
            "report_time" timestamp(6),
            "report_user" varchar(50) COLLATE "pg_catalog"."default",
            "user_mobile" varchar(20) COLLATE "pg_catalog"."default",
            "report_source" varchar(50) COLLATE "pg_catalog"."default",
            "handle_status" int2,
            "location" point DEFAULT NULL,
            "order_code" varchar(50) COLLATE "pg_catalog"."default",
            "workorder_id" varchar(50) COLLATE "pg_catalog"."default",
            "create_by" int8,
            "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
            "update_by" int8,
            "update_time" timestamp(6),
            "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_fault_report"."report_id" IS '主键ID';
COMMENT ON COLUMN "public"."ebike_fault_report"."operator_id" IS '运营商id';
COMMENT ON COLUMN "public"."ebike_fault_report"."bike_code" IS '车辆编号';
COMMENT ON COLUMN "public"."ebike_fault_report"."fault_part" IS '损坏部件';
COMMENT ON COLUMN "public"."ebike_fault_report"."fault_description" IS '故障说明';
COMMENT ON COLUMN "public"."ebike_fault_report"."report_time" IS '上报时间';
COMMENT ON COLUMN "public"."ebike_fault_report"."report_user" IS '上报人';
COMMENT ON COLUMN "public"."ebike_fault_report"."user_mobile" IS '上报人手机号';
COMMENT ON COLUMN "public"."ebike_fault_report"."report_source" IS '上报来源';
COMMENT ON COLUMN "public"."ebike_fault_report"."handle_status" IS '处理状态 0待处理 1处理中 2处理完';
COMMENT ON COLUMN "public"."ebike_fault_report"."location" IS '当前位置';
COMMENT ON COLUMN "public"."ebike_fault_report"."order_code" IS '订单编号';
COMMENT ON COLUMN "public"."ebike_fault_report"."workorder_id" IS '工单ID';
COMMENT ON COLUMN "public"."ebike_fault_report"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_fault_report"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_fault_report"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_fault_report"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_fault_report" IS '用户上报故障信息表';

-- ----------------------------
-- Table structure for ebike_cmd
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_cmd";
CREATE TABLE "public"."ebike_cmd" (
           "cmd_id" int8 NOT NULL DEFAULT nextval('ebike_cmd_cmd_id_seq'::regclass),
           "cmd_name" varchar(50) COLLATE "pg_catalog"."default",
           "cmd_describe" varchar(200) COLLATE "pg_catalog"."default",
           "cmd_code" varchar(30) COLLATE "pg_catalog"."default",
           "create_by" int8,
           "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
           "update_by" int8,
           "update_time" timestamp(6),
           "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_cmd"."cmd_id" IS '主键ID';
COMMENT ON COLUMN "public"."ebike_cmd"."cmd_name" IS 'cmd命令名称';
COMMENT ON COLUMN "public"."ebike_cmd"."cmd_describe" IS 'cmd命令描述';
COMMENT ON COLUMN "public"."ebike_cmd"."cmd_code" IS 'cmd命令编号';
COMMENT ON COLUMN "public"."ebike_cmd"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_cmd"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_cmd"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_cmd"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_cmd" IS '中控命令表';


-- ----------------------------
-- Table structure for ebike_param
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_param";
CREATE TABLE "public"."ebike_param" (
          "param_id" int8 NOT NULL DEFAULT nextval('ebike_param_param_id_seq'::regclass),
          "cmd_id" int8 NOT NULL,
          "param_name" varchar(50) COLLATE "pg_catalog"."default",
          "param_describe" varchar(200) COLLATE "pg_catalog"."default",
          "param_level" int2 NOT NULL,
          "value_type" int2 NOT NULL,
          "parent_id" int8,
          "create_by" int8,
          "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
          "update_by" int8,
          "update_time" timestamp(6),
          "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_param"."param_id" IS '主键ID(参数id)';
COMMENT ON COLUMN "public"."ebike_param"."cmd_id" IS 'cmd主键Id';
COMMENT ON COLUMN "public"."ebike_param"."param_name" IS '命令参数名称';
COMMENT ON COLUMN "public"."ebike_param"."param_describe" IS '命令参数描述';
COMMENT ON COLUMN "public"."ebike_param"."param_level" IS '命令参数等级';
COMMENT ON COLUMN "public"."ebike_param"."value_type" IS '命令参数类型 1、从param_value表中取值；2、自生成；3、由prama子集构成json';
COMMENT ON COLUMN "public"."ebike_param"."parent_id" IS '父级param_id';
COMMENT ON COLUMN "public"."ebike_param"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_param"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_param"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_param"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_param" IS '中控命令参数表';


-- ----------------------------
-- Table structure for ebike_param_value
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_param_value";
CREATE TABLE "public"."ebike_param_value" (
        "param_value_id" int8 NOT NULL DEFAULT nextval('ebike_param_value_value_id_seq'::regclass),
        "param_id" int8 NOT NULL,
        "param_value" varchar(100) COLLATE "pg_catalog"."default",
        "create_by" int8,
        "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
        "update_by" int8,
        "update_time" timestamp(6),
        "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_param_value"."param_value_id" IS '主键ID(参数值id)';
COMMENT ON COLUMN "public"."ebike_param_value"."param_id" IS '参数id';
COMMENT ON COLUMN "public"."ebike_param_value"."param_value" IS '参数值';
COMMENT ON COLUMN "public"."ebike_param_value"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_param_value"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_param_value"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_param_value"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_param_value" IS '中控命令参数取值表';


-- ----------------------------
-- Table structure for ebike_attachment_file
-- ----------------------------
DROP TABLE IF EXISTS "public"."ebike_attachment_file";
CREATE TABLE "public"."ebike_attachment_file" (
          "file_id" int8 NOT NULL DEFAULT nextval('ebike_attachment_file_file_id_seq'::regclass),
          "report_id" int8 NOT NULL,
          "file_name" varchar(100) COLLATE "pg_catalog"."default",
          "file_type" varchar(10) COLLATE "pg_catalog"."default",
          "file_url" varchar(200) COLLATE "pg_catalog"."default",
          "file_size" int8,
          "create_by" int8,
          "create_time" timestamp(6) DEFAULT CURRENT_TIMESTAMP,
          "update_by" int8,
          "update_time" timestamp(6),
          "is_deleted" bool NOT NULL DEFAULT false
);
COMMENT ON COLUMN "public"."ebike_attachment_file"."file_id" IS '主键ID';
COMMENT ON COLUMN "public"."ebike_attachment_file"."report_id" IS '报告id';
COMMENT ON COLUMN "public"."ebike_attachment_file"."file_name" IS '附件文件名';
COMMENT ON COLUMN "public"."ebike_attachment_file"."file_type" IS '附件类型';
COMMENT ON COLUMN "public"."ebike_attachment_file"."file_url" IS '附件地址';
COMMENT ON COLUMN "public"."ebike_attachment_file"."file_size" IS '附件大小';
COMMENT ON COLUMN "public"."ebike_attachment_file"."create_by" IS '创建人ID';
COMMENT ON COLUMN "public"."ebike_attachment_file"."create_time" IS '创建时间';
COMMENT ON COLUMN "public"."ebike_attachment_file"."update_by" IS '最后修改人ID';
COMMENT ON COLUMN "public"."ebike_attachment_file"."update_time" IS '最后修改时间';
COMMENT ON TABLE "public"."ebike_attachment_file" IS '用车相关附件文件记录';




-- ----------------------------
-- Primary Key structure for table ebike_user
-- ----------------------------
ALTER TABLE "public"."ebike_user" ADD CONSTRAINT "ebike_user_pkey" PRIMARY KEY ("user_id");
-- ----------------------------
-- Index structure for table ebike_user
-- ----------------------------
CREATE INDEX idx_ebike_user_open_id ON public.ebike_user (open_id);
CREATE INDEX idx_ebike_user_mobile ON public.ebike_user (mobile);

-- ----------------------------
-- Primary Key structure for table ebike_user_real_info
-- ----------------------------
ALTER TABLE "public"."ebike_user_real_info" ADD CONSTRAINT "ebike_user_real_info_pkey" PRIMARY KEY ("info_id");
-- ----------------------------
-- Index structure for table ebike_user_real_info
-- ----------------------------
CREATE INDEX idx_ebike_user_real_info_user_id ON public.ebike_user (user_id);

-- ----------------------------
-- Primary Key structure for table ebike_order
-- ----------------------------
ALTER TABLE "public"."ebike_order" ADD CONSTRAINT "ebike_order_pkey" PRIMARY KEY ("order_id");
-- ----------------------------
-- Index structure for table ebike_order
-- ----------------------------
CREATE INDEX idx_ebike_order_user_id ON public.ebike_order (user_id);
CREATE INDEX idx_ebike_order_operator_id ON public.ebike_order (operator_id);
CREATE INDEX idx_ebike_order_bike_id ON public.ebike_order (bike_id);


-- ----------------------------
-- Primary Key structure for table ebike_order_detail
-- ----------------------------
ALTER TABLE "public"."ebike_order_detail" ADD CONSTRAINT "ebike_order_detail_pkey" PRIMARY KEY ("detail_id");
-- ----------------------------
-- Index structure for table ebike_order_detail
-- ----------------------------
CREATE INDEX idx_ebike_order_detail_order_id ON public.ebike_order_detail (detail_id);
CREATE INDEX idx_ebike_order_detail_operator_id ON public.ebike_order_detail (operator_id);


-- ----------------------------
-- Primary Key structure for table ebike_payment
-- ----------------------------
ALTER TABLE "public"."ebike_payment" ADD CONSTRAINT "ebike_payment_pkey" PRIMARY KEY ("payment_id");
-- ----------------------------
-- Index structure for table ebike_payment
-- ----------------------------
CREATE INDEX idx_ebike_payment_user_id ON public.ebike_payment (user_id);
CREATE INDEX idx_ebike_payment_order_id ON public.ebike_payment (order_id);
CREATE INDEX idx_ebike_payment_operator_id ON public.ebike_payment (operator_id);
CREATE INDEX idx_ebike_payment_trade_id ON public.ebike_payment (trade_id);


-- ----------------------------
-- Primary Key structure for table ebike_refund
-- ----------------------------
ALTER TABLE "public"."ebike_refund" ADD CONSTRAINT "ebike_refund_pkey" PRIMARY KEY ("refund_id");
-- ----------------------------
-- Index structure for table ebike_refund
-- ----------------------------
CREATE INDEX idx_ebike_refund_refund_order_id ON public.ebike_refund (refund_order_id);
CREATE INDEX idx_ebike_refund_order_id ON public.ebike_refund (order_id);
CREATE INDEX idx_ebike_refund_operator_id ON public.ebike_refund (operator_id);
CREATE INDEX idx_ebike_refund_transaction_id ON public.ebike_refund (transaction_id);

-- ----------------------------
-- Primary Key structure for table ebike_fault_report
-- ----------------------------
ALTER TABLE "public"."ebike_fault_report" ADD CONSTRAINT "ebike_refund_report_pkey" PRIMARY KEY ("report_id");
-- ----------------------------
-- Index structure for table ebike_fault_report
-- ----------------------------
CREATE INDEX idx_ebike_refund_report_bike_code ON public.ebike_fault_report (bike_code);
CREATE INDEX idx_ebike_refund_report_operator_id ON public.ebike_fault_report (operator_id);

-- ----------------------------
-- Primary Key structure for table ebike_cmd
-- ----------------------------
ALTER TABLE "public"."ebike_cmd" ADD CONSTRAINT "ebike_cmd_cmd_pkey" PRIMARY KEY ("cmd_id");

-- ----------------------------
-- Primary Key structure for table ebike_param
-- ----------------------------
ALTER TABLE "public"."ebike_param" ADD CONSTRAINT "ebike_param_param_pkey" PRIMARY KEY ("param_id");
-- ----------------------------
-- Index structure for table ebike_param
-- ----------------------------
CREATE INDEX idx_ebike_param_cmd_id ON public.ebike_param (cmd_id);


-- ----------------------------
-- Primary Key structure for table ebike_param_value
-- ----------------------------
ALTER TABLE "public"."ebike_param_value" ADD CONSTRAINT "ebike_param_value_value_pkey" PRIMARY KEY ("param_value_id");
-- ----------------------------
-- Index structure for table ebike_param_value
-- ----------------------------
CREATE INDEX idx_ebike_param_value_param_id ON public.ebike_param_value (param_id);


-- ----------------------------
-- Primary Key structure for table ebike_attachment_file
-- ----------------------------
ALTER TABLE "public"."ebike_attachment_file" ADD CONSTRAINT "ebike_attachment_file_file_pkey" PRIMARY KEY ("attachment_file_id");