|
@@ -5,10 +5,11 @@ namespace app\v1\logic\tool;
|
|
|
|
|
|
|
|
use support\think\Db;
|
|
use support\think\Db;
|
|
|
|
|
|
|
|
-class BaseTotalHourLogic
|
|
|
|
|
|
|
+class BaseTotalHourLogic extends BaseLogic
|
|
|
{
|
|
{
|
|
|
protected string $table = "base_total_hour";
|
|
protected string $table = "base_total_hour";
|
|
|
- protected string $group = 'game_id, agent_id, site_id';
|
|
|
|
|
|
|
+
|
|
|
|
|
+ protected string $group = 'game_id, agent_id, site_id, tdate, thour';
|
|
|
|
|
|
|
|
protected array $data;
|
|
protected array $data;
|
|
|
|
|
|
|
@@ -81,9 +82,7 @@ class BaseTotalHourLogic
|
|
|
|
|
|
|
|
$this->mediaCost();
|
|
$this->mediaCost();
|
|
|
|
|
|
|
|
- $this->siteAuth();
|
|
|
|
|
-
|
|
|
|
|
- $this->replaceData();
|
|
|
|
|
|
|
+ $this->replaceData(['tdate'=>$this->date, 'thour'=>$this->hour]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
protected function regData()
|
|
protected function regData()
|
|
@@ -92,11 +91,11 @@ class BaseTotalHourLogic
|
|
|
$eTime = strtotime("{$this->date} {$this->hour}:59:59");
|
|
$eTime = strtotime("{$this->date} {$this->hour}:59:59");
|
|
|
|
|
|
|
|
$regTotalTb = "sdk_reg_log_" . date('Ym', strtotime($this->date));
|
|
$regTotalTb = "sdk_reg_log_" . date('Ym', strtotime($this->date));
|
|
|
- $filed = "{$this->group}, count(distinct uid) as reg_total, count(distinct imei) as reg_dev";
|
|
|
|
|
|
|
+ $filed = "game_id, agent_id, site_id, '{$this->date}' as tdate, '{$this->hour}' as thour, count(distinct uid) as reg_total, count(distinct imei) as reg_dev";
|
|
|
$where = [
|
|
$where = [
|
|
|
['reg_time', 'between', [$sTime, $eTime]],
|
|
['reg_time', 'between', [$sTime, $eTime]],
|
|
|
];
|
|
];
|
|
|
- $result = Db::connect('db_data_report')->table($regTotalTb)->field($filed)->where($where)->group($this->group)->select();
|
|
|
|
|
|
|
+ $result = Db::connect('db_game_log')->table($regTotalTb)->field($filed)->where($where)->group($this->group)->select();
|
|
|
$this->pushData($result);
|
|
$this->pushData($result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -106,7 +105,7 @@ class BaseTotalHourLogic
|
|
|
$eTime = strtotime("{$this->date} {$this->hour}:59:59");
|
|
$eTime = strtotime("{$this->date} {$this->hour}:59:59");
|
|
|
|
|
|
|
|
$loginTb = "sdk_login_log_" . date('Ym', strtotime($this->date));
|
|
$loginTb = "sdk_login_log_" . date('Ym', strtotime($this->date));
|
|
|
- $filed = "{$this->group},count(distinct uid) as login_total";
|
|
|
|
|
|
|
+ $filed = "game_id, agent_id, site_id, '{$this->date}' as tdate, '{$this->hour}' as thour,count(distinct uid) as login_total";
|
|
|
$where = [
|
|
$where = [
|
|
|
['login_time', 'between', [$sTime, $eTime]],
|
|
['login_time', 'between', [$sTime, $eTime]],
|
|
|
];
|
|
];
|
|
@@ -120,12 +119,12 @@ class BaseTotalHourLogic
|
|
|
$eTime = strtotime("{$this->date} {$this->hour}:59:59");
|
|
$eTime = strtotime("{$this->date} {$this->hour}:59:59");
|
|
|
|
|
|
|
|
$loginTb = "sdk_login_log_" . date('Ym', strtotime($this->date));
|
|
$loginTb = "sdk_login_log_" . date('Ym', strtotime($this->date));
|
|
|
- $filed = "{$this->group},count(distinct uid) as old_login_total";
|
|
|
|
|
|
|
+ $filed = "game_id, agent_id, site_id, '{$this->date}' as tdate, '{$this->hour}' as thour,count(distinct uid) as old_login_total";
|
|
|
$where = [
|
|
$where = [
|
|
|
['login_time', 'between', [$sTime, $eTime]],
|
|
['login_time', 'between', [$sTime, $eTime]],
|
|
|
['reg_time', '<', strtotime($this->date)],
|
|
['reg_time', '<', strtotime($this->date)],
|
|
|
];
|
|
];
|
|
|
- $result = Db::connect('db_data_report')->table($loginTb)->field($filed)->where($where)->group($this->group)->select();
|
|
|
|
|
|
|
+ $result = Db::connect('db_game_log')->table($loginTb)->field($filed)->where($where)->group($this->group)->select();
|
|
|
$this->pushData($result);
|
|
$this->pushData($result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -137,7 +136,7 @@ class BaseTotalHourLogic
|
|
|
$sTime = "{$this->date} {$this->hour}:00:00";
|
|
$sTime = "{$this->date} {$this->hour}:00:00";
|
|
|
$eTime = "{$this->date} {$this->hour}:59:59";
|
|
$eTime = "{$this->date} {$this->hour}:59:59";
|
|
|
|
|
|
|
|
- $filed = "{$this->group}, sum(money) as reg_pay_total, sum(paid_amount) as reg_pay_amount, count(distinct uid) as reg_pay_num";
|
|
|
|
|
|
|
+ $filed = "game_id, agent_id, site_id, '{$this->date}' as tdate, '{$this->hour}' as thour, sum(money) as reg_pay_total, sum(paid_amount) as reg_pay_amount, count(distinct uid) as reg_pay_num";
|
|
|
|
|
|
|
|
$where = [
|
|
$where = [
|
|
|
['reg_date', 'between', [$sTime, $eTime]],
|
|
['reg_date', 'between', [$sTime, $eTime]],
|
|
@@ -156,7 +155,7 @@ class BaseTotalHourLogic
|
|
|
$sTime = "{$this->date} {$this->hour}:00:00";
|
|
$sTime = "{$this->date} {$this->hour}:00:00";
|
|
|
$eTime = "{$this->date} {$this->hour}:59:59";
|
|
$eTime = "{$this->date} {$this->hour}:59:59";
|
|
|
|
|
|
|
|
- $filed = "{$this->group}, sum(money) as pay_total, sum(paid_amount) as pay_amount, count(distinct uid) as pay_num";
|
|
|
|
|
|
|
+ $filed = "game_id, agent_id, site_id, '{$this->date}' as tdate, '{$this->hour}' as thour, sum(money) as pay_total, sum(paid_amount) as pay_amount, count(distinct uid) as pay_num";
|
|
|
|
|
|
|
|
$where = [
|
|
$where = [
|
|
|
['pay_date', 'between', [$sTime, $eTime]],
|
|
['pay_date', 'between', [$sTime, $eTime]],
|
|
@@ -175,7 +174,7 @@ class BaseTotalHourLogic
|
|
|
$sTime = "{$this->date} {$this->hour}:00:00";
|
|
$sTime = "{$this->date} {$this->hour}:00:00";
|
|
|
$eTime = "{$this->date} {$this->hour}:59:59";
|
|
$eTime = "{$this->date} {$this->hour}:59:59";
|
|
|
|
|
|
|
|
- $filed = "{$this->group}, COUNT(DISTINCT uid) as role_create_user";
|
|
|
|
|
|
|
+ $filed = "game_id, agent_id, site_id, '{$this->date}' as tdate, '{$this->hour}' as thour, COUNT(DISTINCT uid) as role_create_user";
|
|
|
$where = [
|
|
$where = [
|
|
|
['create_time', 'between', [$sTime, $eTime]],
|
|
['create_time', 'between', [$sTime, $eTime]],
|
|
|
];
|
|
];
|
|
@@ -191,7 +190,7 @@ class BaseTotalHourLogic
|
|
|
|
|
|
|
|
protected function mediaCost(): void
|
|
protected function mediaCost(): void
|
|
|
{
|
|
{
|
|
|
- $filed = "{$this->group}, SUM(money) as cost";
|
|
|
|
|
|
|
+ $filed = "game_id, agent_id, site_id, '{$this->date}' as tdate, '{$this->hour}' as thour, SUM(money) as cost";
|
|
|
$where = [
|
|
$where = [
|
|
|
"tdate" => $this->date,
|
|
"tdate" => $this->date,
|
|
|
"thour" => $this->hour,
|
|
"thour" => $this->hour,
|
|
@@ -200,44 +199,4 @@ class BaseTotalHourLogic
|
|
|
$result = Db::connect('db_advert')->table("media_cost_hour")->field($filed)->where($where)->group($this->group)->select();
|
|
$result = Db::connect('db_advert')->table("media_cost_hour")->field($filed)->where($where)->group($this->group)->select();
|
|
|
$this->pushData($result);
|
|
$this->pushData($result);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- protected function siteAuth(): void
|
|
|
|
|
- {
|
|
|
|
|
- $agentList = Db::connect('db_advert')->table("agent")->column("id, media_id, auth_id");
|
|
|
|
|
- $agentListMap = array_column($agentList, null, "id");
|
|
|
|
|
-
|
|
|
|
|
- if($this->data){
|
|
|
|
|
- foreach ($this->data as &$item){
|
|
|
|
|
- $item['tdate'] = $this->date;
|
|
|
|
|
- $item['thour'] = $this->hour;
|
|
|
|
|
- $item['auth_id'] = $agentListMap[$item['agent_id']]['auth_id'] ?? 0; // 负责人
|
|
|
|
|
- $item['media_id'] = $agentListMap[$item['agent_id']]['media_id'] ?? 0; // 媒体
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- protected function replaceData(): bool
|
|
|
|
|
- {
|
|
|
|
|
- // 先删除,再写入
|
|
|
|
|
- Db::connect('db_data_report')->table($this->table)->where(['tdate' => $this->date, 'thour' => $this->hour])->delete();
|
|
|
|
|
-
|
|
|
|
|
- return Db::connect('db_data_report')->table($this->table)->insertAll($this->data) !== false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- protected function pushData($rows): void
|
|
|
|
|
- {
|
|
|
|
|
- if ($rows) {
|
|
|
|
|
- foreach ($rows as $row) {
|
|
|
|
|
- $groupArr = explode(',', $this->group);
|
|
|
|
|
- $uniqueKey = "";
|
|
|
|
|
- foreach ($groupArr as $groupKey){
|
|
|
|
|
- $uniqueKey .= $row[$groupKey] . "-";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- foreach ($row as $k => $v) {
|
|
|
|
|
- $this->data[$uniqueKey][$k] = !empty($this->data[$uniqueKey][$k]) ? $this->data[$uniqueKey][$k] + $v :$v;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|