Merge branch 'dev' of 47.111.118.107:/srv/git/platform into dev

master
ELF 5 years ago
commit b0b3d3f80d

@ -921,70 +921,40 @@ class DownloadController extends BaseController {
* @author sunke * @author sunke
*/ */
public function coinrecord_data_export() { public function coinrecord_data_export() {
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; $gameId = I('game_id', 0);
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); $account = I('account', '');
$childPromoteIds = ''; $sn = I('sn', '');
if(empty($rs)) { $startTime = I('time_end', '');
$map['promote_id'] = PID; $endTime = I('time_start', '');
}else { $loginPromote = $this->getLoginPromote();
foreach ($rs as $rsKey => $rsValue) { $map = ['promote_id' => $loginPromote['id']];
$id = $rsValue['id']; if ($startTime != '' || $endTime != '') {
$childPromoteIds .= $id.','; if ($startTime != '') {
$map['create_time'] = ['egt', strtotime($startTime. ' 00:00:00')];
} }
$childPromoteIds = rtrim($childPromoteIds, ','); if ($endTime != '') {
$childPromoteIds .= ',' . PID; $map['create_time'] = ['elt', strtotime($endTime. ' 23:59:59')];
$map['promote_id'] = ['in', $childPromoteIds];
} }
$map["type"] = 2;
$end_time = strtotime(I('time_end'));
$start_time = strtotime(I('time_start'));
if (!empty($end_time) && !empty($start_time)) {
$map['create_time'] = ['between', [$start_time, $end_time + 86400 - 1]];
} elseif (!empty($start_time)) {
$map['create_time'] = array('gt', $start_time);
} elseif (!empty($end_time)) {
$map['create_time'] = array('lt', $end_time + 86400 - 1);
} }
$account = I('account');
$sn = I('sn');
if($sn) { if($sn) {
$map['sn'] = ['like','%'.$sn.'%']; $map['sn'] = $sn;
} }
if($account) { if($account) {
$searchUsers = M('User', 'tab_')->field('id')->where(['account' => ['like', '%' . $account . '%']])->select(); $map1['account'] = ['like','%'.$account.'%'];
$searchPromotes = M('Promote', 'tab_')->field('id')->where(['account' => ['like', '%' . $account . '%']])->select(); $promotesRs = M('promote','tab_')->field('id')->where($map1)->select();
if (empty($searchUsers) && empty($searchPromotes)) { $idArr = "";
$map['_string'] = '1<>1'; foreach ($promotesRs as $key => $value) {
$idArr .= intval($value['id']).',';
} }
if (empty($searchUsers) && !empty($searchPromotes)) { $idArr1 = rtrim($idArr,',');
$map['source_id'] = ['in', array_column($searchPromotes, 'id')]; $map['target_id'] = ['in',$idArr1];
} }
if (!empty($searchUsers) && empty($searchPromotes)) { if($gameId) {
$map['source_id'] = ['in', array_column($searchUsers, 'id')]; $map['game_id'] = $gameId;
}
if (!empty($searchUsers) && !empty($searchPromotes)) {
$map['_string'] = '(source_id in (' . implode(',', array_column($searchUsers, 'id')) . ') or'
. '(source_id in (' . implode(',', array_column($searchPromotes, 'id')) . '))';
}
}
$searchHandleType = I('handle_type', 0);
if ($searchHandleType) {
if ($searchHandleType == 2) {
$map['source_type'] = 2;
} else {
}
}
$searchGameId = I('game_id', -1);
if ($searchGameId != -1) {
$map['game_id'] = $searchGameId;
} }
$conditions = json_encode($map,TRUE); $conditions = json_encode($map,TRUE);
$addtime = time(); $addtime = time();
$type = "/Home/PromoteCoin/record"; $type = "/Home/PromoteCoin/transferLogs";
$data = [ $data = [
'logid' => 'cr_'.time(), 'logid' => 'cr_'.time(),
'admin_id' => PID, 'admin_id' => PID,
@ -1974,44 +1944,58 @@ class DownloadController extends BaseController {
array('create_time',"交易时间"), array('create_time',"交易时间"),
array('status',"交易状态"), array('status',"交易状态"),
); );
$model = M("PromoteCoin",'tab_'); $model = M('promote_coin_transfer_log', 'tab_');
$data = $model->where($map)->order('create_time desc')->select(); $logs = $model->where($map)->select();
$sourcePromoteIds = []; $service = new PromoteCoinTransferLogService();
$sourceUserIds = []; $gameIds = [];
foreach ($data as $item) { $promoteIds = [];
if ($item['source_type'] == 1) { $uesrIds = [];
$sourcePromoteIds[] = $item['source_id']; foreach ($logs as $log) {
} elseif ($item['source_type'] == 2) { $gameIds[] = $log['game_id'];
$sourceUserIds[] = $item['source_id']; if ($log['target_type'] == 1) {
$promoteIds[] = $log['target_id'];
}
if ($log['target_type'] == 2) {
$uesrIds[] = $log['target_id'];
} }
} }
$sourceUsers = $this->getRecordsByIds(M('User', 'tab_'), $sourceUserIds, ['indexBy' => 'id']); $games = [];
$sourcePromotes = $this->getRecordsByIds(M('Promote', 'tab_'), $sourcePromoteIds, ['indexBy' => 'id']); $promotes = [];
$users = [];
if (count($gameIds) > 0) {
$games = M('game', 'tab_')->field(['id', 'game_name'])->where(['id' => ['in', $gameIds]])->select();
}
if (count($promoteIds) > 0) {
$promotes = M('promote', 'tab_')->field(['id', 'account'])->where(['id' => ['in', $promoteIds]])->select();
}
if (count($uesrIds) > 0) {
$users = M('user', 'tab_')->field(['id', 'account'])->where(['id' => ['in', $uesrIds]])->select();
}
$users = index_by_column('id', $users);
$promotes = index_by_column('id', $promotes);
$games = index_by_column('id', $games);
$records = []; $records = [];
foreach ($data as $item) { foreach ($logs as $log) {
$sourceName = ''; $targetAccount = '';
$promote = null; if ($log['target_type'] == 1) {
if ($item['source_type'] == 2) { $targetAccount = isset($promotes[$log['target_id']]) ? $promotes[$log['target_id']]['account'] : '未知推广账号';
$sourceName = $sourceUsers[$item['source_id']]['account']; }
} elseif ($item['source_type'] == 1) { if ($log['target_type'] == 2) {
$promote = $sourcePromotes[$item['source_id']]; $targetAccount = isset($promotes[$log['target_id']]) ? $promotes[$log['target_id']]['account'] : '未知玩家';
$sourceName = $sourcePromotes[$item['source_id']]['account']; }
} $records[] = [
$handleType = $this->getHandleType($item, $promote); 'id' => $log['id'],
$records = [ 'sn' => $log['sn'],
'id' => $item['id'], 'target_account' => $targetAccount,
'sn' => $item['sn'], 'game_name' => isset($games[$log['game_id']]) ? $games[$log['game_id']]['game_name'] : '所有游戏',
'account' => $item['id'], 'target_type_text' => $service->getTargetTypeText($log['target_type'], $log['target_level']),
'game_name' => isset($games[$item['game_id']]) ? $games[$item['game_id']] : '所有游戏', 'num' => $log['num'],
'create_time' => date('Y-m-d H:i:s', $item['create_time']), 'description' => $log['description'],
'description' => $item['description'], 'status_text' => '成功',
'num' => $item['num'], 'create_time' => date('Y-m-d H:i:s', $log['create_time'])
'source_name' => $sourceName,
'handle_type' => $handleType,
'status' => $item['status'] == 1 ? '成功' : '失败',
]; ];
} }
$xlsData[] = $records; $xlsData = $records;
$this->exportExcel($xlsName, $xlsCell, $xlsData,$id); $this->exportExcel($xlsName, $xlsCell, $xlsData,$id);
} }

Loading…
Cancel
Save