master
elf 11 months ago
parent 84b9faf862
commit 7f9dd7f454

@ -33,16 +33,23 @@ class BaseController extends HomeController
$loginer = $this->getLoginPromote();
$outPayRules = [
'home/query/rechargemine'
];
$url = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME);
if (in_array($url, $outPayRules) && !isOutPaySite()) {
die('地址错误');
}
if (isOutPaySite() && !in_array($url, $outPayRules)) {
$this->redirect('Query/rechargeMine');
die();
if (!in_array($url, [
'home/query/getsubpromotes'
])) {
$outPayRules = [
'home/query/rechargemine',
'home/download/recharge_data_export_new',
'home/download/listsindexnew',
'home/download/export',
];
if (in_array($url, $outPayRules) && !isOutPaySite()) {
die('地址错误');
}
if (isOutPaySite() && !in_array($url, $outPayRules)) {
$this->redirect('Query/rechargeMine');
die();
}
}
$this->accessLimit($loginer);

@ -182,6 +182,102 @@ class DownloadController extends BaseController
return $this->display();
}
public function listsIndexNew($p = 0)
{
$nowTime = date('Y-m-d');
$initBegTime = empty(I('begtime')) ? '' : I('begtime');
$initEndTime = $nowTime;
$initEndTime = empty(I('endtime')) ? '' : I('endtime');
$this->assign('begtime', $initBegTime);
$this->assign('endtime', $initEndTime);
$map1['chain'] = ['like', '%' . '/' . PID . '/' . '%'];
$res = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select();
$childPromoteIds = '';
if (empty($res)) {
$map['tab_downloadlog.promote_id'] = PID;
} else {
foreach ($res as $rsKey => $rsValue) {
$id = $rsValue['id'];
$childPromoteIds .= $id . ',';
}
$childPromoteIds = rtrim($childPromoteIds, ',');
$childPromoteIds .= ',' . PID;
$map['tab_downloadlog.promote_id'] = ['in', $childPromoteIds];
}
$levelPromote = $this->getLevelPromote();
$queryPromote = $this->getQueryPromote($levelPromote);
$map2[] = [
'_logic' => 'or',
'id' => $queryPromote['id'],
'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']
];
$childPromoteIds = M('promote', 'tab_')->where($map2)->getField('id', true);
$map = [];
if (count($childPromoteIds) > 0) {
$map = ['promote_id' => ['in', $childPromoteIds]];
} else {
$map['_string'] = '1<>1';
}
if (!empty($_REQUEST['dataname'])) {
$map['dataname'] = ['like', '%' . $_REQUEST['dataname'] . '%'];
}
if (!empty($_REQUEST['logid'])) {
$map['logid'] = $_REQUEST['logid'];
}
if (!empty($_REQUEST['begtime']) && !empty($_REQUEST['endtime'])) {
if (strtotime($_REQUEST['begtime']) == strtotime($_REQUEST['endtime'])) {
$endtime = strtotime($_REQUEST['endtime']) + 24 * 60 * 60;
} else {
$endtime = strtotime($_REQUEST['endtime']);
}
$map['addtime'] = array('BETWEEN', array(strtotime($_REQUEST['begtime']), $endtime));
}
$map['type'] = '/Home/Query/rechargeMine';
$page = intval(I('get.p', 1));
$page = $page ? $page : 1; //默认显示第一页数据arraypage
$row = 10;
$rs = M('downloadlog', 'tab_')->where($map)->order('tab_downloadlog.addtime desc')
->page($page, $row)->select();
foreach ($rs as $key => $value) {
$pid = intval($value['promote_id']);
$getNameRs = M('promote', 'tab_')->field("real_name")->where(['id' => $pid])->find();
$rs[$key]['actor'] = $getNameRs['real_name'];
}
$promoteArr = explode(',', $childPromoteIds);
$promoteNameArr = [];
foreach ($promoteArr as $key1 => $value1) {
$promoteName = M('promote', 'tab_')->field("real_name")->where(['id' => intval($value1)])->find();
$promoteNameArr[$key1]['name'] = $promoteName['real_name'];
$promoteNameArr[$key1]['promote_id'] = $value1;
}
/* 查询记录总数 */
$count = M("downloadlog", "tab_")
->field('tab_downloadlog.id')
->where($map)
->select();
$count = count($count);
//分页
$parameter['p'] = I('get.p', 1);
$parameter['row'] = I('get.row');
$parameter['dataname'] = $_REQUEST['dataname'];
$parameter['logid'] = $_REQUEST['logid'];
$parameter['begtime'] = I('begtime');
$parameter['endtime'] = I('endtime');
$parameter['level_promote_2'] = $levelPromote[0];
$parameter['level_promote_3'] = $levelPromote[1];
$parameter['level_promote_4'] = $levelPromote[2];
$page = set_pagination($count, $row, $parameter);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('data', $rs);
$this->assign('promoteNameArr', $promoteNameArr);
return $this->display();
}
/**
* IOS详细下载数统计
* @author sunke
@ -1507,6 +1603,134 @@ class DownloadController extends BaseController
$this->success('添加下载成功,导出数据不包含当天', U('listsIndex'));
}
/**
* 充值明细添加下载
* @author sunke
*/
public function recharge_data_export_new()
{
// 支付到账时间
$payedBegTime = I("payed_begtime", '');
if ($payedBegTime) {
$payedBegTime = strtotime($payedBegTime);
$payedEndTime = I("payed_endtime", '');
if ($payedEndTime) {
$payedEndTime = strtotime($payedEndTime) + 86400;
}
}
if ($payedBegTime && !$payedEndTime) {
$this->error('到账时间有误,请检查。');
}
if (($payedEndTime - $payedBegTime) > 31 * 24 * 3600) {
$this->error('到账时间范围不能超过31天');
}
// 下单时间
$beginTime = strtotime(I('begtime') . ' 00:00:00');
$endtime = strtotime(I('endtime') . ' 23:59:59');
if (($endtime - $beginTime) > 31 * 24 * 3600) {
$this->error('下单时间范围不能超过31天');
}
$map1['chain'] = ['like', '%' . '/' . PID . '/' . '%'];
$rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select();
$childPromoteIds = '';
if (empty($rs)) {
$map['tab_spend.promote_id'] = PID;
} else {
foreach ($rs as $rsKey => $rsValue) {
$id = $rsValue['id'];
$childPromoteIds .= $id . ',';
}
$childPromoteIds = rtrim($childPromoteIds, ',');
$childPromoteIds .= ',' . PID;
$map['tab_spend.promote_id'] = ['in', $childPromoteIds];
}
$levelPromote = $this->getLevelPromote();
$queryPromote = $this->getQueryPromote($levelPromote);
$map2[] = [
'_logic' => 'or',
'id' => $queryPromote['id'],
'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']
];
$ids = M('promote', 'tab_')->where($map2)->getField('id', true);
if (empty($ids)) {
$ids = array();
}
if (empty($levelPromote)) {
array_push($ids, PID);
}
array_push($ids, $queryPromote['id']);
if (!empty($ids)) {
$map['tab_spend.promote_id'] = ['in', $ids];
} else {
$map['_string'] = '1<>1';
}
if (!empty(I('own_id'))) {
$map['tab_spend.promote_id'] = $queryPromote['id']; //本账号
}
if (!empty(I('begtime')) && empty(I('endtime'))) {
$map['tab_spend.spend_time'] = ['egt', strtotime(I('begtime'))];
} elseif (empty(I('begtime')) && !empty(I('endtime'))) {
$map['tab_spend.spend_time'] = ['elt', strtotime(I('endtime')) + 86399];
} elseif (!empty(I('begtime')) && !empty(I('endtime'))) {
$map['tab_spend.spend_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]];
} else {
// $nowTime = date('Y-m-d');
// $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
// $initEndTime = date('Y-m-d');
// $initBegTime = strtotime($initBegTime);
// $initEndTime = strtotime($initEndTime);
// $map['tab_spend.spend_time'] = ['between',[$initBegTime,$initEndTime]];
}
if ($payedBegTime) {
$map['tab_spend.payed_time'] = ['between', [$payedBegTime, $payedEndTime - 1]];
}
empty(I('relation_game_id')) || $map['tab_game.relation_game_id'] = I('relation_game_id');
empty(I('sdk_version')) || $map['tab_game.sdk_version'] = I('sdk_version');
empty(I('server_id')) || $map['tab_spend.server_id'] = I('server_id');
empty(I('game_player_name')) || $map['tab_spend.game_player_name'] = ['like', '%' . I('game_player_name') . '%'];
empty(I('user_account')) || $map['tab_spend.user_account'] = ['like', '%' . I('user_account') . '%'];
empty(I('pay_order_number')) || $map['tab_spend.pay_order_number'] = I('pay_order_number');
if (isset($_REQUEST['pay_real_status']) && $_REQUEST['pay_real_status'] !== '') {
$payStatus = intval(I('pay_real_status'));
if (in_array($payStatus, array_keys(self::$payStatus))) {
$map['tab_spend.pay_real_status'] = $payStatus + 2;
}
}
$map['tab_spend.pay_way'] = 41;
$map = $this->spendRepository->withIsCheck($map, 'tab_spend.is_check');
$conditions = json_encode($map, true);
$addtime = time();
$data = [
'logid' => 'cz_' . time(),
'promote_id' => PID,
'type' => '/Home/Query/rechargeMine',
'dataname' => '充值明细数据(新)',
'status' => 0,
'addtime' => $addtime,
'begintime' => 0,
'content' => '',
'conditions' => $conditions
];
$res = M('downloadlog', 'tab_')->add($data);
if (!$res) {
// $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res));
$this->error('添加下载失败');
}
$this->success('添加下载成功,导出数据不包含当天', U('listsIndex'));
}
public function userRecharge_data_export()
{
$gameId = I('relation_game_id', 0);
@ -2355,6 +2579,9 @@ class DownloadController extends BaseController
case "充值明细数据":
$this->rechargeExcelInfo($id, $map);
break;
case "充值明细数据(新)":
$this->rechargeExcelInfoNew($id, $map);
break;
case "充值玩家数据":
$this->userRechargeExcelInfo($id, $map);
break;
@ -4703,6 +4930,175 @@ class DownloadController extends BaseController
$this->backSuccessExport($id);
}
public function rechargeExcelInfoNew($id, $map)
{
$xlsName = "订单查询";
$xlsCell = array(
'玩家账号',
'游戏订单',
'订单金额',
// '折扣金额',
'实付金额',
'支付方式',
'充值状态',
'游戏名称',
'设备类型',
'区服',
'角色名',
'部门长',
'组长',
'推广员',
'下单时间',
'到账时间',
);
recordPromoteLogs('数据管理', '充值明细导出');
$model = M('spend', 'tab_');
if (!empty($map['tab_spend.pay_status'])) {
$map['tab_spend.pay_status'] = $map['tab_spend.pay_status'] - 2;
}
$data1 = $model
->field('tab_spend.id')
->join('tab_game on tab_spend.game_id = tab_game.id')
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->where($map)
->order('tab_spend.id desc')
->select();
$csvFileName = $xlsName . '.csv';
//设置好告诉浏览器要下载excel文件的headers
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="' . $csvFileName . '"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
$fp = fopen('php://output', 'a'); //打开output流
mb_convert_variables('gb2312', 'UTF-8', $xlsCell);
fputcsv($fp, $xlsCell); //将数据格式化为CSV格式并写入到output流中
$accessNum = count($data1) ?: 0;
$perSize = 5000; //每次查询的条数
$pages = ceil($accessNum / $perSize);
$promoteIdData = [];
$promoteData = [];
$loginPromote = $this->getLoginPromote();
for ($i = 1; $i <= $pages; $i++) {
$model = M('spend', 'tab_');
$data = $model
->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain,tab_promote.level,tab_promote.parent_id')
->join('tab_game on tab_spend.game_id = tab_game.id')
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->where($map)
->limit(($i - 1) * $perSize, $perSize)
->order('tab_spend.id desc')
->select();
foreach ($data as $list) {
switch ($list['level']) {
case 3:
$promoteIdData[] = $list['parent_id'];
break;
case 4:
$promoteIdData[] = $list['parent_id'];
$chain = trim($list['chain'], '/');
$chainArr = explode('/', $chain);
$promoteIdData[] = $chainArr[1];
break;
}
}
if (!empty($promoteIdData)) {
$promoteIdData = array_unique($promoteIdData);
$promoteData = M('promote', 'tab_')->where(array('id' => ['in', $promoteIdData]))->getField('id,account,real_name');
}
foreach ($data as $key1 => $value1) {
$value1['pay_way'] = $this->payWay[$value1['pay_way']];
$value1['p_p_proinfo'] = $value1['pro_account'] . '(' . $value1['pro_real_name'] . ')';
$value1['p_proinfo'] = $value1['pro_account'] . '(' . $value1['pro_real_name'] . ')';
$value1['proinfo'] = $value1['pro_account'] . '(' . $value1['pro_real_name'] . ')';
// $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12);
$value1['user_account'] = getUserAccountOfPromote($value1['user_account'], $loginPromote);
$value1['pay_order_number'] = hideOrderNumber($value1['pay_order_number']);
$value1['payed_time'] = ($value1['pay_status'] == 1) ? date('Y-m-d H:i:s', $value1['payed_time']) : '--';
$value1['pay_status'] = isset(self::$payStatus[$value1['pay_status']]) ? self::$payStatus[$value1['pay_status']] : "未知状态";
$value1['sdk_version'] = getSDKTypeName($value1['sdk_version']);
switch ($value1['level']) {
case 3:
$value1['p_p_pro_account'] = $promoteData[$value1['parent_id']]['account'];
$value1['p_p_pro_real_name'] = $promoteData[$value1['parent_id']]['real_name'];
$value1['p_pro_account'] = $value1['pro_account'];
$value1['p_pro_real_name'] = $value1['pro_real_name'];
break;
case 4:
$promoteIdData[] = $value1['parent_id'];
$chain = trim($value1['chain'], '/');
$chainArr = explode('/', $chain);
$value1['p_p_pro_account'] = $promoteData[$chainArr[1]]['account'];
$value1['p_p_pro_real_name'] = $promoteData[$chainArr[1]]['real_name'];
$value1['p_pro_account'] = $promoteData[$value1['parent_id']]['account'];
$value1['p_pro_real_name'] = $promoteData[$value1['parent_id']]['real_name'];
break;
}
$value1['p_p_proinfo'] = $value1['p_p_pro_account'] . '(' . $value1['p_p_pro_real_name'] . ')'; //部门长
$value1['p_proinfo'] = $value1['p_pro_account'] . '(' . $value1['p_pro_real_name'] . ')'; //组长
unset($value1['p_p_pro_account']);
unset($value1['p_p_pro_real_name']);
unset($value1['p_pro_account']);
unset($value1['p_pro_real_name']);
$csvData["user_account"] = $value1["user_account"];
$csvData["pay_order_number"] = $value1["pay_order_number"];
$csvData["cost"] = $value1["cost"];
// $csvData["discount_amount"] = $value1["discount_amount"];
$csvData["pay_amount"] = $value1["pay_amount"];
$csvData["pay_way"] = $value1["pay_way"];
$csvData['pay_status'] = $value1['pay_status'];
$csvData["game_name"] = $value1["game_name"];
$csvData["sdk_version"] = $value1['sdk_version'];
$csvData["server_name"] = $value1["server_name"];
$csvData["game_player_name"] = $value1["game_player_name"];
$csvData["p_p_proinfo"] = $value1["p_p_proinfo"];
$csvData["p_proinfo"] = $value1["p_proinfo"];
$csvData["proinfo"] = $value1["proinfo"];
$csvData["spend_time"] = date('Y-m-d H:i:s', $value1["spend_time"]);
$csvData["payed_time"] = $value1["payed_time"];
mb_convert_variables('GBK', 'UTF-8', $csvData);
fputcsv($fp, $csvData);
$xlsData[] = $csvData;
}
unset($xlsData);
ob_flush();
flush();
}
$aggregation = M('Spend', 'tab_')
->field('sum(tab_spend.cost) as cost, sum(tab_spend.pay_amount) as pay_amount, sum(tab_spend.discount_amount) as discount_amount')
->join('tab_game on tab_spend.game_id = tab_game.id')
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->where($map)
->order('tab_spend.id desc')
->find();
$csvData1["user_account"] = "合计";
$csvData1["pay_order_number"] = "--";
$csvData1["cost"] = $aggregation['cost'];
// $csvData1["discount_amount"] = $aggregation['discount_amount'];
$csvData1["pay_amount"] = $aggregation['pay_amount'];
$csvData1["pay_way"] = "--";
$csvData1['pay_status'] = "--";
$csvData1["game_name"] = "--";
$csvData1["sdk_version"] = "--";
$csvData1["server_name"] = "--";
$csvData1["game_player_name"] = "--";
$csvData1["p_p_proinfo"] = "--";
$csvData1["p_proinfo"] = "--";
$csvData1["proinfo"] = "--";
$csvData1["spend_time"] = "--";
$csvData1["payed_time"] = "--";
mb_convert_variables('GBK', 'UTF-8', $csvData1);
fputcsv($fp, $csvData1);
$xlsData[] = $csvData1;
fclose($fp);
$this->backSuccessExport($id);
}
public function backSuccessExport($id)
{ //导出成功后
if (!$id) {

@ -250,7 +250,7 @@
</div>
<div class="pagenation clearfix">
<?php if ($loginer['level'] !== 4) :?>
<a id="sch-btn" data-href="{:U('download/recharge_data_export',array_merge(['xlsname'=>'ceshi'],I('get.')))}" class="ajax-get">导出</a>
<a id="sch-btn" data-href="{:U('download/recharge_data_export_new',array_merge(['xlsname'=>'ceshi'],I('get.')))}" class="ajax-get">导出</a>
<?php endif ;?>
{$_page}
</div>

Loading…
Cancel
Save