|
@@ -4,7 +4,7 @@
|
|
|
|
|
|
|
|
namespace app\v1\logic\dataReport;
|
|
namespace app\v1\logic\dataReport;
|
|
|
|
|
|
|
|
-use app\exception\ApiException;
|
|
|
|
|
|
|
+use plugin\saiadmin\exception\ApiException;
|
|
|
use plugin\saiadmin\basic\BaseLogic;
|
|
use plugin\saiadmin\basic\BaseLogic;
|
|
|
use plugin\saiadmin\service\OpenSpoutWriter;
|
|
use plugin\saiadmin\service\OpenSpoutWriter;
|
|
|
use support\think\Db;
|
|
use support\think\Db;
|
|
@@ -18,10 +18,22 @@ class UserLogLogic extends BaseLogic
|
|
|
$params = $this->searchByAuth($where);
|
|
$params = $this->searchByAuth($where);
|
|
|
$limit = request()->input('limit', 10);
|
|
$limit = request()->input('limit', 10);
|
|
|
|
|
|
|
|
- if(!$params['reg_time']){
|
|
|
|
|
- throw new ApiException("注册时间不能为空");
|
|
|
|
|
|
|
+ // 检查注册时间只能查询3个月内
|
|
|
|
|
+ if (empty($params['reg_time']) || count($params['reg_time']) != 2) {
|
|
|
|
|
+ throw new ApiException('请选择注册时间范围');
|
|
|
|
|
+ }
|
|
|
|
|
+ $startTime = strtotime($params['reg_time'][0]);
|
|
|
|
|
+ $endTime = strtotime($params['reg_time'][1]);
|
|
|
|
|
+ if ($endTime < $startTime) {
|
|
|
|
|
+ throw new ApiException('注册时间范围不正确');
|
|
|
|
|
+ }
|
|
|
|
|
+ // 计算时间差,限制为3个月(90天)内
|
|
|
|
|
+ $maxDays = 90;
|
|
|
|
|
+ if (($endTime - $startTime) > ($maxDays * 86400)) {
|
|
|
|
|
+ throw new ApiException('注册时间只能查询3个月内');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// 公共处理完的where, 自然量ID, auth_id=0为自然量
|
|
// 公共处理完的where, 自然量ID, auth_id=0为自然量
|
|
|
[$where, $whereRaw] = $this->getUlogCommonWhere($params);
|
|
[$where, $whereRaw] = $this->getUlogCommonWhere($params);
|
|
|
$monthRange = getMonthsBetweenDates($params['reg_time'][0], $params['reg_time'][1]);
|
|
$monthRange = getMonthsBetweenDates($params['reg_time'][0], $params['reg_time'][1]);
|
|
@@ -30,7 +42,7 @@ class UserLogLogic extends BaseLogic
|
|
|
$unionQuery = [];
|
|
$unionQuery = [];
|
|
|
foreach ($monthRange as $month){
|
|
foreach ($monthRange as $month){
|
|
|
$tableName = 'sdk_reg_log_' . $month;
|
|
$tableName = 'sdk_reg_log_' . $month;
|
|
|
- $unionQuery[] = $db->table($tableName)->where($where)->whereRaw($whereRaw)->buildSql();
|
|
|
|
|
|
|
+ $unionQuery[] = $db->table($tableName)->where($where)->whereRaw(where: $whereRaw)->buildSql();
|
|
|
}
|
|
}
|
|
|
$fullSql = "(" . implode(' UNION ALL ', $unionQuery) . ") as unTable";
|
|
$fullSql = "(" . implode(' UNION ALL ', $unionQuery) . ") as unTable";
|
|
|
|
|
|
|
@@ -46,23 +58,50 @@ class UserLogLogic extends BaseLogic
|
|
|
$limit = request()->input('limit', 10);
|
|
$limit = request()->input('limit', 10);
|
|
|
|
|
|
|
|
$params = $this->searchByAuth($where);
|
|
$params = $this->searchByAuth($where);
|
|
|
- $tableName = 'sdk_login_log_' . date('Ym', strtotime($params['login_time']));
|
|
|
|
|
|
|
|
|
|
- $loginLogQuery = Db::connect('db_game_log')->table($tableName);
|
|
|
|
|
|
|
|
|
|
- // 公共处理完的where, 自然量ID, auth_id=0为自然量
|
|
|
|
|
- [$where, $whereRaw] = $this->getUlogCommonWhere($params);
|
|
|
|
|
- if($where){
|
|
|
|
|
- $loginLogQuery = $loginLogQuery->where($where);
|
|
|
|
|
|
|
+ // 检查注册时间只能查询3个月内
|
|
|
|
|
+ if (empty($params['login_time']) || count($params['login_time']) != 2) {
|
|
|
|
|
+ throw new ApiException('请选择登录时间范围');
|
|
|
}
|
|
}
|
|
|
- if($whereRaw){
|
|
|
|
|
- $loginLogQuery = $loginLogQuery->whereRaw($whereRaw);
|
|
|
|
|
|
|
+ $startTime = strtotime($params['login_time'][0]);
|
|
|
|
|
+ $endTime = strtotime($params['login_time'][1]);
|
|
|
|
|
+ if ($endTime < $startTime) {
|
|
|
|
|
+ throw new ApiException('登录时间范围不正确');
|
|
|
}
|
|
}
|
|
|
|
|
+ // 计算时间差,限制为3个月(90天)内
|
|
|
|
|
+ $maxDays = 90;
|
|
|
|
|
+ if (($endTime - $startTime) > ($maxDays * 86400)) {
|
|
|
|
|
+ throw new ApiException('登录时间只能查询3个月内');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 检查登录时间只能查询3个月内
|
|
|
|
|
+ if(!empty($params['reg_time'])){
|
|
|
|
|
+ $startTime = strtotime($params['reg_time'][0]);
|
|
|
|
|
+ $endTime = strtotime($params['reg_time'][1]);
|
|
|
|
|
+ if ($endTime < $startTime) {
|
|
|
|
|
+ throw new ApiException('注册时间范围不正确');
|
|
|
|
|
+ }
|
|
|
|
|
+ // 计算时间差,限制为3个月(90天)内
|
|
|
|
|
+ $maxDays = 90;
|
|
|
|
|
+ if (($endTime - $startTime) > ($maxDays * 86400)) {
|
|
|
|
|
+ throw new ApiException('注册时间只能查询3个月内');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 公共处理完的where, 自然量ID, auth_id=0为自然量
|
|
|
|
|
+ [$where, $whereRaw] = $this->getUlogCommonWhere($params);
|
|
|
|
|
+ $monthRange = getMonthsBetweenDates($params['login_time'][0], $params['login_time'][1]);
|
|
|
|
|
|
|
|
- // 执行查询并排序
|
|
|
|
|
- $loginLogQuery->order($orderBy, $orderType);
|
|
|
|
|
|
|
+ $db = Db::connect('db_game_log');
|
|
|
|
|
+ $unionQuery = [];
|
|
|
|
|
+ foreach ($monthRange as $month){
|
|
|
|
|
+ $tableName = 'sdk_login_log_' . $month;
|
|
|
|
|
+ $unionQuery[] = $db->table($tableName)->where($where)->whereRaw(where: $whereRaw)->buildSql();
|
|
|
|
|
+ }
|
|
|
|
|
+ $fullSql = "(" . implode(' UNION ALL ', $unionQuery) . ") as unTable";
|
|
|
|
|
|
|
|
- return $loginLogQuery->paginate($limit)->toArray();
|
|
|
|
|
|
|
+ return $db->table($fullSql)->paginate($limit)->toArray();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 充值明细
|
|
// 充值明细
|
|
@@ -246,19 +285,10 @@ class UserLogLogic extends BaseLogic
|
|
|
$limit = request()->input('limit', 10);
|
|
$limit = request()->input('limit', 10);
|
|
|
|
|
|
|
|
$params = $this->searchByAuth($where);
|
|
$params = $this->searchByAuth($where);
|
|
|
- $regTime = $params['reg_time'];
|
|
|
|
|
-
|
|
|
|
|
- $egTableName = 'sdk_reg_log_' . date('Ym', strtotime($regTime));
|
|
|
|
|
-
|
|
|
|
|
- $userData = Db::connect('db_game_log')->table($egTableName)->where('reg_time', '>=', strtotime($regTime . ' 00:00:00'))->where('reg_time', '<=', strtotime($regTime . ' 23:59:59'))->select()->toArray();
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$where_sql = $this->generateWhereSql($params);
|
|
$where_sql = $this->generateWhereSql($params);
|
|
|
-
|
|
|
|
|
- $uids = array_column($userData, 'uid');
|
|
|
|
|
-
|
|
|
|
|
- if (empty($userData)) return [];
|
|
|
|
|
-
|
|
|
|
|
- $where_sql = " AND uid in (" . implode(',', $uids) . ") {$where_sql}";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $where_sql = str_replace('AND reg_time', 'AND create_time', $where_sql);
|
|
|
|
|
|
|
|
$sql_parts = [];
|
|
$sql_parts = [];
|
|
|
$sql_parts[] = "SELECT * FROM role_data_and WHERE 1=1 {$where_sql}";
|
|
$sql_parts[] = "SELECT * FROM role_data_and WHERE 1=1 {$where_sql}";
|