* @version : HUOSDK-mp */ namespace huomp\model\hour; use huo\model\log\LogModel; class DayHourLogModel extends LogModel { protected $name = 'day_hour'; protected $pk = 'id'; protected $table_date = ''; protected $table_prefix = ''; protected $partition_data = []; protected $partition_field = 'date'; protected $partition_rule = ['type' => 'month', 'expr' => 1]; protected $type = [ 'id' => 'integer', 'date' => 'string', 'hour_key' => 'integer', 'mem_id' => 'string', 'agent_id' => 'integer', 'app_id' => 'integer', 'reg_time' => 'integer', 'reg_days' => 'integer', 'reg_hour_key' => 'integer', 'game_reg_time' => 'integer', 'game_reg_days' => 'integer', 'game_reg_hour_key' => 'integer', 'login_cnt' => 'integer', 'sum_money' => 'float', 'sum_real_money' => 'float', 'order_cnt' => 'integer', ]; /** * LogModel constructor. * * @param array $data */ public function __construct($data = []) { $_db_conf = []; if (file_exists(GLOBAL_CONF_PATH.'database_log.php')) { $_db_conf = include GLOBAL_CONF_PATH.'database_log.php'; } $this->connection = $_db_conf; parent::db(); parent::__construct($data); } public function getFieldType() { return $this->type; } /** * 生成表 * * @param int $create_time * * @return bool|int */ function checkTable($create_time = 0) { $_time = !empty($create_time) ? $create_time : time(); $this->partition_data[$this->partition_field] = date('Y-m-d', $_time); $this->table = $this->getPartitionTableName( $this->partition_data, $this->partition_field, $this->partition_rule ); $_sql = "CREATE TABLE IF NOT EXISTS `$this->table` ("; $_sql .= " `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',"; $_sql .= " `date` date NOT NULL DEFAULT '2020-11-01' COMMENT '日期',"; $_sql .= " `hour_key` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '时间KEY值 1~24',"; $_sql .= " `mem_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '玩家id',"; $_sql .= " `agent_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '归属渠道',"; $_sql .= " `app_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '游戏ID',"; $_sql .= " `reg_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '玩家注册时间',"; $_sql .= " `reg_days` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '注册天数',"; $_sql .= " `reg_hour_key` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '注册时间key 1~24',"; $_sql .= " `game_reg_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '玩家注册时间',"; $_sql .= " `game_reg_days` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '注册天数',"; $_sql .= " `game_reg_hour_key` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '注册时间key 1~24',"; $_sql .= " `login_cnt` int(11) unsigned NOT NULL DEFAULT '1' COMMENT '打开次数',"; $_sql .= " `sum_money` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '累计充值',"; $_sql .= " `sum_real_money` decimal(12,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '累计真实充值',"; $_sql .= " `order_cnt` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '订单数量',"; $_sql .= " PRIMARY KEY (`id`),"; $_sql .= " UNIQUE KEY `dh_date_mem_app_device_unique` (`date`,`hour_key`,`mem_id`,`app_id`),"; $_sql .= " KEY `dh_mem_index` (`mem_id`),"; $_sql .= " KEY `dh_game_index` (`app_id`)"; $_sql .= " ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='每时统计表';"; return $this->execute($_sql); } }