/*
 Navicat Premium Data Transfer

 Source Server         : Mini线上数据库
 Source Server Type    : MySQL
 Source Server Version : 50732
 Source Host           : rm-2ze0x6dhwun8z2637o.mysql.rds.aliyuncs.com:3306
 Source Schema         : minigame

 Target Server Type    : MySQL
 Target Server Version : 50732
 File Encoding         : 65001

 Date: 18/05/2021 10:28:12
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for adinfo
-- ----------------------------
DROP TABLE IF EXISTS `adinfo`;
CREATE TABLE `adinfo`  (
  `firmId` int(10) NOT NULL COMMENT '平台id',
  `ratio` int(10) NOT NULL COMMENT '分成比例 范围 1- 100',
  `todayEcpm` int(10) NULL DEFAULT NULL COMMENT '当前平台的 ecpm  （指广告端当日的千次视频展示获得的收入）',
  `yesterdayEcpm` int(10) NULL DEFAULT NULL COMMENT '昨天的ecpm',
  `recordTime` int(10) NULL DEFAULT NULL COMMENT '最后一次记录时间',
  PRIMARY KEY (`firmId`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `name` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `pwd` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `lastLoginTime` int(11) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for everyday
-- ----------------------------
DROP TABLE IF EXISTS `everyday`;
CREATE TABLE `everyday`  (
  `id` bigint(20) NOT NULL,
  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `stime` int(11) NULL DEFAULT NULL,
  `headurl` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for gaincash
-- ----------------------------
DROP TABLE IF EXISTS `gaincash`;
CREATE TABLE `gaincash`  (
  `id` int(10) NOT NULL,
  `gameId` int(10) NULL DEFAULT NULL,
  `source` int(10) NULL DEFAULT NULL,
  `type` int(10) NULL DEFAULT NULL,
  `money` int(10) NULL DEFAULT NULL,
  `recordTime` int(12) NULL DEFAULT NULL
) ENGINE = InnoDB AUTO_INCREMENT = 2566 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for moneyrecord
-- ----------------------------
DROP TABLE IF EXISTS `moneyrecord`;
CREATE TABLE `moneyrecord`  (
  `id` int(10) NOT NULL COMMENT '玩家ID',
  `opType` int(10) NULL DEFAULT NULL COMMENT '操作类型1-获得 2-支付',
  `itemType` int(10) NULL DEFAULT NULL COMMENT '1-钻石 2-红包券 3-经验',
  `changeCount` int(10) NULL DEFAULT NULL COMMENT '变化的数量',
  `lastCount` int(10) NULL DEFAULT NULL COMMENT '最新的数量',
  `recordTime` int(11) NULL DEFAULT NULL COMMENT '记录时间'
) ENGINE = InnoDB AUTO_INCREMENT = 45162 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for player
-- ----------------------------
DROP TABLE IF EXISTS `player`;
CREATE TABLE `player`  (
  `id` int(11) NOT NULL,
  `data` json NULL,
  `lastRecordTime` int(11) NULL DEFAULT NULL COMMENT '最后一次刷新记录时间',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for rewardcenter
-- ----------------------------
DROP TABLE IF EXISTS `rewardcenter`;
CREATE TABLE `rewardcenter`  (
  `itemId` int(10) NOT NULL COMMENT '道具id',
  `type` int(10) NULL DEFAULT NULL COMMENT '1-种植园 2-养殖场 3-商店',
  `curCount` int(10) NULL DEFAULT NULL COMMENT '今日当前数量',
  `allCount` int(10) NULL DEFAULT NULL COMMENT '每日总的数量'
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for serverinfo
-- ----------------------------
DROP TABLE IF EXISTS `serverinfo`;
CREATE TABLE `serverinfo`  (
  `userVersion` int(10) NULL DEFAULT NULL
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '当前的用户数据版本' ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `account` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `pwd` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `name` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `loginType` int(10) NULL DEFAULT NULL COMMENT '1-本地登陆  2-微信登陆',
  `accountStatus` int(10) NULL DEFAULT NULL COMMENT '1-正常状态 2-白名单 3-灰名单 4-黑名单',
  `token` char(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `regTime` int(11) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 100277 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Table structure for warning
-- ----------------------------
DROP TABLE IF EXISTS `warning`;
CREATE TABLE `warning`  (
  `id` int(10) NOT NULL,
  `type` int(10) NULL DEFAULT NULL,
  `recordTime` int(12) NULL DEFAULT NULL
) ENGINE = InnoDB AUTO_INCREMENT = 34 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Procedure structure for ADCount
-- ----------------------------
DROP PROCEDURE IF EXISTS `ADCount`;
delimiter ;;
CREATE PROCEDURE `ADCount`()
BEGIN
	DECLARE adCount int default 0;
	DECLARE i INT DEFAULT 0;
	select json_length(JSON_EXTRACT(player.data,'$.allAdInfo')) from player where player.id = 100000 into adCount;
	
	WHILE i < adCount DO
		select JSON_EXTRACT(JSON_EXTRACT(player.data,'$.allAdInfo'), '$[1].count') as a1 from player where player.id = 100000;
		set i = i + 1;
	END WHILE;

END
;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;
