| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 | 
							- <?php
 
- /**
 
-  * DayMemLogModel.php UTF-8
 
-  * 玩家每日数据_切量
 
-  *
 
-  * @date    : 2018/5/31 10:58
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : chenbingling<cbl@huosdk.com>
 
-  * @version : HUOSDK 8.0
 
-  */
 
- namespace huo\model\log;
 
- class DmlSwitchModel extends LogModel {
 
-     protected $name = 'ldm_switch';
 
-     /**
 
-      * @param array $where
 
-      *                    date
 
-      *                    mem_id
 
-      *                    app_id
 
-      *
 
-      * @return array|bool|false
 
-      */
 
-     public function getDetail($where) {
 
-         $_map['date'] = isset($where['date']) ? $where['date'] : date('Y-m-d');
 
-         $_map['mem_id'] = isset($where['mem_id']) ? $where['mem_id'] : 0;
 
-         $_map['app_id'] = isset($where['app_id']) ? $where['app_id'] : 0;
 
-         $_data = $this->computeTable($_map['date'])->where($_map)->find();
 
-         if (is_object($_data)) {
 
-             $_data = $_data->toArray();
 
-         }
 
-         if (empty($_data)) {
 
-             return false;
 
-         }
 
-         return $_data;
 
-     }
 
-     /**
 
-      * 计算总登陆次数
 
-      *
 
-      * @param $where
 
-      *
 
-      * @return float|int
 
-      */
 
-     public function getSumLoginCnt($where) {
 
-         $_map['date'] = isset($where['date']) ? $where['date'] : date('Y-m-d');
 
-         $_map['mem_id'] = isset($where['mem_id']) ? $where['mem_id'] : 0;
 
-         $_sum_login_cnt = $this->computeTable($_map['date'])->where($_map)->sum('login_cnt');
 
-         if (empty($_sum_login_cnt)) {
 
-             return 0;
 
-         }
 
-         return $_sum_login_cnt;
 
-     }
 
-     /**
 
-      * @param      $data
 
-      * @param bool $replace
 
-      * @param bool $get_last_insert_id
 
-      *
 
-      * @return bool|int|string
 
-      */
 
-     public function insertLog($data, $replace = true, $get_last_insert_id = true) {
 
-         return parent::insertLog($data, $replace, $get_last_insert_id);
 
-     }
 
-     /**
 
-      * 更新每日玩家表
 
-      *
 
-      * @param array $data
 
-      *
 
-      * @param int   $id 主键ID
 
-      *
 
-      * @return bool
 
-      */
 
-     public function updateLog($data, $id) {
 
-         $_map['id'] = $id;
 
-         if (false === $this->computeTable($data['date'])->where($_map)->update($data)) {
 
-             return false;
 
-         } else {
 
-             return true;
 
-         }
 
-     }
 
-     /**
 
-      * 删除每日玩家表
 
-      *
 
-      * @param int    $mem_id 玩家id
 
-      *
 
-      * @param string $date   日期
 
-      *
 
-      * @return bool
 
-      */
 
-     public function deleteLog($mem_id, $date) {
 
-         $_map['date'] = $mem_id;
 
-         $_map['mem_id'] = $date;
 
-         if (false === $this->computeTable($date)->where($_map)->delete()) {
 
-             return false;
 
-         } else {
 
-             return true;
 
-         }
 
-     }
 
-     /**
 
-      * 创建表
 
-      *
 
-      * @return int
 
-      * @throws \think\db\exception\BindParamException
 
-      * @throws \think\exception\PDOException
 
-      */
 
-     function checkTable() {
 
-         $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) NOT NULL AUTO_INCREMENT COMMENT '',";
 
-         $_sql .= "  `date` date NOT NULL COMMENT '日期',";
 
-         $_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)  NOT NULL DEFAULT '0' COMMENT '注册天数',";
 
-         $_sql .= "  `role_days` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创角天数',";
 
-         $_sql .= "  `device_id` varchar(64) NOT NULL DEFAULT '' COMMENT '手机设备码',";
 
-         $_sql .= "  `device_cnt` int(11) NOT NULL DEFAULT '1' COMMENT '登陆的设备个数',";
 
-         $_sql .= "  `login_cnt` int(11) NOT NULL DEFAULT '1' COMMENT '登陆次数',";
 
-         $_sql .= "  `sum_money` decimal(20,2) NOT NULL DEFAULT '0.00' COMMENT '累计充值',";
 
-         $_sql .= "  `sum_real_money` decimal(20,2) NOT NULL DEFAULT '0.00' COMMENT '累计真实充值',";
 
-         $_sql .= "  `first_pay_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '第一笔充值时间',";
 
-         $_sql .= "  `last_pay_time` bigint(20) NOT NULL DEFAULT '0' COMMENT '最近充值时间',";
 
-         $_sql .= "  `last_money` decimal(20,2) NOT NULL DEFAULT '0.00' COMMENT '最近充值金额',";
 
-         $_sql .= "  `order_cnt` int(20) unsigned NOT NULL DEFAULT '0' COMMENT '订单数量',";
 
-         $_sql .= "  `order_suc_cnt` int(20) unsigned NOT NULL DEFAULT '0' COMMENT '支付成功订单数量',";
 
-         $_sql .= "  `last_login_ip` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '玩家最近登陆ip',";
 
-         $_sql .= "  `auth_cnt` int(11) NOT NULL DEFAULT '0' COMMENT '授权登陆次数',";
 
-         $_sql .= "  `is_cpa` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '是否计算cpa 1 否 2是',";
 
-         $_sql .= "  `is_auth` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '是否第三方注册 1 否 2是',";
 
-         $_sql .= "  `reg_app_id` int(11) NOT NULL DEFAULT '0' COMMENT '注册游戏ID',";
 
-         $_sql .= "  PRIMARY KEY (`id`),";
 
-         $_sql .= "  UNIQUE KEY `ldm_date_mem_app_unique` (`date`,`mem_id`,`app_id`),";
 
-         $_sql .= "  KEY `ldm_ip_index` (`last_login_ip`),";
 
-         $_sql .= "  KEY `ldm_mem_index` (`mem_id`)";
 
-         $_sql .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='玩家每日';";
 
-         return $this->execute($_sql);
 
-     }
 
- }
 
 
  |