123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <?php
- if (!function_exists('tablename_sql')) {
- function tablename_sql($name)
- {
- return config('database.connections.mysql.prefix') . '' . $name;
- }
- }
- if (!function_exists('fieldexists_sql')) {
- function fieldexists_sql($tablename_sql, $fieldname, $ispre = false)
- {
- $fields = \think\facade\Db::query("SHOW COLUMNS FROM " . ($ispre ? $tablename_sql : tablename_sql($tablename_sql)));
- if (empty($fields)) {
- return false;
- }
- foreach ($fields as $field) {
- if ($fieldname === $field['Field']) {
- return true;
- }
- }
- return false;
- }
- }
- function check_sql($tablename_sql, $id, $ispre = false)
- {
- $fields = \think\facade\Db::query("SELECT * FROM " . ($ispre ? $tablename_sql : tablename_sql($tablename_sql)) ." where id=" .$id);
- if (empty($fields)) {
- return false;
- }
- return true;
- }
- if (!function_exists('execute_db_sql')) {
- function execute_db_sql($sql)
- {
- return \think\facade\Db::execute($sql);
- }
- }
- if (!function_exists('query__db_sql')) {
- function query__db_sql($sql)
- {
- return \think\facade\Db::query($sql);
- }
- }
- if(!check_sql('admin_menu','123')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (123, 'AI绘画', '', '_iframe', '', 1, 4, 1, 1, 'layui-icon layui-icon-tree', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- if(!check_sql('admin_menu','124')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (124, '艺术画展', '/admin/painting/gallery/index.html', '_iframe', '', 1, 0, 123, 1, '', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- if(!check_sql('admin_menu','125')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (125, '文案词条', '/admin/painting/words/index.html', '_iframe', '', 1, 0, 123, 1, '', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- if(!check_sql('admin_menu','128')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (128, '入驻订单', '/admin/commission/settle.html', '_iframe', '', 1, 0, 90, 1, '', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- if(!check_sql('admin_menu','129')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (129, '模型', '/admin/painting/models/index.html', '_iframe', '', 1, 0, 123, 1, '', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- if(!check_sql('admin_menu','130')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (130, '会员', '/admin/vipinfo/index.html', '_iframe', '', 1, 0, 91, 1, '', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- if(!check_sql('admin_menu','131')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (131, '分销海报', '/admin/commission/poster.html', '_iframe', '', 1, 0, 90, 1, '', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- if(!check_sql('admin_menu','132')){
- query__db_sql("insert into " . tablename_sql('admin_menu') . "
- (`id`, `name`, `href`, `open_type`, `rule`, `is_menu`, `sort`, `pid`, `is_show`, `icon`, `des`, `create_time`, `update_time`, `delete_time`) VALUES
- (132, '四方支付', '/admin/conf/system/yipay.html', '_iframe', '', 1, 0, 35, 1, '', NULL, '2023-03-08 13:18:12', '2023-03-08 13:18:12', NULL)
- ");
- }
- query__db_sql("CREATE TABLE IF NOT EXISTS " . tablename_sql("gallery") . "(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `uniacid` int(10) UNSIGNED NOT NULL,
- `status` tinyint(1) NOT NULL DEFAULT '2' COMMENT '状态.2=锁定,1=正常,默认:2 ',
- `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序,从大到小,倒叙排序 ',
- `create_time` datetime NOT NULL,
- `update_time` datetime NOT NULL,
- `delete_time` datetime DEFAULT NULL,
- `uid` int(11) UNSIGNED NOT NULL,
- `job_id` varchar(64) NOT NULL COMMENT '任务ID ',
- `prompt` text COMMENT '描述词',
- `img` varchar(32) DEFAULT NULL COMMENT '图片',
- `paid_coin` varchar(64) NOT NULL COMMENT '支付的金币',
- `mode` varchar(32) DEFAULT NULL COMMENT '文生图或图生图',
- `origin_url` varchar(500) DEFAULT NULL COMMENT '原始路径',
- `engine` varchar(32) DEFAULT NULL COMMENT '引擎',
- `api_id` int(11) DEFAULT 0 COMMENT 'api_id',
- `model_id` varchar(128) DEFAULT NULL COMMENT '模型id',
- `width` int(11) DEFAULT 0 COMMENT '宽',
- `height` int(11) DEFAULT 0 COMMENT '高',
- `seed` varchar(128) DEFAULT NULL COMMENT '种子',
- `steps` int(5) DEFAULT 0 COMMENT '步数',
- `n_samples` int(2) DEFAULT 0 COMMENT '张数',
- `scheduler` varchar(128) DEFAULT NULL COMMENT '采样器',
- `mj_id` varchar(32) DEFAULT NULL COMMENT 'mj id',
- `mj_hash` varchar(128) DEFAULT NULL COMMENT 'mj hash',
- `done` tinyint(1) DEFAULT 0 COMMENT 'done',
- `uuid` varchar(128) DEFAULT NULL COMMENT 'uuid',
- `is_open` tinyint(1) DEFAULT 0 COMMENT '是否公开',
- `mj_action` varchar(128) DEFAULT NULL COMMENT 'mj action',
- `pid` int(11) DEFAULT 0 COMMENT 'pid',
- `real_prompt` varchar(2000) DEFAULT NULL COMMENT 'real_prompt',
- PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
- ");
- query__db_sql("CREATE TABLE IF NOT EXISTS " . tablename_sql("commission_settle") . "(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `uid` int(10) UNSIGNED NOT NULL DEFAULT '0',
- `uniacid` int(10) UNSIGNED NOT NULL DEFAULT '0',
- `create_time` datetime NOT NULL,
- `update_time` datetime NOT NULL,
- `order_number` varchar(32) NOT NULL COMMENT '订单编号',
- `paid` tinyint(1) NOT NULL DEFAULT '0' COMMENT '支付状态 0: 未支付 1:已支付',
- `pay_price` decimal(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '支付金额',
- `pay_type` varchar(32) DEFAULT NULL COMMENT '支付方式',
- `pay_time` int(10) DEFAULT '0' COMMENT '确认支付完成时间',
- `real_name` varchar(32) DEFAULT NULL COMMENT '姓名',
- `telnum` varchar(32) DEFAULT NULL COMMENT '手机号',
- PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
- ");
- query__db_sql("CREATE TABLE IF NOT EXISTS " . tablename_sql("words") . "(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `uniacid` int(10) UNSIGNED NOT NULL,
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态.2=锁定,1=正常,默认:1 ',
- `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序,从大到小,倒叙排序 ',
- `create_time` datetime NOT NULL,
- `update_time` datetime NOT NULL,
- `delete_time` datetime DEFAULT NULL,
- `type` varchar(32) NOT NULL DEFAULT 'word' COMMENT '类型,句子或词',
- `name` varchar(500) NOT NULL COMMENT '名称',
- `guide` varchar(2000) DEFAULT NULL COMMENT '引导',
- PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
- ");
- query__db_sql("CREATE TABLE IF NOT EXISTS " . tablename_sql("models") . "(
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `uniacid` int(10) UNSIGNED NOT NULL,
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态.2=锁定,1=正常,默认:1 ',
- `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序,从大到小,倒叙排序 ',
- `create_time` datetime NOT NULL,
- `update_time` datetime NOT NULL,
- `delete_time` datetime DEFAULT NULL,
- `name` varchar(500) NOT NULL COMMENT '名称',
- `intro` varchar(2000) DEFAULT NULL,
- `imgs` varchar(128) DEFAULT NULL,
- `coin` int(10) DEFAULT 0,
- `code` varchar(32) DEFAULT NULL,
- `model_id` varchar(128) NOT NULL,
- `type` varchar(32) DEFAULT NULL,
- `engine` varchar(32) DEFAULT NULL,
- `lora` varchar(128) DEFAULT NULL,
- `version` varchar(32) DEFAULT NULL,
- PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
- ");
- query__db_sql("CREATE TABLE IF NOT EXISTS " . tablename_sql("vipinfo") . "(
- `uid` int(11) NOT NULL DEFAULT 0,
- `uniacid` int(10) UNSIGNED NOT NULL,
- `create_time` datetime NOT NULL,
- `update_time` datetime NOT NULL,
- `order_number` varchar(32) DEFAULT NULL,
- `member_id` int(11) NOT NULL DEFAULT 0,
- `gpt35_times` int(11) NOT NULL DEFAULT 0,
- `gpt4_times` int(11) NOT NULL DEFAULT 0,
- `sd_times` int(11) NOT NULL DEFAULT 0,
- `mj_times` int(11) NOT NULL DEFAULT 0,
- `gpt35_type` varchar(32) NOT NULL DEFAULT 'time',
- `gpt4_type` varchar(32) NOT NULL DEFAULT 'time',
- `sd_type` varchar(32) NOT NULL DEFAULT 'time',
- `mj_type` varchar(32) NOT NULL DEFAULT 'time',
- PRIMARY KEY (`uid`) ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4;
- ");
- if (!fieldexists_sql('user', 'account')) {
- query__db_sql("ALTER TABLE " . tablename_sql('user') . " ADD `account` varchar(100);");
- }
- if (!fieldexists_sql('commission_user', 'real_name')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_user') . " ADD `real_name` varchar(64) DEFAULT NULL COMMENT '真实姓名';");
- }
- if (!fieldexists_sql('commission_user', 'qrcode_wechat')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_user') . " ADD `qrcode_wechat` varchar(128) DEFAULT NULL COMMENT '收款码';");
- }
- if (!fieldexists_sql('commission_user', 'alipay')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_user') . " ADD `alipay` varchar(128) DEFAULT NULL COMMENT '支付宝';");
- }
- if (!fieldexists_sql('commission_team', 'gfid')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_team') . " ADD `gfid` int(10) DEFAULT 0 ;");
- }
- if (!fieldexists_sql('commission_user', 'telnum')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_user') . " ADD `telnum` varchar(32) DEFAULT NULL ;");
- }
- if (!fieldexists_sql('commission_user', 'paid')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_user') . " ADD `paid` int(10) DEFAULT 1 ;");
- }
- if (!fieldexists_sql('commission_income', 'oid')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_income') . " ADD `oid` int(10) DEFAULT 0 ;");
- }
- if (!fieldexists_sql('commission_income', 'buy_uid')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_income') . " ADD `buy_uid` int(10) DEFAULT 0 ;");
- }
- if (!fieldexists_sql('commission_income', 'buy_price')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_income') . " ADD `buy_price` decimal(8,2) NOT NULL DEFAULT '0.00';");
- }
- if (!fieldexists_sql('commission_settle', 'real_name')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_settle') . " ADD `real_name` varchar(32) DEFAULT NULL;");
- }
- if (!fieldexists_sql('commission_settle', 'telnum')) {
- query__db_sql("ALTER TABLE " . tablename_sql('commission_settle') . " ADD `telnum` varchar(32) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'origin_url')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `origin_url` varchar(500) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'imgs')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `imgs` varchar(128) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'uuid')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `uuid` varchar(128) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'engine')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `engine` varchar(32) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'api_id')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `api_id` int(11) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'model_id')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `model_id` varchar(128) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'width')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `width` int(11) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'height')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `height` int(11) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'seed')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `seed` varchar(128) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'steps')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `steps` int(5) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'n_samples')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `n_samples` int(2) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'scheduler')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `scheduler` varchar(128) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'mj_id')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `mj_id` varchar(32) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'mj_hash')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `mj_hash` varchar(128) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'done')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `done` tinyint(1) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'is_open')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `is_open` tinyint(1) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'mj_action')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `mj_action` varchar(128) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'pid')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `pid` int(1) DEFAULT 0;");
- }
- if (!fieldexists_sql('gallery', 'real_prompt')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `real_prompt` varchar(2000) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'mj_api_engine')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `mj_api_engine` varchar(32) DEFAULT NULL;");
- }
- if (!fieldexists_sql('gallery', 'mj_index')) {
- query__db_sql("ALTER TABLE " . tablename_sql('gallery') . " ADD `mj_index` int(1) DEFAULT 0;");
- }
- if (!fieldexists_sql('words', 'guide')) {
- query__db_sql("ALTER TABLE " . tablename_sql('words') . " ADD `guide` varchar(2000) DEFAULT NULL;");
- }
- if (!fieldexists_sql('bill', 'is_time')) {
- query__db_sql("ALTER TABLE " . tablename_sql('bill') . " ADD `is_time` tinyint(1) NOT NULL DEFAULT 0;");
- }
- if (!fieldexists_sql('member', 'gpt35_times')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `gpt35_times` int(11) NOT NULL DEFAULT 0;");
- }
- if (!fieldexists_sql('member', 'gpt4_times')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `gpt4_times` int(11) NOT NULL DEFAULT 0;");
- }
- if (!fieldexists_sql('member', 'sd_times')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `sd_times` int(11) NOT NULL DEFAULT 0;");
- }
- if (!fieldexists_sql('member', 'mj_times')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `mj_times` int(11) NOT NULL DEFAULT 0;");
- }
- if (!fieldexists_sql('member', 'gpt35_type')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `gpt35_type` varchar(32) NOT NULL DEFAULT 'time';");
- }
- if (!fieldexists_sql('member', 'gpt4_type')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `gpt4_type` varchar(32) NOT NULL DEFAULT 'time';");
- }
- if (!fieldexists_sql('member', 'sd_type')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `sd_type` varchar(32) NOT NULL DEFAULT 'time';");
- }
- if (!fieldexists_sql('member', 'mj_type')) {
- query__db_sql("ALTER TABLE " . tablename_sql('member') . " ADD `mj_type` varchar(32) NOT NULL DEFAULT 'time';");
- }
|