@ -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 '< br > ';
echo $userPlayModel . ": all--{$userPlayAll} success--{$userPlaySuccess} error--{$userPlayError} error_data--{$userPlayErrorData}";
echo '< br > ';
echo $userPlayInfoModel . ": all--{$userPlayInfoAll} success--{$userPlayInfoSuccess} error--{$userPlayInfoError} error_data--{$userPlayInfoErrorData}";
echo '< br > ';
}
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;
}
}