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


create table image_info
(
    id          bigint auto_increment
        primary key,
    ssid        varchar(255)  null comment 'ssid',
    image_url   varchar(255)  null comment '图片地址',
    tool_type   varchar(255)  null comment '工具类型',
    tool_id     bigint        null comment '工具id',
    content     varchar(3000) null comment '返回结果',
    method      int           null comment '方式 0-免费 1-通过激励 2-会员',
    evaluate    int           null comment '评价 1-赞 2-踩',
    status      int           null comment '状态',
    create_time datetime      null comment '创建时间'
);

create index idx_create_time
    on image_info (create_time);

create index idx_ssid
    on image_info (ssid);


create table member_auth
(
    id              bigint auto_increment
        primary key,
    ssid            varchar(64)      not null,
    out_trade_no    varchar(64)      null,
    auth            varchar(255)     not null,
    auth_value      bigint default 0 not null,
    start_timestamp bigint           not null,
    end_timestamp   bigint           not null,
    status          int    default 0 not null comment '状态',
    create_time     datetime         not null,
    update_time     datetime         not null
);

create index idx_auth
    on member_auth (auth);

create index idx_out_trade_no
    on member_auth (out_trade_no);

create index idx_ssid
    on member_auth (ssid);


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,
    constraint idx_out_trade_no
        unique (out_trade_no)
)
    collate = utf8mb4_unicode_ci;

create index idx_create_time
    on order_info (create_time);

create index idx_ssid
    on order_info (ssid);


create table risk_check_log
(
    id               int auto_increment
        primary key,
    user_id          varchar(64) null,
    phone            varchar(32) null,
    source_type      varchar(16) null,
    content_type     varchar(16) null,
    content          mediumtext  null,
    response_code    varchar(16) null,
    response_message varchar(64) null,
    risk_level       varchar(32) null,
    risk_level_msg   varchar(64) null,
    create_time      datetime    null,
    ip               varchar(64) null,
    data             mediumtext  null
);


create table upload_log
(
    id                bigint auto_increment
        primary key,
    ssid              varchar(64)   not null,
    cdn_host          varchar(255)  not null,
    file_key          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 index ssid_index
    on upload_log (ssid);