diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php
index a7c908c24..1e1fd8f12 100644
--- a/Application/Admin/Controller/AutoController.class.php
+++ b/Application/Admin/Controller/AutoController.class.php
@@ -926,7 +926,6 @@ public function auto_rrdae(){
{
if (isset($map['pay_time'])) {
$map['pay_status'] = 1;
- $map['pay_game_status'] = 1;
$map['game_player_id'] = ['gt', 0];
$map['server_id'] = ['gt', 0];
$field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,promote_id,user_id,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count';
@@ -964,11 +963,70 @@ public function auto_rrdae(){
$userData = M('user', 'tab_')->field('id,promote_id')->where($map)->select();
$userPlayData = M('user_play', 'tab_')->field('id,promote_id')->where($map)->select();
$userPlayInfoData = M('user_play_info', 'tab_')->field('id,promote_id')->where($map)->select();
+ $promoteData = [];
+
+ $userModel = 'tab_user';
+ $userRet = $this->updateUserPromoteAccountSql($userModel, $userData, $promoteData);
+ $userSuccess = $userRet['success'];
+ $userError = $userRet['error'];
+ $userErrorData = empty($userRet['error_data']) ? '' : implode(',', $userRet['error_data']);
+ $promoteData = $userRet['promote_data'];
+ $userAll = count($userData);
+
+ $userPlayModel = 'tab_user_play';
+ $userPlayRet = $this->updateUserPromoteAccountSql($userPlayModel, $userData, $promoteData);
+ $userPlaySuccess = $userPlayRet['success'];
+ $userPlayError = $userPlayRet['error'];
+ $userPlayErrorData = empty($userPlayRet['error_data']) ? '' : implode(',', $userPlayRet['error_data']);
+ $promoteData = $userPlayRet['promote_data'];
+ $userPlayAll = count($userPlayData);
+
+ $userPlayInfoModel = 'tab_user_play_info';
+ $userPlayInfoRet = $this->updateUserPromoteAccountSql($userPlayInfoModel, $userData, $promoteData);
+ $userPlayInfoSuccess = $userPlayInfoRet['success'];
+ $userPlayInfoError = $userPlayInfoRet['error'];
+ $userPlayInfoErrorData = empty($userPlayInfoRet['error_data']) ? '' : implode(',', $userPlayInfoRet['error_data']);
+ $promoteData = $userPlayInfoRet['promote_data'];
+ $userPlayInfoAll = count($userPlayInfoData);
+
+ echo $userModel . ":all--{$userAll} success--{$userSuccess} error--{$userError} error_data--{$userErrorData}";
+ echo '
';
+ echo $userPlayModel . ":all--{$userPlayAll} success--{$userPlaySuccess} error--{$userPlayError} error_data--{$userPlayErrorData}";
+ echo '
';
+ echo $userPlayInfoModel . ":all--{$userPlayInfoAll} success--{$userPlayInfoSuccess} error--{$userPlayInfoError} error_data--{$userPlayInfoErrorData}";
+ echo '
';
+ }
+ private function updateUserPromoteAccountSql($model, $data = [], $promoteData = [])
+ {
+ $success = 0;
+ $error = 0;
+ $errorData = [];
+ foreach ($data as &$list) {
+ if (isset($promoteData[$list['promote_id']])) {
+ $promoteAccount = $promoteData[$list['promote_id']];
+ } else {
+ $promoteAccount = M('promote', 'tab_')->where(array('id' => $list['promote_id']))->getField('account');
+ $promoteAccount = empty($promoteAccount) ? '未知推广员' : $promoteAccount;
+ $promoteData[$list['promote_id']] = $promoteAccount;
+ }
- foreach ($userData as $list) {
- $promoteAccount = M('promote', 'tab_')->where(array('id' => $list['promote_id']))->getField('account');
- $res = M()->query("update `tab_user` set promote_account = '{$promoteAccount}' where id = {$list['id']}");
+ $res = M()->query("update `$model` set promote_account = '{$promoteAccount}' where id = {$list['id']}");
+ if ($res === false) {
+ $error++;
+ $errorData = $list['id'];
+ } else {
+ $success++;
+ }
+ unset($list);
}
+
+ $ret = [
+ 'success' => $success,
+ 'error' => $error,
+ 'error_data' => $errorData,
+ 'promote_data' => $promoteData,
+ ];
+ return $ret;
}
}
diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php
index 4b3a27fdc..fb967f468 100644
--- a/Application/Home/Controller/QueryController.class.php
+++ b/Application/Home/Controller/QueryController.class.php
@@ -1828,7 +1828,7 @@ class QueryController extends BaseController
$field = $fieldUC . ',' . $fieldUI;
$subQuery = M('user_play_data_count', 'tab_')->alias('uc')
->field($field)
- ->join('tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id')
+ ->join('left join tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id')
->where($map)
->group('uc.role_id,uc.server_id,uc.game_id')
->buildSql();
@@ -1837,7 +1837,7 @@ class QueryController extends BaseController
->order($orderBy);
$total = M('user_play_data_count', 'tab_')->alias('uc')
->field($fieldUC)
- ->join('tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id')
+ ->join('left join tab_user_play_info as ui on ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id')
->where($map)
->find();