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