@ -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,16 +3068,35 @@ class DownloadController extends BaseController {
$perSize = 5000;//每次查询的条数
$perSize = 5000;//每次查询的条数
$pages = ceil($accessNum / $perSize);
$pages = ceil($accessNum / $perSize);
$promoteIdData = [];
$promoteData = [];
for($i = 1; $i < = $pages; $i++) {
for($i = 1; $i < = $pages; $i++) {
$model = M('spend','tab_');
$model = M('spend','tab_');
$data = $model
$data = $model
->field('tab_spend.*,tab_promote.account as pro_account,tab_promote.real_name as pro_real_name,tab_promote.chain as chain')
->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('tab_game on tab_spend.game_id = tab_game.id')
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->join('left join tab_promote on tab_spend.promote_id = tab_promote.id')
->where($map)
->where($map)
->limit(($i-1)*$perSize ,$perSize)
->limit(($i-1)*$perSize ,$perSize)
->order('tab_spend.id desc')
->order('tab_spend.id desc')
->select();
->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) {
foreach ($data as $key1 => $value1) {
$value1['pay_way'] = $this->payWay[$value1['pay_way']];
$value1['pay_way'] = $this->payWay[$value1['pay_way']];
$value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']);
$value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']);
@ -3087,26 +3106,30 @@ class DownloadController extends BaseController {
// $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12);
// $value1['user_account'] = substr_replace($value1['user_account'],'************',3,12);
$value1['user_account'] = $this->encryption($value1['user_account']);
$value1['user_account'] = $this->encryption($value1['user_account']);
$value1['pay_order_number'] = $this->encryption($value1['pay_order_number']);
$value1['pay_order_number'] = $this->encryption($value1['pay_order_number']);
if(!empty($value1['chain'])) {
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'], '/');
$chain = trim($value1['chain'], '/');
$chainArr = explode('/', $chain);
$chainArr = explode('/', $chain);
if(!empty($chainArr[1])) {
$value1['p_p_pro_account'] = $promoteData[$chainArr[1]]['account'];
$thisPromoteData1 = D('Promote')
$value1['p_p_pro_real_name'] = $promoteData[$chainArr[1]]['real_name'];
->field('account,real_name')
$value1['p_pro_account'] = $promoteData[$value1['parent_id']]['account'];
->where(array('id' => $chainArr[1]))
$value1['p_pro_real_name'] = $promoteData[$value1['parent_id']]['real_name'];
->find();
break;
$value1['p_p_proinfo'] = $thisPromoteData1['account'].'('.$thisPromoteData1['real_name'].')'; //部门长
}
if(!empty($chainArr[2])) {
$thisPromoteData2 = D('Promote')
->field('account,real_name')
->where(array('id' => $chainArr[2]))
->find();
$value1['p_proinfo'] = $thisPromoteData2['account'].'('.$thisPromoteData2['real_name'].')'; //组长
}
}
$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["user_account"] = $value1["user_account"];
$csvData["pay_order_number"] = $value1["pay_order_number"];
$csvData["pay_order_number"] = $value1["pay_order_number"];
$csvData["pay_amount"] = $value1["pay_amount"];
$csvData["pay_amount"] = $value1["pay_amount"];