<?php

$sql = ["DROP TABLE IF EXISTS `app_web`;",
        "CREATE TABLE `app_web`( `site_name` text comment '网站名称', `site_title` text comment '网站标题', `site_desc` text comment '网站描述', `site_keywords` text comment '网站关键词', `site_item_num` int comment '每页条数', `redis_address` varchar(11) comment 'Redis地址', `redis_port` int comment 'Redis端口号', `redis_password` text comment 'Redis密码[默认为空]', `api_request_limit` int comment 'API请求次数限制', `api_request_interval` int null comment 'API请求速率[单位：秒]', `send_smtp_host` text comment 'SMTP服务器', `send_smtp_port` text comment 'SMTP端口号', `send_from_name` text comment '发信名称', `send_username` text comment '邮箱账号', `send_password` text comment '邮箱密码', `send_collect_email` text comment '测试邮箱', `code_prefix` text comment '验证码前置', `code_length` int comment '验证码长度', `code_exp_time` int comment '验证码过期时间', `site_notice` text comment '网站公告', `site_notice_status` int comment '网站公告开关[0关1开]', `allow_registration` int comment '是否允许注册[0关1开]', `enable_email_verification` int comment '是否启用邮箱验证[0关1开]', `enable_membership_activation_code` int comment '是否启用卡密开通会员[0关1开]', `enable_online_membership` int comment '是否启用在线开通会员[0关1开]', `enable_local_key_input` int comment '是否启用填写本地Key[0关1开]', `reg_chat_limit` int comment '用户注册对话额度[0不送]', `bad_words` text comment '违禁词内容', `openai_api` varchar(255) default 'https://api.openai.com/' comment 'ChatGPT API', `system_maintenance` int comment '是否开启系统维护', `footer` text comment '底部版权') ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COMMENT '网站设置表';",
        "insert into app_web(site_name, site_title, site_desc, site_keywords, site_item_num, redis_address, redis_port, redis_password, api_request_limit, api_request_interval, send_smtp_host, send_smtp_port, send_from_name, send_username, send_password, send_collect_email, code_prefix, code_length, code_exp_time, site_notice, site_notice_status, allow_registration, enable_email_verification, enable_membership_activation_code, enable_online_membership, enable_local_key_input, reg_chat_limit, bad_words, system_maintenance, footer) values ('闪联', '闪联智能', '闪联智能，一站式人工智能AI工具，润色文章、修正语法、生成文案、写代码、聊天，全方位提升网页效率', '闪联,ai,chatgpt', 10, '127.0.0.1', 6379, null, 60, 300, 'smtp.qq.com', '465', '闪联', 'cloudza@vip.qq.com', 'kbuxjbubrysjdhci', '2922619853@.qq.com', 'AU-', 4, 300, '欢迎光临', 1, '1', '1', '1', '1', '1', '0', '违禁词1,违禁词2', '0', '云之安');",
        "DROP TABLE IF EXISTS `app_admin`;",
        "CREATE TABLE `app_admin`( `usernick` varchar(32) comment '管理员昵称', `userqq` varchar(20) comment '管理员QQ', `username` varchar(20) comment '管理员账号', `password` varchar(32) comment '管理员密码', `cookie` varchar(32) comment 'Cookie', `salt` varchar(128) comment '密码盐') ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COMMENT '管理员表';",
        "INSERT INTO app_admin(usernick, userqq, username, password, cookie, salt) VALUES ('云之安', '2922619853', 'admin123', 'e10adc3949ba59abbe56e057f20f883e', '5844a8e587c353ce2dfbca3def069981', 'Y_g8A!^b0ad48ef5c8759fc8d5c14bacf50caa0f46445000beb8e3c0506bafeb8e9b8e0b');",
        "DROP TABLE IF EXISTS `app_keys`;",
        " CREATE TABLE `app_keys`( `id` int primary key auto_increment comment '主键', `gpt_keys` text comment 'GPT Key', `granted` varchar(10) comment '总额度', `used` varchar(10) comment '已使用额度', `available` varchar(10) comment '剩余额度', `effective_at` datetime comment 'Key生效日期', `expires_at` datetime comment 'Key过期日期', `key_status` int comment 'Key状态[0停用1启用]') ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COMMENT 'GPT Key表';",
        "DROP TABLE IF EXISTS `app_order`;",
        " CREATE TABLE `app_order`( `id` int primary key auto_increment comment '主键', `pay_order` varchar(64) comment '系统订单号', `pay_orderno` varchar(64) comment '商户订单号', `pay_type` text comment '支付方式', `pay_name` text comment '商品名称', `pay_money` text comment '支付金额', `pay_content` text comment '订单参数内容', `pay_time` datetime comment '时间', `pay_ip` text comment 'ip', `pay_region` text comment '所在地区', `pay_status` int comment '状态[1已支付,0未支付,2已取消][3处理中]') ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COMMENT '订单表';",
        "DROP TABLE IF EXISTS `app_plans`;",
        " CREATE TABLE `app_plans`( `id` int primary key auto_increment comment '主键', `name` varchar(32) comment '套餐名称', `period` int comment '有效期', `price` varchar(10) comment '价格', `chat_limit` varchar(10) comment '限制对话次数') ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT '会员套餐表';",
        "DROP TABLE IF EXISTS `app_plan_coupons`;",
        "CREATE TABLE `app_plan_coupons`( `id` int primary key auto_increment comment '主键', `plan_id` int comment '所属套餐ID', `coupon` varchar(32) comment '卡密', `is_used` tinyint(1) default 0 comment '是否已使用|0未使用|1已使用', `created_at` datetime comment '创建时间', `used_at` datetime comment '使用时间') ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT '套餐卡密表';",
        "DROP TABLE IF EXISTS `app_user`;",
        " CREATE TABLE `app_user`( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', `username` varchar(20) comment '用户名', `password` varchar(32) comment '密码', `cookie` varchar(32) comment 'Cookie', `salt` varchar(128) comment '密码盐', `email` varchar(32) comment '邮箱', `plans` int default 0 comment '会员状态|0未开通|1正常|2已过期', `plans_id` int comment '套餐ID', `plans_name` varchar(32) default 0 comment '会员名称', `chat_limit` varchar(10) default 0 comment '对话额度', `effective_at` datetime comment '生效时间', `expires_at` datetime comment '过期时间', PRIMARY KEY (`id`)) ENGINE = InnoDB DEFAULT CHARSET = utf8 COMMENT ='用户表';",
        "ALTER TABLE `app_user` AUTO_INCREMENT = 100;",
        "DROP TABLE IF EXISTS `payment_config`;",
        " CREATE TABLE `payment_config`( `pay_branch` int default 0 comment '支付渠道选择[0官方|1易支付]', `wx_mchid` varchar(128) comment '微信支付mchid', `wx_appid` varchar(128) comment '微信公众账号ID', `wx_key` varchar(255) comment '微信支付API密钥', `cert_route` varchar(128) comment '微信商户API证书文件路径', `key_route` varchar(128) comment '微信API证书密钥文件路径', `ali_appid` varchar(128) comment '支付宝应用ID', `ali_private_key` text comment '支付宝商户私钥', `ali_public_key` text comment '支付宝商户公钥', `epay_api_url` varchar(255) comment '易支付API地址', `epay_appid` varchar(128) comment '易支付商户ID', `epay_key` varchar(255) comment '易支付商户密钥') ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='支付配置表';",
        "insert into payment_config(pay_branch, wx_mchid, wx_appid, wx_key, cert_route, key_route, ali_appid, ali_private_key, ali_public_key, epay_api_url, epay_appid, epay_key) values (0, '', '', '', '', '', '', '', '', '', '', '');",
        "ALTER TABLE `app_web` 
ADD COLUMN `APPID` varchar(20) DEFAULT NULL COMMENT '快捷登录APPID', 
ADD COLUMN `APPKEY` varchar(50) DEFAULT NULL COMMENT '快捷登录APPKEY', 
ADD COLUMN `wx` int(1) NOT NULL DEFAULT '0' COMMENT '微信开关', 
ADD COLUMN `qq` int(1) NOT NULL DEFAULT '0' COMMENT 'QQ登录开关', 
ADD COLUMN `zfb` int(1) NOT NULL DEFAULT '0' COMMENT '支付宝登录开关';",
"
ALTER TABLE `app_user` MODIFY COLUMN `username` varchar(50) NOT NULL COMMENT '用户名';
"
];

















