begin;

CREATE TABLE `t_orderid` (
  `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
  `request` mediumblob COMMENT 'request',
  `confirmed` int(11) NOT NULL DEFAULT '0' COMMENT '是否已确认',
  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `t_inapp_record` (
  `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
  `amount` double NOT NULL DEFAULT '0' COMMENT '充值总额',
  `buy_times` int(11) NOT NULL DEFAULT '0' COMMENT '充值次数',
  `amount_ok` double NOT NULL DEFAULT '0' COMMENT '充值成功总额',
  `buy_ok_times` int(11) NOT NULL DEFAULT '0' COMMENT '充值成功次数',
  `daytime` int(11) NOT NULL DEFAULT '0' COMMENT '时间',
  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `t_inapp_order` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id',
  `sp_order_id` varchar(64) DEFAULT NULL COMMENT 'app store order_id',
  `platform` int(11) NOT NULL DEFAULT '0' COMMENT '0: ios 1: android',
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '申请账号id',
  `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品id',
  `price` double NOT NULL DEFAULT '0' COMMENT '价格',
  `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  UNIQUE KEY `order_id` (`order_id`),
  UNIQUE KEY `platform_sp_order_id` (`platform`, `sp_order_id`),
  KEY `account_id` (`account_id`),
  KEY `sp_order_id` (`sp_order_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `t_outapp_order` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `order_id` varchar(60) NOT NULL DEFAULT '' COMMENT '订单id',
  `sp_order_id` varchar(64) DEFAULT NULL COMMENT 'app store order_id',
  `platform` int(11) NOT NULL DEFAULT '0' COMMENT '0: ios 1: android',
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '申请账号id',
  `address` varchar(60) DEFAULT NULL COMMENT '申请时账号绑定的钱包',
  `goods_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品id',
  `price` double NOT NULL DEFAULT '0' COMMENT '价格',
  `params` mediumblob COMMENT 'params',
  `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  UNIQUE KEY `order_id` (`order_id`),
  UNIQUE KEY `platform_sp_order_id` (`platform`, `sp_order_id`),
  KEY `account_id` (`account_id`),
  KEY `address` (`address`),
  KEY `sp_order_id` (`sp_order_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `t_mall` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id',
  `goods_uuid` varchar(255) NOT NULL DEFAULT '' COMMENT '商品uuid',
  `seller` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller',
  `seller_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'seller_address',
  `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品id',
  `item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量',
  `currency` varchar(60) NOT NULL COMMENT 'currency',
  `price` varchar(255) NOT NULL DEFAULT '' COMMENT 'price',
  `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
  `last_buy_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次购买时间',
  `last_buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '最后一次购买者',
  `last_modify_price_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次修改价格事件',
  `buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '购买成功者',
  `buy_ok_time` int(11) NOT NULL DEFAULT '0' COMMENT '购买成功时间',
  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  KEY `seller` (`seller`),
  KEY `seller_address` (`seller_address`),
  KEY `price` (`price`),
  UNIQUE KEY `order_id` (`order_id`),
  UNIQUE KEY `goods_uuid` (`goods_uuid`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `t_market` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id',
  `order_id` varchar(255) NOT NULL DEFAULT '' COMMENT '订单id',
  `token_id` varchar(60) NOT NULL COMMENT 'token_id',
  `seller` varchar(60) NOT NULL COMMENT 'owner',
  `buyer` varchar(60) NOT NULL COMMENT 'owner',
  `nft_token` varchar(60) NOT NULL COMMENT 'nft_token',
  `amount` varchar(255) NOT NULL DEFAULT '' COMMENT 'amount',
  `currency` varchar(60) NOT NULL COMMENT 'currency',
  `price` varchar(255) NOT NULL DEFAULT '' COMMENT 'price',
  `update_price` varchar(255) COMMENT 'update_price',
  `update_time` int(11) COMMENT 'update_time',
  `c_name` varchar(32) NOT NULL DEFAULT '' COMMENT '缓存-名称',
  `c_job` int(11) NOT NULL DEFAULT '0' COMMENT '缓存-职业',
  `c_type` int(11) NOT NULL DEFAULT '0' COMMENT '缓存-碎片类型',
  `c_lv` int(11) NOT NULL DEFAULT '0' COMMENT '缓存-级别',
  `c_quality` int(11) NOT NULL DEFAULT '0' COMMENT '缓存-品阶',
  `c_durability` float NOT NULL DEFAULT '0' COMMENT '缓存-能量',
  `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status',
  `activated` int(11) NOT NULL DEFAULT '0' COMMENT 'activated',
  `selltime` int(11) COMMENT 'selltime',
  `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  UNIQUE KEY `order_id` (`order_id`),
  KEY `seller_activated` (`seller`, `activated`),
  KEY `activated` (`activated`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

insert into version (version) values(2023081501);

commit;
