create table complaint
(
    id          bigint auto_increment
        primary key,
    ssid        varchar(64)   not null,
    uid         bigint        null,
    reason      varchar(255)  null,
    content     varchar(500)  not null,
    phone       varchar(255)  null,
    images      varchar(1000) null,
    create_time datetime      not null,
    update_time datetime      not null,
    status      int           not null
);

create table device_bind
(
    id           bigint auto_increment
        primary key,
    out_trade_no varchar(128) not null,
    device_id    varchar(64)  not null,
    ssid         varchar(64)  not null,
    create_time  datetime     not null
);

create table device_func_auth
(
    id              bigint auto_increment
        primary key,
    auths           varchar(255) not null,
    device_id       varchar(64)  not null,
    ssid            varchar(64)  not null,
    start_timestamp bigint       not null comment '计时开始时间戳',
    end_timestamp   bigint       not null comment '计时结束时间戳',
    create_time     datetime     not null,
    update_time     datetime     not null
);

create table order_info
(
    id                 bigint auto_increment
        primary key,
    out_trade_no       varchar(128) not null,
    ssid               varchar(64)  not null,
    device_id          varchar(64)  not null,
    phone              varchar(64)  null,
    item_id            bigint       not null,
    item_name          varchar(255) not null,
    original_amount    bigint       not null,
    amount             bigint       not null,
    app_platform       int          not null,
    package_name       varchar(255) not null,
    channel_name       varchar(255) null,
    ip                 varchar(255) null,
    create_time        datetime     not null,
    update_time        datetime     not null,
    pay_status         int          not null comment '-- 0:已创建 1:未支付 2:已支付 3:已关闭 4:已退款',
    status             int          not null,
    auth_code          varchar(64)  null,
    bound_out_trade_no varchar(128) null,
    client_id          varchar(128) null,
    pay_method         int          null,
    pay_platform       int          null,
    constraint out_trade_no_index
        unique (out_trade_no)
)
    comment '订单表';

create index query_index
    on order_info (ssid, pay_status, status);

create table upload_log
(
    id                bigint auto_increment
        primary key,
    ssid              varchar(64)   not null,
    cdn_host          varchar(255)  not null,
    fileKey           varchar(1000) not null,
    original_filename varchar(255)  null,
    ip                varchar(255)  null,
    create_time       datetime      not null,
    update_time       datetime      not null,
    status            int           not null
);

create table user_case
(
    id          bigint auto_increment
        primary key,
    title       varchar(255)  not null,
    content     varchar(1000) null,
    images      varchar(1000) null,
    link        varchar(1000) null,
    create_time datetime      not null,
    update_time datetime      not null,
    status      int default 0 not null
);

