From f948bfbb7d4a085877fae67c7cdb3b3602d612f3 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Thu, 7 Nov 2019 20:39:36 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=99=A8=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/DownloadController.class.php | 2678 ++++++++++++++++- .../Home/Controller/QueryController.class.php | 20 - .../View/default/Download/listsindex.html | 238 ++ .../Home/View/default/Finance/index.html | 2 + .../View/default/Finance/settlementDtl.html | 1 + .../View/default/Finance/withdrawDtl.html | 1 + .../View/default/Finance/withdrawRecord.html | 1 + .../Home/View/default/Promote/children.html | 1 + .../Home/View/default/Promote/mychlid.html | 443 +++ .../Home/View/default/PromoteCoin/myCoin.html | 1 + .../Home/View/default/PromoteCoin/record.html | 1 + .../View/default/Public/promote_base.html | 2 +- .../Home/View/default/Query/achievement.html | 1 + Application/Home/View/default/Query/arpu.html | 7 +- .../Home/View/default/Query/dailySummary.html | 3 + .../Home/View/default/Query/recharge.html | 1 + .../Home/View/default/Query/register.html | 1 + .../Home/View/default/Query/summary.html | 1 + .../View/default/Query/userRecharges.html | 1 + .../Home/View/default/Query/userRoles.html | 1 + .../Home/View/default/TestResource/index.html | 2 +- .../Home/View/default/TestResource/lists.html | 5 +- .../TestResource/supportNumberList.html | 5 +- Public/Home/css/20180207/common.css | 22 + Public/Home/js/common.js | 6 +- 25 files changed, 3416 insertions(+), 29 deletions(-) create mode 100644 Application/Home/View/default/Download/listsindex.html create mode 100644 Application/Home/View/default/Promote/mychlid.html diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index cfe5abec6..6987c0714 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2,13 +2,38 @@ namespace Home\Controller; use Think\Controller; +use App\Model\GameModel; +use User\Api\PromoteApi; +use Base\Repository\PromoteRepository; +use Base\Repository\SpendRepository; +use Base\Repository\UserRepository; +use Base\Service\PromoteService; use Base\Facade\Request; use Base\Service\ApplyService; /** * @author elf<360197197@qq.com> */ -class DownloadController extends Controller { +class DownloadController extends BaseController { + public $payWay = [ + -1 => '绑币', + 0 => '平台币', + 1 => '支付宝', + 3 => '微信', + 5 => '聚宝云', + 6 => '竣付通', + 7 => '苹果支付', + 8 => '金猪支付', + 9 => '双乾支付', + ]; + + //提现状态 + public static $withdrawStatus = [ + -1 => '审核未通过', + 0 => '待审核', + 1 => '汇款中', + 2 => '已汇款', + ]; public function downloadError($message) { @@ -93,4 +118,2655 @@ class DownloadController extends Controller { } } } + + /** + * excel + */ + public function exportExcel($expTitle, $expCellName, $expTableData,$id) + { + $xlsTitle = iconv('utf-8', 'gb2312', $expTitle);//文件名称 +// $fileName = session('user_auth.username').date('_YmdHis');//or $xlsTitle 文件名称可根据自己情况设定 + $fileName = $expTitle.'_'.date('YmdHis'); + $cellNum = count($expCellName); + $dataNum = count($expTableData); + Vendor("PHPExcel.PHPExcel"); + $objPHPExcel = new \PHPExcel(); + $cellName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ'); + $objPHPExcel->getActiveSheet(0)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1');//合并单元格 + $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $expTitle); + $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER); + for ($i = 0; $i < $cellNum; $i++) { + $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellName[$i] . '2', $expCellName[$i][1]); + } + for ($i = 0; $i < $dataNum; $i++) { + for ($j = 0; $j < $cellNum; $j++) { + $objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j] . ($i + 3), $expTableData[$i][$expCellName[$j][0]]); + } + } + ob_end_clean();//清除缓冲区,避免乱码 + header('pragma:public'); + header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $xlsTitle . '.xls"'); + header("Content-Disposition:attachment;filename=$fileName.xls");//attachment新窗口打印inline本窗口打印 + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); + $objWriter->save('php://output'); + $this->backSuccessExport($id); + exit; + } + + public function listsIndex($p = 0) { + $childPromoteIds = getAllChildPromoteList(3); + if (empty($childPromoteIds)) { + $map1['admin_id'] = PID; + $promote = PID; + } else { + $childPromoteIds .= ','.PID; + $map1['admin_id'] = ['in', $childPromoteIds]; + $promote = $childPromoteIds; + } + $pro = $_REQUEST['pid']; + if(empty($pro)) { + $map['admin_id'] = $map1['admin_id']; + }else { + $map['admin_id'] = intval($pro); + } + 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)); + } + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $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['admin_id']); + $getNameRs = M('promote','tab_')->field("real_name")->where(['id' => $pid])->find(); + $rs[$key]['actor'] = $getNameRs['real_name']; + } + + $promoteArr = explode(',', $promote); + $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'); + $page = set_pagination($count, $row, $parameter); + if ($page) { + $this->assign('_page', $page); + } + $this->assign('data',$rs); + $this->assign('promoteNameArr',$promoteNameArr); + return $this->display(); + } + + /** + * 每日概况 + * @author sunke + */ + public function dailysummary_data_export() { + $relationGameId = intval(I('relation_game_id', 0)); + $sdkVersion = intval(I('sdk_version', 0)); + $serverId = intval(I('server_id'), 0); + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $endTime += +3600 * 24; + $levelPromote = $this->getLevelPromote(); + $queryPromote = $this->getQueryPromote($levelPromote); + + $loginPromote = $this->getLoginPromote(); + $map1['chain'] = ['like','%'.PID.'/'.'%']; + $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_test_resource.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['promote_id'] = ['in', $childPromoteIds]; + } + + $ownId = intval(I('own_id'), 0);//本账号 + if ($ownId) { + $map['promote_id'] = $queryPromote['id']; + } else { + $map2['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']; + $ids = M('promote', 'tab_')->where($map2)->getField('id', true); + $ids[] = $queryPromote['id']; + $ids = implode(',', $ids); + $map['promote_id'] = $ids; + } + if ($serverId > 0) { + $map['server_id'] = $serverId; + } + if ($relationGameId > 0 || $sdkVersion > 0) { + if ($sdkVersion > 0) { + $map['sdk_version'] = $sdkVersion; + } + if ($relationGameId > 0) { + $map['relation_game_id'] = $relationGameId; + } + $gameIds = M('Game', 'tab_')->where($map)->getField('id', true); + $map['gameIds'] = $gameIds; + } + + $map['begin_time'] = $begTime; + $map['end_time'] = $endTime; + + $dayList = $this->getDayList($begTime, $endTime); + $map['dayList'] = $dayList; + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'dy_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/dailySummary', + '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')); + + + } + + /** + * 提现记录 + * @author sunke + */ + public function withdrawRecord_data_export() { + $withdrawNumber = I('widthdraw_number', ''); + $initBegTime = I('begtime', ''); + $initEndTime = I('endtime', ''); + $begTime = strtotime(date('Y-m-d', strtotime($initBegTime))); + $endTime = strtotime(date('Y-m-d', strtotime($initEndTime))) + 3600 * 24; + $status = ''; + $map['promote_id'] = $this->loginPromote['id']; + if (!empty($withdrawNumber)) { + $map['widthdraw_number'] = $withdrawNumber; + } + if (!empty($initBegTime) && empty($initEndTime)) { + $map['create_time'] = ['egt', $begTime]; + } elseif (empty($initBegTime) && !empty($initEndTime)) { + $map['create_time'] = ['lt', $endTime]; + } elseif (!empty($initBegTime) && !empty($initEndTime)) { + $map['create_time'] = ['between', [$begTime, $endTime - 1]]; + } + + if (isset($_GET['status']) && $_GET['status'] !== '') { + $status = intval($_GET['status']); + if (!isset(FinanceController::$withdrawStatus[$status])) { + $this->error('参数异常'); + } + + $map['status'] = $status; + } + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'withdrawRecord'.time(), + 'admin_id' => PID, + 'type' => '/Home/Finance/withdrawRecord', + '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')); + } + /** + * 提现明细 + * @author sunke + */ + public function withdrawDtl_data_export() { + $withdrawId = intval(I('get.id', 0)); + if ($withdrawId == 0) { + $this->error('参数异常'); + } + $withdraw = M('withdraw', 'tab_')->field('promote_id,status')->where(array('id' => $withdrawId))->find(); + if (empty($withdraw) || $withdraw['promote_id'] != $this->loginPromote['id']) { + $this->error('参数异常'); + } + $gameId = intval(I('game_id', 0)); + $userAccount = I('user_account', ''); + $payOrderNumber = I('pay_order_number', ''); + $map['withdraw_id'] = $withdrawId; + if (!empty($gameId)) { + $map['game_id'] = $gameId; + } + if (!empty($userAccount)) { + $map['user_account'] = $userAccount; + } + if (!empty($payOrderNumber)) { + $map['pay_order_number'] = $payOrderNumber; + } + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'withdrawDtl_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Finance/withdrawDtl', + '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')); + } + + /** + * 结算中心 + * @author sunke + */ + public function financeindex_data_export() { + $thisDay = strtotime(date('Y-m-d')); + $thisMonth = strtotime(date('Y-m')); + $yesterday = strtotime(date('Y-m-d', strtotime('-1 day', time()))); + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $endTime = $endTime + 3600 * 24; + $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; + $promoteIds = M('promote', 'tab_')->where($map)->getField('id', true); + $promoteIds[] = $this->loginPromote['id']; + $promoteIds = implode(',', $promoteIds); + $map = []; + $map['pay_status'] = 1; + $map['promote_id'] = ['in', $promoteIds]; + $map['pay_time'] = ['between', [$begTime, $endTime]]; + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'finance_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Finance/index', + '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')); + } + + /** + * 结算明细 + * @author sunke + */ + public function settlementDtl_data_export() { + $payOrderNumber = I('pay_order_number', ''); + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + + $map['chain'] = ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%']; + $ids = M('promote', 'tab_')->where($map)->getField('id', true); + $ids[] = $this->loginPromote['id']; + $ids = implode(',', $ids); + $map = []; + $map['promote_id'] = ['in', $ids]; + if (!empty($payOrderNumber)) { + $map['pay_order_number'] = $payOrderNumber; + } + if (!empty($begTime) && empty($endTime)) { + $map['pay_time'] = ['egt', $begTime]; + } elseif (empty($begTime) && !empty($endTime)) { + $map['pay_time'] = ['elt', $endTime + 86399]; + } elseif (!empty($begTime) && !empty($endTime)) { + $map['pay_time'] = ['between', [$begTime, $endTime + 86399]]; + } + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'settlementDtl_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Finance/settlementDtl', + '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')); + + } + /** + * 测试资源 + * @author sunke + */ + public function testresource_data_export() { + $map1['chain'] = ['like','%'.PID.'/'.'%']; + $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_test_resource.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_test_resource.promote_id'] = ['in', $childPromoteIds]; + } + + if(!empty(I('role_name'))){ + $map['role_name']=['like','%'.I('role_name').'%']; + } + if(!empty(I('server_name'))){ + $map['server_name']=I('server_name'); + } + if(!empty(I('game_name'))){ + $map['game_name']=I('game_name'); + } + if(!empty(I('user_account'))){ + $map['user_account']=['like','%'.I('user_account').'%']; + } + if(!empty($_REQUEST['start'])&&empty($_REQUEST['end'])){ + $map['create_time'] = array('GT',strtotime($_REQUEST['start'])); + unset($_REQUEST['start']); + } + if(empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ + $map['create_time'] = array('LT',strtotime($_REQUEST['end'])+24*60*60-1); + unset($_REQUEST['end']); + } + if(!empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ + $map['create_time'] = array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); + unset($_REQUEST['start']);unset($_REQUEST['end']); + } + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'test_'.time(), + 'admin_id' => PID, + 'type' => '/Home/TestResource/index', + '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')); + } + + /** + * 测试资源申请记录 + * @author sunke + */ + public function testresourcelists_data_export() { + $map1['chain'] = ['like','%'.PID.'/'.'%']; + $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_test_resource.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_test_resource.promote_id'] = ['in', $childPromoteIds]; + } + + if(!empty(I('type'))||I('type')==='0'){ + $map['apply_status']=I('type'); + } + + if(!empty(I('role_name'))){ + $map['role_name']=['like','%'.I('role_name').'%']; + } + if(!empty(I('server_name'))){ + $map['server_name']=I('server_name'); + } + if(!empty(I('game_name'))){ + $map['game_name']=I('game_name'); + } + if(!empty(I('user_account'))){ + $map['user_account']=['like','%'.I('user_account').'%']; + } + if(!empty($_REQUEST['start'])&&empty($_REQUEST['end'])){ + $map['create_time'] = array('GT',strtotime($_REQUEST['start'])); + unset($_REQUEST['start']); + } + if(empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ + $map['create_time'] = array('LT',strtotime($_REQUEST['end'])+24*60*60-1); + unset($_REQUEST['end']); + } + if(!empty($_REQUEST['start'])&&!empty($_REQUEST['end'])){ + $map['create_time'] = array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); + unset($_REQUEST['start']);unset($_REQUEST['end']); + } + //$data=M('test_resource','tab_')->where($map)->order('id desc')->select(); + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'test_'.time(), + 'admin_id' => PID, + 'type' => '/Home/TestResource/lists', + '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')); + } + + /** + * 扶持号管理 + * @author sunke + */ + public function supportNumberList_data_export() { + $map1['chain'] = ['like','%'.PID.'/'.'%']; + $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_test_resource.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_test_resource.promote_id'] = ['in', $childPromoteIds]; + } + + if(!empty(I('server_name'))){ + $map['tab_test_resource.server_name']=I('server_name'); + } + if(!empty(I('game_name'))){ + $map['tab_test_resource.game_name']=I('game_name'); + } + if(!empty(I('role_name'))){ + $map['tab_test_resource.role_name']=['like','%'.I('role_name').'%']; + } + if(!empty(I('user_account'))){ + $map['tab_test_resource.user_account']=['like','%'.I('user_account').'%']; + } + if(!empty(I('promote_id'))){ + $map['tab_test_resource.promote_id']=I('promote_id'); + } + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'test_'.time(), + 'admin_id' => PID, + 'type' => '/Home/TestResource/supportNumberList', + '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')); + + } + + /** + * arpu统计 + * @author sunke + */ + public function arpu_data_export() { + $defaultTime = date('Y-m-d', time() - 6 * 24 * 3600) . ' 至 ' . date('Y-m-d'); + + $time = I('time', ''); + $time = $time == '' ? $defaultTime : $time; + $sdkVersion = I('sdk_version', 0); + $gameId = I('game_id', 0); + $serverId = I('server_id', 0); + + $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.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['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)) { + $pro = ""; + foreach ($ids as $value1) { + $pid = $value1; + $pro .= $pid.','; + } + $pro = rtrim($pro,','); + $map['promote_id'] = ['in',$pro]; + + }else { + $map['_string'] = '1<>1'; + } + + $searchGameName = ''; + $searchServerName = ''; + if ($gameId > 0) { + $map['game_id'] = $gameId; + $searchGameName = M('game', 'tab_')->where(['id' => $gameId])->getField('game_name'); + } + if ($serverId > 0) { + $map['server_id'] = $serverId; + $searchServerName = M('server', 'tab_')->where(['server_id' => $serverId])->getField('server_name'); + } + if ($sdkVersion > 0) { + $map['sdk_version'] = $sdkVersion; + } + list($beginTime, $endTime) = $this->getBetweenTime($time); + $map['begin_time'] = $beginTime; + $map['end_time'] = $endTime; + + $dayList = $this->getDayList($beginTime, $endTime); + $map['dayList'] = $dayList; + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'zc_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/arpu', + 'dataname' => 'ARPU统计', + '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')); + + } + /** + * 注册数据添加下载 + * @author sunke + */ + public function regist_data_export() { + + $map1['chain'] = ['like','%'.PID.'/'.'%']; + $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_user.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_user.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_user.promote_id'] = ['in',$ids]; + + }else { + $map['_string'] = '1<>1'; + } + + if (!empty(I('own_id'))) { + $map['tab_user.promote_id'] = $queryPromote['id'];//本账号 + } + + if (!empty(I('begtime')) && empty(I('endtime'))) { + $map['tab_user.register_time'] = ['egt', strtotime(I('begtime'))]; + } elseif (empty(I('begtime')) && !empty(I('endtime'))) { + $map['tab_user.register_time'] = ['elt', strtotime(I('endtime')) + 86399]; + } elseif (!empty(I('begtime')) && !empty(I('endtime'))) { + $map['tab_user.register_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]]; + } + + empty(I('account')) || $map['tab_user.account'] = ['like', '%' . I('account') . '%']; + empty(I('id')) || $map['tab_user.id'] = intval(I('id')); + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'zc_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/registe', + '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 children_data_export() { + $promoteType = intval(I('promote_type', 0)); + $loginer = $this->getLoginPromote(); + $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.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['promote_id'] = ['in', $childPromoteIds]; + } + + if ($promoteType == 0) { + $map['level'] = 2; + } elseif ($promoteType == 1) { + $map['level'] = 3; + } elseif ($promoteType == 2) { + $map['level'] = 4; + } + if(I('account', '')) { + $map['account'] = ['like', '%' . I('account', '') . '%']; + } + if (I('mobile', '')) { + $map['mobile_phone'] = ['like', '%' . I('mobile', '') . '%']; + } + if (I('idcard', '')) { + $map['idcard'] = ['like', '%' . I('idcard', '') . '%']; + } + if (I('real_name', '')) { + $map['real_name'] = ['like', '%' . I('real_name', '') . '%']; + } + if (I('status', 'all') != 'all') { + $map['status'] = ['eq', I('status', 'all')]; + } + $conditions = json_encode($map,TRUE); + $addtime = time(); + $type = "/Home/Promote/children/promote_type/".$promoteType; + $data = [ + 'logid' => 'cz_'.time(), + 'admin_id' => PID, + 'type' => $type, + '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')); + + } + + /** + * 平台币转移 + * @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.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $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) { + $map['sn'] = ['like','%'.$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')]; + } + if (!empty($searchUsers) && empty($searchPromotes)) { + $map['source_id'] = ['in', array_column($searchUsers, 'id')]; + } + 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); + $addtime = time(); + $type = "/Home/PromoteCoin/record"; + $data = [ + 'logid' => 'cr_'.time(), + 'admin_id' => PID, + 'type' => $type, + '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')); + + + } + + /** + * 我的平台币明细 + * @author sunke + */ + public function mycoinrecord_data_export() { + $map['tab_promote_coin_record.target_id'] = PID; + empty(I('type')) || $map['tab_promote_coin_record.type'] = I('type'); + empty(I('sub_type')) || $map['tab_promote_coin_record.sub_type'] = I('sub_type'); + + if (!empty(I('start_time')) && empty(I('end_time'))) { + $map['tab_promote_coin_record.create_time'] = ['egt', strtotime(I('start_time'))]; + } elseif (empty(I('start_time')) && !empty(I('end_time'))) { + $map['tab_promote_coin_record.create_time'] = ['elt', strtotime(I('end_time')) + 86399]; + } elseif (!empty(I('start_time')) && !empty(I('end_time'))) { + $map['tab_promote_coin_record.create_time'] = ['between', [strtotime(I('start_time')), strtotime(I('end_time')) + 86399]]; + } + + $having = ''; + $where['_string'] = '1 = 1'; + if (empty(I('get.game_id'))) { + $where['_logic'] = 'or'; + $join = 'left join tab_promote_coin on tab_promote_coin_record.ref_id = tab_promote_coin.id and tab_promote_coin_record.sub_type > 2 and tab_promote_coin.banlan_type = 1'; + $having = '(coin_id > 0 or pay_id > 0)'; + } else { + $where['tab_promote_coin_record.sub_type'] = ['gt', 2]; + $join = 'inner join tab_promote_coin on tab_promote_coin_record.ref_id = tab_promote_coin.id and tab_promote_coin.banlan_type = 2 and tab_promote_coin.game_id = ' . I('get.game_id'); + } + + if (!empty(I('handle_type'))) { + switch (I('handle_type')) { + case 1: + $where['tab_promote_coin.source_type'] = 1; + $join .= ' inner join tab_promote on tab_promote_coin.source_id = tab_promote.id and tab_promote.parent_id = 0'; + break; + case 2: + $where['tab_promote_coin.source_type'] = 1; + $join .= ' inner join tab_promote on tab_promote_coin.source_id = tab_promote.id and tab_promote.parent_id > 0 and tab_promote.grand_id = 0'; + break; + case 3: + $where['tab_promote_coin.source_type'] = 1; + $join .= ' inner join tab_promote on tab_promote_coin.source_id = tab_promote.id and tab_promote.grand_id > 0'; + break; + case 4: + $where['tab_promote_coin.source_type'] = 2; + break; + } + } + + $join .= ' left join tab_coin_pay_order on tab_promote_coin_record.ref_id = tab_coin_pay_order.id and tab_promote_coin_record.sub_type in (1,2)'; + $map['_complex'] = $where; + $conditions = json_encode($map,TRUE); + $addtime = time(); + $type = "/Home/PromoteCoin/coinRecord"; + $data = [ + 'logid' => 'pt_'.time(), + 'admin_id' => PID, + 'type' => $type, + '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')); + + + } + /** + * 我的平台币 + * @author sunke + */ + public function mycoin_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.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['promote_id'] = ['in', $childPromoteIds]; + } + // var_dump($map); + $game_id = I('game_id'); + if(!empty($game_id)) { + $map['game_id'] = $game_id; + } + $status = I("status"); + if(!empty($status)) { + $map['status'] = $status; + } + $coin_type = I('coin_type'); + if(!empty($coin_type)) { + switch ($coin_type) { + case 1: + $map['game_id'] = 0; + break; + case 2: + $map['game_id'] = ["gt",0]; + break; + } + } + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $type = "/Home/PromoteCoin/myCoin"; + $data = [ + 'logid' => 'pt_'.time(), + 'admin_id' => PID, + 'type' => $type, + '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')); + } + /** + * 充值明细添加下载 + * @author sunke + */ + public function recharge_data_export() { + + $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.pay_time'] = ['egt', strtotime(I('begtime'))]; + } elseif (empty(I('begtime')) && !empty(I('endtime'))) { + $map['tab_spend.pay_time'] = ['elt', strtotime(I('endtime')) + 86399]; + } elseif (!empty(I('begtime')) && !empty(I('endtime'))) { + $map['tab_spend.pay_time'] = ['between', [strtotime(I('begtime')), strtotime(I('endtime')) + 86399]]; + } + + 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('order_number')) || $map['tab_spend.order_number'] = I('order_number'); + $map['tab_spend.pay_status'] = 1; + $map['tab_spend.is_check'] = ['neq', 2]; + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'cz_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/recharge', + '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('game_id', 0); + $serverId = I('server_id', 0); + $isSelf = I('is_self', 0); + $roleName = I('role_name', ''); + $userAccount = I('user_account', ''); + $promoteId = I('promote_id', 0); + $sdkVersion = I('sdk_version', 0); + $headmanPromoteId = I('headman_promote_id', 0); + $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.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['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['promote_id'] = ['in',$ids]; + + }else { + $map['_string'] = '1<>1'; + } + + if ($gameId != 0) { + $map['game_id'] = $gameId; + } + if ($serverId != 0) { + $map['server_id'] = $serverId; + } + if ($roleName != '') { + $map['role_name'] = ['like', '%' . $roleName . '%']; + } + if ($userAccount != '') { + $map['user_account'] = ['like', '%' . $userAccount . '%']; + } + if ($sdkVersion != 0) { + $map['sdk_version'] = $sdkVersion; + } + if ($isSelf) { + $map['promote_id'] = $queryPromote['id'];//本账号 + } else { + if ($headmanPromoteId != 0) { + $map['promote_id'] = $headmanPromoteId; + } + if ($promoteId != 0) { + $map['promote_id'] = $promoteId; + } + } + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'wj_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/userRecharges', + 'dataname' => '充值玩家数据', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' =>$conditions + ]; + $res = M('downloadlog','tab_')->add($data); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功',U('listsIndex')); + + } + + public function achievement_data_export() { + $time = I('time', date('Y-m-d')); + $sdkVersion = I('sdk_version', 0); + $gameId = I('game_id', 0); + $serverId = I('server_id', 0); + $parentId = I('parent_id', 0); + $promoteId = I('promote_id', 0); + $status = I('status', 0); + $searchLevel = 0; + $searchLevelName = ''; + $currentDisplay = ''; + $prevParentId = 0; + $promoteService = new PromoteService(); + $loginPromote = $this->getLoginPromote(); + $parent = null; + if ($parentId > 0) { + $parent = M('promote', 'tab_')->where(['id' => $parentId])->find(); + $currentDisplay = $promoteService->getLevelName($parent['level']) . '推广'; + $prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id']; + } else { + $parent = $loginPromote; + $currentDisplay = '自己'; + } + $map = ['parent_id' => $parent['id']]; + if ($promoteId > 0) { + $map['id'] = $promoteId; + } + $data = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level'])->where($map)->select(); + $ids = array_column($data, 'id'); + $rows = []; + if (count($ids) > 0) { + $rows = M('promote', 'tab_')->field(['id', 'parent_id'])->where(['parent_id' => ['in', $ids]])->select(); + } + $basicPromotes = []; + foreach ($rows as $row) { + $basicPromotes[$row['id']] = $row['parent_id']; + } + $map = [ + 'isContainSubs' => true, + 'basicPromotes' => json_encode($basicPromotes,FALSE), + ]; + $map['promotes'] = json_encode($data,FALSE); + $map['ids'] = $ids; + if ($gameId > 0) { + $params['game_id'] = $gameId; + } + if ($serverId > 0) { + $params['server_id'] = $serverId; + } + if ($sdkVersion > 0) { + $params['sdk_version'] = $sdkVersion; + } + if ($status > 0) { + $params['lock_status'] = $status; + } + list($beginTime, $endTime) = $this->getBetweenTime($time); + $map['begin_time'] = $beginTime; + $map['end_time'] = $endTime; + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data1 = [ + 'logid' => 'tg_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/achievement', + 'dataname' => '推广员业绩', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' =>$conditions + ]; + $res = M('downloadlog','tab_')->add($data1); + if (!$res) { + // $this->ajaxReturn(array("status" => -1, "msg" => "添加导出日志失败", 'ret' => $res)); + $this->error('添加下载失败'); + } + $this->success('添加下载成功',U('listsIndex')); + + } + //玩家角色 + public function userRoles_data_export() { + $gameId = I('game_id', 0); + $serverId = I('server_id', 0); + $isSelf = I('is_self', 0); + $roleName = I('role_name', ''); + $userAccount = I('user_account', ''); + $promoteId = I('promote_id', 0); + $sdkVersion = I('sdk_version', 0); + $roleLevelBegin = intval(I('role_level_begin', 0)); + $roleLevelEnd = intval(I('role_level_end', 0)); + $headmanPromoteId = I('headman_promote_id', 0); + $playTime = I('play_time', ''); + $promote = $this->getLoginPromote(); + $map1['chain'] = ['like','%'.PID.'/'.'%']; + $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_user.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['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['promote_id'] = ['in',$ids]; + + }else { + $map['_string'] = '1<>1'; + } + + + if ($gameId != 0) { + $map['game_id'] = $gameId; + } + if ($serverId != 0) { + $map['serverId'] = $serverId; + } + if ($roleName != '') { + $map['role_name'] = ['like', '%' . $roleName . '%']; + } + if ($userAccount != '') { + $map['user_account'] = ['like', '%' . $userAccount . '%']; + } + if ($sdkVersion != 0) { + $map['sdk_version'] = $sdkVersion; + } + if ($roleLevelBegin != 0 && $roleLevelEnd == 0) { + $map['role_level'] = ['egt', $roleLevelBegin]; + } elseif ($roleLevelEnd != 0 && $roleLevelBegin == 0) { + $map['role_level'] = ['elt', $roleLevelEnd]; + } elseif ($roleLevelEnd != 0 && $roleLevelBegin != 0) { + $map['role_level'] = ['between', [$roleLevelBegin, $roleLevelEnd]]; + } + if ($playTime != '') { + $playTimeRow = explode(' 至 ', $playTime); + $playTimeBegin = 0; + $playTimeEnd = 0; + if (count($playTimeRow) == 2) { + $playTimeBegin = strtotime($playTimeRow[0] . ' 00:00:00'); + $playTimeEnd = strtotime($playTimeRow[1] . ' 23:59:59'); + } else { + $playTimeBegin = strtotime($playTimeRow[0] . ' 00:00:00'); + $playTimeEnd = strtotime($playTimeRow[0] . ' 23:59:59'); + } + $map['play_time'] = ['between', [$playTimeBegin, $playTimeEnd]]; + } + if ($isSelf) { + $map['promote_id'] = $queryPromote['id']; + } else { + if ($headmanPromoteId != 0) { + $map['promote_id'] = $headmanPromoteId; + } + if ($promoteId != 0) { + $map['promote_id'] = $promoteId; + } + } + + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'js_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/userRoles', + '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')); + + + } + /** + * 数据汇总添加下载 + * @author sunke + */ + public function summary_data_export() { + $promoteId = I('promote_id',0); + $teamLeaderId = I('team_leader_id',0); + $own_id = I('own_id',0); + $relation_game_id = I('relation_game_id',0); + $sdk_version = I('sdk_version',0); + $begtime = I('begtime',''); + $endtime = I('endtime',''); + // $childPromoteIds = getAllChildPromoteList(3); + $map1['chain'] = ['like','%'.PID.'/'.'%']; + $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); + $childPromoteIds = ''; + if(empty($rs)) { + $map['tab_user.promote_id'] = PID; + }else { + foreach ($rs as $rsKey => $rsValue) { + $id = $rsValue['id']; + $childPromoteIds .= $id.','; + } + $childPromoteIds = rtrim($childPromoteIds, ','); + $childPromoteIds .= ',' . PID; + $map['tab_apply.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_apply.promote_id'] = ['in',$ids]; + + }else { + $map['_string'] = '1<>1'; + } + + if (!empty($own_id)) { + if (!empty($map['_string'])) { + unset($map['_string']); + unset($userPlayInfoWhere['_string']); + unset($userGameLoginWhere['_string']); + unset($spendWhere['_string']); + } + + $map['tab_apply.promote_id'] = $queryPromote['id'];//本账号 + + } + empty($relation_game_id) || $map['tab_game.relation_game_id'] = $relation_game_id; + empty($sdk_version) || $map['tab_game.sdk_version'] = $sdk_version; + if(!empty($begtime) && !empty($endtime)) { + $map["apply_time"] = ["between",[$begtime,$endtime]]; + } + $serverField = ''; + $serverJoin = ''; + if (!empty(I('server_id'))) { + $map['tab_server.id'] = I('server_id'); + } + + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data = [ + 'logid' => 'hz_'.time(), + 'admin_id' => PID, + 'type' => '/Home/Query/summary', + '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 export() { //开始导出 + $id = $_REQUEST['id']; + $dataname = $_REQUEST['dataname']; + $downloadStatus = M('downloadlog','tab_')->where(['id'=>$id])->field('status')->select(); + if($downloadStatus[0]['status'] == 1) { + $this->error("该数据已下载请重新添加",U('listsIndex')); + } + $conditions = $_REQUEST['conditions']; + $map = array(); + foreach (json_decode($conditions,FALSE) as $key => $value) { + if($value !== 0 && $value !== "" ) { + $map[$key] = $value; + } + } + switch ($dataname) { + case "注册明细数据": + $this->registerExcelInfo($id,$map); //注册明细 + break; + case "角色查询数据": + $this->userRolesExcelInfo($id,$map); //角色查询 + break; + case "数据汇总数据": + $this->summaryExcelInfo($id,$map); + break; + case "充值明细数据": + $this->rechargeExcelInfo($id,$map); + break; + case "充值玩家数据": + $this->userRechargeExcelInfo($id,$map); + break; + case "推广员业绩": + $this->achievementExcelInfo($id,$map); + break; + case "渠道管理": + $this->childrenExcelInfo($id,$map); + break; + case "我的平台币": + $this->mycoinExcelInfo($id,$map); + break; + case "我的平台币明细"; + $this->mycoinRecordExcelInfo($id, $map); + break; + case "平台币转移": + $this->coinrecordExcelInfo($id,$map); + break; + case "申请测试资源": + $this->testresourceExcelInfo($id,$map); + break; + case "申请测试资源记录": + $this->testresourcelistExcelInfo($id, $map); + break; + case "扶持号管理": + $this->supportNumberListExcelInfo($id, $map); + break; + case "ARPU统计": + $this->arpuExcelInfo($id,$map); + break; + case "每日概况": + $this->dailysummaryExcelInfo($id,$map); + break; + case "结算中心": + $this->financeindexExcelInfo($id,$map); + break; + case "结算明细": + $this->settlementExcelInfo($id,$map); + break; + case "提现记录": + $this->withdrawRecordExcelInfo($id,$map); + break; + case "提现明细": + $this->withdrawDtlExcelInfo($id,$map); + default: + break; + } + } + + //注册明细excel信息 + public function registerExcelInfo($id,$map) { + $xlsName = "注册明细"; + $xlsCell = array( + array('account','玩家账号'), + array('promote_account','推广账号'), + array('register_time','注册时间'), + array('register_ip','注册ip'), + array('login_time','登陆时间'), + array('login_ip','登陆ip') + ); + $model = M('user','tab_'); + + $data = $model->field('account,promote_account,register_time,register_ip,login_time,login_ip')->where($map)->select(); + //var_dump($data); + $xlsData = []; + foreach ($data as $key1 => $value1) { + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + //玩家角色excel信息 + public function userRolesExcelInfo($id,$map) { + $xlsName = "角色查询"; + $xlsCell = array( + array('user_account','玩家账号'), + array('promote_account','推广账号'), + array('game_name','游戏名称'), + array('server_name','区服'), + array('user_nickname','游戏昵称'), + array('role_level','等级'), + ); + $model = M('user_play_info','tab_'); + $data = $model->field('user_account,promote_account,game_name,server_name,user_nickname,role_level')->where($map)->select(); + $xlsData = []; + foreach ($data as $key1 => $value1) { + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + //数据汇总excel信息 + public function summaryExcelInfo($id,$map) { + $xlsName = "数据汇总"; + $xlsCell = array( + array('game_name','游戏名称'), + array('sdk_version','平台'), + array('role_num','创角数'), + array('user_num','创建用户'), + array('new_user_num','新创角用户'), + array('new_device_num','新创角设备'), + array('new_ip_num','新增创角ip'), + array('login_user_num','登陆用户数'), + array('spend_user_num','充值人数'), + array('spend_num','充值次数'), + array('spend_all_amount','充值总额'), + array('spend_cash','现金充值'), + array('spend_generic','通用币充值'), + array('spend_binding','绑定币充值'), + array('spend_discount','折扣币充值'), + array('spend_voucher','代金券使用'), + + + ); + if(!empty($map['tab_apply.promote_id'][1])) { + $params['promote_ids'] = $map['tab_apply.promote_id'][1]; + } + $serverJoin = ''; + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $params['begin_time'] = $begTime; + $params['end_time'] = $endTime; + if(!empty($map['apply_time'][1])) { + $begTime = $map['apply_time'][1][0]; + $endTime = $map['apply_time'][1][1]; + $params['begin_time'] = $begTime; + $params['end_time'] = $endTime; + unset($map['apply_time']); + } + if(!empty($map['tab_server.server_id'])) { + $serverJoin = 'tab_server on tab_server.game_id = tab_apply.game_id'; + $params['server_id'] = $map['tab_server.server_id']; + } + $data = M('Apply', 'tab_') + ->field('tab_apply.game_id,tab_apply.game_name,tab_apply.sdk_version') + ->join('tab_game as g on g.id = tab_apply.game_id') + ->join($serverJoin)//关联区服表 + ->where($map) + ->group('tab_apply.game_id') + ->order('g.sort desc,tab_apply.id desc') + ->select(); + $records = []; + if (!empty($data)) { + if (intval($endTime - $begTime) / (24 * 3600) <= 30) { + $gameIds = []; + foreach ($data as $list) { + $gameIds[] = $list['game_id']; + } + $params['game_ids'] = $gameIds; + + $userRepository = new UserRepository(); + $spendRepository = new SpendRepository(); + $roleNumList = $userRepository->getCreateRoleCountByGame($params);//创角数 + $userNumList = $userRepository->getCreateRoleUserCountByGame($params);//创角用户 + $newUserNumList = $userRepository->getNewCreateRoleUserCountByGame($params);//新创角用户 + $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByGame($params);//新创角设备 + $newIpNumList = $userRepository->getNewCreateRoleIpCountByGame($params);//新创角IP + $loginUserNumList = $userRepository->getLoginCountGroupByGame($params);//登录用户数 + $spendUserNumList = $spendRepository->getPayUserCountGroupByGame($params);//充值人数 + $spendNumList = $spendRepository->getPayCountGroupByGame($params);//充值次数 + $spendAllAmountList = $spendRepository->getPayAmountGroupByGameAndType($params);//充值总额 + $params['pay_way'] = ['in', '1,2,3,4,5,6']; + $spendCashList = $spendRepository->getPayAmountGroupByGameAndType($params);//现金充值 + $params['pay_way'] = 0; + $spendGenericList = $spendRepository->getPayAmountGroupByGameAndType($params);//通用币充值 + $params['pay_way'] = -1; + $spendBindingList = $spendRepository->getPayAmountGroupByGameAndType($params);//绑定币充值 + foreach ($data as &$list) { + $gameId = $list['game_id']; + $records[] = [ + 'game_id' => $gameId, + 'game_name' => $list['game_name'], + 'sdk_version' => $list['sdk_version'], + 'role_num' => $roleNumList[$gameId], + 'user_num' => $userNumList[$gameId], + 'new_user_num' => $newUserNumList[$gameId], + 'new_device_num' => $newDeviceNumList[$gameId], + 'new_ip_num' => $newIpNumList[$gameId], + 'login_user_num' => $loginUserNumList[$gameId], + 'spend_user_num' => $spendUserNumList[$gameId], + 'spend_num' => $spendNumList[$gameId], + 'spend_all_amount' => $spendAllAmountList[$gameId], + 'spend_cash' => $spendCashList[$gameId], + 'spend_generic' => $spendGenericList[$gameId], + 'spend_binding' => $spendBindingList[$gameId], + 'spend_discount' => 0, + 'spend_voucher' => 0, + ]; + } + } + } + + + $xlsData = []; + foreach ($records as $key1 => $value1) { + if($value1["sdk_version"] == 1) { + $value1["sdk_version"] = "安卓"; + } + if($value1["sdk_version"] == 2) { + $value1["sdk_version"] = "苹果"; + } + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + /* + *渠道管理 + */ + public function childrenExcelInfo($id,$map) { + $xlsName = "渠道管理"; + $xlsCell = array( + array('id','ID'), + array('account','账号'), + array('real_name','真实姓名'), + array('idcard','身份证'), + array('mobile_phone','手机号'), + array('parent_name','上级渠道'), + array('nickname','昵称'), + array('promotestatus','帐号状态'), + array('create_time','创建时间'), + + ); + + $model = M('promote','tab_'); + $data = $model->where($map)->select(); + $xlsData = []; + foreach ($data as $key1 => $value1) { +// $value1['status'] = $this->payWay[$value1['pay_way']]; + $value1['promotestatus'] = "未知状态"; + if($value1['status'] == 0) { + $value1['promotestatus'] = "审核中"; + } + if($value1['status'] == 1) { + $value1['promotestatus'] = "启用"; + } + if($value1['status'] == 2) { + $value1['promotestatus'] = "冻结中"; + } + + $value1['create_time'] = date('Y-m-d H:i:s',$value1['create_time']); + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function mycoinExcelInfo($id,$map) { + $xlsName = "我的平台币"; + $xlsCell = array( + array('cointype','平台币类型'), + array('game_name','游戏名称'), + array('num','平台币余额'), + array('status','资产状态'), + + ); + $data = M('PromoteBalanceCoin', 'tab_') + ->field('tab_promote_balance_coin.*,tab_game.game_name') + ->join('left join tab_game on tab_promote_balance_coin.game_id = tab_game.id') + ->where($map) + ->select(); + foreach($data as $key => $value) { + if($value['game_id'] == 0) { + $value['cointype'] = "通用币"; + $value['game_name'] = "通用"; + }else { + $value['cointype'] = "绑定币"; + $value['game_name'] = $value['game_name']; + } + if($value['status'] == 1) { + $value['status'] = "正常"; + }elseif($value['status'] == 2) { + $value['status'] = "锁定"; + }else { + $value['status'] = "验证失败"; + } + $xlsData[] = $value; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function mycoinRecordExcelInfo($id,$map) { + $xlsName = "我的平台币明细"; + $xlsCell = array( + array('sn','流水号'), + array('type','操作类型'), + array('sub_type','操作方式'), + array('handle_type','账号类型'), + array('coin','平台币数量'), + array('balance_coin','平台币余额'), + array('description','交易说明'), + array('create_time','交易时间'), + ); + $join .= ' left join tab_coin_pay_order on tab_promote_coin_record.ref_id = tab_coin_pay_order.id and tab_promote_coin_record.sub_type in (1,2)'; + $data = M('PromoteCoinRecord', 'tab_') + ->field('tab_promote_coin_record.*,tab_promote_coin.id as coin_id,tab_promote_coin.source_type,tab_promote_coin.source_id,tab_coin_pay_order.id as pay_id') + ->join($join) + ->where($map) + ->having($having) + ->order('id desc') + // ->fetchSql(true) + ->select(); + + } + + // 我的平台币的交易明细 + public function coinrecordExcelInfo($id,$map) { + $xlsName = "平台币转移"; + $xlsCell = array( + array("sn","订单号"), + array("source_name","收款方账号"), + array("game_name","适用游戏"), + array("handle_type","账号类型"), + array("num","转账数量"), + array('description',"交易说明"), + 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']; + } + } + $sourceUsers = $this->getRecordsByIds(M('User', 'tab_'), $sourceUserIds, ['indexBy' => 'id']); + $sourcePromotes = $this->getRecordsByIds(M('Promote', 'tab_'), $sourcePromoteIds, ['indexBy' => 'id']); + $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 ? '成功' : '失败', + ]; + } + $xlsData[] = $records; + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + + } + + public function testresourceExcelInfo($id,$map) { + $xlsName = "测试资源"; + $xlsCell = array( + array('game_name',"产品名称"), + array('server_name',"区服"), + array('user_account',"测试账号"), + array('promote_account',"所属推广员"), + array('role_name',"角色名称"), + array('verify_resource_count',"累计发放资源"), + array('verify_count',"累计发放次数"), + array('apply_resource_count',"申请数量"), + array('check_status',"状态"), + array('create_time',"创建时间"), + ); + + $data = M('test_resource','tab_') + ->field("tab_test_resource.*,user.check_status") + ->join('tab_user user on tab_test_resource.user_id=user.id','left') + ->order("create_time desc") + ->where($map) + ->group("user_id,game_id,server_id") + ->select(); + foreach ($data as $key => $value) { + $value['create_time'] = date("Y-m-d H:i:s", $value['create_time']); + //获取累计发放 + $where = array( + "user_id"=>$value['user_id'], + "game_id"=>$value['game_id'], + "server_id"=>$value['server_id'] + ); + $where1 = array( + "apply_status"=>2, + ); + //获取累计 + $verify_resource = M('test_resource','tab_')->field("IFNULL(sum(verify_resource),0) verify_resource_count,count(*) verify_count")->where(array_merge($where,$where1))->find(); + //获取申请 + $where2 = array( + "apply_status"=>0, + ); + $apply_resource = M('test_resource','tab_')->field("IFNULL(sum(apply_resource),0) apply_resource_count")->where(array_merge($where,$where2))->find(); + $data[$key] = array_merge($value,$verify_resource,$apply_resource); + } + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + + + } + + public function testresourcelistExcelInfo($id,$map){ + $xlsName = "测试资源申请记录"; + $xlsCell = array( + array('game_name',"游戏名称"), + array('server_name',"区服"), + array('user_account',"测试账号"), + array('phone',"手机号"), + array('role_name',"角色名称"), + array('apply_resource',"申请数量"), + array('verify_resource',"实际发放"), + array('apply_remark',"备注"), + array('apply_status',"审核状态"), + array('verify_remark',"审核意见"), + array('promote_account',"申请人"), + array('create_time',"申请时间"), + array('verify_time',"审核时间"), + ); + $data=M('test_resource','tab_')->where($map)->order('id desc')->select(); + foreach($data as $key => $value) { + if($value['apply_status'] == 1) { + $data[$key]['apply_status'] = "审核未通过"; + } + elseif($value['apply_status'] == 2) { + $data[$key]['apply_status'] = "审核通过"; + } + else { + $data[$key]['apply_status'] = "待审核"; + } + $data[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']); + $data[$key]['verify_time'] = date('Y-m-d H:i:s',$value['verify_time']); + } + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function supportNumberListExcelInfo($id,$map) { + $xlsName = "扶持号管理"; + $xlsCell = array( + array('game_name',"产品名称"), + array('server_name',"区服"), + array('user_account',"测试账号"), + array('promote_account',"所属推广员"), + array('role_name',"角色名称"), + array('device_number',"设备信息"), + array('check_status',"状态"), + array('create_time',"创建时间"), + ); + $data = M('test_resource','tab_') + ->field('tab_test_resource.id,tab_test_resource.user_id,tab_test_resource.game_name,tab_test_resource.server_name,tab_test_resource.user_account,tab_test_resource.promote_account,tab_test_resource.role_name,tab_test_resource.create_time,device_number,lock_status as check_status') + ->join('left join tab_user as user on tab_test_resource.user_id = user.id') + ->where($map) + ->order('tab_test_resource.create_time DESC') + ->select(); + foreach ($data as $key => $value) { + $data[$key]['create_time'] = date('Y-m-d H:m:i',$value['create_time']); + if($value['check_status'] == 1) { + $data[$key]['check_status'] = "冻结"; + }else { + $data[$key]['check_status'] = "启用"; + } + } + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function arpuExcelInfo($id,$params) { + $xlsName = "ARPU统计"; + $xlsCell = array( + array('day','日期'), + array('payGameCount','付费游戏数'), + array('loginCount','活跃用户'), + array('registerCount','新增用户'), + array('payUserCount','付费用户'), + array('newPayUserCount','新增付费用户'), + array('payAmount','付费总额'), + array('payRate','付费率'), + array('newPayAmount','新增付费额'), + array('historyPayCount','累计付费用户'), + array('arpu','ARPU'), + array('arppu','ARPPU'), + ); + $dayList = $params["dayList"]; + $arr = explode(',', $params['promote_id'][1]); + $params['promote_id'] = $arr; + $records = []; + $userRepository = new UserRepository(); + $spendRepository = new SpendRepository(); + $payGameCountList = $spendRepository->getPayGameCountGroupByDay($params); + $payUserCountList = $spendRepository->getPayUserCountGroupByDay($params); + $newPayUserCountList = $spendRepository->getNewPayUserCountGroupByDay($params); + $payAmountList = $spendRepository->getPayAmountGroupByDay($params); + $newPayAmountList = $spendRepository->getNewPayAmountGroupByDay($params); + $historyPayCountList = $spendRepository->getHistoryPayCountGroupByDay($params); + $loginCountList = $userRepository->getLoginCountGroupByDay($params); + $registerCountList = $userRepository->getRegisterCountGroupByDay($params); + + foreach ($dayList as $day) { + $records[] = [ + 'day' => $day, + 'payGameCount' => $payGameCountList[$day], + 'payUserCount' => $payUserCountList[$day], + 'newPayUserCount' => $newPayUserCountList[$day], + 'payAmount' => number_format($payAmountList[$day], 2), + 'newPayAmount' => number_format($newPayAmountList[$day], 2), + 'historyPayCount' => $historyPayCountList[$day], + 'loginCount' => $loginCountList[$day], + 'registerCount' => $registerCountList[$day], + 'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day] / $loginCountList[$day] * 100, 2) . '%', + 'ratentionOneDay' => '--', + 'arpu' => $loginCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $loginCountList[$day], 2), 2), + 'arppu' => $payUserCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $payUserCountList[$day], 2), 2), + ]; + } + $xlsData = []; + foreach ($records as $key1 => $value1) { + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + + + } + + public function withdrawDtlExcelInfo($id,$map) { + $xlsName = "提现记录"; + $xlsCell = array( + array('pay_order_number','充值订单号'), + array('game_name','游戏'), + array('sdk_version','平台'), + array('user_account','玩家账号'), + array('pay_amount','订单总额'), + array('cash_base','现金分成基数'), + array('selle_ratio','现金分成比例'), + array('platform_base','平台币分成基数'), + array('selle_ratio','平台币分成比例'), + array('bind_base','绑定币分成基数'), + array('selle_ratio','绑定币分成比例'), + array('pay_way_name','现金支付通道'), + array('income','收益'), + array('status','订单状态'), + array('pay_time','充值时间'), + ); + $spendModel = M('spend', 'tab_'); + $withdrawId = $map['withdraw_id']; + $withdraw = M('withdraw', 'tab_')->field('promote_id,status')->where(array('id' => $withdrawId))->find(); + $data = $spendModel + ->field('id,pay_order_number,game_name,sdk_version,user_account,pay_amount,pay_way,selle_ratio,pay_time') + ->where($map) + ->order('id desc') + ->select(); + if (!empty($data)) { + foreach ($data as &$list) { + $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); + $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); + switch ($list['pay_way']) { + case 2: + case 3: + case 4: + $list['pay_way_name'] = QueryController::$payWay[2]; + break; + default: + $list['pay_way_name'] = QueryController::$payWay[$list['pay_way']]; + break; + } + if($list['pay_way'] !== -1 && $list['pay_way'] !== 0) { + $list['cash_base'] = $list['pay_amount']; + }else { + $list['cash_base'] = 0; + } + + if($list['pay_way'] == 0) { + $list['platform_base'] = $list['pay_amount']; + }else { + $list['platform_base'] = 0; + } + + if($list['pay_way'] == -1) { + $list['bind_base'] = $list['pay_amount']; + }else { + $list['bind_base'] = 0; + } + + $list['status'] = FinanceController::$withdrawStatus[$withdraw['status']]; + + + } + } + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function withdrawRecordExcelInfo($id,$map) { + $xlsName = "提现记录"; + $xlsCell = array( + array('widthdraw_number','提现订单'), + array('create_time','提现日期'), + array('settlement_end_time','结算截止日期'), + array('sum_money','收益金额'), + array('sum_money','实际提现金额'), + array('status','提现状态'), + array('respond','说明'), + ); + $model = M('withdraw', 'tab_'); + $data = $model->field('id,widthdraw_number,create_time,settlement_end_time,sum_money,status,respond') + ->where($map) + ->order('id desc') + ->select(); + if (!empty($data)) { + foreach ($data as &$list) { + $list['create_time'] = date('Y-m-d H:i:s', $list['create_time']); + $list['settlement_end_time'] = date('Y-m-d H:i:s', $list['settlement_end_time']); + $list['status'] = FinanceController::$withdrawStatus[$list['status']]; + } + } + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function settlementExcelInfo($id,$map) { + $xlsName = "结算明细"; + $xlsCell = array( + array('pay_order_number','游戏订单号'), + array('game_name','游戏'), + array('user_account','玩家账号'), + array('promote_account','推广员账号'), + array('pay_amount','订单总额'), + array('pay_amount_zhi','直充'), + array('pay_amount_nei','内充'), + array('selle_ratio','分成比例(直充)'), + array('selle_ratio','分成比例(内充)'), + array('income','收益'), + array('pay_time','充值时间'), + array('selle_status','订单状态'), + ); + $model = M('spend', 'tab_'); + $data = $model->field('pay_order_number,game_name,user_account,promote_account,pay_amount,pay_way,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_time,selle_status,pay_status,withdraw_id') + ->where($map) + ->order('id desc') + ->select(); + //提现状态 + $withdrawIds = []; + foreach ($data as $key => $value) { + if ($value['withdraw_id'] > 0 && !in_array($value['withdraw_id'], $withdrawIds)) { + $withdrawIds[] = $value['withdraw_id']; + } + } + if(empty($withdrawIds)) { + $withdrawIds = "-10000"; + } + $withdrawStatus = M('withdraw', 'tab_') + ->where(array('id' => ['in',$withdrawIds])) + ->getField('id,status'); + + foreach ($data as &$list) { + //提现状态 + if ($list['pay_status'] == 1) { + switch ($list['selle_status']) { + case 0: + $list['selle_status'] = '未提现'; + break; + default: + if ($list['withdraw_id'] > 0) { + $list['selle_status'] = FinanceController::$withdrawStatus[$withdrawStatus[$list['withdraw_id']]]; + } else { + $list['selle_status'] = ''; + } + break; + } + } else { + $list['selle_status'] = '支付失败'; + } + + $list['income'] = bcmul($list['pay_amount'], bcdiv($list['selle_ratio'], 100, 2), 2); + $list['pay_time'] = date('Y-m-d H:i:s', $list['pay_time']); + if($list['pay_way'] == -1) { + $list['pay_amount_zhi'] = 0; + $list['pay_amount_nei'] = $list['pay_amount']; + }else { + $list['pay_amount_zhi'] = $list['pay_amount']; + $list['pay_amount_nei'] = 0; + } + } + + $xlsData = $data; + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + + } + + public function financeindexExcelInfo($id,$map) { + $xlsName = "结算中心"; + $xlsCell = array( + array('day','时间'), + array('income','收益') + ); + if(!empty($map['pay_time'])) { + $begTime = $map['pay_time'][1][0]; + $endTime = $map['pay_time'][1][1]; + }else { + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $endTime = $endTime + 3600 * 24; + } + $model = M('spend', 'tab_'); + $dayList = $this->getDayList($begTime, $endTime); + $data = $model->field('FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day, + sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as income') + ->where($map) + ->group('day') + ->select(); + $data = $this->assembleRecords($data, $dayList, 'income'); + foreach ($dayList as $day) { + $date = date('Ymd', strtotime($day)); + $records[] = [ + 'day' => $date, + 'income' => bcdiv($data[$day], 100, 2), + + ]; + } + $xlsData = []; + foreach ($records as $key1 => $value1) { + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + + } + + public function dailysummaryExcelInfo($id,$map) { + $xlsName = "每日概况"; + $xlsCell = array( + array('day','日期'), + array('role_num','创角数'), + array('user_num','创角用户'), + array('new_user_num','新创角用户'), + array('new_device_num','新创角设备'), + array('new_ip_num','新增创角IP'), + array('login_user_num','登陆用户数'), + array('spend_user_num','充值人数'), + array('spend_num','充值次数'), + array('spend_all_amount','充值总额'), + array('spend_cash','现金充值'), + array('spend_generic','通用币充值'), + array('spend_binding','绑定币充值'), + array('spend_discount','折扣币充值'), + array('spend_voucher','代金劵使用'), + + ); + $nowTime = date('Y-m-d'); + $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); + $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); + $initEndTime = $nowTime; + $initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime'); + $begTime = strtotime($initBegTime); + $endTime = strtotime($initEndTime); + $params['promote_id'] = $map['promote_id']; + if(!empty($map['sdk_version']) || !empty($map['relation_game_id'])) { + if(!empty($map['gameIds'])) { + $params['game_id'] = ['in',$map['gameIds']]; + }else { + $params['_string'] = '1=2'; + } + } + if(!empty($map['begin_time'])) { + $params['begin_time'] = $map['begin_time']; + }else { + $params['begin_time'] = $begTime; + } + + if(!empty($map['end_time'])) { + $params['end_time'] = $map['end_time']; + }else { + $params['begin_time'] = $endTime; + } + $params['dayList'] = $map["dayList"]; + $summaryData = []; + $records = []; + if (intval($endTime - $begTime) / (24 * 3600) <= 30) { + $userRepository = new UserRepository(); + $spendRepository = new SpendRepository(); + $roleNumList = $userRepository->getCreateRoleCountByDay($params);//创角数 + $userNumList = $userRepository->getCreateRoleUserCountByDay($params);//创角用户 + $newUserNumList = $userRepository->getNewCreateRoleUserCountByDay($params);//新创角用户 + $newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params);//新创角设备 + $newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params);//新创角IP + $loginUserNumList = $userRepository->getLoginCountGroupByDayNew($params);//登录用户数 + $spendUserNumList = $spendRepository->getPayUserCountGroupByDayNew($params);//充值人数 + $spendNumList = $spendRepository->getPayCountGroupByDay($params);//充值次数 + $spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params);//充值总额 + $params['pay_way'] = ['in', '1,2,3,4,5,6']; + $spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params);//现金充值 + $params['pay_way'] = 0; + $spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值 + $params['pay_way'] = -1; + $spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params);//绑定币充值 + + foreach ($params['dayList'] as $day) { + $date = date('Ymd', strtotime($day)); + $records[] = [ + 'day' => $date, + 'role_num' => $roleNumList[$day], + 'user_num' => $userNumList[$day], + 'new_user_num' => $newUserNumList[$day], + 'new_device_num' => $newDeviceNumList[$day], + 'new_ip_num' => $newIpNumList[$day], + 'login_user_num' => $loginUserNumList[$day], + 'spend_user_num' => $spendUserNumList[$day], + 'spend_num' => $spendNumList[$day], + 'spend_all_amount' => $spendAllAmountList[$day], + 'spend_cash' => $spendCashList[$day], + 'spend_generic' => $spendGenericList[$day], + 'spend_binding' => $spendBindingList[$day], + 'spend_discount' => 0, + 'spend_voucher' => 0, + ]; + + } + $xlsData = []; + foreach ($records as $key1 => $value1) { + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + + } + + } + + public function achievementExcelInfo($tid,$map) { + $xlsName = "推广员业绩"; + $xlsCell = array( + array('account','账号'), + array('real_name','姓名'), + array('create_role_count','创角数'), + array('create_role_user_count','创角用户'), + array('new_create_role_user_count','新创角用户'), + array('new_create_role_device_count','新创角设备'), + array('new_create_role_ip_count','新创角ip'), + array('login_user_count','登陆用户数'), + array('recharge_count','充值人数'), + array('recharge_user_count','充值次数'), + array('recharge_amount','充值总额'), + array('recharge_by_ban_coin','现金充值'), + array('recharge_by_coin','通用币充值'), + array('recharge_by_cash','绑定币充值'), + + + ); + $params['isContainSubs'] =$map['isContainSubs']; + $params['basicPromotes'] = json_decode($map['basicPromotes'],TRUE); + $ids = $map['ids']; + $promotes = json_decode($map["promotes"],TRUE); + if(!empty($map['game_id'])) { + $params['game_id'] = $map["game_id"]; + } + if(!empty($map['server_id'])) { + $params['server_id'] = $map["server_id"]; + } + if(!empty($map['sdk_version'])) { + $params['sdk_version'] = $map["sdk_version"]; + } + if(!empty($map['lock_status'])) { + $params['lock_status'] = $map["lock_status"]; + } + $params['begin_time'] = $map['begin_time']; + $params['end_time'] = $map['end_time']; + +// var_dump($params);die(); + $promoteRepository = new PromoteRepository(); + $createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params); + $createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params); + $newCreateRoleUserCountList = $promoteRepository->getNewCreateRoleUserCountByIds($ids, $params); + $newCreateRoleDeviceCountList = $promoteRepository->getNewCreateRoleDeviceCountByIds($ids, $params); + $newCreateRoleIpCountList = $promoteRepository->getNewCreateRoleIpCountByIds($ids, $params); + $loginUserCountList = $promoteRepository->getLoginUserCountByIds($ids, $params); + $rechargeCountList = $promoteRepository->getRechargeCountByIds($ids, $params); + $rechargeUserCountList = $promoteRepository->getRechargeUserCountByIds($ids, $params); + $rechargeAmountList = $promoteRepository->getRechargeAmountByIds($ids, $params); + + $records = []; + foreach ($promotes as $promote) { + $id = $promote['id']; + $records[] = [ + 'id' => $id, + 'account' => $promote['account'], + 'real_name' => $promote['real_name'], + 'level' => $promote['level'], + 'create_role_count' => $createRoleCountList[$id], + 'create_role_user_count' => $createRoleUserCountList[$id], + 'new_create_role_user_count' => $newCreateRoleUserCountList[$id], + 'new_create_role_device_count' => $newCreateRoleDeviceCountList[$id], + 'new_create_role_ip_count' => $newCreateRoleIpCountList[$id], + 'login_user_count' => $loginUserCountList[$id], + 'recharge_count' => $rechargeCountList[$id], + 'recharge_user_count' => $rechargeUserCountList[$id], + 'recharge_amount' => $rechargeAmountList[$id]['ban_coin'] + $rechargeAmountList[$id]['coin'] + $rechargeAmountList[$id]['cash'], + 'recharge_by_ban_coin' => $rechargeAmountList[$id]['ban_coin'], + 'recharge_by_coin' => $rechargeAmountList[$id]['coin'], + 'recharge_by_cash' => $rechargeAmountList[$id]['cash'], + 'current_display' => '', + ]; + } + $xlsData = []; + foreach ($records as $key1 => $value1) { + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function rechargeExcelInfo($id,$map) { + $xlsName = "订单查询"; + $xlsCell = array( + array('user_account','玩家账号'), + array('order_number','游戏订单'), + array('pay_amount','订单金额'), + array('pay_way','支付方式'), + array('game_name','游戏名称'), + array('server_name','区服'), + array('game_player_name','角色名'), + array('pay_time','付款时间'), + + ); + $model = M('spend','tab_'); + $data = $model->where($map)->select(); + $xlsData = []; + foreach ($data as $key1 => $value1) { + $value1['pay_way'] = $this->payWay[$value1['pay_way']]; + $value1['pay_time'] = date('Y-m-d H:i:s',$value1['pay_time']); + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$id); + } + + public function backSuccessExport($id) { //导出成功后 + if(!$id) { + + }else { + $res = M('downloadlog','tab_')->where(['id'=>$id])->select(); + $data = $res[0]; + $data['status'] = 1; + $data['begintime'] = time(); + $updateRs = M('downloadlog','tab_')->where(['id'=>$id])->save($data); + } + + } + + + public function encryptDecrypt($key, $string, $decrypt){ + if($decrypt){ + $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "12"); + return $decrypted; + }else{ + $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); + return $encrypted; + } + } + +// public function getLoginPromote() +// { +// $promoteId = session('promote_auth.pid'); +// return M('promote', 'tab_')->where(['id' => $promoteId])->find(); +// } + + private function getGroupPromotes($promote) + { + $promotes = []; + if ($promote['parent_id'] == 0) { + $promotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select(); + } + return $promotes; + } + + public function paginate($query, $defaultPageSize = 10, $defaultPage = 1) + { + $page = I('get.p', $defaultPage); + $pageSize = I('get.row', $defaultPageSize); + + $countQuery = clone $query; + $count = $countQuery->count(); + $records = $query->page($page, $pageSize)->select(); + + $params = [ + 'p' => $page, + 'row' => $pageSize + ]; + $pagination = set_pagination($count, $pageSize); + + return [$records, $pagination, $count]; + } + + private function getGamesByPromote($promote) + { + return M('apply', 'tab_')->field(['game_id', 'game_name'])->where(['promote_id' => $promote['id']])->select(); + } + + private function getBetweenTime($time, $defaultBegin = 0, $defaultEnd = 0) + { + $delimiter = ' 至 '; + $begin = $defaultBegin; + $end = $defaultEnd; + if ($time != '') { + if (strpos($time, $delimiter) == -1) { + $begin = strtotime($time . ' 00:00:00'); + $end = strtotime($time . ' 23:59:59'); + } else { + $timeRow = explode($delimiter, $time); + $begin = strtotime($timeRow[0] . ' 00:00:00'); + $end = strtotime($timeRow[1] . ' 23:59:59'); + } + } + return [$begin, $end]; + } + + private function getQueryPromote($levelPromote) + { + $queryPromote = null; + $promote = $this->getLoginPromote(); + $queryPromoteId = 0; + foreach($levelPromote as $item) { + if ($item != 0) { + $queryPromoteId = $item; + } + } + if ($queryPromoteId == 0) { + $queryPromote = $this->getLoginPromote(); + } else { + $queryPromote = M('promote', 'tab_')->where(['id' => $queryPromoteId])->find(); + } + return $queryPromote; + } + + public function getHandleType($promoteCoin, $promote) + { + if ($promoteCoin['source_type'] == 2) { + return '玩家转账'; + } else { + if ($promote['parent_id'] == 1) { + return '会长转账'; + } elseif ($promote['parent_id'] > 0 && $promote['grand_id'] == 0) { + return '组长转账'; + } elseif ($promote['grand_id'] > 0) { + return '推广员转账'; + } + } + } + + private function getLevelPromote() + { + $levelPromote = []; + $levelPromote[] = I('level_promote_2', 0); + $levelPromote[] = I('level_promote_3', 0); + $levelPromote[] = I('level_promote_4', 0); + return $levelPromote; + } + + private function getDayList($beginTime, $endTime) + { + $dayList = []; + do { + $dayList[] = date('Y-m-d', $beginTime); + $beginTime += 24 * 60 * 60; + } while ($beginTime < $endTime); + + return $dayList; + } + + private function assembleRecords($items, $keys, $valueColumn, $keyColumn = 'day') + { + $records = []; + foreach ($keys as $key) { + $value = 0; + foreach ($items as $item) { + if ($item[$keyColumn] == $key) { + $value = $item[$valueColumn]; + } + } + $records[$key] = $value; + } + return $records; + } + public function getLoginPromote() + { + if ($this->loginPromote == null) { + $promoteId = session('promote_auth.pid'); + $this->loginPromote = M('promote', 'tab_')->where(['id' => $promoteId])->find(); + } + return $this->loginPromote; + } } + diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 6027adc5c..d30ee8a4f 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -38,16 +38,6 @@ class QueryController extends BaseController $row = 10; } -// $childPromoteIds = getAllChildPromoteList(3); -// if (empty($childPromoteIds)) { -// $map['tab_spend.promote_id'] = PID; -// } else { -// $childPromoteIds .= ',' . PID; -// -// $map['tab_spend.promote_id'] = ['in', $childPromoteIds]; -// } - - $map1['chain'] = ['like', '%' . PID . '/' . '%']; $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; @@ -200,16 +190,6 @@ class QueryController extends BaseController $row = 10; } - - //$childPromoteIds = getAllChildPromoteList(3); -// if (empty($childPromoteIds)) { -// $map['tab_user.promote_id'] = PID; -// } else { -// $childPromoteIds .= ',' . PID; -// -// $map['tab_user.promote_id'] = ['in', $childPromoteIds]; -// } - // $map['tab_user.promote_id'] = ['like','%'.PID.'/'.'%']; $map1['chain'] = ['like', '%' . PID . '/' . '%']; $rs = M('promote', 'tab_')->where($map1)->field('id,account,nickname')->select(); $childPromoteIds = ''; diff --git a/Application/Home/View/default/Download/listsindex.html b/Application/Home/View/default/Download/listsindex.html new file mode 100644 index 000000000..110f7c81c --- /dev/null +++ b/Application/Home/View/default/Download/listsindex.html @@ -0,0 +1,238 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Application/Home/View/default/Finance/index.html b/Application/Home/View/default/Finance/index.html index c527c2559..a78f49948 100644 --- a/Application/Home/View/default/Finance/index.html +++ b/Application/Home/View/default/Finance/index.html @@ -77,6 +77,8 @@
+ + 导出 {$_page}
diff --git a/Application/Home/View/default/Finance/settlementDtl.html b/Application/Home/View/default/Finance/settlementDtl.html index 08d2c16fa..cf036df7d 100644 --- a/Application/Home/View/default/Finance/settlementDtl.html +++ b/Application/Home/View/default/Finance/settlementDtl.html @@ -155,6 +155,7 @@
+ 导出 {$_page}
diff --git a/Application/Home/View/default/Finance/withdrawDtl.html b/Application/Home/View/default/Finance/withdrawDtl.html index b7b1273e5..1e4d13e17 100644 --- a/Application/Home/View/default/Finance/withdrawDtl.html +++ b/Application/Home/View/default/Finance/withdrawDtl.html @@ -188,6 +188,7 @@
+ 导出 {$_page}
diff --git a/Application/Home/View/default/Finance/withdrawRecord.html b/Application/Home/View/default/Finance/withdrawRecord.html index 284b914bf..6c655457b 100644 --- a/Application/Home/View/default/Finance/withdrawRecord.html +++ b/Application/Home/View/default/Finance/withdrawRecord.html @@ -180,6 +180,7 @@
+ 导出 {$_page}
diff --git a/Application/Home/View/default/Promote/children.html b/Application/Home/View/default/Promote/children.html index 3655f0055..f4a597db0 100644 --- a/Application/Home/View/default/Promote/children.html +++ b/Application/Home/View/default/Promote/children.html @@ -123,6 +123,7 @@
+ 导出 {$pagination}
diff --git a/Application/Home/View/default/Promote/mychlid.html b/Application/Home/View/default/Promote/mychlid.html new file mode 100644 index 000000000..d24c87db3 --- /dev/null +++ b/Application/Home/View/default/Promote/mychlid.html @@ -0,0 +1,443 @@ + + + + + +
+
+
+
当前位置:管理中心>组长管理
+
+ + 组长列表 +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID帐号真实姓名身份证手机号上级渠道昵称帐号状态创建时间操作

暂无数据

{$vo.id}{$vo.real_name}{$vo.idcard}{$vo.mobile_phone}{$vo.nickname} + + 审核中 + + 启用 + + 冻结中 + + 未知状态 + + {$vo.create_time|date='Y-m-d H:i:s',###} + 修改 + + 冻结 + + 解冻 + + 重置密码 + + + 渠道迁移 + + 取消渠道迁移 + + + + + 玩家迁移 + + 取消玩家迁移 + + +
+ +
+
+ +导出 + {$_page} +
+
+
+
+ +
+
+
+ + + +
+ + + + + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/PromoteCoin/myCoin.html b/Application/Home/View/default/PromoteCoin/myCoin.html index cdb210be1..98fe98a1a 100644 --- a/Application/Home/View/default/PromoteCoin/myCoin.html +++ b/Application/Home/View/default/PromoteCoin/myCoin.html @@ -193,6 +193,7 @@
+ 导出 {$_page}
diff --git a/Application/Home/View/default/PromoteCoin/record.html b/Application/Home/View/default/PromoteCoin/record.html index 309aa57e5..aafd82c00 100644 --- a/Application/Home/View/default/PromoteCoin/record.html +++ b/Application/Home/View/default/PromoteCoin/record.html @@ -103,6 +103,7 @@
+ 导出 {$pagination}
diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index 06b8970ce..9c000cbd7 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -94,7 +94,7 @@
+ 导出 {$pagination}
diff --git a/Application/Home/View/default/Query/arpu.html b/Application/Home/View/default/Query/arpu.html index d2ff25d5d..1eadcaa99 100644 --- a/Application/Home/View/default/Query/arpu.html +++ b/Application/Home/View/default/Query/arpu.html @@ -205,6 +205,10 @@ + +
+ 导出 +
@@ -300,7 +304,8 @@ var gameId = $('#game-select').val(); } }); } - +var promoteUrl = "{:U('Query/getSubPromotes')}" + initPromoteSelect(promoteUrl) diff --git a/Application/Home/View/default/Query/dailySummary.html b/Application/Home/View/default/Query/dailySummary.html index ae3573b08..84ea5e672 100644 --- a/Application/Home/View/default/Query/dailySummary.html +++ b/Application/Home/View/default/Query/dailySummary.html @@ -237,6 +237,9 @@ + +
+

导出

diff --git a/Application/Home/View/default/Query/recharge.html b/Application/Home/View/default/Query/recharge.html index 52710917e..209a1b325 100644 --- a/Application/Home/View/default/Query/recharge.html +++ b/Application/Home/View/default/Query/recharge.html @@ -220,6 +220,7 @@
+ 导出 {$_page}
diff --git a/Application/Home/View/default/Query/register.html b/Application/Home/View/default/Query/register.html index 5bd9f9eb2..94698cfc3 100644 --- a/Application/Home/View/default/Query/register.html +++ b/Application/Home/View/default/Query/register.html @@ -134,6 +134,7 @@
+ 导出 {$_page}
diff --git a/Application/Home/View/default/Query/summary.html b/Application/Home/View/default/Query/summary.html index 9f42c8245..88045dcab 100644 --- a/Application/Home/View/default/Query/summary.html +++ b/Application/Home/View/default/Query/summary.html @@ -208,6 +208,7 @@
+ 导出 {$_page}
diff --git a/Application/Home/View/default/Query/userRecharges.html b/Application/Home/View/default/Query/userRecharges.html index 6b020d09f..799f6decf 100644 --- a/Application/Home/View/default/Query/userRecharges.html +++ b/Application/Home/View/default/Query/userRecharges.html @@ -108,6 +108,7 @@
+ 导出 {$pagination}
diff --git a/Application/Home/View/default/Query/userRoles.html b/Application/Home/View/default/Query/userRoles.html index d79cfdd73..65ac3682c 100644 --- a/Application/Home/View/default/Query/userRoles.html +++ b/Application/Home/View/default/Query/userRoles.html @@ -107,6 +107,7 @@
+ 导出 {$pagination}
diff --git a/Application/Home/View/default/TestResource/index.html b/Application/Home/View/default/TestResource/index.html index 320479efa..e4c23d084 100644 --- a/Application/Home/View/default/TestResource/index.html +++ b/Application/Home/View/default/TestResource/index.html @@ -292,7 +292,7 @@
- + 导出 {$_page}
diff --git a/Application/Home/View/default/TestResource/lists.html b/Application/Home/View/default/TestResource/lists.html index da72f100b..1628e0261 100644 --- a/Application/Home/View/default/TestResource/lists.html +++ b/Application/Home/View/default/TestResource/lists.html @@ -155,7 +155,10 @@ -
{$_page}
+
+ 导出 + {$_page} +
diff --git a/Application/Home/View/default/TestResource/supportNumberList.html b/Application/Home/View/default/TestResource/supportNumberList.html index 7230e7170..4253683ff 100644 --- a/Application/Home/View/default/TestResource/supportNumberList.html +++ b/Application/Home/View/default/TestResource/supportNumberList.html @@ -177,7 +177,10 @@ -
{$_page}
+
+ 导出 + {$_page} +
diff --git a/Public/Home/css/20180207/common.css b/Public/Home/css/20180207/common.css index 8fece9672..f3c1e44d2 100644 --- a/Public/Home/css/20180207/common.css +++ b/Public/Home/css/20180207/common.css @@ -288,6 +288,28 @@ input,select,button{outline:none;font-size:14px;font-family:inherit;} position:relative;padding:0 5px 0 0; } +.pagenation #sch-btn:before{ + content:url(../../images/20180207/icon_daochu1.png); + position:relative;padding:0 5px 0 0; + +} + #sch-btn { + + font-size: 14px; + font-weight: normal; + cursor: pointer; + border-radius: 3px; + text-align: center; + border-bottom: none; + float: right; + width: 70px; + background: transparent; + color: #404040; + border: 1px solid #ccc; + margin-left: 8px; + height: 28px; + line-height: 28px; + } .pagenation .totalvalue {float:right;border:none;} diff --git a/Public/Home/js/common.js b/Public/Home/js/common.js index 14c082d2b..c35fb256d 100644 --- a/Public/Home/js/common.js +++ b/Public/Home/js/common.js @@ -28,7 +28,7 @@ $(function(){ return false; } } - if ( (target = $(this).attr('href')) || (target = $(this).attr('url')) ) { + if ( (target = $(this).attr('data-href')) || (target = $(this).attr('url')) || (target = $(this).attr('href')) ) { $.get(target).success(function(data){ if (data.status==1) { if (data.url) { @@ -140,10 +140,10 @@ $(function(){ window.updateAlert = function (text,status,c) { switch(status){ case 1: - layer.msg(text, {icon: 1}); + layer.msg(text, {icon: 2}); break; default: - layer.msg(text, {icon: 2}); + layer.msg(text, {icon: 1}); break; } } From 895265a330c1934f49fa719a3dec36d27094c78c Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Thu, 7 Nov 2019 20:41:15 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0->?= =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=91=98->=E7=BB=93=E7=AE=97=E7=AE=A1?= =?UTF-8?q?=E7=90=86->=E6=8E=A8=E5=B9=BF=E6=8F=90=E7=8E=B0--=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/FileController.class.php | 26 + .../Controller/QueryController.class.php | 1148 +++++++++-------- Application/Admin/View/Query/withdraw.html | 557 +++----- Application/Common/Common/function.php | 13 + Data/update.sql | 3 + 5 files changed, 891 insertions(+), 856 deletions(-) diff --git a/Application/Admin/Controller/FileController.class.php b/Application/Admin/Controller/FileController.class.php index 0611c72b3..864003999 100644 --- a/Application/Admin/Controller/FileController.class.php +++ b/Application/Admin/Controller/FileController.class.php @@ -44,6 +44,32 @@ class FileController extends AdminController $this->ajaxReturn($return); } + /* 文件上传--cxj */ + public function uploadNew() + { + $return = array('status' => 1, 'info' => '上传成功', 'id' => ''); + /* 调用文件上传组件上传文件 */ + $File = D('File'); + $file_driver = C('DOWNLOAD_UPLOAD_DRIVER'); + $info = $File->upload( + $_FILES, + C('DOWNLOAD_UPLOAD'), + C('DOWNLOAD_UPLOAD_DRIVER'), + C("UPLOAD_{$file_driver}_CONFIG") + ); + + /* 记录附件信息 */ + if ($info) { + $return['id'] = $info['file']['id']; + } else { + $return['status'] = 0; + $return['info'] = $File->getError(); + } + + /* 返回JSON数据 */ + $this->ajaxReturn($return); + } + /* 文件分片上传 */ public function shard_upload() { diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php index 371233b78..6d3c88f7f 100644 --- a/Application/Admin/Controller/QueryController.class.php +++ b/Application/Admin/Controller/QueryController.class.php @@ -1,372 +1,385 @@ assign('group',$group); - if(isset($_REQUEST['total_status'])){ +class QueryController extends ThinkController +{ + public function settlement($p = 0) + { + + $group = I('group', 1); + $this->assign('group', $group); + if (isset($_REQUEST['total_status'])) { unset($_REQUEST['total_status']); } - $this->m_title = '推广结算'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Query/settlement','status'=>1])->find()); + $this->m_title = '推广结算'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find()); if ($group == 1) { - if($_REQUEST['unum']==2){ - $order='unum'; - $order_type=SORT_ASC; - }else if($_REQUEST['unum']==1){ - $order='unum'; - $order_type=SORT_DESC; + if ($_REQUEST['unum'] == 2) { + $order = 'unum'; + $order_type = SORT_ASC; + } else if ($_REQUEST['unum'] == 1) { + $order = 'unum'; + $order_type = SORT_DESC; } - if($_REQUEST['spay_amount']==2){ - $order='spay_amount'; - $order_type=SORT_ASC; - }else if($_REQUEST['spay_amount']==1){ - $order='spay_amount'; - $order_type=SORT_DESC; + if ($_REQUEST['spay_amount'] == 2) { + $order = 'spay_amount'; + $order_type = SORT_ASC; + } else if ($_REQUEST['spay_amount'] == 1) { + $order = 'spay_amount'; + $order_type = SORT_DESC; } $model = array( - 'title' => '渠道结算', - 'template_list' =>'settlement', + 'title' => '渠道结算', + 'template_list' => 'settlement', 'order' => $order, - 'order_type'=>$order_type//0倒序 1 正序 + 'order_type' => $order_type//0倒序 1 正序 ); - $start=$_REQUEST['timestart']; - $end=$_REQUEST['timeend']; - if(I('group')!=''){ - if($start==''||$end==''&&$_REQUEST['promote_account']==''){ - $this->error('结算周期、所属渠道不能为空!','',1); + $start = $_REQUEST['timestart']; + $end = $_REQUEST['timeend']; + if (I('group') != '') { + if ($start == '' || $end == '' && $_REQUEST['promote_account'] == '') { + $this->error('结算周期、所属渠道不能为空!', '', 1); } - if($start==''||$end==''){ - $this->error('请选择结算周期!','',1); + if ($start == '' || $end == '') { + $this->error('请选择结算周期!', '', 1); } - if($_REQUEST['promote_account']==''){ - $this->error('请选择渠道!','',1); + if ($_REQUEST['promote_account'] == '') { + $this->error('请选择渠道!', '', 1); } } - $smap['tab_spend.pay_status']=1; + $smap['tab_spend.pay_status'] = 1; //判断是否结算绑币 - if($_REQUEST['bind_coin'] == 0){ - $smap['tab_spend.pay_way'] = array('neq',-1); + if ($_REQUEST['bind_coin'] == 0) { + $smap['tab_spend.pay_way'] = array('neq', -1); } $this->meta_title = '渠道结算列表'; - $this->assign('setdate',date("Y-m-d",strtotime("-1 day"))); - if($start && $end){ - if((strtotime($end)+24*60*60-1)error('时间选择不正确!',U('Query/settlement'),''); + $this->assign('setdate', date("Y-m-d", strtotime("-1 day"))); + if ($start && $end) { + if ((strtotime($end) + 24 * 60 * 60 - 1) < strtotime($start)) { + $this->error('时间选择不正确!', U('Query/settlement'), ''); } - $umap['register_time']=array('BETWEEN',array(strtotime($start),strtotime($end)+24*60*60-1)); - if(isset($_REQUEST['game_name']) && $_REQUEST['game_name']!=''){ - $umap['fgame_id']=get_game_id($_REQUEST['game_name']); - $smap['tab_spend.game_id']=get_game_id($_REQUEST['game_name']); + $umap['register_time'] = array('BETWEEN', array(strtotime($start), strtotime($end) + 24 * 60 * 60 - 1)); + if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') { + $umap['fgame_id'] = get_game_id($_REQUEST['game_name']); + $smap['tab_spend.game_id'] = get_game_id($_REQUEST['game_name']); } - if(isset($_REQUEST['promote_account'])&&$_REQUEST['promote_account']!=''){ - $allid=get_subordinate_promote_($_REQUEST['promote_account']); - $allid[]=$_REQUEST['promote_account']; - $umap['tab_user.promote_account']=array('in',$allid); - $smap['tab_spend.promote_account']=array('in',$allid); - }else{ - $this->error('未选择渠道!','',1); + if (isset($_REQUEST['promote_account']) && $_REQUEST['promote_account'] != '') { + $allid = get_subordinate_promote_($_REQUEST['promote_account']); + $allid[] = $_REQUEST['promote_account']; + $umap['tab_user.promote_account'] = array('in', $allid); + $smap['tab_spend.promote_account'] = array('in', $allid); + } else { + $this->error('未选择渠道!', '', 1); } - $umap['is_check']=1; - $umap['settle_check']=0; - $smap['pay_time']=array('BETWEEN',array(strtotime($start),strtotime($end)+24*60*60-1)); - $smap['is_check']=1; - $smap['settle_check']=0; - $map['umap']=$umap; - $map['smap']=$smap; - - $user = A('Settlement','Event'); - $user->settlement($model,$p,$map); - }else{ + $umap['is_check'] = 1; + $umap['settle_check'] = 0; + $smap['pay_time'] = array('BETWEEN', array(strtotime($start), strtotime($end) + 24 * 60 * 60 - 1)); + $smap['is_check'] = 1; + $smap['settle_check'] = 0; + $map['umap'] = $umap; + $map['smap'] = $smap; + + $user = A('Settlement', 'Event'); + $user->settlement($model, $p, $map); + } else { $this->display(); } } if ($group == 2) { - if(isset($_REQUEST['stimestart'])&&isset($_REQUEST['stimeend'])){ - $map['create_time']=array('BETWEEN',array(strtotime($_REQUEST['stimestart']),strtotime($_REQUEST['stimeend'])+24*60*60-1)); - }elseif(isset($_REQUEST['stimestart'])){ - $map['create_time']=array('BETWEEN',array(strtotime($_REQUEST['stimestart']),time())); - }elseif(isset($_REQUEST['stimeend'])){ - $map['create_time']=array('LT',(strtotime($_REQUEST['stimeend'])+24*60*60-1)); + if (isset($_REQUEST['stimestart']) && isset($_REQUEST['stimeend'])) { + $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['stimestart']), strtotime($_REQUEST['stimeend']) + 24 * 60 * 60 - 1)); + } elseif (isset($_REQUEST['stimestart'])) { + $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['stimestart']), time())); + } elseif (isset($_REQUEST['stimeend'])) { + $map['create_time'] = array('LT', (strtotime($_REQUEST['stimeend']) + 24 * 60 * 60 - 1)); } - if(isset($_REQUEST['timestart'])&&isset($_REQUEST['timeend'])){ - $map['starttime']=['GT',strtotime($_REQUEST['timestart'])]; - $map['endtime']=['LT',strtotime($_REQUEST['timeend'])+24*60*60]; - }elseif(isset($_REQUEST['timestart'])) { - $map['starttime']=['GT',strtotime($_REQUEST['timestart'])]; - }elseif(isset($_REQUEST['timeend'])){ - $map['endtime']=['LT',strtotime($_REQUEST['timeend'])+24*60*60]; + if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { + $map['starttime'] = ['GT', strtotime($_REQUEST['timestart'])]; + $map['endtime'] = ['LT', strtotime($_REQUEST['timeend']) + 24 * 60 * 60]; + } elseif (isset($_REQUEST['timestart'])) { + $map['starttime'] = ['GT', strtotime($_REQUEST['timestart'])]; + } elseif (isset($_REQUEST['timeend'])) { + $map['endtime'] = ['LT', strtotime($_REQUEST['timeend']) + 24 * 60 * 60]; } - if(isset($_REQUEST['game_name'])){ - if($_REQUEST['game_name']=='全部'){ + if (isset($_REQUEST['game_name'])) { + if ($_REQUEST['game_name'] == '全部') { unset($_REQUEST['game_name']); - }else{ + } else { $map['game_name'] = $_REQUEST['game_name']; } } - if(isset($_REQUEST['promote_account'])){ - if($_REQUEST['promote_account']=='全部'){ + if (isset($_REQUEST['promote_account'])) { + if ($_REQUEST['promote_account'] == '全部') { unset($_REQUEST['promote_account']); - }else{ + } else { $map['promote_account'] = $_REQUEST['promote_account']; } } - if(!empty($_REQUEST['settlement_number'])){ + if (!empty($_REQUEST['settlement_number'])) { $map['settlement_number'] = $_REQUEST['settlement_number']; } - $map['developers'] = 0; + $map['developers'] = 0; $model = array( 'm_name' => 'settlement', 'fields' => array( - 'settlement_number', - 'starttime','endtime', - 'promote_id','promote_account', - 'sum(total_money) as total_money', - 'sum(total_number) as total_number', - 'sum(sum_money) as sum_money', - 'bind_coin_status', - 'create_time'), - 'group' => 'promote_id,starttime,endtime,create_time,bind_coin_status', - 'order' => 'create_time desc ', - 'title' => '结算账单', - 'template_list' =>'settlement', + 'settlement_number', + 'starttime', 'endtime', + 'promote_id', 'promote_account', + 'sum(total_money) as total_money', + 'sum(total_number) as total_number', + 'sum(sum_money) as sum_money', + 'bind_coin_status', + 'create_time'), + 'group' => 'promote_id,starttime,endtime,create_time,bind_coin_status', + 'order' => 'create_time desc ', + 'title' => '结算账单', + 'template_list' => 'settlement', ); - $map1=$map; - $ztotal=null_to_0(D('settlement')->where($map1)->sum('sum_money*10000')/10000); - $this->assign('ztotal',$ztotal); - $ttotal=null_to_0(D('settlement')->where('create_time'.total(1))->sum('sum_money*10000')/10000); - $this->assign('ttotal',$ttotal); - $ytotal=null_to_0(D('settlement')->where('create_time'.total(5))->sum('sum_money*10000')/10000); - $this->assign('ytotal',$ytotal); - $user = A('Bill','Event'); - $user->money_list($model,$p,$map); + $map1 = $map; + $ztotal = null_to_0(D('settlement')->where($map1)->sum('sum_money*10000') / 10000); + $this->assign('ztotal', $ztotal); + $ttotal = null_to_0(D('settlement')->where('create_time' . total(1))->sum('sum_money*10000') / 10000); + $this->assign('ttotal', $ttotal); + $ytotal = null_to_0(D('settlement')->where('create_time' . total(5))->sum('sum_money*10000') / 10000); + $this->assign('ytotal', $ytotal); + $user = A('Bill', 'Event'); + $user->money_list($model, $p, $map); } } - public function cpsettlement($p=0) { + + public function cpsettlement($p = 0) + { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 - if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } - $this->assign('setdate',date("Y-m-d",strtotime("-1 day"))); - if($_REQUEST['sum_money']==2){ - $order='total desc'; - }else if($_REQUEST['sum_money']==1){ - $order='total asc'; + $this->assign('setdate', date("Y-m-d", strtotime("-1 day"))); + if ($_REQUEST['sum_money'] == 2) { + $order = 'total desc'; + } else if ($_REQUEST['sum_money'] == 1) { + $order = 'total asc'; } - $group = I('group',1); - $this->assign('group',$group); + $group = I('group', 1); + $this->assign('group', $group); - $this->m_title = '开发者结算'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Query/cpsettlement','status'=>1])->find()); + $this->m_title = '开发者结算'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/cpsettlement', 'status' => 1])->find()); - if(isset($_REQUEST['timestart'])&&$_REQUEST['timestart']!=''&&$_REQUEST['group']==1){ + if (isset($_REQUEST['timestart']) && $_REQUEST['timestart'] != '' && $_REQUEST['group'] == 1) { $starttime = strtotime($_REQUEST['timestart']); - $endtime = strtotime($_REQUEST['timeend'])+24*3600-1; + $endtime = strtotime($_REQUEST['timeend']) + 24 * 3600 - 1; - if(isset($_REQUEST['developers_id'])){ + if (isset($_REQUEST['developers_id'])) { $map['g.developers'] = $_REQUEST['developers_id']; - }else{ + } else { $this->error('请选择开发者'); } - if(isset($_REQUEST['selle_status'])){ - if($_REQUEST['selle_status']=="未结算"){ - $map['s.selle_status']=0; - }else if($_REQUEST['selle_status']=="已结算"){ - $map['s.selle_status']=1; + if (isset($_REQUEST['selle_status'])) { + if ($_REQUEST['selle_status'] == "未结算") { + $map['s.selle_status'] = 0; + } else if ($_REQUEST['selle_status'] == "已结算") { + $map['s.selle_status'] = 1; } } else { - $map['s.selle_status'] = 0; - } + $map['s.selle_status'] = 0; + } //判断是否结算绑币 - if($_REQUEST['bind_coin'] == 0){ - $map['s.pay_way'] = array('neq',-1); + if ($_REQUEST['bind_coin'] == 0) { + $map['s.pay_way'] = array('neq', -1); } - $map['s.pay_status']=1; - $map['pay_time']=array('BETWEEN',array($starttime,$endtime)); + $map['s.pay_status'] = 1; + $map['pay_time'] = array('BETWEEN', array($starttime, $endtime)); $model = array( 'm_name' => 'Spend as s', - 'order' => $order, - 'title' => '渠道结算', - 'group' => 'g.developers,g.id', + 'order' => $order, + 'title' => '渠道结算', + 'group' => 'g.developers,g.id', 'fields' => 'sum(s.pay_amount) as total,s.selle_ratio,s.id,g.developers,s.selle_status,g.id as gid,g.game_name,s.pay_status,s.pay_amount', - 'template_list' =>'cpsettlement', + 'template_list' => 'cpsettlement', ); - $user = A('Spend','Event'); - $this->meta_title = '开发者结算'; - $user->cpsettl_list($model,$p,$map); - }else if($_REQUEST['group']==2){ + $user = A('Spend', 'Event'); + $this->meta_title = '开发者结算'; + $user->cpsettl_list($model, $p, $map); + } else if ($_REQUEST['group'] == 2) { - if(isset($_REQUEST['timestart']) && $_REQUEST['timeend']!=''){ + if (isset($_REQUEST['timestart']) && $_REQUEST['timeend'] != '') { + $starttime = strtotime($_REQUEST['timestart']); + $endtime = strtotime($_REQUEST['timeend']) + 24 * 3600 - 1; + $map['starttime'] = array('egt', $starttime); + $map['endtime'] = array('elt', $endtime); + } elseif (isset($_REQUEST['timestart'])) { $starttime = strtotime($_REQUEST['timestart']); - $endtime = strtotime($_REQUEST['timeend'])+24*3600-1; - $map['starttime'] = array('egt',$starttime); - $map['endtime'] = array('elt',$endtime); - }elseif(isset($_REQUEST['timestart'])){ - $starttime = strtotime($_REQUEST['timestart']); - $map['starttime'] = array('egt',$starttime); - }elseif(isset($_REQUEST['timeend'])){ - $endtime = strtotime($_REQUEST['timeend'])+24*3600-1; - $map['endtime'] = array('elt',$endtime); + $map['starttime'] = array('egt', $starttime); + } elseif (isset($_REQUEST['timeend'])) { + $endtime = strtotime($_REQUEST['timeend']) + 24 * 3600 - 1; + $map['endtime'] = array('elt', $endtime); } - if(isset($_REQUEST['start']) && $_REQUEST['end']!=''){ + if (isset($_REQUEST['start']) && $_REQUEST['end'] != '') { $starttime = strtotime($_REQUEST['start']); - $endtime = strtotime($_REQUEST['end'])+24*3600-1; - $map['create_time'] = array('BETWEEN',array($starttime,$endtime)); - }elseif(isset($_REQUEST['start'])){ + $endtime = strtotime($_REQUEST['end']) + 24 * 3600 - 1; + $map['create_time'] = array('BETWEEN', array($starttime, $endtime)); + } elseif (isset($_REQUEST['start'])) { $starttime = strtotime($_REQUEST['start']); - $map['create_time'] = array('BETWEEN',array($starttime,time())); - }elseif(isset($_REQUEST['end'])){ - $endtime = strtotime($_REQUEST['end'])+24*3600-1; - $map['create_time'] = array('LT',$endtime); + $map['create_time'] = array('BETWEEN', array($starttime, time())); + } elseif (isset($_REQUEST['end'])) { + $endtime = strtotime($_REQUEST['end']) + 24 * 3600 - 1; + $map['create_time'] = array('LT', $endtime); } - if(isset($_REQUEST['developers_id'])){ - $map['developers']=$_REQUEST['developers_id']; - }else{ - $map['developers'] = array('neq',0); + if (isset($_REQUEST['developers_id'])) { + $map['developers'] = $_REQUEST['developers_id']; + } else { + $map['developers'] = array('neq', 0); } - $data = M('TotalSettlement','tab_')->where($map)->order('create_time desc')->page($page,$row)->select(); - $count = M('TotalSettlement','tab_')->where($map)->order('create_time desc')->count(); + $data = M('TotalSettlement', 'tab_')->where($map)->order('create_time desc')->page($page, $row)->select(); + $count = M('TotalSettlement', 'tab_')->where($map)->order('create_time desc')->count(); - $page = set_pagination($count,$row); - if($page) {$this->assign('_page', $page);} + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } - $this->assign('data',$data); - $this->assign('meta_title','开发者结算记录'); + $this->assign('data', $data); + $this->assign('meta_title', '开发者结算记录'); $this->display(); - }else{ + } else { $this->meta_title = '开发者结算列表'; $this->display(); } } - public function generatesettlementAll(){ - $request = I('request.ids'); - if(empty($request)){ + public function generatesettlementAll() + { + $request = I('request.ids'); + + if (empty($request)) { $this->error('请选择要操作的数据'); } if (is_array($request)) { - foreach($request as $k => $v) { - $query = explode(',',$v); + foreach ($request as $k => $v) { + $query = explode(',', $v); $ids[] = $k; $_REQUEST[$k]['cooperation'] = $query[0]; - $_REQUEST[$k]['cps_ratio'] = $query[1]; - $_REQUEST[$k]['cpa_price'] = $query[2]; - $_REQUEST[$k]['unum'] = $query[3]; + $_REQUEST[$k]['cps_ratio'] = $query[1]; + $_REQUEST[$k]['cpa_price'] = $query[2]; + $_REQUEST[$k]['unum'] = $query[3]; $_REQUEST[$k]['spay_amount'] = $query[4]; - $_REQUEST[$k]['game_id'] = $query[5]; + $_REQUEST[$k]['game_id'] = $query[5]; } unset($_REQUEST['ids']); } elseif (is_numeric($request)) { $id = $ids[] = $request; - $_REQUEST[$id]['ids']=$id; + $_REQUEST[$id]['ids'] = $id; $_REQUEST[$id]['cooperation'] = $_REQUEST['cooperation']; - $_REQUEST[$id]['cps_ratio'] = $_REQUEST['cps_ratio']; - $_REQUEST[$id]['cpa_price'] = $_REQUEST['cpa_price']; - $_REQUEST[$id]['unum'] = $_REQUEST['unum']; + $_REQUEST[$id]['cps_ratio'] = $_REQUEST['cps_ratio']; + $_REQUEST[$id]['cpa_price'] = $_REQUEST['cpa_price']; + $_REQUEST[$id]['unum'] = $_REQUEST['unum']; $_REQUEST[$id]['spay_amount'] = $_REQUEST['spay_amount']; } else { $this->error('参数有误!!!'); } sort(array_unique($ids)); if (is_array($ids)) { - $promote_id = get_promote_id($_REQUEST['promote_account']); + $promote_id = get_promote_id($_REQUEST['promote_account']); $create_time = time(); foreach ($ids as $k => $v) { - if(get_settlement($_REQUEST['timestart'],$_REQUEST['timeend'],$promote_id,$_REQUEST[$v]['game_id'])){ - continue; + if (get_settlement($_REQUEST['timestart'], $_REQUEST['timeend'], $promote_id, $_REQUEST[$v]['game_id'])) { + continue; } - $data[$k]['game_id'] = $_REQUEST[$v]['game_id']; - $data[$k]['game_name'] = get_game_name($_REQUEST[$v]['game_id']); - $data[$k]['promote_account'] = $_REQUEST['promote_account']; - $data[$k]['promote_id'] = $promote_id; - $data[$k]['total_money'] = $_REQUEST[$v]['spay_amount']; - $data[$k]['total_number'] = $_REQUEST[$v]['unum']; - $data[$k]['starttime'] = strtotime($_REQUEST['timestart']); - $data[$k]['endtime'] = strtotime($_REQUEST['timeend'])+24*60*60-1; - $data[$k]['pattern'] = $_REQUEST[$v]['cooperation']=='CPS'?0:1; - $data[$k]['ratio'] = $_REQUEST[$v]['cps_ratio']; - $data[$k]['money'] = $_REQUEST[$v]['cpa_price']; - $data[$k]['create_time'] = $create_time; - $data[$k]['bind_coin_status'] = $_REQUEST['bind_coin']; - $data[$k]['settlement_number'] = 'JS-'.date('Ymd').date('His').sp_random_string(4); - - if(get_settlement($data[$k]['starttime'],$data[$k]['endtime'],$data[$k]['promote_id'],$data[$k]['game_id'])){ + $data[$k]['game_id'] = $_REQUEST[$v]['game_id']; + $data[$k]['game_name'] = get_game_name($_REQUEST[$v]['game_id']); + $data[$k]['promote_account'] = $_REQUEST['promote_account']; + $data[$k]['promote_id'] = $promote_id; + $data[$k]['total_money'] = $_REQUEST[$v]['spay_amount']; + $data[$k]['total_number'] = $_REQUEST[$v]['unum']; + $data[$k]['starttime'] = strtotime($_REQUEST['timestart']); + $data[$k]['endtime'] = strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1; + $data[$k]['pattern'] = $_REQUEST[$v]['cooperation'] == 'CPS' ? 0 : 1; + $data[$k]['ratio'] = $_REQUEST[$v]['cps_ratio']; + $data[$k]['money'] = $_REQUEST[$v]['cpa_price']; + $data[$k]['create_time'] = $create_time; + $data[$k]['bind_coin_status'] = $_REQUEST['bind_coin']; + $data[$k]['settlement_number'] = 'JS-' . date('Ymd') . date('His') . sp_random_string(4); + + if (get_settlement($data[$k]['starttime'], $data[$k]['endtime'], $data[$k]['promote_id'], $data[$k]['game_id'])) { $this->error('该结算周期不可结算,请重新选择'); } - if($data[$k]['pattern']){ - $data[$k]['sum_money']=$data[$k]['total_number']*$data[$k]['money']; - }else{ - $data[$k]['sum_money']=$data[$k]['total_money']*$data[$k]['ratio']/100; + if ($data[$k]['pattern']) { + $data[$k]['sum_money'] = $data[$k]['total_number'] * $data[$k]['money']; + } else { + $data[$k]['sum_money'] = $data[$k]['total_money'] * $data[$k]['ratio'] / 100; } - if($data[$k]['game_id']==''||$data[$k]['promote_id']==''||$data[$k]['starttime']==''||$data[$k]['endtime']==''){ + if ($data[$k]['game_id'] == '' || $data[$k]['promote_id'] == '' || $data[$k]['starttime'] == '' || $data[$k]['endtime'] == '') { $this->error('必要参数不存在'); } - $map['fgame_id']=$data[$k]['game_id']; + $map['fgame_id'] = $data[$k]['game_id']; // $map['is_check']=1; $map['puid'] = 0; - $map['register_time']=array('BETWEEN',array($data[$k]['starttime'],$data[$k]['endtime'])); - $allid=get_subordinate_promote_($data[$k]['promote_account']); - $allid[]=$data[$k]['promote_account']; - $map['promote_account']=array('in',$allid); - $u=M('User','tab_'); - $user=$u->where($map)->setField('settle_check',1); + $map['register_time'] = array('BETWEEN', array($data[$k]['starttime'], $data[$k]['endtime'])); + $allid = get_subordinate_promote_($data[$k]['promote_account']); + $allid[] = $data[$k]['promote_account']; + $map['promote_account'] = array('in', $allid); + $u = M('User', 'tab_'); + $user = $u->where($map)->setField('settle_check', 1); unset($map['register_time']); unset($map['puid']); $map['pay_status'] = 1; - $map['pay_time']=array('BETWEEN',array($data[$k]['starttime'],$data[$k]['endtime'])); - $s=M('spend','tab_'); - $spend=$s->where($map)->setField('settle_check',1); + $map['pay_time'] = array('BETWEEN', array($data[$k]['starttime'], $data[$k]['endtime'])); + $s = M('spend', 'tab_'); + $spend = $s->where($map)->setField('settle_check', 1); } } $data = array_values($data); - $result=M('settlement','tab_')->addAll($data); - if($result){ - $settMap['promote_id'] = $promote_id; - $settMap['starttime'] = strtotime($_REQUEST['timestart']); - $settMap['endtime'] = strtotime($_REQUEST['timeend'])+24*60*60-1; + $result = M('settlement', 'tab_')->addAll($data); + if ($result) { + $settMap['promote_id'] = $promote_id; + $settMap['starttime'] = strtotime($_REQUEST['timestart']); + $settMap['endtime'] = strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1; $settMap['create_time'] = $data[0]['create_time']; $settMap['bind_coin_status'] = $_REQUEST['bind_coin']; - $dataSett = M('settlement','tab_')->field(array( - 'settlement_number', - 'starttime','endtime', - 'promote_id','promote_account', - 'sum(total_money) as total_money', - 'sum(total_number) as total_number', - 'sum(sum_money) as sum_money', - 'status', - 'ti_status', - 'bind_coin_status', - 'create_time'))->where($settMap) - ->group('promote_id,starttime,endtime,create_time,bind_coin_status') - ->order('create_time desc') - ->select(); - M('TotalSettlement','tab_')->addAll($dataSett); - $this->success('结算成功',U('Query/settlement',array('group'=>2))); - }else{ + $dataSett = M('settlement', 'tab_')->field(array( + 'settlement_number', + 'starttime', 'endtime', + 'promote_id', 'promote_account', + 'sum(total_money) as total_money', + 'sum(total_number) as total_number', + 'sum(sum_money) as sum_money', + 'status', + 'ti_status', + 'bind_coin_status', + 'create_time'))->where($settMap) + ->group('promote_id,starttime,endtime,create_time,bind_coin_status') + ->order('create_time desc') + ->select(); + M('TotalSettlement', 'tab_')->addAll($dataSett); + $this->success('结算成功', U('Query/settlement', array('group' => 2))); + } else { /*if (is_array($ids)) { $promote_id = get_promote_id($_REQUEST['promote_account']); @@ -396,396 +409,511 @@ class QueryController extends ThinkController { $this->error('结算失败'); } } - public function generatesettlement(){ + + public function generatesettlement() + { //批量结算要加判断 - $data['game_id']=$_REQUEST['game_id']; - $data['game_name']=get_game_name($_REQUEST['game_id']); - $data['promote_id']=$_REQUEST['promote_id']; - $data['promote_account']=get_promote_name($_REQUEST['promote_id']); - $data['total_money']=$_REQUEST['spay_amount']; - $data['total_number']=$_REQUEST['unum']; - $data['starttime']=strtotime($_REQUEST['starttime']); - $data['endtime']=strtotime($_REQUEST['endtime'])+24*60*60-1; - $data['pattern']=$_REQUEST['cooperation']=='CPS'?0:1; - $data['ratio']=$_REQUEST['cps_ratio']; - $data['money']=$_REQUEST['cpa_price']; - $data['create_time']=time(); - $data['settlement_number']='JS-'.date('Ymd').date('His').sp_random_string(4); - if(get_settlement($data['starttime'],$data['promote_id'],$data['game_id'])){ + $data['game_id'] = $_REQUEST['game_id']; + $data['game_name'] = get_game_name($_REQUEST['game_id']); + $data['promote_id'] = $_REQUEST['promote_id']; + $data['promote_account'] = get_promote_name($_REQUEST['promote_id']); + $data['total_money'] = $_REQUEST['spay_amount']; + $data['total_number'] = $_REQUEST['unum']; + $data['starttime'] = strtotime($_REQUEST['starttime']); + $data['endtime'] = strtotime($_REQUEST['endtime']) + 24 * 60 * 60 - 1; + $data['pattern'] = $_REQUEST['cooperation'] == 'CPS' ? 0 : 1; + $data['ratio'] = $_REQUEST['cps_ratio']; + $data['money'] = $_REQUEST['cpa_price']; + $data['create_time'] = time(); + $data['settlement_number'] = 'JS-' . date('Ymd') . date('His') . sp_random_string(4); + if (get_settlement($data['starttime'], $data['promote_id'], $data['game_id'])) { $this->error('该结算周期不可结算,请重新选择'); } - if($data['pattern']){ - $data['sum_money']=$data['total_number']*$data['money']; - }else{ - $data['sum_money']=$data['total_money']*$data['ratio']/100; + if ($data['pattern']) { + $data['sum_money'] = $data['total_number'] * $data['money']; + } else { + $data['sum_money'] = $data['total_money'] * $data['ratio'] / 100; } - if($data['game_id']==''||$data['promote_id']==''||$data['starttime']==''||$data['endtime']==''){ + if ($data['game_id'] == '' || $data['promote_id'] == '' || $data['starttime'] == '' || $data['endtime'] == '') { $this->error('必要参数不存在'); } - $map['fgame_id']=$data['game_id']; + $map['fgame_id'] = $data['game_id']; // $map['is_check']=1; - $map['register_time']=array('BETWEEN',array($data['starttime'],$data['endtime'])); - $allid=get_subordinate_promote_($data['promote_account']); - $allid[]=$data['promote_account']; - $map['promote_id']=array('in',$data['promote_id']); - $u=M('User','tab_'); - $user=$u->where($map)->setField('settle_check',1); + $map['register_time'] = array('BETWEEN', array($data['starttime'], $data['endtime'])); + $allid = get_subordinate_promote_($data['promote_account']); + $allid[] = $data['promote_account']; + $map['promote_id'] = array('in', $data['promote_id']); + $u = M('User', 'tab_'); + $user = $u->where($map)->setField('settle_check', 1); unset($map['register_time']); - $map['pay_time']=array('BETWEEN',array($data['starttime'],$data['endtime'])); - $s=M('spend','tab_'); - $spend=$s->where($map)->setField('settle_check',1); - $result=M('settlement','tab_')->add($data); - if($result){ + $map['pay_time'] = array('BETWEEN', array($data['starttime'], $data['endtime'])); + $s = M('spend', 'tab_'); + $spend = $s->where($map)->setField('settle_check', 1); + $result = M('settlement', 'tab_')->add($data); + if ($result) { $this->success('结算成功'); - }else{ + } else { $this->error('结算失败'); } } - public function generatecpsettlement() {//cp结算 - $request = I('request.ids'); - if(empty($request)){ + public function generatecpsettlement() + {//cp结算 + + $request = I('request.ids'); + if (empty($request)) { $this->error('请选择要操作的数据'); } $starttime = strtotime($_REQUEST['timestart']); - $endtime = strtotime($_REQUEST['endtime'])+24*3600-1; - $map['s.pay_status'] = 1; + $endtime = strtotime($_REQUEST['endtime']) + 24 * 3600 - 1; + $map['s.pay_status'] = 1; $map['s.selle_status'] = 0; foreach ($request as $key => $value) { - $query = explode(',',$value); + $query = explode(',', $value); $ids[] = $query[0]; - $requestData[$key]['game_id'] = $query[0]; - $requestData[$key]['selle_ratio'] = $query[1]; - $requestData[$key]['total'] = $query[2]; + $requestData[$key]['game_id'] = $query[0]; + $requestData[$key]['selle_ratio'] = $query[1]; + $requestData[$key]['total'] = $query[2]; } - $map['s.game_id']=array('in',$ids); - $map['pay_time']=array('BETWEEN',array($starttime,$endtime)); - $spe = M('spend as s','tab_'); - $smap = array('s.selle_time'=>date('Y-m-d',time()),'s.selle_status'=>1); + $map['s.game_id'] = array('in', $ids); + $map['pay_time'] = array('BETWEEN', array($starttime, $endtime)); + $spe = M('spend as s', 'tab_'); + $smap = array('s.selle_time' => date('Y-m-d', time()), 's.selle_status' => 1); $data = $spe - ->field('s.id,s.selle_status,s.selle_time') - ->join('tab_game as g on g.id=s.game_id','LEFT') - ->where($map) - ->setField($smap); - if($data){ + ->field('s.id,s.selle_status,s.selle_time') + ->join('tab_game as g on g.id=s.game_id', 'LEFT') + ->where($map) + ->setField($smap); + if ($data) { $create_time = time(); foreach ($requestData as $key => $value) { - $datas[$key]['game_id'] = $value['game_id']; - $datas[$key]['game_name'] = get_game_name($value['game_id']); - $datas[$key]['promote_id'] = '0'; - $datas[$key]['promote_account'] = '0'; - $datas[$key]['total_money'] = $value['total']; - $datas[$key]['total_number'] = 0; - $datas[$key]['starttime'] = $starttime; - $datas[$key]['endtime'] = $endtime; - $datas[$key]['pattern'] = 0;//$_REQUEST['cooperation']=='CPS'?0:1; - $datas[$key]['ratio'] = $value['selle_ratio']; - $datas[$key]['sum_money'] = $value['selle_ratio']*$value['total']/100; - $datas[$key]['money'] = 0; - $datas[$key]['developers'] = $_REQUEST['developers_id']; - $datas[$key]['create_time'] = $create_time; - $datas[$key]['settlement_number'] = 'JS-'.date('Ymd').date('His').sp_random_string(4); - $datas[$key]['bind_coin_status'] = $_REQUEST['bind_coin']; + $datas[$key]['game_id'] = $value['game_id']; + $datas[$key]['game_name'] = get_game_name($value['game_id']); + $datas[$key]['promote_id'] = '0'; + $datas[$key]['promote_account'] = '0'; + $datas[$key]['total_money'] = $value['total']; + $datas[$key]['total_number'] = 0; + $datas[$key]['starttime'] = $starttime; + $datas[$key]['endtime'] = $endtime; + $datas[$key]['pattern'] = 0;//$_REQUEST['cooperation']=='CPS'?0:1; + $datas[$key]['ratio'] = $value['selle_ratio']; + $datas[$key]['sum_money'] = $value['selle_ratio'] * $value['total'] / 100; + $datas[$key]['money'] = 0; + $datas[$key]['developers'] = $_REQUEST['developers_id']; + $datas[$key]['create_time'] = $create_time; + $datas[$key]['settlement_number'] = 'JS-' . date('Ymd') . date('His') . sp_random_string(4); + $datas[$key]['bind_coin_status'] = $_REQUEST['bind_coin']; } $datas = array_values($datas); - $result=M('settlement','tab_')->addAll($datas); - $settMap['developers'] = $_REQUEST['developers_id']; - $settMap['starttime'] = $starttime; - $settMap['endtime'] = $endtime; + $result = M('settlement', 'tab_')->addAll($datas); + $settMap['developers'] = $_REQUEST['developers_id']; + $settMap['starttime'] = $starttime; + $settMap['endtime'] = $endtime; $settMap['create_time'] = $create_time; - $dataSett = M('settlement','tab_')->field(array( - 'settlement_number', - 'starttime','endtime', - 'promote_id','promote_account', - 'sum(total_money) as total_money', - 'sum(total_number) as total_number', - 'sum(sum_money) as sum_money', - 'status', - 'ti_status', - 'bind_coin_status', - 'developers', - 'create_time',))->where($settMap) - ->group('developers,starttime,endtime,create_time,bind_coin_status') - ->order('create_time desc') - ->select(); - M('TotalSettlement','tab_')->addAll($dataSett); - \Think\Log::actionLog('Query/generatecpsettlement','Query',1); - $this->success('结算成功',U('Query/cpsettlement',array('group'=>2))); - }else{ + $dataSett = M('settlement', 'tab_')->field(array( + 'settlement_number', + 'starttime', 'endtime', + 'promote_id', 'promote_account', + 'sum(total_money) as total_money', + 'sum(total_number) as total_number', + 'sum(sum_money) as sum_money', + 'status', + 'ti_status', + 'bind_coin_status', + 'developers', + 'create_time',))->where($settMap) + ->group('developers,starttime,endtime,create_time,bind_coin_status') + ->order('create_time desc') + ->select(); + M('TotalSettlement', 'tab_')->addAll($dataSett); + \Think\Log::actionLog('Query/generatecpsettlement', 'Query', 1); + $this->success('结算成功', U('Query/cpsettlement', array('group' => 2))); + } else { $this->error('结算失败'); } - $map1 = array('status'=>1,'selle_status'=>1); - $total = null_to_0(D('spend')->where($map1)->sum('pay_amount')); - $ttotal = null_to_0(D('spend')->where('pay_time'.total(1))->where($map1)->sum('pay_amount')); - $ytotal = null_to_0(D('spend')->where('pay_time'.total(5))->where($map1)->sum('pay_amount')); - $this->assign('total',$total); - $this->assign('ttotal',$ttotal); - $this->assign('ytotal',$ytotal); + $map1 = array('status' => 1, 'selle_status' => 1); + $total = null_to_0(D('spend')->where($map1)->sum('pay_amount')); + $ttotal = null_to_0(D('spend')->where('pay_time' . total(1))->where($map1)->sum('pay_amount')); + $ytotal = null_to_0(D('spend')->where('pay_time' . total(5))->where($map1)->sum('pay_amount')); + $this->assign('total', $total); + $this->assign('ttotal', $ttotal); + $this->assign('ytotal', $ytotal); } - public function changeratio(){ - $gid = I('request.game_id'); - if(empty($gid)){ - $this->ajaxReturn(0,"请选择要操作的数据",0);exit; - } - $starttime=strtotime($_REQUEST['timestart'].'-01'); - $endtime=strtotime($_REQUEST['timestart']."+1 month -1 day")+24*3600-1; - $map['s.pay_status']=1; - $map['s.selle_status']=0; - $map['s.game_id']=$_REQUEST['game_id']; - $map['pay_time']=array('BETWEEN',array($starttime,$endtime)); - $spe=M('spend as s','tab_'); - $data=$spe - ->field('s.id,s.selle_status,s.selle_ratio') - ->join('tab_game as g on g.id=s.game_id','LEFT') - ->where($map) - ->setField('s.selle_ratio',$_POST['ratio']); - if($data === false){ - $this->ajaxReturn(array('status'=>0)); - }else{ - $this->ajaxReturn(['status'=>1,'data'=>$data]); + + public function changeratio() + { + $gid = I('request.game_id'); + if (empty($gid)) { + $this->ajaxReturn(0, "请选择要操作的数据", 0); + exit; + } + $starttime = strtotime($_REQUEST['timestart'] . '-01'); + $endtime = strtotime($_REQUEST['timestart'] . "+1 month -1 day") + 24 * 3600 - 1; + $map['s.pay_status'] = 1; + $map['s.selle_status'] = 0; + $map['s.game_id'] = $_REQUEST['game_id']; + $map['pay_time'] = array('BETWEEN', array($starttime, $endtime)); + $spe = M('spend as s', 'tab_'); + $data = $spe + ->field('s.id,s.selle_status,s.selle_ratio') + ->join('tab_game as g on g.id=s.game_id', 'LEFT') + ->where($map) + ->setField('s.selle_ratio', $_POST['ratio']); + if ($data === false) { + $this->ajaxReturn(array('status' => 0)); + } else { + $this->ajaxReturn(['status' => 1, 'data' => $data]); } } - public function cp_withdraw($p=0){ - if(isset($_REQUEST['settlement_number'])){ - $map['settlement_number']=array('like','%'.$_REQUEST['settlement_number'].'%'); + + public function cp_withdraw($p = 0) + { + if (isset($_REQUEST['settlement_number'])) { + $map['settlement_number'] = array('like', '%' . $_REQUEST['settlement_number'] . '%'); } - if(isset($_REQUEST['status'])){ - $map['status']=$_REQUEST['status']; + if (isset($_REQUEST['status'])) { + $map['status'] = $_REQUEST['status']; } - if(isset($_REQUEST['developers'])){ - if($_REQUEST['developers']=='全部'){ + if (isset($_REQUEST['developers'])) { + if ($_REQUEST['developers'] == '全部') { unset($_REQUEST['developers']); - }else{ + } else { $map['developers'] = $_REQUEST['developers']; } - }else{ - $map['developers'] = array('neq',0); + } else { + $map['developers'] = array('neq', 0); } - if(isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])){ + if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { $starttime = strtotime($_REQUEST['timestart']); - $endtime = strtotime($_REQUEST['timeend'])+24*3600-1; - $map['audit_time'] = array('BETWEEN',array($starttime,$endtime)); - unset($_REQUEST['timestart']);unset($_REQUEST['timeend']); - }elseif(isset($_REQUEST['timestart'])){ - $map['audit_time'] = ['GT',strtotime(I('timestart'))]; + $endtime = strtotime($_REQUEST['timeend']) + 24 * 3600 - 1; + $map['audit_time'] = array('BETWEEN', array($starttime, $endtime)); + unset($_REQUEST['timestart']); + unset($_REQUEST['timeend']); + } elseif (isset($_REQUEST['timestart'])) { + $map['audit_time'] = ['GT', strtotime(I('timestart'))]; unset($_REQUEST['timestart']); - }elseif(isset($_REQUEST['timeend'])){ - $map['audit_time'] = ['LT',strtotime(I('timeend'))+86399]; + } elseif (isset($_REQUEST['timeend'])) { + $map['audit_time'] = ['LT', strtotime(I('timeend')) + 86399]; unset($_REQUEST['timeend']); } - if($_REQUEST['create_time']==2){ - $order='create_time desc'; - }elseif($_REQUEST['create_time']==1){ - $order='create_time asc'; - }else{ - $order='create_time desc'; + if ($_REQUEST['create_time'] == 2) { + $order = 'create_time desc'; + } elseif ($_REQUEST['create_time'] == 1) { + $order = 'create_time asc'; + } else { + $order = 'create_time desc'; } - if($_REQUEST['sum_money']==2){ - $order='sum_money desc'; - }elseif($_REQUEST['sum_money']==1){ - $order='sum_money asc'; + if ($_REQUEST['sum_money'] == 2) { + $order = 'sum_money desc'; + } elseif ($_REQUEST['sum_money'] == 1) { + $order = 'sum_money asc'; } $model = array( 'm_name' => 'withdraw', - 'order' => $order, - 'title' => '渠道提现', - 'template_list' =>'cp_withdraw', + 'order' => $order, + 'title' => '渠道提现', + 'template_list' => 'cp_withdraw', ); $map1 = $map; - $map1['status']=1; - if(isset($_REQUEST['status'])&&$_REQUEST['status']==0){ - $total = '0.00';$ttotal='0.00';$ytotal='0.00'; - }else{ - $total = null_to_0(D('withdraw')->where($map1)->sum('sum_money')); - $ttotal = null_to_0(D('withdraw')->where('audit_time'.total(1))->where($map1)->sum('sum_money')); - $ytotal = null_to_0(D('withdraw')->where('audit_time'.total(5))->where($map1)->sum('sum_money')); + $map1['status'] = 1; + if (isset($_REQUEST['status']) && $_REQUEST['status'] == 0) { + $total = '0.00'; + $ttotal = '0.00'; + $ytotal = '0.00'; + } else { + $total = null_to_0(D('withdraw')->where($map1)->sum('sum_money')); + $ttotal = null_to_0(D('withdraw')->where('audit_time' . total(1))->where($map1)->sum('sum_money')); + $ytotal = null_to_0(D('withdraw')->where('audit_time' . total(5))->where($map1)->sum('sum_money')); } - $this->assign('stotal',$total); - $this->assign('ttotal',$ttotal); - $this->assign('ytotal',$ytotal); - $user = A('Bill','Event'); + $this->assign('stotal', $total); + $this->assign('ttotal', $ttotal); + $this->assign('ytotal', $ytotal); + $user = A('Bill', 'Event'); - $this->m_title = '开发者提现'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Query/cp_withdraw','status'=>1])->find()); + $this->m_title = '开发者提现'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/cp_withdraw', 'status' => 1])->find()); - $user->money_list($model,$p,$map); + $user->money_list($model, $p, $map); } - public function withdraw() { + + public function withdraw() + { $adminid = C('USER_ADMINISTRATOR');//获取超管id $adminmobile = M('UcenterMember')->field('mobile')->find($adminid); - $this->assign('adminmobile',$adminmobile['mobile']); - if(isset($_REQUEST['settlement_number'])){ - $map['settlement_number']=$_REQUEST['settlement_number']; + $this->assign('adminmobile', $adminmobile['mobile']); + if (isset($_REQUEST['widthdraw_number'])) { + $map['widthdraw_number'] = $_REQUEST['widthdraw_number']; } - if(isset($_REQUEST['ti_status'])){ - $map['status']=$_REQUEST['ti_status']; + if (isset($_REQUEST['ti_status'])) { + $map['status'] = $_REQUEST['ti_status']; } - if(isset($_REQUEST['promote_account'])){ - if($_REQUEST['promote_account']=='全部'){ + if (isset($_REQUEST['promote_account'])) { + if ($_REQUEST['promote_account'] == '全部') { unset($_REQUEST['promote_account']); - }else{ + } else { $map['promote_account'] = $_REQUEST['promote_account']; } - }else{ - $map['promote_id'] = array('gt',0); + } else { + $map['promote_id'] = array('gt', 0); } - if($_REQUEST['create_time']==2){ - $order='create_time desc'; - }elseif($_REQUEST['create_time']==1){ - $order='create_time asc'; - }else{ - $order='create_time desc'; - } - if($_REQUEST['sum_money']==2){ - $order='sum_money desc'; - }elseif($_REQUEST['sum_money']==1){ - $order='sum_money asc'; + $order = 'create_time desc'; + if (isset($_REQUEST['data_order'])) { + $dataOrder = explode(',', $_REQUEST['data_order']); + if (count($dataOrder) == 2 && in_array($dataOrder[1], ['create_time', 'sum_money'])) { + if (intval($dataOrder[0]) == 4) { + $order = $dataOrder[1] . ' desc'; + } elseif (intval($dataOrder[0]) == 3) { + $order = $dataOrder[1] . ' asc'; + } + } } $model = array( 'm_name' => 'withdraw', - 'order' => $order, - 'title' => '渠道提现', - 'template_list' =>'withdraw', + 'order' => $order, + 'title' => '渠道提现', + 'template_list' => 'withdraw', ); - $map1=array('status'=>1); - $total=null_to_0(D('withdraw')->where($map1)->sum('sum_money')); - $ttotal=null_to_0(D('withdraw')->where('end_time'.total(1))->where($map1)->sum('sum_money')); - $ytotal=null_to_0(D('withdraw')->where('end_time'.total(5))->where($map1)->sum('sum_money')); - $this->assign('total',$total); - $this->assign('ttotal',$ttotal); - $this->assign('ytotal',$ytotal); - $user = A('Bill','Event'); + $map1 = array('status' => 1); + $total = null_to_0(D('withdraw')->where($map1)->sum('sum_money')); + $ttotal = null_to_0(D('withdraw')->where('end_time' . total(1))->where($map1)->sum('sum_money')); + $ytotal = null_to_0(D('withdraw')->where('end_time' . total(5))->where($map1)->sum('sum_money')); + $this->assign('total', $total); + $this->assign('ttotal', $ttotal); + $this->assign('ytotal', $ytotal); + $user = A('Bill', 'Event'); - $this->m_title = '推广提现'; - $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Query/withdraw','status'=>1])->find()); + $this->m_title = '推广提现'; + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/withdraw', 'status' => 1])->find()); - $user->money_list($model,$p,$map); + $user->money_list($model, $p, $map); } - public function set_withdraw_status($model='withdraw') { - $withdraw = M('withdraw',"tab_"); - $settlement = M('settlement',"tab_"); - $count = count($_REQUEST['ids']); - if($count > 1 || is_array($_REQUEST['ids'])){ - for ($i=0; $i <$count; $i++) { - $map['id']=$_REQUEST['ids'][$i]; - $dataWithdraw = $withdraw->where($map)->find(); - $withdraw->where($map)->save(array("audit_time"=>time())); - //修改 total_settlement表和settlement的ti_status状态 - $this->set_total_settlement_ti_status($dataWithdraw['settlement_number']); - } - }else{ - $map['id']=$_REQUEST['ids']; - $dataWithdraw = $withdraw->where($map)->find(); - $withdraw->where($map)->save(array("audit_time"=>time())); - //修改 total_settlement表和settlement的ti_status状态 - $this->set_total_settlement_ti_status($dataWithdraw['settlement_number']); - } - parent::set_status($model); + public function set_withdraw_status() + { + $withdraw = M('withdraw', "tab_"); + $ids = I('ids', 0); + $status = 1; + if (empty($ids)) { + $this->error('参数异常'); + } + if (is_array($ids)) { + $map['id'] = ['in', $ids]; + } else { + $map['id'] = $ids; + } + $map['status'] = 0; + $save['audit_time'] = time(); + $save['status'] = $status; + $res = $withdraw->where($map)->save($save); + if ($res === false) { + $this->error('审核失败'); + } else { + $this->success('审核成功', U('withdraw')); + } + } + + public function set_withdraw() + { + $case = I('case', ''); + if (empty($case)) { + $data['status'] = 0; + $data['msg'] = '参数异常'; + $this->ajaxReturn($data); + } + switch ($case) { + case 'deny': + $data = $this->set_withdraw_deny(); + break; + case 'upload_transfer_proof': + $data = $this->set_withdraw_transfer_proof(); + break; + default: + $data['status'] = 0; + $data['msg'] = '参数异常'; + break; + } + $this->ajaxReturn($data); + } + + public function set_withdraw_deny() + { + $withdraw = M('withdraw', "tab_"); + $ids = I('ids', 0); + $respond = I('respond', ''); + $status = -1; + if (empty($ids)) { + $data['status'] = 0; + $data['msg'] = '参数异常'; + return $data; + } + if (empty($respond)) { + $data['status'] = 0; + $data['msg'] = '请填写驳回说明'; + return $data; + } + $idsData = explode(',', $ids); + if (is_array($ids) || (is_array($idsData) && count($idsData) > 1)) { + $map['id'] = ['in', $ids]; + } else { + $map['id'] = $ids; + } + $map['status'] = 0; + $save['audit_time'] = time(); + $save['status'] = $status; + $save['respond'] = $respond; + $res = $withdraw->where($map)->save($save); + if ($res === false) { + $data['status'] = 0; + $data['msg'] = '驳回失败'; + } else { + $data['status'] = 1; + $data['msg'] = '驳回成功'; + } + + return $data; } - private function set_total_settlement_ti_status($settlement_number){ + public function set_withdraw_transfer_proof() + { + $withdraw = M('withdraw', "tab_"); + $ids = intval(I('ids', 0)); + $transferProof = intval(I('transfer_proof', 0)); + $status = 2; + if (empty($ids)) { + $data['status'] = 0; + $data['msg'] = '参数异常'; + return $data; + } + if (empty($transferProof)) { + $data['status'] = 0; + $data['msg'] = '请上传汇款证明'; + return $data; + } + $map['id'] = $ids; + $map['status'] = 1; + $save['audit_time'] = time(); + $save['status'] = $status; + $save['transfer_proof'] = $transferProof; + $res = $withdraw->where($map)->save($save); + if ($res === false) { + $data['status'] = 0; + $data['msg'] = '保存失败'; + } else { + $data['status'] = 1; + $data['msg'] = '保存成功'; + } + + return $data; + } + + private function set_total_settlement_ti_status($settlement_number) + { $totalSettlementMap['settlement_number'] = $settlement_number; - $totalSettlement = M('TotalSettlement','tab_'); - $totalSettlement->where($totalSettlementMap)->save(array("ti_status"=>$_REQUEST['status'])); + $totalSettlement = M('TotalSettlement', 'tab_'); + $totalSettlement->where($totalSettlementMap)->save(array("ti_status" => $_REQUEST['status'])); $dataTotalSettlement = $totalSettlement->where($totalSettlementMap)->find(); - $settMap['promote_id'] = $dataTotalSettlement['promote_id']; - $settMap['starttime'] = $dataTotalSettlement['starttime']; - $settMap['endtime'] = $dataTotalSettlement['endtime']; + $settMap['promote_id'] = $dataTotalSettlement['promote_id']; + $settMap['starttime'] = $dataTotalSettlement['starttime']; + $settMap['endtime'] = $dataTotalSettlement['endtime']; $settMap['create_time'] = $dataTotalSettlement['create_time']; - M("settlement","tab_")->where($settMap)->save(array('ti_status'=>$_REQUEST['status'])); + M("settlement", "tab_")->where($settMap)->save(array('ti_status' => $_REQUEST['status'])); } - protected function upPromote($promote_id){ + protected function upPromote($promote_id) + { $model = D('Promote'); $data['id'] = $promote_id; $data['money'] = 0; return $model->save($data); } - public function details($promote_id=0,$create_time=0){ + public function details($promote_id = 0, $create_time = 0) + { $map['promote_id'] = $promote_id; $map['create_time'] = $create_time; - $data = M('settlement','tab_')->where($map)->select(); - $total = M('settlement','tab_')->where($map)->sum('sum_money'); - $this->assign('total',$total); - $this->assign('list_data',$data); + $data = M('settlement', 'tab_')->where($map)->select(); + $total = M('settlement', 'tab_')->where($map)->sum('sum_money'); + $this->assign('total', $total); + $this->assign('list_data', $data); $this->display(); } - public function detailscps($developers_id=0,$create_time=0,$p=0){ + public function detailscps($developers_id = 0, $create_time = 0, $p = 0) + { $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 - $row = !empty(C('ADMIN_LIST_ROW'))?C('ADMIN_LIST_ROW'):10; + $row = !empty(C('ADMIN_LIST_ROW')) ? C('ADMIN_LIST_ROW') : 10; $map['developers_id'] = $developers_id; $map['create_time'] = $create_time; - $data = M('settlement','tab_')->where($map)->page($page,$row)->select(); - $count = M('settlement','tab_')->where($map)->count(); - if($count > $row){ + $data = M('settlement', 'tab_')->where($map)->page($page, $row)->select(); + $count = M('settlement', 'tab_')->where($map)->count(); + if ($count > $row) { $page = new \Think\Page($count, $row); - $page->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%'); - $this->assign('_page', $page->show()); + $page->setConfig('theme', '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%'); + $this->assign('_page', $page->show()); } - $total = M('settlement','tab_')->where($map)->sum('sum_money'); - $this->assign('total',$total); - $this->assign('list_data',$data); + $total = M('settlement', 'tab_')->where($map)->sum('sum_money'); + $this->assign('total', $total); + $this->assign('list_data', $data); $this->display(); } - public function withdrawDetails($settlement_number=''){ + public function withdrawDetails($settlement_number = '') + { $map['settlement_number'] = $settlement_number; - $data = M('TotalSettlement','tab_')->where($map)->find(); + $data = M('TotalSettlement', 'tab_')->where($map)->find(); $settMap['promote_id'] = $data['promote_id']; - $settMap['starttime'] = $data['starttime']; - $settMap['endtime'] = $data['endtime']; + $settMap['starttime'] = $data['starttime']; + $settMap['endtime'] = $data['endtime']; $settMap['create_time'] = $data['create_time']; - $dataSett = M('settlement','tab_')->where($settMap)->select(); - $total = M('settlement','tab_')->where($settMap)->sum('sum_money'); - $this->assign('list_data',$dataSett); - $this->assign('total',$total); + $dataSett = M('settlement', 'tab_')->where($settMap)->select(); + $total = M('settlement', 'tab_')->where($settMap)->sum('sum_money'); + $this->assign('list_data', $dataSett); + $this->assign('total', $total); $this->display(); } + /** * 审核推广提现 * @author */ - public function set_withdraw_agree(){ - + public function set_withdraw_agree() + { //行为日志判断 - if(I('status')==1&&I('msg_type')==5&&I('field')=='status'){ + if (I('status') == 1 && I('msg_type') == 5 && I('field') == 'status') { //同意推广提现 - action_log('tg_tx_agree','withdraw',UID,UID); + action_log('tg_tx_agree', 'withdraw', UID, UID); } - if(I('status')==2&&I('msg_type')==6&&I('field')=='status'){ + if (I('status') == 2 && I('msg_type') == 6 && I('field') == 'status') { //拒绝推广提现 - action_log('tg_tx_disagree','withdraw',UID,UID); + action_log('tg_tx_disagree', 'withdraw', UID, UID); } //判断打款类型 - if(I('withdraw_type',0,'intval')==1){ + if (I('withdraw_type', 0, 'intval') == 1) { //手动打款,直接就改状态 $this->set_withdraw_status(); - }else{ + } else { $adminid = C('USER_ADMINISTRATOR');//获取超管id $adminmobile = M('UcenterMember')->field('mobile')->find($adminid); $dx = A('Phone'); $res = -1; - $res = $dx->check_tel_code($adminmobile['mobile'],$_POST['code']); + $res = $dx->check_tel_code($adminmobile['mobile'], $_POST['code']); switch ($res) { case '-1': $this->error('短信验证码无效,请重新获取'); @@ -797,28 +925,28 @@ class QueryController extends ThinkController { $this->error('短信验证码不正确,请重新输入'); break; } - $withdraw=M('withdraw',"tab_"); + $withdraw = M('withdraw', "tab_"); $pay = new \Think\Pay('alipay', C('alipay')); $withdraw_way = $_POST['withdraw_way']; //支付宝 - if($withdraw_way==1){ - $map['id']=$_POST['ids']; - $dind=$withdraw->where($map)->find(); - if($dind['status']==1){ - $this->ajaxReturn(['status'=>-1,'info'=>'请不要重复打款']); + if ($withdraw_way == 1) { + $map['id'] = $_POST['ids']; + $dind = $withdraw->where($map)->find(); + if ($dind['status'] == 1) { + $this->ajaxReturn(['status' => -1, 'info' => '请不要重复打款']); } $widthdrawNo = "TX_" . date('Ymd') . date('His') . sp_random_string(4); - $vo = new \Think\Pay\PayVo(); + $vo = new \Think\Pay\PayVo(); $vo->setOrderNo($dind['settlement_number']) - ->setBatchNo($widthdrawNo) - ->setTable('Withdraw') - ->setPayMethod("transfer") - ->setDetailData('渠道结算提现,订单'.$dind["settlement_number"]); - $res = $pay->buildRequestForm($vo); - if($res==10000){ - $this->ajaxReturn(['status'=>1,'info'=>'打款成功']); - }else{ - $this->ajaxReturn(['status'=>0,'info'=>'打款失败']); + ->setBatchNo($widthdrawNo) + ->setTable('Withdraw') + ->setPayMethod("transfer") + ->setDetailData('渠道结算提现,订单' . $dind["settlement_number"]); + $res = $pay->buildRequestForm($vo); + if ($res == 10000) { + $this->ajaxReturn(['status' => 1, 'info' => '打款成功']); + } else { + $this->ajaxReturn(['status' => 0, 'info' => '打款失败']); } } diff --git a/Application/Admin/View/Query/withdraw.html b/Application/Admin/View/Query/withdraw.html index 59ff00860..4d9b4118d 100644 --- a/Application/Admin/View/Query/withdraw.html +++ b/Application/Admin/View/Query/withdraw.html @@ -2,6 +2,7 @@ + + - + + + + - - -
@@ -62,14 +75,15 @@
- +
@@ -82,7 +96,6 @@ -
@@ -94,16 +107,12 @@ 提现单号 - 提现金额 推广员账号 - 申请时间 提现状态 + 说明 审核时间 - 打款方式 - - 操作 @@ -125,44 +134,25 @@ - {$data.settlement_number} - {$data.sum_money} + {$data.widthdraw_number} + {$data.sum_money} {:get_promote_name($data['promote_id'])} {$data.create_time|date='Y-m-d H:i:s',###}--- + 已驳回 待审核 - 已通过 - 已驳回 + 汇款中 + 已汇款 - {$data.end_time|date='Y-m-d H:i:s',###}--- - - {:$data['widthdraw_number']==''&&$data['status']==1?'手动':($data['widthdraw_number']!=''&&$data['status']==1?'自动':'--')} - + {$data.respond} + {$data.audit_time|date='Y-m-d H:i:s',###}--- @@ -192,60 +182,40 @@
-
+ - - - - - - - 打款方式: - - - - - - +
    -
  1. -
    推广员账号: 
    -
    结算金额:
    -
    通过
    -
  2. -
  3. -
    - 打款途径: - - - - -
    +
  4. - 支付宝账号: - - + *说明: +
    -
    推广员账号:
    -
    结算金额:
    -
    - 超管手机号: - {$adminmobile} - 获取验证码 -
    -
    - 手机验证码: - +
    驳回
    +
  5. +
  6. +
    + *汇款证明: +
    + +
    +
    选择文件
    +
    +
    +
    +
    + +
    +
    + +
    -
    确定打款
    +
    保存
- @@ -267,51 +237,11 @@ $(".select_gallery").select2(); //导航高亮 highlight_subnav('{:U('Query/withdraw')}'); $(function(){ - $(".paixu").click(function(){ - $ddd=$(this).attr('date-url'); - $sum_money="{:I('sum_money')}"; - $create_time = "{:I('create_time')}"; - if($ddd=='sum_money'){ - if($sum_money==1){ - $(".sortBy").attr('name','sum_money'); - $(".sortBy").attr('value',2); - $("#search").click(); - }else{ - $(".sortBy").attr('name','sum_money'); - $(".sortBy").attr('value',1); - $("#search").click(); - } - } - if($ddd=='create_time' ){ - if($create_time==1){ - $(".sortBy").attr('name','create_time'); - $(".sortBy").attr('value',2); - $("#search").click(); - }else{ - $(".sortBy").attr('name','create_time'); - $(".sortBy").attr('value',1); - $("#search").click(); - } - } - }) - //搜索功能 - $("#search").click(function(){ - var url = $(this).attr('url'); - var query = $('.jssearch').find('input').serialize(); - query += "&"+$('.jssearch').find('select').serialize(); - query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,''); - query = query.replace(/^&/g,''); - if( url.indexOf('?')>0 ){ - url += '&' + query; - }else{ - url += '?' + query; - } - window.location.href = url; - }); $(".paixu").click(function(){ var that=$(this); $data_order=that.attr('data-order'); $order_type='{$userarpu_order}'; + console.log($order_type); if($order_type==''||$order_type=='4'){ $(".sortBy").attr('name','data_order'); val='3,'+$data_order; @@ -324,86 +254,66 @@ $(function(){ $("#search").click(); } }); + //搜索功能 + $("#search").click(function(){ + var url = $(this).attr('url'); + var query = $('.jssearch').find('input').serialize(); + query += "&"+$('.jssearch').find('select').serialize(); + query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,''); + query = query.replace(/^&/g,''); + if( url.indexOf('?')>0 ){ + url += '&' + query; + }else{ + url += '?' + query; + } + window.location.href = url; + }); //回车自动提交 $('.jssearch').find('input').keyup(function(event){ if(event.keyCode===13){ $("#search").click(); } }); - $('#time-start').datetimepicker({ - format: 'yyyy-mm-dd', - language:"zh-CN", - minView:2, - autoclose:true - }); - - $('#datetimepicker').datetimepicker({ - format: 'yyyy-mm-dd', - language:"zh-CN", - minView:2, - autoclose:true, - pickerPosition:'bottom-left' - }) - - $('#promote').on('click',function(event) { - var navlist = $(this).find('.nav-list'); - if (navlist.hasClass('hidden')) { - navlist.removeClass('hidden'); - $(this).find('.sort-txt').focus().val(''); - } else { - navlist.addClass('hidden'); - } - $(document).one('click', function(){ - navlist.addClass('hidden'); - }); - event.stopPropagation(); - }); - - $('#promote .sort-txt').on('keyup',function(event) { - var val = $.trim($(this).val()).toLowerCase(); - $('#promote').siblings('input').val(val); - }); - - $('#promote .nav-list').find("a").each(function(){ - var that = $('#promote'); - $(this).click(function(){ - var text = $.trim($(this).text()).toLowerCase(); - that.find('.sort-txt').val(text); - that.siblings('input').val(text); - }) - }); - +}); -}) - -function details(settlement_number){ +function details(id){ layer.open({ type: 2, title: '结算详情', shadeClose: true, shade: 0.8, area: ['80%', '70%'], - content: '/admin.php?s=/Query/withdrawDetails/settlement_number/'+settlement_number+'' //iframe的url + content: '/admin.php?s=/Query/withdrawDetails/id/'+id+'' //iframe的url }); } - diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php index 540686488..1805daad8 100644 --- a/Application/Common/Common/function.php +++ b/Application/Common/Common/function.php @@ -1421,3 +1421,16 @@ if(!function_exists('dd')){ } } +//获取推广员提现状态 +function promoteWithdrawStatus() +{ + $statusData = [ + -1 => '审核未通过', + 0 => '待审核', + 1 => '汇款中', + 2 => '已汇款', + ]; + + return $statusData; +} + diff --git a/Data/update.sql b/Data/update.sql index 2fec765a6..612fc1f47 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -358,3 +358,6 @@ CREATE TABLE `tab_device_bans` ( -- 2019-11-07 elf 迁移任务 ALTER TABLE `sys_shift_task` ADD COLUMN `shift_ids` varchar(255) NOT NULL DEFAULT '' COMMENT '迁移ID'; ALTER TABLE `sys_shift_task` ADD COLUMN `remark` varchar(255) NOT NULL DEFAULT '' COMMENT '备注'; + +-- 2019-11-07 cxj +ALTER TABLE `platform_query`.`tab_withdraw` ADD COLUMN `transfer_proof` int(11) NOT NULL DEFAULT 0 COMMENT '汇款证明' AFTER `settlement_end_time`; \ No newline at end of file From 0787c976ef6836ea75a698fb7179890cb23d58cd Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Thu, 7 Nov 2019 20:58:06 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0->?= =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=91=98->=E7=BB=93=E7=AE=97=E7=AE=A1?= =?UTF-8?q?=E7=90=86->=E6=8E=A8=E5=B9=BF=E6=8F=90=E7=8E=B0--=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/View/Query/withdraw.html | 14 ++-- Application/Common/Common/function.php | 80 +++++++++++++--------- 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/Application/Admin/View/Query/withdraw.html b/Application/Admin/View/Query/withdraw.html index 4d9b4118d..d9f71f886 100644 --- a/Application/Admin/View/Query/withdraw.html +++ b/Application/Admin/View/Query/withdraw.html @@ -80,10 +80,9 @@
@@ -138,12 +137,7 @@ {$data.sum_money} {:get_promote_name($data['promote_id'])} {$data.create_time|date='Y-m-d H:i:s',###}--- - - 已驳回 - 待审核 - 汇款中 - 已汇款 - + {:promoteWithdrawStatus($data['status'])} {$data.respond} {$data.audit_time|date='Y-m-d H:i:s',###}--- diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php index 1805daad8..c0396423c 100644 --- a/Application/Common/Common/function.php +++ b/Application/Common/Common/function.php @@ -70,7 +70,7 @@ function str2arr($str, $glue = ',') * @return string * @author 麦当苗儿 */ -function arr2str($arr=[], $glue = ',') +function arr2str($arr = [], $glue = ',') { return implode($glue, $arr); } @@ -1369,52 +1369,60 @@ function get_game_wxlogin_param($game_id) } } -function pp($val='', $isdie=true) { - var_dump($val); - if ($isdie) die(); +function pp($val = '', $isdie = true) +{ + var_dump($val); + if ($isdie) die(); } -function curl_post($url = '', $post_data = array()) { - if (empty($url) || empty($post_data)) { - return false; - } - - $requestString = http_build_query($post_data); - $postUrl = $url; - $curl = curl_init();//初始化curl - curl_setopt($curl, CURLOPT_URL, $postUrl); // 要访问的地址 - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 - curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在 - curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 - curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转 - curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer - curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 - curl_setopt($curl, CURLOPT_POSTFIELDS, $requestString); // Post提交的数据包 - curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环 - curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 - curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 - $data = curl_exec($curl);//运行curl - curl_close($curl); - return $data; +function curl_post($url = '', $post_data = array()) +{ + if (empty($url) || empty($post_data)) { + return false; + } + + $requestString = http_build_query($post_data); + $postUrl = $url; + $curl = curl_init();//初始化curl + curl_setopt($curl, CURLOPT_URL, $postUrl); // 要访问的地址 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在 + curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器 + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转 + curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer + curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求 + curl_setopt($curl, CURLOPT_POSTFIELDS, $requestString); // Post提交的数据包 + curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环 + curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回 + $data = curl_exec($curl);//运行curl + curl_close($curl); + return $data; } -if(!function_exists('dd')){ - function dd($var){ +if (!function_exists('dd')) { + function dd($var) + { if (func_num_args() > 1) { $var = func_get_args(); } $debug = debug_backtrace(); echo '
';
-        echo '
',$debug[0]['file'],' ',$debug[0]['line'],PHP_EOL,'
'; + echo '
', $debug[0]['file'], ' ', $debug[0]['line'], PHP_EOL, '
'; if (is_object($var) || is_array($var)) { $mode = 0; } else { $mode = 1; } - switch($mode){ - case 0: print_r($var); break; - case 1: var_dump($var); break; - default: print_r($var); + switch ($mode) { + case 0: + print_r($var); + break; + case 1: + var_dump($var); + break; + default: + print_r($var); } echo '
'; exit; @@ -1422,7 +1430,7 @@ if(!function_exists('dd')){ } //获取推广员提现状态 -function promoteWithdrawStatus() +function promoteWithdrawStatus($status = null) { $statusData = [ -1 => '审核未通过', @@ -1431,6 +1439,10 @@ function promoteWithdrawStatus() 2 => '已汇款', ]; + if (isset($statusData[$status])) { + return $statusData[$status]; + } + return $statusData; } From 68e57ab1f54f0e852a61de99fc17488ea80b52a7 Mon Sep 17 00:00:00 2001 From: zyx Date: Fri, 8 Nov 2019 09:06:15 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=93=BE=E8=B7=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/ExportController.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 5c65c1408..337e43bd6 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -5714,7 +5714,7 @@ if ($key == 'model'){ if (!empty(I("root_id"))) { $root_id = I("root_id"); $parentData = $this->getParentSpendData($root_id,$month,2); - $map['chain'] =['like','%'.$root_id.'%']; + $map['chain'] =['like','%/'.$root_id.'/%']; $map['level'] = 2; } else if(!empty(I("sign"))){ $map['parent_id'] = ['neq',0]; @@ -5793,7 +5793,7 @@ if ($key == 'model'){ $parentData = $this->getParentSpendData($root_id,$month,3); - $map['chain'] =['like','%'.$root_id.'%']; + $map['chain'] =['like','%/'.$root_id.'/%']; $map['level'] = 3; } else if(!empty(I("sign"))){ @@ -5873,7 +5873,7 @@ if ($key == 'model'){ $parent_id = I("parent_id"); $parentData = $this->getParentSpendData($parent_id,$month,4); - $map['chain'] =['like','%'.$parent_id.'%']; + $map['chain'] =['like','%/'.$parent_id.'/%']; $map['level'] = 4; } From e8d28792186bf779a0f6dc7088ee46c03300a078 Mon Sep 17 00:00:00 2001 From: sunke <18850253506@163.com> Date: Fri, 8 Nov 2019 09:24:25 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/View/default/Finance/index.html | 2 +- Application/Home/View/default/PromoteCoin/myCoin.html | 2 +- Application/Home/View/default/PromoteCoin/record.html | 2 +- Application/Home/View/default/TestResource/index.html | 2 +- Application/Home/View/default/TestResource/lists.html | 2 +- .../Home/View/default/TestResource/supportNumberList.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Application/Home/View/default/Finance/index.html b/Application/Home/View/default/Finance/index.html index a78f49948..18355e200 100644 --- a/Application/Home/View/default/Finance/index.html +++ b/Application/Home/View/default/Finance/index.html @@ -77,7 +77,7 @@
- + 导出 {$_page}
diff --git a/Application/Home/View/default/PromoteCoin/myCoin.html b/Application/Home/View/default/PromoteCoin/myCoin.html index 98fe98a1a..bcd58b1ac 100644 --- a/Application/Home/View/default/PromoteCoin/myCoin.html +++ b/Application/Home/View/default/PromoteCoin/myCoin.html @@ -193,7 +193,7 @@
- 导出 + 导出 {$_page}
diff --git a/Application/Home/View/default/PromoteCoin/record.html b/Application/Home/View/default/PromoteCoin/record.html index aafd82c00..dac1ecf8f 100644 --- a/Application/Home/View/default/PromoteCoin/record.html +++ b/Application/Home/View/default/PromoteCoin/record.html @@ -103,7 +103,7 @@
- 导出 + 导出 {$pagination}
diff --git a/Application/Home/View/default/TestResource/index.html b/Application/Home/View/default/TestResource/index.html index e4c23d084..a00db2337 100644 --- a/Application/Home/View/default/TestResource/index.html +++ b/Application/Home/View/default/TestResource/index.html @@ -292,7 +292,7 @@
- 导出 + 导出 {$_page}
diff --git a/Application/Home/View/default/TestResource/lists.html b/Application/Home/View/default/TestResource/lists.html index 1628e0261..6f5977857 100644 --- a/Application/Home/View/default/TestResource/lists.html +++ b/Application/Home/View/default/TestResource/lists.html @@ -156,7 +156,7 @@
- 导出 + 导出 {$_page}
diff --git a/Application/Home/View/default/TestResource/supportNumberList.html b/Application/Home/View/default/TestResource/supportNumberList.html index 4253683ff..dec993184 100644 --- a/Application/Home/View/default/TestResource/supportNumberList.html +++ b/Application/Home/View/default/TestResource/supportNumberList.html @@ -178,7 +178,7 @@
- 导出 + 导出 {$_page}