Merge pull request '优化' (#569) from hotfix/ts_slow_sql into master

Reviewed-on: http://8.136.139.249:3000/wmtx/platform/pulls/569
master
廖金灵 3 years ago
commit 39f6dd7011

@ -585,9 +585,9 @@ class TestingResourceRepository
$roleName = $params['role_name'] ?? '';
$conditions = [];
$subConditions = [
/* $subConditions = [
'_string' => '1=1'
];
]; */
$strCondition = '1=1';
@ -596,53 +596,60 @@ class TestingResourceRepository
if ($permissionPromote) {
$visibleGameIds = $promoteService->getVisibleGameIds($permissionPromote);
if (count($visibleGameIds) > 0) {
$strCondition .= ' and game_id in (' . implode(',', $visibleGameIds) . ')';
$strCondition .= ' and r.game_id in (' . implode(',', $visibleGameIds) . ')';
} else {
$strCondition .= ' and 1=0';
}
$strCondition .= ' and promote_id in (' . $promoteService->subInSql($permissionPromote) . ')';
$strCondition .= ' and r.promote_id in (' . $promoteService->subInSql($permissionPromote) . ')';
}
$gameIds = $this->getHadSettingGameIds();
if (!empty($gameIds)) {
$strCondition .= ' and game_id in ('. implode(',', $gameIds) . ')';
$strCondition .= ' and r.game_id in ('. implode(',', $gameIds) . ')';
} else {
$strCondition .= ' and 1=0';
}
if ($createTimeStart) {
$strCondition .= ' and create_time >=' . strtotime($createTimeStart . ' 00:00:00');
$strCondition .= ' and r.create_time >=' . strtotime($createTimeStart . ' 00:00:00');
}
if ($createTimeEnd) {
$strCondition .= ' and create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
$strCondition .= ' and r.create_time <=' . strtotime($createTimeEnd . ' 23:59:59');
}
if ($status != 0) {
$subConditions['status'] = $status;
$conditions['u.status'] = $status;
}
$subConditions['verify_status'] = 1;
/* $subConditions['verify_status'] = 1;
$subSql = M('testing_user', 'tab_')->field(['user_id'])->where($subConditions)->select(false);
$strCondition .= ' and user_id in (' . $subSql . ')';
$strCondition .= ' and user_id in (' . $subSql . ')'; */
$conditions['u.verify_status'] = 1;
$strCondition .= ' and u.id is not null';
if ($account) {
$user = M('user', 'tab_')->field(['id'])->where('account like "' . $account . '%"')->find();
if ($user) {
$conditions['user_id'] = $user['id'];
$conditions['r.user_id'] = $user['id'];
} else {
$strCondition .= ' and 1<>1';
}
}
if ($gameId) {
$conditions['game_id'] = $gameId;
$conditions['r.game_id'] = $gameId;
}
if ($serverId) {
$conditions['server_id'] = $serverId;
$conditions['r.server_id'] = $serverId;
}
if ($roleName) {
$conditions['role_name'] = ['like', $roleName . '%'];
$conditions['r.role_name'] = ['like', $roleName . '%'];
}
$conditions['_string'] = $strCondition;
return M('user_play_info', 'tab_')->where($conditions)->order('create_time desc');
return M('user_play_info', 'tab_')
->alias('r')
->field('r.*')
->join("left join tab_testing_user u on r.user_id=u.user_id")
->where($conditions)
->order('r.create_time desc');
}
public function getTestingUsersQuery($params, array $promote = null)

Loading…
Cancel
Save