@ -1135,8 +1135,8 @@ class DownloadController extends BaseController {
public function recharge_data_export() {
public function recharge_data_export() {
$beginTime = strtotime(I('begtime') . ' 00:00:00');
$beginTime = strtotime(I('begtime') . ' 00:00:00');
$endtime = strtotime(I('endtime') . ' 23:59:59');
$endtime = strtotime(I('endtime') . ' 23:59:59');
if (($endtime - $beginTime) > 7 * 24 * 3600) {
if (($endtime - $beginTime) > 31 * 24 * 3600) {
$this->error('时间范围不能超过7 天');
$this->error('时间范围不能超过31 天');
}
}
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
@ -3068,88 +3068,111 @@ class DownloadController extends BaseController {
$perSize = 5000;//每次查询的条数
$perSize = 5000;//每次查询的条数
$pages = ceil($accessNum / $perSize);
$pages = ceil($accessNum / $perSize);
for($i = 1; $i < = $pages; $i++) {
$promoteIdData = [];
$model = M('spend','tab_');
$promoteData = [];
$data = $model
for($i = 1; $i < = $pages; $i++) {
->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain')
$model = M('spend','tab_');
->join('tab_game on tab_spend.game_id = tab_game.id')
$data = $model
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->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')
->where($map)
->join('tab_game on tab_spend.game_id = tab_game.id')
->limit(($i-1)*$perSize ,$perSize)
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->order('tab_spend.id desc')
->where($map)
->select();
->limit(($i-1)*$perSize ,$perSize)
foreach ($data as $key1 => $value1) {
->order('tab_spend.id desc')
$value1['pay_way'] = $this->payWay[$value1['pay_way']];
->select();
$value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']);
foreach ($data as $list) {
$value1['p_p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
switch ($list['level']) {
$value1['p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
case 3:
$value1['proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
$promoteIdData[] = $list['parent_id'];
// $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12);
break;
$value1['user_account'] = $this->encryption($value1['user_account']);
case 4:
$value1['pay_order_number'] = $this->encryption($value1['pay_order_number']);
$promoteIdData[] = $list['parent_id'];
if(!empty($value1['chain'])) {
$chain = trim($list['chain'], '/');
$chain = trim($value1['chain'],'/');
$chainArr = explode('/', $chain);
$chainArr = explode('/', $chain);
$promoteIdData[] = $chainArr[1];
if(!empty($chainArr[1])) {
break;
$thisPromoteData1 = D('Promote')
}
->field('account,real_name')
}
->where(array('id' => $chainArr[1]))
if (!empty($promoteIdData)) {
->find();
$promoteIdData = array_unique($promoteIdData);
$value1['p_p_proinfo'] = $thisPromoteData1['account'].'('.$thisPromoteData1['real_name'].')'; //部门长
$promoteData = M('promote', 'tab_')->where(array('id' => ['in',$promoteIdData]))->getField('id,account,real_name');
}
}
if(!empty($chainArr[2])) {
foreach ($data as $key1 => $value1) {
$thisPromoteData2 = D('Promote')
$value1['pay_way'] = $this->payWay[$value1['pay_way']];
->field('account,real_name')
$value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']);
->where(array('id' => $chainArr[2]))
$value1['p_p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
->find();
$value1['p_proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
$value1['p_proinfo'] = $thisPromoteData2['account'].'('.$thisPromoteData2['real_name'].')'; //组长
$value1['proinfo'] = $value1['pro_account'].'('.$value1['pro_real_name'].')';
}
// $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12);
$value1['user_account'] = $this->encryption($value1['user_account']);
$value1['pay_order_number'] = $this->encryption($value1['pay_order_number']);
}
switch ($value1['level']) {
$csvData["user_account"] = $value1["user_account"];
case 3:
$csvData["pay_order_number"] = $value1["pay_order_number"];
$value1['p_p_pro_account'] = $promoteData[$value1['parent_id']]['account'];
$csvData["pay_amount"] = $value1["pay_amount"];
$value1['p_p_pro_real_name'] = $promoteData[$value1['parent_id']]['real_name'];
$csvData["pay_way"] = $value1["pay_way"];
$value1['p_pro_account'] = $value1['pro_account'];
$csvData["game_name"] = $value1["game_name"];
$value1['p_pro_real_name'] = $value1['pro_real_name'];
$csvData["server_name"] = $value1["server_name"];
break;
$csvData["game_player_name"] = $value1["game_player_name"];
case 4:
$csvData["p_p_proinfo"] = $value1["p_p_proinfo"];
$promoteIdData[] = $value1['parent_id'];
$csvData["p_proinfo"] = $value1["p_proinfo"];
$chain = trim($value1['chain'], '/');
$csvData["proinfo"] = $value1["proinfo"];
$chainArr = explode('/', $chain);
$csvData["pay_time"] = $value1["pay_time"];
$value1['p_p_pro_account'] = $promoteData[$chainArr[1]]['account'];
mb_convert_variables('GBK', 'UTF-8', $csvData);
$value1['p_p_pro_real_name'] = $promoteData[$chainArr[1]]['real_name'];
fputcsv($fp, $csvData);
$value1['p_pro_account'] = $promoteData[$value1['parent_id']]['account'];
$xlsData[] = $csvData;
$value1['p_pro_real_name'] = $promoteData[$value1['parent_id']]['real_name'];
}
break;
unset($xlsData);
}
ob_flush();
$value1['p_p_proinfo'] = $value1['p_p_pro_account'].'('.$value1['p_p_pro_real_name'].')'; //部门长
flush();
$value1['p_proinfo'] = $value1['p_pro_account'].'('.$value1['p_pro_real_name'].')'; //组长
}
unset($value1['p_p_pro_account']);
$income = '0.00';
unset($value1['p_p_pro_real_name']);
$income = M('Spend', 'tab_')
unset($value1['p_pro_account']);
->field('sum(tab_spend.pay_amount) as income')
unset($value1['p_pro_real_name']);
->join('tab_game on tab_spend.game_id = tab_game.id')
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
$csvData["user_account"] = $value1["user_account"];
->where($map)
$csvData["pay_order_number"] = $value1["pay_order_number"];
->order('tab_spend.id desc')
$csvData["pay_amount"] = $value1["pay_amount"];
->find()['income'];
$csvData["pay_way"] = $value1["pay_way"];
$csvData1["user_account"] = "合计";
$csvData["game_name"] = $value1["game_name"];
$csvData1["pay_order_number"] = "--";
$csvData["server_name"] = $value1["server_name"];
$csvData1["pay_amount"] = $income;
$csvData["game_player_name"] = $value1["game_player_name"];
$csvData1["pay_way"] = "--";
$csvData["p_p_proinfo"] = $value1["p_p_proinfo"];
$csvData1["game_name"] = "--";
$csvData["p_proinfo"] = $value1["p_proinfo"];
$csvData1["server_name"] = "--";
$csvData["proinfo"] = $value1["proinfo"];
$csvData1["game_player_name"] = "--";
$csvData["pay_time"] = $value1["pay_time"];
$csvData1["p_p_proinfo"] = "--";
mb_convert_variables('GBK', 'UTF-8', $csvData);
$csvData1["p_proinfo"] = "--";
fputcsv($fp, $csvData);
$csvData1["proinfo"] = "--";
$xlsData[] = $csvData;
$csvData1["pay_time"] = "--";
}
mb_convert_variables('GBK', 'UTF-8', $csvData1);
unset($xlsData);
fputcsv($fp, $csvData1);
ob_flush();
$xlsData[] = $csvData1;
flush();
fclose($fp);
}
$this->backSuccessExport($id);
$income = '0.00';
$income = M('Spend', 'tab_')
->field('sum(tab_spend.pay_amount) as income')
->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()['income'];
$csvData1["user_account"] = "合计";
$csvData1["pay_order_number"] = "--";
$csvData1["pay_amount"] = $income;
$csvData1["pay_way"] = "--";
$csvData1["game_name"] = "--";
$csvData1["server_name"] = "--";
$csvData1["game_player_name"] = "--";
$csvData1["p_p_proinfo"] = "--";
$csvData1["p_proinfo"] = "--";
$csvData1["proinfo"] = "--";
$csvData1["pay_time"] = "--";
mb_convert_variables('GBK', 'UTF-8', $csvData1);
fputcsv($fp, $csvData1);
$xlsData[] = $csvData1;
fclose($fp);
$this->backSuccessExport($id);
}
}
public function backSuccessExport($id) { //导出成功后
public function backSuccessExport($id) { //导出成功后