diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index a37e87067..8ebfc1ae6 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1865,7 +1865,7 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_ foreach ($data['statement_info'] as $key => $value) { $objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1)->mergeCells("J$line:K$line"); $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['statement_begin_time'] . '-' . $value['statement_end_time']); - if ($value['statement_type'] == 1) {//罚款 + if ($value['statement_type'] > 0) {//罚款 $product_name = $value['type_name']; $objPHPExcel->getActiveSheet()->setCellValue('F'.$line , '-'); $objPHPExcel->getActiveSheet()->setCellValue('G'.$line, '-'); @@ -1950,7 +1950,7 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al $objPHPExcel->getActiveSheet()->removeConditionalStyles(); $objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $value['statement_begin_time'] . '-' . $value['statement_end_time']); - if ($value['statement_type'] == 1) {//罚款 + if ($value['statement_type']>0) {//罚款 $product_name = $value['type_name']; $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, '-'); $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, '-'); @@ -2018,10 +2018,23 @@ function getWithdrawNumber() { //上有流水计算 function caculateUpstream($game_id,$pay_amount) { - $data = M('cp_game_ratio','tab_') + $ladderData = M('cp_game_ratio','tab_') ->where(['game_id'=>$game_id,'begin_total_amount'=>['elt',$pay_amount],'is_del'=>0]) - ->order('begin_total_amount Desc') - ->find(); + ->limit(0,2) + ->order('begin_total_amount desc') + ->select(); + + foreach($ladderData as $key => $value) { + + if ($value['instanceof'] == 1 && $value['begin_total_amount'] <= $pay_amount + || $value['instanceof'] == 2 && $value['begin_total_amount'] != $pay_amount ) { + $data['ratio'] = $value['ratio']; + break; + } else { + $data['ratio'] = $value['ratio']; + } + + } return number_format($pay_amount*($data['ratio']/100),2,'.',''); diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index e3e1458aa..83cc1f5fd 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -270,9 +270,18 @@ class AjaxController extends ThinkController{ $statementData = json_decode($getStatementData['statement_info'],true); + + $reward = 0; + $forfeit = 0; + + if ($statementData) { $data['sum'] = $getStatementData['statement_money']; $data['pay_amount'] = $getStatementData['pay_amount']; + + $data['reward'] = 0; + $data['forfeit'] = 0; + $handleStatementData = []; foreach ($statementData as $key=>$sv) { if ($sv['game_id']) { @@ -287,9 +296,15 @@ class AjaxController extends ThinkController{ $handleStatementData[$sv['game_id']][] = $nowVal; } else { - $data['forfeit'] = $sv['sum_money']; + if ($sv['statement_type'] == 2) { + $data['reward'] += $sv['sum_money']; + } else if ($sv['statement_type'] == 1) { + $data['forfeit'] += $sv['sum_money']; + } } } + +// dump($handleStatementData);die(); $first_party_info = json_decode($getStatementData['first_party_info'],true); $second_party_info = json_decode($getStatementData['second_party_info'],true); $data['game_ratio'] = $handleStatementData; @@ -345,11 +360,21 @@ class AjaxController extends ThinkController{ if (!in_array($v['game_name'],$gameStr)) { array_push($gameStr,$v['game_name']); } else { - $game_ratio[$v['game_name']] = $v; - unset($data['game_ratio'][$key]); +// var_dump($key); + if (!$game_ratio[$v['game_name']]) { + $game_ratio[$v['game_name']] = $v; + } + else { + $game_ratio[$v['game_name']]['sum_amount'] += $v['sum_amount']; + } + unset($value[$k]); } } + if (!$value) { + unset($data['game_ratio'][$key]); + } + } // dump($data['game_ratio']);die(); @@ -358,6 +383,32 @@ class AjaxController extends ThinkController{ foreach ($value as $k => &$v) { + $startTime = strtotime($v['begin_time']); + $endTime = strtotime($v['end_time']); + + $rewardData = M('reward_record','tab_') + ->field("sum(tab_reward_record.money) as money,reward_type") + ->join("left join (select * from tab_game group by relation_game_id)tab_game on tab_reward_record.relation_game_id=tab_game.relation_game_id") + ->where(['company_type'=>2,'relation_game_name'=>['like',"%{$v['game_name']}%"],'company_id'=>$data['company_id'],'reward_time'=>['between',[$startTime,$endTime]]]) + ->group('reward_type') + ->select(); + + foreach ($rewardData as $key => $valReward) { + + if ($valReward['reward_type']==1) { + + $reward = $reward + $valReward['money']; + + } else if ($valReward['reward_type']==2) { + + $forfeit = $forfeit + $valReward['money']; + + } + + } + +// dump($reward);die(); + if ($game_ratio[$v['game_name']]) { $v['sum_amount'] = number_format($v['sum_amount'] + $game_ratio[$v['game_name']]['sum_amount'],2,'.',''); @@ -370,6 +421,9 @@ class AjaxController extends ThinkController{ } + $data['reward'] = $reward; + $data['forfeit'] = $forfeit; + $yfData = M('tool','tab_')->where(['name'=>'company_info'])->find(); $yfData = json_decode($yfData['config'],true); diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 52c59f193..14f221229 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -1054,87 +1054,108 @@ class ExportController extends Controller break; case 7: + $startDate = empty($_REQUEST['timestart']) ? date('Y-m-d', strtotime('-6 day', time())) : $_REQUEST['timestart']; + $endDate = empty($_REQUEST['timeend']) ? date('Y-m-d') : $_REQUEST['timeend']; + + $startTime = strtotime($startDate); + $endTime = strtotime($endDate) + 86399; + $map['pay_time'] = array('BETWEEN', array($startTime, $endTime)); + + unset($_REQUEST['timestart']); + unset($_REQUEST['timeend']); + if (isset($_REQUEST['user_account'])) { - $map['user_account'] = array('like', '%' . trim($_REQUEST['user_account']) . '%'); + $map['user_account'] = array('like', trim($_REQUEST['user_account'])); unset($_REQUEST['user_account']); } if (isset($_REQUEST['spend_ip'])) { - $map['spend_ip'] = array('like', '%' . trim($_REQUEST['spend_ip']) . '%'); + $map['spend_ip'] = array('like', trim($_REQUEST['spend_ip']) . '%'); unset($_REQUEST['spend_ip']); } - if (isset($_REQUEST['time-start']) && isset($_REQUEST['time-end'])) { - $map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['time-start']), strtotime($_REQUEST['time-end']) + 24 * 60 * 60 - 1)); - unset($_REQUEST['time-start']); - unset($_REQUEST['time-end']); - } - if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { - $map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 24 * 60 * 60 - 1)); - unset($_REQUEST['timestart']); - unset($_REQUEST['timeend']); - } - if (isset($_REQUEST['start']) && isset($_REQUEST['end'])) { - $map['pay_time'] = array('BETWEEN', array(strtotime($_REQUEST['start']), strtotime($_REQUEST['end']) + 24 * 60 * 60 - 1)); - unset($_REQUEST['start']); - unset($_REQUEST['end']); - } - if(isset($_REQUEST['game_name'])){ - if($_REQUEST['game_name']=='全部'){ + if (isset($_REQUEST['game_name'])) { + if ($_REQUEST['game_name'] == '全部') { unset($_REQUEST['game_name']); - }else{ - $map['tab_spend.game_id']= ['in', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')]; + } else { + $map['game_id'] = ['in', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')]; unset($_REQUEST['game_name']); } } - if(isset($_REQUEST['server_name'])){ - $map['tab_spend.server_name']=$_REQUEST['server_name']; - unset($_REQUEST['server_name']); + if (isset($_REQUEST['game_type']) && $_REQUEST['game_type']) { + $map['sdk_version'] = $_REQUEST['game_type']; + } + if (isset($_REQUEST['server_id'])) { + $map['server_id'] = $_REQUEST['server_id']; + unset($_REQUEST['server_id']); } if (isset($_REQUEST['pay_order_number'])) { - $map['pay_order_number'] = array('like', '%' . trim($_REQUEST['pay_order_number']) . '%'); + $map['pay_order_number'] = array('like', trim($_REQUEST['pay_order_number'])); unset($_REQUEST['pay_order_number']); } + if (isset($_REQUEST['extend'])) { + $map['extend'] = array('like', trim($_REQUEST['extend'])); + unset($_REQUEST['extend']); + } if (isset($_REQUEST['pay_status'])) { $map['pay_status'] = $_REQUEST['pay_status']; unset($_REQUEST['pay_status']); } if (isset($_REQUEST['pay_way'])) { - $map['pay_way'] = $_REQUEST['pay_way']; - unset($_REQUEST['pay_status']); + if ($_REQUEST['pay_way'] == 2) { + $map['pay_way'] = ['in', '2,3,4']; + } else { + $map['pay_way'] = $_REQUEST['pay_way']; + } + unset($_REQUEST['pay_way']); } if (isset($_REQUEST['pay_game_status'])) { $map['pay_game_status'] = $_REQUEST['pay_game_status']; unset($_REQUEST['pay_game_status']); } -// $promoteRoot = getPowerPromoteIds(); -// $data_empower_type = session('user_auth')['data_empower_type']; +// $promoteRoot = getPowerPromoteIds(); +// $data_empower_type = session('user_auth')['data_empower_type']; // -// if ($promoteRoot) { -// $map['promote_id'] =array('in',$promoteRoot); -// } else if(!$promoteRoot&&$data_empower_type!=1){ -// $map['id'] = array('lt',1); -// } +// if ($promoteRoot) { +// $map['promote_id'] =array('in',$promoteRoot); +// } else if(!$promoteRoot&&$data_empower_type!=1){ +// $map['id'] = array('lt',1); +// } setPowerPromoteIds($map,'promote_id'); - if(isset($_REQUEST['promote_id'])) { - if ($_REQUEST['promote_id'] == 0) { + if (isset($_REQUEST['promote_id'])) { + $promoteId = intval($_REQUEST['promote_id']); + if ($promoteId == 0) { $map['promote_id'] = 0; } else { - $map['_complex'] = ['tp.chain'=>['like', "%/{$_REQUEST['promote_id']}/%"], 'tp.id'=>$_REQUEST['promote_id'], '_logic' => 'or']; + $promoteMap['chain'] = ['like', "%/$promoteId/%"]; + $promoteIds = M('Promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promoteId; + $map['promote_id'] = ['in', $promoteIds]; } - $tab_promote_join = "left join tab_promote as tp on tp.id = tab_spend.promote_id"; - //unset($_REQUEST['promote_id']); + } + if ($_REQUEST['data_order'] != '') { + $data_order = reset(explode(',', $_REQUEST['data_order'])); + $data_order_type = end(explode(',', $_REQUEST['data_order'])); + $this->assign('userarpu_order', $data_order); + $this->assign('userarpu_order_type', $data_order_type); + $sort = $data_order == 3 ? 'desc' : 'asc'; + $order = $data_order_type . ' ' . $sort; } else { - $tab_promote_join = false; + $order = ' pay_time desc '; } + + // if (intval(($endTime + 1) - $startTime) / (24 * 3600) <= 31) { + // $map1 = $map; + // $map1['pay_status'] = 1; + // } else { + // $map = '1 = 2'; + // $map1 = $map; + // } $map1 = $map; $map1['pay_status'] = 1; - $total = D('Spend')->where($map1)->join($tab_promote_join)->sum('pay_amount'); - if (isset($map['pay_status']) && $map['pay_status'] == 0) { - $total = sprintf("%.2f", 0); - } else { - $total = sprintf("%.2f", $total); - } + $total = M('Spend','tab_')->where($map1)->sum('pay_amount'); +// var_dump($total);die(); + $total=$total?$total:0; $xlsCell = array( @@ -1155,10 +1176,7 @@ class ExportController extends Controller fputcsv($fp, $xlsCell);//将数据格式化为CSV格式并写入到output流中 $accessNum = D('Spend') - ->field('pay_order_number,pay_time,user_account,game_name,promote_account,spend_ip,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status') ->where($map) - ->join($tab_promote_join) - ->order('pay_time DESC') ->count(); $perSize = 10000;//每次查询的条数 @@ -1167,15 +1185,21 @@ class ExportController extends Controller // var_dump($count);die(); for($i = 1; $i <= $pages; $i++) { $xlsData = D('Spend') +// ->field('pay_order_number,extend,pay_time,user_account,game_name,promote_account,spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status') +// ->where($map) +// ->limit(($i-1)*$perSize ,$perSize) +// ->join($tab_promote_join) +// ->order('pay_time DESC') +// ->select(); ->field('pay_order_number,extend,pay_time,user_account,game_name,promote_account,spend_ip,server_id,server_name,game_player_id,game_player_name,cost,pay_amount,pay_way,pay_status,pay_game_status') ->where($map) ->limit(($i-1)*$perSize ,$perSize) - ->join($tab_promote_join) - ->order('pay_time DESC') + ->order($order ? $order : 'pay_time desc') ->select(); foreach($xlsData as $value) { $value['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']); + $value['extend'] = $value['extend'].'`'; $value['pay_way'] = get_pay_way($value['pay_way']); $value['pay_status'] = get_info_status($value['pay_status'],9); $value['pay_game_status'] = get_info_status($value['pay_game_status'],14); @@ -7139,7 +7163,7 @@ class ExportController extends Controller if (!empty(I('timestart'))) { $timestart = strtotime(I('timestart')); - $map['_string'] = "s.pay_time > {$timestart}"; + $map['_string'] = "s.pay_time >= {$timestart}"; } if (!empty(I('timeend'))) { diff --git a/Application/Admin/Controller/FileController.class.php b/Application/Admin/Controller/FileController.class.php index bb6b721df..a9db7bd78 100644 --- a/Application/Admin/Controller/FileController.class.php +++ b/Application/Admin/Controller/FileController.class.php @@ -241,6 +241,51 @@ class FileController extends AdminController $this->ajaxReturn($return); } + /** + * 上传图片 + * @author huajie + */ + public function uploadPictureNotLimit() + { + //TODO: 用户登录检测 + + /* 返回标准数据 */ + $return = array('status' => 1, 'info' => '上传成功', 'data' => ''); + + /* 调用文件上传组件上传文件 */ + $Picture = D('Picture'); + $pic_driver = C('PICTURE_UPLOAD_DRIVER'); + + $info = $Picture->upload( + $_FILES, + C('PICTURE_UPLOAD'), + C('PICTURE_UPLOAD_DRIVER'), + C("UPLOAD_{$pic_driver}_CONFIG"), + $_REQUEST['flag'] + ); //TODO:上传到远程服务器 + + // 添加水印 +// if ($_REQUEST['flag']) { +// $this->addWatermarkOnPic($info['download']); +// } + + /* 记录图片信息 */ + if ($info) { + $return['status'] = 1; + if (empty($info['download'])) { + $file = $info['file']; + } else { + $file = $info['download']; + } + $return = array_merge($file, $return); + } else { + $return['status'] = 0; + $return['info'] = $Picture->getError(); + } + ob_clean(); + /* 返回JSON数据 */ + $this->ajaxReturn($return); + } public function uploadDoc() { diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 993f7b4b1..111b5fa45 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -17,6 +17,8 @@ use BaiduBce\Services\Bos\CannedAcl; use BaiduBce\Services\Bos\BosOptions; use BaiduBce\Auth\SignOptions; use BaiduBce\Log\LogFactory; +use Admin\Model\AuthRuleModel; +use Admin\Model\AuthGroupModel; use Base\Service\GameService; /** @@ -301,9 +303,46 @@ class GameController extends ThinkController } } + public function delSociatyGames() { + $res = ['code' => 10000]; + $id = $_REQUEST['id']; + $delRest = M('sociaty_games','tab_')->where(['id'=>$id])->delete(); + if($delRest) { + $res['code'] = 10001; + $this->ajaxReturn($res); + } + } + public function edit($id = null) { if (IS_POST) { + if(!empty($_REQUEST['apply_auth'])) { + $gameData['apply_auth'] = $_REQUEST['apply_auth']; + $game_appid = $_REQUEST['game_appid']; + $gameId = M('game','tab_')->where(['game_appid' => $game_appid])->getField('id'); + M('game','tab_')->where(['id'=>$gameId])->save($gameData); + if($_REQUEST['apply_auth'] == 1) { + M('sociaty_games','tab_')->where(['game_id'=>$gameId])->delete(); + } + if(!empty($_REQUEST['promote_data'])) { + $promote_data = json_decode($_REQUEST['promote_data'],TRUE); + $game_appid = $_REQUEST['game_appid']; + $gameId = M('game','tab_')->where(['game_appid' => $game_appid])->getField('id'); + $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gameId])->select(); + $dataList = array(); + foreach($promote_data as $key => $promoteInfo) { + $isSociaty = M('sociaty_games','tab_')->where(['promote_id'=>intval($promoteInfo['value']),'game_id'=>intval($gameId)])->getField('id'); + if(!empty($isSociaty)) { + // $this->error("选择会长中有已存在会长"); + }else { + $dataList[] = ['promote_id' => intval($promoteInfo['value']),'game_id' => intval($gameId),'status'=>$gameInfo[0]['game_status'],'create_time'=>time()]; + } + + } + M('sociaty_games','tab_')->addAll($dataList); + } + // $_REQUEST['apply_auth'] == 1 ? $this->success('开放全部会长权限成功') : $this->success('设置会长权限成功'); + } if ($_POST['game_score'] < 0 || $_POST['game_score'] > 5) { $this->error('游戏评分只能为0-5之间的数字!'); exit; @@ -419,7 +458,30 @@ class GameController extends ThinkController $data['icon_data'] = explode(',', $data['icon']); } - + $apply_auth = M('game','tab_')->where(['id'=>$id])->getField('apply_auth'); + $this->assign('apply_auth',$apply_auth); + $sociatyGames = M('sociaty_games','tab_')->where(['game_id'=>$id])->select(); + $sociatyGamesData = []; + if(!empty($sociatyGames)) { + foreach($sociatyGames as $key => $value) { + $sociatyGamesData[$key]['id'] = $value['id']; + if($value['promote_id'] == -1) { + $sociatyGamesData[$key]['promoteAccount'] = "官方渠道"; + }else { + $promoteAccount = M('promote','tab_')->where(['id'=>$value['promote_id']])->getField('account'); + $sociatyGamesData[$key]['promoteAccount'] = $promoteAccount; + } + $sociatyGamesData[$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']); + $applyStatus = M('apply','tab_')->field('id')->where(['game_id'=>$value['game_id'],'status'=>1])->select(); + if(empty($applyStatus)) { + $sociatyGamesData[$key]['isPromote'] = "否"; + }else { + $sociatyGamesData[$key]['isPromote'] = "是"; + } + } + } + $this->assign('sociatygames',$sociatyGamesData); + $data['introduction'] = str_replace("~~", "\r\n", $data['introduction']); $this->assign('data', $data); $this->assign('game_id', $id); @@ -430,6 +492,11 @@ class GameController extends ThinkController $this->m_title = '游戏列表'; $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Game/lists', 'status' => 1])->find()); $this->assign('game_ratio',$game_ratio); + $auth_group = M('AuthGroup')->where( array('status'=>array('egt','0'),'module'=>'admin','type'=>AuthGroupModel::TYPE_ADMIN) ) + ->getfield('id,id,title,rules'); + $empower_type = M('AuthGroup')->field('data_empower_type')->where(array('id'=>1))->find(); + $this->assign('data_empower_type', $empower_type['data_empower_type']); + $this->assign('auth_group', $auth_group); $this->display(); } } @@ -906,4 +973,92 @@ class GameController extends ThinkController //M('cp_game_ratio', 'tab_')->where("id=".$_POST['data_id'])->data(array("is_del"=>"1","update_time"=>time()))->save(); echo(json_encode(array("result"=>"1","desc"=>"删除成功"))); } + + + public function uploadExcel1() { + Vendor("PHPExcel.PHPExcel"); + $gid = $_REQUEST['game_id']; + if(@is_uploaded_file($_FILES['file']['tmp_name'])){ + $upfile = $_FILES["file"]; + $name = $upfile["name"]; + $type = $upfile["type"]; + $size = $upfile["size"]; + $tmp_name = $upfile["tmp_name"]; + $savePath = $_SERVER['DOCUMENT_ROOT'].__ROOT__.'/Uploads/Excel/'; + move_uploaded_file($tmp_name,$savePath.$name); + $file_name = $savePath.$name; + $error=$upfile["error"];//上传后系统返回的值 + $extension = strtolower( pathinfo($file_name, PATHINFO_EXTENSION) ); + if($extension == 'xlsx') { + $objReader = \PHPExcel_IOFactory::createReader('excel2007'); + }elseif($extension == 'csv') { + $objReader = \PHPExcel_IOFactory::createReader('csv'); + }else { + $objReader = \PHPExcel_IOFactory::createReader('Excel5');//创建读取实例 + } + $objPHPExcel = $objReader->load($file_name,$encode='utf-8');//加载文件 + $sheet = $objPHPExcel->getSheet(0); + $highestRow = $sheet->getHighestRow(); + $highestColumn = $sheet->getHighestColumn(); + $dataList = []; + $outPromote = []; //录入出错的会长 + $outGame = []; //录入出错的游戏 + $successAccount = []; + $keyPro = 0; + $keyGame = 0; + $keyData = 0; + for($i=2;$i<=$highestRow;$i++) + { + $promoteAccount = $objPHPExcel->getActiveSheet()->getCell("A".$i)->getValue(); + $promoteInfo = M('promote','tab_')->field('id')->where(['account' => $promoteAccount ])->find(); + if($promote_id == -1) {$promoteInfo['account'] = "官方渠道"; } + if(empty($promoteInfo)) { + $outPromote[$keyPro]['promote_account'] = $promoteAccount; + $keyPro += 1; + }else { + $promote_id = $promoteInfo['id']; + } + $gameInfo = M('game','tab_')->field('game_name,game_status')->where(['id'=>$gid])->select(); + $time = time(); + $isSociaty = M('sociaty_games','tab_')->where(['promote_id'=>$promote_id,'game_id'=>$gid])->getField('id'); + if(empty($isSociaty) && !empty($gameInfo) && !empty($promoteInfo)) { + $dataList[$keyData] = ['promote_id'=>$promote_id,'game_id'=>$gid,'status'=>$gameInfo[0]['game_status'],'create_time'=>$time]; + $successAccount[$keyData] = ['account'=>$promoteAccount]; + $keyData += 1; + } + + } + $backData['outPromote'] = $outPromote; + $backData['datalist'] = $successAccount; + M('sociaty_games','tab_')->addAll($dataList); + $gameData['apply_auth'] = 2; + M('game','tab_')->where(['id'=>$gid])->save($gameData); + $this->ajaxReturn(json_encode($backData,TRUE)); + + } + } + + function getRootPromote() { + $promoteData = M('promote','tab_')->field('id as value,account as title')->where(array('level'=>1,'chain'=>'/'))->select(); + $data_president = M('AuthGroup')->field('data_president')->where(array('id'=>1))->find(); + + $promoteData = array_merge([0=>['value'=>'-1','title'=>'官方渠道']],$promoteData); + + $returnData = array('data_president'=>$data_president['data_president'],'list'=>$promoteData); + $this->ajaxReturn(json_encode($returnData)); + } + + //下载模板 + public function downloadDemo() { + $game_id = $_REQUEST['game_id']; + $game_name = M('game','tab_')->where(['id'=>$game_id])->getField('game_name'); + $data[] = [ + 'promoteid' => "官方渠道", + ]; + $field = array( + "promoteid"=>"会长账号", + ); + data2csv($data,'【'.$game_name.'】'.'模板',$field); + } + } diff --git a/Application/Admin/Controller/PartnerController.class.php b/Application/Admin/Controller/PartnerController.class.php index 4b3afe97b..4cbcfd3c5 100644 --- a/Application/Admin/Controller/PartnerController.class.php +++ b/Application/Admin/Controller/PartnerController.class.php @@ -100,7 +100,7 @@ class PartnerController extends ThinkController $this->error('合作方已存在'); } - if(!preg_match("/^1[358][0-9]{9}$/u",I('link_phone'))) { + if(!checkPhone(I('link_phone'))) { $this->error('联系电话格式不正确'); } $res2 = $model->where(['link_phone' => I('link_phone')])->getField('id'); @@ -173,7 +173,7 @@ class PartnerController extends ThinkController $this->error('合作方已存在'); } - if(!preg_match("/^1[358][0-9]{9}$/u",I('link_phone'))) { + if(!checkPhone(I('link_phone'))) { $this->error('联系电话格式不正确'); } $res2 = $model->where([ diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index c1dde574d..83da6cbb3 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -1224,6 +1224,10 @@ class PromoteController extends ThinkController $map['pb.can_view_recharge'] = I('can_view_recharge'); } + if (!is_null(I('company_type', null))) { + $map['pb.company_type'] = I('company_type'); + } + if (!is_null(I('company_id', null))) { $map['p.company_id'] = I('company_id'); } @@ -1266,7 +1270,7 @@ class PromoteController extends ThinkController $this->display(); } - public function belong_add($promote_id=null, $company_belong = null, $company_relation = null, $remark = null, $can_view_recharge = null) + public function belong_add($promote_id=null, $company_belong = null, $company_relation = null, $remark = null, $can_view_recharge = null, $company_type = null) { if (IS_POST) { if (empty($promote_id)) { @@ -1277,6 +1281,7 @@ class PromoteController extends ThinkController 'company_belong' => $company_belong, 'company_relation' => $company_relation, 'can_view_recharge' => $can_view_recharge, + 'company_type' => $company_type, 'verify_status' => 0, 'remark' => $remark, 'applicant_id' => getAdmin(), @@ -1303,7 +1308,7 @@ class PromoteController extends ThinkController } } - public function belong_edit($promote_id=null, $company_belong = null, $company_relation = null, $remark = null, $can_view_recharge = null) + public function belong_edit($promote_id=null, $company_belong = null, $company_relation = null, $remark = null, $can_view_recharge = null, $company_type = null) { if (IS_POST) { if (empty($promote_id)) { @@ -1314,6 +1319,7 @@ class PromoteController extends ThinkController 'company_belong' => $company_belong, 'company_relation' => $company_relation, 'can_view_recharge' => $can_view_recharge, + 'company_type' => $company_type, 'verify_status' => 0, 'remark' => $remark, 'applicant_id' => getAdmin(), @@ -1346,6 +1352,7 @@ class PromoteController extends ThinkController 'verify_status' => $verify_status, 'approver_id' => getAdmin(), 'approver_name' => getAdmin('username'), + 'verify_time' => time() ]); if (!is_null($res) ) { if ($verify_status == 1) {//审核通过才修改推广员的归属关系 @@ -1368,4 +1375,134 @@ class PromoteController extends ThinkController } + public function certification() + { + if ($_POST) { + $promoteId = intval(I('post.id', 0)); + if (empty($promoteId)) { + $this->error('参数异常'); + } + + $promote = D('promote')->field('real_name, idcard, mobile_phone')->where(array('id' => $promoteId))->find(); + if (empty($promote)) { + $this->error('参数异常'); + } + if (empty($promote['real_name']) || $promote['real_name'] != I('post.real_name', '')) { + if (empty($_POST['real_name'])) { + $this->error('真实姓名不能为空'); + } + $save['real_name'] = I('post.real_name', ''); + } + if (empty($promote['idcard']) || $promote['idcard'] != I('post.idcard', '')) { + if (empty($_POST['idcard'])) { + $this->error('身份证号码不能为空'); + } + if(!is_idcard($_POST['idcard'])) { + $this->error('证件号码错误'); + } + $save['idcard'] = I('post.idcard', ''); + } + if (empty($promote['mobile_phone']) || $promote['mobile_phone'] != I('post.mobile_phone', '')) { + if (empty($_POST['mobile_phone'])) { + $this->error('手机号码不能为空'); + } + $patternPhone = "/^1[3|5|7|8]\\d{9}$/i"; + if(!preg_match($patternPhone, $_POST['mobile_phone'])) { + $this->error("手机号码格式不合法"); + } + $save['mobile_phone'] = I('post.mobile_phone', ''); + } + if (empty($_POST['idcarpic'])) { + $this->error('身份证证件照不能为空'); + } + if (empty($_POST['s_province'])) { + $this->error('联系省份不能为空'); + } + if (empty($_POST['s_city'])) { + $this->error('联系地级市不能为空'); + } + if (empty($_POST['s_county'])) { + $this->error('联系市、县级市不能为空'); + } + if (empty($_POST['s_address'])) { + $this->error('详细地址不能为空'); + } + if (empty($_POST['email'])) { + $this->error('邮箱不能为空'); + } + $patternEmail = "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i"; + if (!preg_match($patternEmail, $_POST['email'])) { + $this->error('邮箱地址错误'); + } + if (empty($_POST['account_type'])) { + $this->error('账户类型不能为空'); + } + if (empty($_POST['bank_name'])) { + $this->error('开户银行不能为空'); + } + if (empty($_POST['bank_account'])) { + $this->error('银行户名不能为空'); + } + $patternBankAccount = "/^[\x{4e00}-\x{9fa5}]{2,}$/u"; + if (!preg_match($patternBankAccount, $_POST['bank_account'])) { + $this->error('银行卡开户人姓名错误'); + } + if (empty($_POST['bank_card'])) { + $this->error('卡号不能为空'); + } + $patternBankCard = "/^\d{10,19}$/u"; + if (!preg_match($patternBankCard, $_POST['bank_card'])) { + $this->error('卡号格式错误'); + } + + $save['id'] = $promoteId; + $save['ver_status'] = 1; + $save['idcarpic'] = I('post.idcarpic', ''); + $save['address'][] = I('post.s_province', '') . ',' . I('post.s_city', '') . ',' . I('post.s_county', ''); + $save['address'][] = I('post.s_address', ''); + $save['address'] = json_encode($save['address']); + $save['email'] = I('post.email', ''); + $save['account_type'] = intval(I('post.account_type', 1)); + $save['bank_name'] = I('post.bank_name', ''); + $save['bank_account'] = I('post.bank_account', ''); + $save['bank_card'] = I('post.bank_card', ''); + if (isset($_POST['businesspic'])) { + $save['businesspic'] = I('post.businesspic', ''); + } + if (isset($_POST['agreementpic'])) { + $save['agreementpic'] = I('post.agreementpic', ''); + } + if (isset($_POST['anothpic'])) { + $save['anothpic'] = I('post.anothpic', ''); + } + + $result = D('promote')->save($save); + if ($result === false) { + $this->error('操作失败'); + } else { + $this->success('操作成功'); + } + } else { + $promoteId = intval(I('id', 0)); + if ($promoteId <= 0) { + $this->error('参数错误'); + } + + $promote = D('promote')->where(array('id' => $promoteId))->find(); + $promote['idcarpic_array'] = $promote['idcarpic'] ? explode(',', $promote['idcarpic']) : []; + $promote['businesspic_array'] = $promote['businesspic'] ? explode(',', $promote['businesspic']) : []; + $promote['agreementpic_array'] = $promote['agreementpic'] ? explode(',', $promote['agreementpic']) : []; + $promote['anothpic_array'] = $promote['anothpic'] ? explode(',', $promote['anothpic']) : []; + $promote['address'] = json_decode($promote['address'], true); + if (!empty($promote['address'])) { + foreach ($promote['address'] as &$address) { + $address = explode(',', $address); + } + } + + $this->assign('records', $promote); + $this->assign('meta_title', '资质认证'); + $this->display(); + } + } } diff --git a/Application/Admin/Controller/PublicController.class.php b/Application/Admin/Controller/PublicController.class.php index 7daf4f29a..7b210c0f2 100644 --- a/Application/Admin/Controller/PublicController.class.php +++ b/Application/Admin/Controller/PublicController.class.php @@ -346,7 +346,7 @@ class PublicController extends \Think\Controller public function telsafecode($phone = '', $delay = 10, $flag = true) { $taskClient = new TaskClient(); - $result = $taskClient->sendSmsCode($phone, get_client_ip()); + $result = $taskClient->sendSms($phone, get_client_ip()); $data = []; if ($result['code'] == TaskClient::SUCCESS) { $data['status'] = 1; diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php index a28fb5f2e..259fccaa8 100644 --- a/Application/Admin/Controller/QueryController.class.php +++ b/Application/Admin/Controller/QueryController.class.php @@ -1007,6 +1007,7 @@ class QueryController extends ThinkController { $page = I('p', 1); $row = I('row', 10); + $reviewTypeList = WithdrawModel::$reviewTypeList; $map['_string'] = '1=1'; $adminid = C('USER_ADMINISTRATOR');//获取超管id $adminmobile = M('UcenterMember')->field('mobile')->find($adminid); @@ -1023,6 +1024,9 @@ class QueryController extends ThinkController if (isset($_REQUEST['settlement_type'])) { $map['settlement_type'] = $_REQUEST['settlement_type']; } + if (isset($_REQUEST['review_type'])) { + $map['review_type'] = $_REQUEST['review_type']; + } if (isset($_REQUEST['promote_account'])) { if ($_REQUEST['promote_account'] == '全部') { unset($_REQUEST['promote_account']); @@ -1052,7 +1056,7 @@ class QueryController extends ThinkController } } - $fields = 'id, widthdraw_number, sum_money, promote_id, promote_account, op_id, op_type, last_op_id, last_op_type, settlement_type, settlement_begin_time, settlement_end_time, create_time, status, respond, audit_time'; + $fields = 'id, widthdraw_number, sum_money, promote_id, promote_account, op_id, op_type, last_op_id, last_op_type, settlement_type, settlement_begin_time, settlement_end_time, create_time, status, respond, audit_time, review_type'; $count = 0; if (I('export', 0) == 1) { $records = D('withdraw')->field($fields) @@ -1093,6 +1097,7 @@ class QueryController extends ThinkController 'last_op_id_text' => $this->getOpTypeText($record['last_op_type'], $record['last_op_id']), 'op_type_text' => getPromoteWithdrawOpType($record['op_type']), 'last_op_type_text' => getPromoteWithdrawOpType($record['last_op_type']), + 'review_type_text' => $reviewTypeList[$record['review_type']] ?? '未知', 'settlement_type_text' => getPromoteWithdrawSettlementType($record['settlement_type']), 'settlement_begin_time' => $record['settlement_begin_time'] ? date('Y-m-d H:i:s', $record['settlement_begin_time']) : '--', 'settlement_end_time' => date('Y-m-d H:i:s', $record['settlement_end_time']), @@ -1118,6 +1123,7 @@ class QueryController extends ThinkController 'op_type_text' => '操作人类型', 'last_op_id_text' => '最后操作人', 'last_op_type_text' => '最后操作人类型', + 'review_type_text' => '审核模式', 'settlement_type_text' => '提现模式', 'settlement_begin_time' => '结算开始时间', 'settlement_end_time' => '结算截止时间', @@ -1153,6 +1159,7 @@ class QueryController extends ThinkController setPowerPromoteIds($map); $companys = getPromoteCompanys(); $this->assign('companys', $companys); + $this->assign('reviewTypeList', $reviewTypeList); $this->assign('is_admin', is_administrator()); $this->assign('list_data', $datas); $this->display(); @@ -1194,11 +1201,10 @@ class QueryController extends ThinkController $this->ajaxReturn(['msg' => $msg]); } - public function set_withdraw_status() + public function set_withdraw_status($status = 1) { $withdraw = M('withdraw', "tab_"); $ids = I('ids', 0); - $status = 1; if (empty($ids)) { $this->error('参数异常'); } @@ -1207,14 +1213,21 @@ class QueryController extends ThinkController } else { $map['id'] = $ids; } - $map['status'] = 0; + switch ($status) { + case 1: + $map['status'] = 0; + break; + case 2: + $map['status'] = 1; + break; + } $save['audit_time'] = time(); $save['status'] = $status; $res = $withdraw->where($map)->save($save); - if ($res === false) { - $this->error('审核失败'); + if ($res) { + $this->success('操作成功', U('withdraw')); } else { - $this->success('审核成功', U('withdraw')); + $this->error('操作失败'); } } @@ -1764,7 +1777,7 @@ class QueryController extends ThinkController $records = []; if (!empty($promotes)) { foreach ($promotes as $promote) { - $promote['company_name'] = $companyList[$promote['company_id']] ?? '未知'; + $promote['company_name'] = ($companyList[$promote['company_id']] ? $companyList[$promote['company_id']] : ($promote['company_id'] == 0 ? '万盟天下科技' : '未知')); if ($promote['auto_review_withdraw_status'] == 0) { $className = 'auto-closed'; $text = '关闭'; diff --git a/Application/Admin/Controller/StatementController.class.php b/Application/Admin/Controller/StatementController.class.php index ba9fb63f8..d4a5a1f95 100644 --- a/Application/Admin/Controller/StatementController.class.php +++ b/Application/Admin/Controller/StatementController.class.php @@ -18,8 +18,14 @@ class StatementController extends ThinkController $first_party_info = json_decode($dbres['first_party_info'],true); $second_party_info = json_decode($dbres['second_party_info'],true); $statement_info = json_decode($dbres['statement_info'],true); - $fine = array_pop($statement_info); + if($dbres['company_name'] == $first_party_info['partner']){ + $first_partner_type=0; + }else{ + $first_partner_type=1; + } + // $fine = array_pop($statement_info); $senddata = array( + "first_partner_type"=>$first_partner_type, "first_part_company"=>$first_party_info['partner'], "second_part_company"=>$second_party_info['partner'], "statement_type"=>$_REQUEST['pay_type'] == 0 ? 1 :0, @@ -27,13 +33,13 @@ class StatementController extends ThinkController "second_party_info"=>$second_party_info, "statement_info"=>$statement_info, "statement_count"=>array("sum_money"=>$dbres['statement_money'],"pay_amount"=>$dbres['pay_amount']), - "fine"=>$fine['sum_money'], + "fine"=>0, "statement_begin_time"=>date("Y-m-d",$dbres['statement_begin_time']), "statement_end_time"=>date("Y-m-d",$dbres['statement_end_time']) ); $this->assign("data",$senddata); if($_REQUEST['pay_type'] == 0){ - $this->assign("company",$dbres['company_name']); + $this->assign("company",$second_party_info['partner']); }else{ $this->assign("company",$first_party_info['partner']); } @@ -56,15 +62,20 @@ class StatementController extends ThinkController $this->ajaxReturn(array("error"=>"database error","code"=>2000)); } } + public function getCompanyList() + { + $data = array(); + $data['ptCompany']= M("CompanyInfo","tab_")->field('id,partner')->select(); + $data['cpCompany']= getPartner(); + $this->ajaxReturn(array("success"=>$data,"code"=>2000)); + } //获取推广公司基础信息 public function getCpCompanyInfo() { $CompanyId = $_REQUEST['company_id']; - if($CompanyId == 0){ - $mycompany = M("tool","tab_")->field("config")->where("name='company_info'")->find(); - $info = json_decode($mycompany['config'],true); - $info['id'] = 0; - unset($info['status']); + $company_type = $_REQUEST['company_type']; + if($company_type == 'pt'){ + $info = M("CompanyInfo","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where("id = '{$CompanyId}'")->find(); }else{ $info = M("partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where("id = '{$CompanyId}'")->find(); } @@ -81,7 +92,8 @@ class StatementController extends ThinkController $map["pay_status"] = 1; $CompanyId = $_REQUEST['company_id']; //对账公司id - $statement_type = $_REQUEST['statement_type']; + $statement_type = $_REQUEST['statement_type'];//付款方 + $first_partner_type = $_REQUEST['first_partner_type'];//甲方类型:0cp,1pt $is_month = false;//是否是月结判断,非月结无需梯度计算 if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { @@ -164,8 +176,14 @@ class StatementController extends ThinkController // $redio = $ratiores[0]['ratio']; // } $redio = getGameCpRadio($v['game_id'],$v['pay_amount'],$is_month);//获取分成比例 - $v['second_ratio'] = $redio; - $v['first_ratio'] = (100-$redio); + if($first_partner_type==0){ + //甲方cp + $v['first_ratio'] = round($redio,2); + $v['second_ratio'] = round((100-$redio),2); + }else{ + $v['second_ratio'] = round($redio,2); + $v['first_ratio'] = round((100-$redio),2); + } if($statement_type == 0){ $v['sum_money'] = round($v['pay_amount']*$v['first_ratio']/100,2); }else{ @@ -180,6 +198,62 @@ class StatementController extends ThinkController $v['statement_end_time']=$_REQUEST['time_end']; $v['statement_type']=0; } + //获取奖罚 + $rrmap = array( + "reward_time" => ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]], + "company_type"=>1, + "company_id"=>$CompanyId + ); + $rfres = M("RewardRecord","tab_") + ->field(" + IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count, + IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count + ") + ->where($rrmap)->find(); + if($statement_type == 0 ){ + //乙->甲 甲方cp + if($first_partner_type==0){ + $reward_count = $rfres['reward_count']-0; + $fine_count = 0-$rfres['fine_count']; + }else{ + $reward_count = 0-$rfres['reward_count']; + $fine_count = $rfres['fine_count']-0; + } + }else{ + if($first_partner_type==0){ + $reward_count = 0-$rfres['reward_count']-0; + $fine_count = $rfres['fine_count']-0; + }else{ + $reward_count = $rfres['reward_count']-0; + $fine_count = 0-$rfres['fine_count']; + } + } + + if($rfres['reward_count'] > 0){ + $list[] = array( + "statement_begin_time"=>$_REQUEST['time_start'], + "statement_end_time"=>$_REQUEST['time_end'], + 'statement_type'=>2, + "game_name"=>"奖励", + 'pay_amount'=>$reward_count, + 'sum_money'=>$reward_count, + ); + $countarr['pay_amount'] +=$reward_count; + $countarr['sum_money']+=$reward_count; + } + if($rfres['fine_count'] > 0){ + $list[] = array( + "statement_begin_time"=>$_REQUEST['time_start'], + "statement_end_time"=>$_REQUEST['time_end'], + 'statement_type'=>1, + "game_name"=>"罚款", + 'pay_amount'=>$fine_count, + 'sum_money'=>$fine_count, + ); + $countarr['pay_amount'] += $fine_count; + $countarr['sum_money'] += $fine_count; + } + $countarr['pay_amount'] = round($countarr['pay_amount'],2); $countarr['sum_money'] = round($countarr['sum_money'],2); @@ -188,19 +262,26 @@ class StatementController extends ThinkController } //添加数据 public function doAddCpStatement($id = 0){ + $first_partner_type = $_REQUEST['first_partner_type']; + if($first_partner_type == 0){ + //甲方cp + $company = $_REQUEST['first_party_info']; + }else{ + $company =$_REQUEST['second_party_info']; + } $second_party_info = $_REQUEST['second_party_info']; $statement_info = $_REQUEST['statement_info']; - $statement_info[] = array( - "sum_money"=>$_REQUEST['fine'], - "type_name"=>"罚款", - "statement_type"=>1 - ); + // $statement_info[] = array( + // "sum_money"=>$_REQUEST['fine'], + // "type_name"=>"罚款", + // "statement_type"=>1 + // ); //拼凑数据 $adddata = array( "statement_type"=>0, - "company_id"=>$second_party_info['id'], - "company_name"=>$second_party_info['partner'], - "link_phone"=>$second_party_info['link_phone'], + "company_id"=>$company['id'], + "company_name"=>$company['partner'], + "link_phone"=>$company['link_phone'], "statement_begin_time"=>strtotime($_REQUEST['statement_begin_time']), "statement_end_time"=>strtotime($_REQUEST['statement_end_time']), 'create_time'=>time(), diff --git a/Application/Admin/Controller/StatementMangementController.class.php b/Application/Admin/Controller/StatementMangementController.class.php index 86f9e9afb..6532fb38c 100644 --- a/Application/Admin/Controller/StatementMangementController.class.php +++ b/Application/Admin/Controller/StatementMangementController.class.php @@ -233,6 +233,18 @@ class StatementMangementController extends ThinkController public function rewardManageList($row = 10, $p = 1) { $map = []; + if (!empty(I("game_name"))) { + $game_ids = array_column(getGameByName(I("game_name")), 'id'); + if ($game_ids) { + $map['relation_game_id'] = ['in', $game_ids]; + } + } + if (!empty(I('partner_id'))) { + $map['company_id'] = I('partner_id'); + } + if (!empty(I('account'))) { + $map['accounts'] = ['like', '%' . I('account') . '%']; + } $list = M('reward_record', 'tab_')->where($map)->page($p, $row)->select(); if ($list) { $companys[1] = array_column(M('partner', 'tab_')->field('id, partner as name')->select(), 'name', 'id'); @@ -313,6 +325,9 @@ class StatementMangementController extends ThinkController $data['accounts'] = json_decode($data['accounts'], true) ?: []; $this->assign('data', $data); } + } else { + $data['reward_time'] = strtotime(date('Y-m-01')); + $this->assign('data', $data); } $this->display(); } @@ -331,4 +346,103 @@ class StatementMangementController extends ThinkController return $this->success($data, '', true); } + public function PersonOrderList() { + + $map = []; + + $data = M('withdraw','tab_') + ->field("tab_withdraw.id,pc.company_name,pc.id as cid,tab_withdraw.promote_id,tab_withdraw.promote_account,username,'个人' as type,game_ratio + ,mobile_phone,real_name,tab_promote.bank_card,account_openin,tab_promote.address,bank_account") + ->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id') + ->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field") + ->join("left join tab_promote on tab_promote.id=tab_promote_belong.promote_id") + ->join("left join tab_promote_company as pc on pc.id = tab_promote.company_id") + ->join("left join sys_ucenter_member on sys_ucenter_member.id=tab_promote.admin_id") + ->where("ext_field is null and tab_promote_belong.company_type=2") + ->where($map) + ->select(); + + $gameStr = []; + $game_ratio = []; + foreach($data as $dkey => &$dval) { + + $dval['game_ratio'] = json_decode($dval['game_ratio'],true); + + if (is_array($dval['game_ratio'])) { + foreach ($dval['game_ratio'] as $key => &$value) { + + foreach ($value as $k => &$v) { + +// $v['game_id'] = $key; + + $v['game_name'] = substr(get_gamename($key),0,strpos(get_gamename($key), '(')); + + if (!in_array($v['game_name'],$gameStr)) { + array_push($gameStr,$v['game_name']); + + } else { +// var_dump($key); + if (!$game_ratio[$v['game_name']]) { + $game_ratio[$v['game_name']] = $v; + } + else { + $game_ratio[$v['game_name']]['sum_amount'] += $v['sum_amount']; + } + unset($value[$k]); + } +// + } + if (!$value) { + unset($dval['game_ratio'][$key]); + } + + } + + + foreach ($dval['game_ratio'] as $key => $val) { + + $startTime = strtotime($val[0]['begin_time']); + $endTime = strtotime($val[0]['end_time']); + + $rewardData = M('reward_record','tab_') + ->field("sum(tab_reward_record.money) as money,reward_type,relation_game_name") + ->join("left join (select * from tab_game group by relation_game_id)tab_game on tab_reward_record.relation_game_id=tab_game.relation_game_id") + ->where(['company_type'=>2,'relation_game_name'=>['like',"%{$val[0]['game_name']}%"],'reward_time'=>['between',[$startTime,$endTime]]]) + ->group('reward_type') + ->select(); + + foreach ($rewardData as $rk => $rv) { + + if ($rv['reward_type'] == 1) { + $val[0]['reward'] = $rv['money']; + } else { + $val[0]['forfeit'] = $rv['money']; + } + + } + + + foreach ($val as $k => &$v) { + + if ($game_ratio[$v['game_name']]) { + + $v['sum_amount'] = number_format($v['sum_amount'] + $game_ratio[$v['game_name']]['sum_amount'],2,'.',''); + + } + } + unset($dval['game_ratio'][$key]); + array_push($dval['game_ratio'],$val[0]); + + } + + } + } + + + dump($data); + + $this->display(); + + } + } diff --git a/Application/Admin/Controller/ToolController.class.php b/Application/Admin/Controller/ToolController.class.php index 056c6c1ec..37968f32b 100644 --- a/Application/Admin/Controller/ToolController.class.php +++ b/Application/Admin/Controller/ToolController.class.php @@ -28,6 +28,13 @@ class ToolController extends ThinkController { $map_['name']=array("in",'wei_xin,wei_xin_app,weixin'); M('tool','tab_')->where($map_)->setField('status','0'); } + if (!is_numeric($config['channel_rate'])) { + $this->error('请输入正确的渠道费率'); + } + if ($config['channel_rate'] > 100) { + $this->error('渠道费率最大值为100%'); + } + $config['channel_rate'] = round($config['channel_rate'], 2); $flag = M('Tool','tab_')->where($map)->setField($data); if($flag !== false){ $config['status']=$_POST['status']; diff --git a/Application/Admin/Model/WithdrawModel.class.php b/Application/Admin/Model/WithdrawModel.class.php index 7db178856..75b82fb75 100644 --- a/Application/Admin/Model/WithdrawModel.class.php +++ b/Application/Admin/Model/WithdrawModel.class.php @@ -26,6 +26,10 @@ class WithdrawModel extends Model{ const SETTLEMENT_TYPE_RECOUP = 3; const SETTLEMENT_TYPE_OTHER = 9; + //审核模式 + const REVIEW_TYPE_MANUAL = 1; + const REVIEW_TYPE_AUTO = 2; + /** * 构造函数 * @param string $name 模型名称 @@ -51,6 +55,11 @@ class WithdrawModel extends Model{ self::SETTLEMENT_TYPE_RECOUP => '补点', self::SETTLEMENT_TYPE_OTHER => '其他', ]; + + public static $reviewTypeList = [ + self::REVIEW_TYPE_MANUAL => '人工审核', + self::REVIEW_TYPE_AUTO => '自动审核', + ]; /* * 开发者提现未处理列表 @@ -193,7 +202,13 @@ class WithdrawModel extends Model{ $add['promote_id'] = $promote['id']; $add['promote_account'] = $promote['account']; $add['create_time'] = $thisTime; - $add['status'] = ($promote['auto_review_withdraw_status'] == 1) ? 1 : 0; + if ($promote['auto_review_withdraw_status'] == 1) { + $add['status'] = 1; + $add['review_type'] = 2; + } else { + $add['status'] = 0; + $add['review_type'] = 1; + } $add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber(1); $add['settlement_begin_time'] = $settlementBeginTime; $add['settlement_end_time'] = $settlementEndTime; @@ -329,7 +344,13 @@ class WithdrawModel extends Model{ $add['promote_id'] = $promote['id']; $add['promote_account'] = $promote['account']; $add['create_time'] = $thisTime; - $add['status'] = ($promote['auto_review_withdraw_status'] == 1) ? 1 : 0; + if ($promote['auto_review_withdraw_status'] == 1) { + $add['status'] = 1; + $add['review_type'] = 2; + } else { + $add['status'] = 0; + $add['review_type'] = 1; + } $add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber(2); $add['settlement_begin_time'] = $settlementBeginTime; $add['settlement_end_time'] = $settlementEndTime; @@ -447,7 +468,13 @@ class WithdrawModel extends Model{ $add['promote_id'] = $promote['id']; $add['promote_account'] = $promote['account']; $add['create_time'] = $thisTime; - $add['status'] = ($promote['auto_review_withdraw_status'] == 1) ? 1 : 0; + if ($promote['auto_review_withdraw_status'] == 1) { + $add['status'] = 1; + $add['review_type'] = 2; + } else { + $add['status'] = 0; + $add['review_type'] = 1; + } $add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber(3); $add['settlement_begin_time'] = $settlementBeginTime; $add['settlement_end_time'] = $settlementEndTime; diff --git a/Application/Admin/View/Game/edit.html b/Application/Admin/View/Game/edit.html index 714f470e7..fc6163e8f 100644 --- a/Application/Admin/View/Game/edit.html +++ b/Application/Admin/View/Game/edit.html @@ -44,6 +44,7 @@
  • 参数配置
  • H5分享页面
  • 用户等级设置
  • +
  • 推广配置
  • 编辑游戏【{$data.relation_game_name}】

    说明:查看和编辑游戏的基础信息、下载设置、参数信息等。

    @@ -923,7 +924,92 @@ + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    会长账号添加时间是否已进行推广操作
    aOh! 暂时还没有内容!
    {$data['promoteAccount']}{$data['create_time']}{$data['isPromote']}移除
    该游戏未设置会长权限,现面对所有会长开放!
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    +
    @@ -952,7 +1038,198 @@ + + + + diff --git a/Application/Admin/View/Promote/belong.html b/Application/Admin/View/Promote/belong.html index 20a550f41..7a0db395f 100644 --- a/Application/Admin/View/Promote/belong.html +++ b/Application/Admin/View/Promote/belong.html @@ -81,6 +81,13 @@
    +
    + +
    无 + - - - - - - - 工会关系: - - - + + 工会关系: + + + + + + + + + + + + 工会类型: + + + + + + + + + 充值信息查看权限: diff --git a/Application/Admin/View/Promote/belong_edit.html b/Application/Admin/View/Promote/belong_edit.html index f39d3750a..ee3b035c9 100644 --- a/Application/Admin/View/Promote/belong_edit.html +++ b/Application/Admin/View/Promote/belong_edit.html @@ -64,7 +64,12 @@ 工会归属: - + + + @@ -84,6 +94,11 @@ 工会关系: +
    @@ -110,6 +111,14 @@ +
    + +
    搜索 @@ -138,6 +147,7 @@ 操作人类型 最后操作人 最后操作人类型 + 审核模式 提现模式 结算开始时间 结算截止时间 @@ -160,11 +170,11 @@ - + - + - + {$data.widthdraw_number} {$data.sum_money} @@ -174,6 +184,7 @@ {$data.op_type_text} {$data.last_op_id_text} {$data.last_op_type_text} + {$data.review_type_text} {$data.settlement_type_text} {$data.settlement_begin_time} {$data.settlement_end_time} @@ -187,7 +198,7 @@ 通过 驳回 - 上传汇款证明 + 确认汇款
    diff --git a/Application/Admin/View/Statement/createCpStatement.html b/Application/Admin/View/Statement/createCpStatement.html index 07efd2329..56e1016d4 100644 --- a/Application/Admin/View/Statement/createCpStatement.html +++ b/Application/Admin/View/Statement/createCpStatement.html @@ -89,16 +89,24 @@
    + + + + @@ -107,25 +115,25 @@ @@ -135,16 +143,16 @@
    公司类型: +
    + +
    +
    甲方:
    联系人: - +
    联系电话: - +
    邮寄地址: - +
    公司税号: - +
    + + + + @@ -381,26 +389,26 @@ - diff --git a/Application/Admin/View/StatementMangement/rewardManageSave.html b/Application/Admin/View/StatementMangement/rewardManageSave.html index 08332f1bf..7c86ec66b 100644 --- a/Application/Admin/View/StatementMangement/rewardManageSave.html +++ b/Application/Admin/View/StatementMangement/rewardManageSave.html @@ -62,7 +62,7 @@ charset="UTF-8"> + class="form-horizontal form_info_ml" id="form">
    奖惩编辑
    @@ -171,18 +174,29 @@ $(document).on('click', '.bnt_remove', function(){ $(this).parents('li').remove(); }); - - // $('#reward_time').datetimepicker({ - // format: 'yyyy-mm-dd', - // language: "zh-CN", - // minView: 2, - // autoclose: true - // }); - $('#reward_time').datetimepicker({ - language:"zh-CN", - hour: 13, - minute: 15 + var date = new Date(); + var monthStart = date.getFullYear()+'-0'+(date.getMonth()+1)+'-01'; + $("#reward_time").datetimepicker({ + format : "yyyy-mm-dd hh:ii", + autoclose : true, + todayBtn : true, + todayHighlight : true, + startDate : monthStart, + language : 'zh-CN', + startView : 2,//月视图 + showMeridian : true, + pickerPosition : "bottom-left", + minuteStep : 5 }); + + /* $('#reward_time').datetimepicker({ + language:"zh-CN", + hour: 13, + minute: 15, + setStartDate:'2020-02-01', + todayHighlight : true, + todayBtn:true + });*/ var company_id = '{$data["company_id"]}'; function companyTypeChange() { diff --git a/Application/Admin/View/Tool/payset.html b/Application/Admin/View/Tool/payset.html index 6ce600f37..52a7ee57a 100644 --- a/Application/Admin/View/Tool/payset.html +++ b/Application/Admin/View/Tool/payset.html @@ -216,7 +216,6 @@ - @@ -237,7 +236,19 @@ - + + + + + + + @@ -329,8 +340,19 @@ - + + + + + + + @@ -423,7 +445,19 @@ - + + + + + + + @@ -690,7 +724,19 @@ + + + + + + @@ -809,7 +855,19 @@ - + + + + + + + @@ -927,7 +985,19 @@ - + + + + + + + @@ -1078,7 +1148,19 @@ - + + + + + + + @@ -1275,7 +1357,19 @@ + + + + + +
    乙方:
    启用状态
    渠道费率 + + + + % + +
    渠道费率 + + + % + +
    渠道费率 + + + + % + +
    渠道费率 + + + + % + +
    渠道费率 + + + + % + +
    渠道费率 + + + + % + +
    渠道费率 + + + + % + +
    渠道费率 + + + + % + +
    @@ -1365,7 +1459,19 @@ + + 渠道费率 + + + + + + % + + + + diff --git a/Application/Admin/View/VerifyBill/company_show.html b/Application/Admin/View/VerifyBill/company_show.html index 995ba6c54..cafdcf067 100644 --- a/Application/Admin/View/VerifyBill/company_show.html +++ b/Application/Admin/View/VerifyBill/company_show.html @@ -104,7 +104,7 @@ - + - diff --git a/Application/Admin/View/VerifyBill/partner_show.html b/Application/Admin/View/VerifyBill/partner_show.html index 688ac0c83..c19d3007c 100644 --- a/Application/Admin/View/VerifyBill/partner_show.html +++ b/Application/Admin/View/VerifyBill/partner_show.html @@ -101,7 +101,7 @@ - + - @@ -113,6 +113,7 @@ - {$item.sum_money}元 + diff --git a/Application/Base/Repository/PromoteRepository.class.php b/Application/Base/Repository/PromoteRepository.class.php index 518d2cc5e..253b2b392 100644 --- a/Application/Base/Repository/PromoteRepository.class.php +++ b/Application/Base/Repository/PromoteRepository.class.php @@ -45,7 +45,10 @@ class PromoteRepository { if (isset($params['sdk_version'])) { $map['sdk_version'] = $params['sdk_version']; } - if (isset($params['begin_time']) && isset($params['begin_time']) && isset($params['time_column'])) { + if (isset($params['role_level'])) { + $map['role_level'] = $params['role_level']; + } + if (isset($params['begin_time']) && isset($params['end_time']) && isset($params['time_column'])) { $map[$params['time_column']] = ['between', [$params['begin_time'], $params['end_time']]]; } if (isset($params['lock_status'])) { diff --git a/Application/Base/Service/ApplyService.class.php b/Application/Base/Service/ApplyService.class.php index 5590f5924..fc5fb7926 100644 --- a/Application/Base/Service/ApplyService.class.php +++ b/Application/Base/Service/ApplyService.class.php @@ -197,4 +197,30 @@ class ApplyService { parse_str($items['query'], $params); return $params; } + + public function checkSociatyPerm($promote, $game) + { + if ($game['apply_auth'] == 1) { + return true; + } + $promoteService = new PromoteService(); + $topPromote = $promoteService->getTopPromote($promote); + $record = M('sociaty_games', 'tab_')->where(['game_id' => $game['id'], 'promote_id' => $topPromote['id']])->find(); + if ($record['status'] == 1) { + return true; + } else { + return false; + } + } + + public function getSociatyGameIds($promote) + { + $promoteService = new PromoteService(); + $topPromote = $promoteService->getTopPromote($promote); + $tempIds = M('sociaty_games', 'tab_')->where(['promote_id' => $topPromote['id']])->getField('game_id', true); + $tempIds = $tempIds ?? []; + $ids = M('game', 'tab_')->where(['apply_auth' => 1])->getField('id', true); + $ids = $ids ?? []; + return array_merge($tempIds, $ids); + } } \ No newline at end of file diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index d473d7d5c..28fbfc621 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -1212,4 +1212,78 @@ function gameSearch($relationGameId, $sdkVersion) $gameIds = $gameIds ?? [-1]; return $gameIds; +} + +function convertAmountToCn($num) { + //判断$num是否存在 + if(!$num) return '零圆'; + //保留小数点后两位 + $num = round($num, 2); + //将浮点转换为整数 + $tem_num = $num * 100; + //判断数字长度 + $tem_num_len = strlen($tem_num); + if($tem_num_len > 14) { + return '数值过大'; + } + + //大写数字 + $dint = array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'); + //大写金额单位 + $danwei = array('仟', '佰', '拾', '亿', '仟', '佰', '拾', '万', '仟', '佰', '拾', '圆'); + $danwei1 = array('角', '分'); + + //空的变量用来保存转换字符串 + $daxie = ''; + + //分割数字,区分圆角分 + list($left_num, $right_num) = explode('.', $num); + + //计算单位长度 + $danwei_len = count($danwei); + //计算分割后的字符串长度 + $left_num_len = strlen($left_num); + $right_num_len = strlen($right_num); + + //循环计算亿万元等 + for($i = 0; $i < $left_num_len; $i++) { + //循环单个文字 + $key_ = substr($left_num, $i, 1); + + //判断数字不等于0或数字等于0与金额单位为亿、万、圆,就返回完整单位的字符串 + if($key_ !== '0' || ($key_ == '0' && ($danwei[$danwei_len - $left_num_len + $i] == '亿' || $danwei[$danwei_len - $left_num_len + $i] == '万' || $danwei[$danwei_len - $left_num_len + $i] == '圆'))) { + $daxie = $daxie . $dint[$key_] . $danwei[$danwei_len - $left_num_len + $i]; + } else { + //否则就不含单位 + $daxie = $daxie . $dint[$key_]; + } + } + + //循环计算角分 + for($i = 0; $i < $right_num_len; $i++) { + $key_ = substr($right_num, $i, 1); + if($key_ > 0) { + $daxie = $daxie . $dint[$key_] . $danwei1[$i]; + } + } + + //计算转换后的长度 + $daxie_len = strlen($daxie); + //设置文字切片从0开始,utf-8汉字占3个字符 + $j = 0; + while($daxie_len > 0) { + //每次切片两个汉字 + $str = substr($daxie, $j, 6); + //判断切片后的文字不等于零万、零圆、零亿、零零 + if($str == '零万' || $str == '零圆' || $str == '零亿' || $str == '零零') { + //重新切片 + $left = substr($daxie, 0, $j); + $right = substr($daxie, $j + 3); + $daxie = $left . $right; + } + $j += 3; + $daxie_len -= 3; + } + + return $daxie . '整'; } \ No newline at end of file diff --git a/Application/Home/Controller/ApplyController.class.php b/Application/Home/Controller/ApplyController.class.php index 60ded3316..a50f68bb1 100644 --- a/Application/Home/Controller/ApplyController.class.php +++ b/Application/Home/Controller/ApplyController.class.php @@ -66,11 +66,11 @@ class ApplyController extends BaseController { $loginPromote = $this->getLoginPromote(); - $promoteId = empty(I('promote_id')) ? $loginPromote['id'] : I('promote_id');//搜索的渠道ID - $promoteRole = empty(I('promote_role')) ? 1 : I('promote_role');//渠道角色 - $parentPromoteId = getParentPromoteId($promoteId);//上级渠道ID - $grandPromoteId = getGrandPromoteId($promoteId);//本账号会长渠道ID - $childGameAddPermission = getChildGameAddPermission($grandPromoteId);//游戏添加权限 + $promoteId = empty(I('promote_id')) ? $loginPromote['id'] : I('promote_id'); //搜索的渠道ID + $promoteRole = empty(I('promote_role')) ? 1 : I('promote_role'); //渠道角色 + $parentPromoteId = getParentPromoteId($promoteId); //上级渠道ID + $grandPromoteId = getGrandPromoteId($promoteId); //本账号会长渠道ID + $childGameAddPermission = getChildGameAddPermission($grandPromoteId); //游戏添加权限 $map['tab_game.online_status'] = 1;//开发者游戏上线状态 $map['tab_game.down_port'] = 1;//游戏端口 第三方接口不能申请 @@ -92,6 +92,10 @@ class ApplyController extends BaseController $map['tab_game.sdk_version'] = $type; + $applyService = new ApplyService(); + $tempIds = $applyService->getSociatyGameIds($loginPromote); + $gameIdList = array_intersect($gameIdList, $tempIds); + if (count($gameIdList) > 0) { $gameIds = implode(',', $gameIdList); @@ -115,9 +119,12 @@ class ApplyController extends BaseController } else { $gameIdList = M('Game', 'tab_')->group('relation_game_id')->having('count(id) = 2')->getField('id', true); + $applyService = new ApplyService(); + $tempIds = $applyService->getSociatyGameIds($loginPromote); + $gameIdList = array_intersect($gameIdList, $tempIds); + if (count($gameIdList) > 0) { $gameIds = implode(',', $gameIdList); - $map['tab_game.id'] = ['in', $gameIds]; } else { $map = '1 = 2'; diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 9dc5af389..4ad6dfd11 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -1304,7 +1304,7 @@ class DownloadController extends BaseController { empty(I('user_account')) || $map['tab_spend.user_account'] = ['like', '%' . I('user_account') . '%']; empty(I('pay_order_number')) || $map['tab_spend.pay_order_number'] = I('pay_order_number'); // $map['tab_spend.pay_status'] = 1; - $map['tab_spend.is_check'] = ['neq', 2]; + // $map['tab_spend.is_check'] = ['neq', 2]; if (isset($_REQUEST['pay_status']) && $_REQUEST['pay_status'] !== '') { $payStatus = intval(I('pay_status')); @@ -1446,6 +1446,183 @@ class DownloadController extends BaseController { $this->success('添加下载成功',U('listsIndex')); } + + /*推广员指标查看详情 */ + + public function quotaDtl_data_export() { + $nowTime = date('Y-m-d', time()); + $defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime; + $time = I('time', $defaultTime); + $relationGameId = I('relation_game_id', 0); + $sdkVersion = I('sdk_version', 0); + $serverId = I('server_id', 0); + $roleLevelBegin = intval(I('level_begin', 0)); + $roleLevelEnd = intval(I('level_end', 0)); + $promoteId = I('promote_id', 0); + $isSelf = I('is_self', 0); + + if ($relationGameId != 0 || $sdkVersion != 0) { + $gameIds = gameSearch($relationGameId, $sdkVersion); + $map['game_id'] = ['in', $gameIds]; + } + if ($serverId != 0) { + $map['server_id'] = $serverId; + } + 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]]; + } + list($beginTime, $endTime) = $this->getBetweenTime($time); + $map['create_time'] = ['between', [$beginTime, $endTime]]; + + if ($promoteId) { + if ($isSelf) { + $map['promote_id'] = $promoteId; + } else { + $promote = M('promote', 'tab_')->field(['id', 'chain'])->where(array('id' => $promoteId))->find(); + $promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"]; + $promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promoteId; + $map['promote_id'] = ['in', $promoteIds]; + } + } else { + $map = '1 = 2'; + } + + // $data = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select(); + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data1 = [ + 'logid' => 'quotadtl_'.time(), + 'promote_id' => PID, + 'type' => '/Home/Query/promoteQuota', + 'dataname' => '推广员详情', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' =>$conditions + ]; + $res = M('downloadlog','tab_')->add($data1); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功',U('listsIndex')); + } + + /*推广指标首页导出*/ + public function promoteQuota_data_export() { + $nowTime = date('Y-m-d', time()); + $defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime; + $time = I('time', $defaultTime); + if (!empty($time)) { + $defaultTime = $time; + } + $sdkVersion = I('sdk_version', 0); + $relationGameId = I('relation_game_id', 0); + $serverId = I('server_id', 0); + $parentId = I('parent_id', 0); + $promoteId = I('promote_id', 0); + $levelBegin = I('level_begin', ''); + $levelEnd = I('level_end', ''); + $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', 'chain']) + ->where(['chain' => ['like', [$parent['chain'] . $parent['id'] . '/%']], 'level' => ['gt', $parent['level'] + 1]]) + ->select(); + } + $basicPromotes = []; + foreach ($ids as $id) { + foreach ($rows as $row) { + $needChain = $parent['chain'] . $parent['id'] . '/' . $id . '/'; + if (strpos($row['chain'], $needChain) !== false) { + $basicPromotes[$row['id']] = $id; + } + } + } + $map = [ + 'isContainSubs' => true, + 'basicPromotes' => json_encode($basicPromotes,FALSE), + ]; + $map['promotes'] = json_encode($data,FALSE); + $map['parentsinfo'] = json_encode($parent,FALSE);; + $map['currentDisplay'] = $currentDisplay; + $map['ids'] = $ids; + if ($relationGameId != 0 || $sdkVersion != 0) { + $gameIds = gameSearch($relationGameId, $sdkVersion); + $map['game_id'] = ['in', $gameIds]; + } + if ($serverId > 0) { + $map['server_id'] = $serverId; + } + $where = $map; + if ($sdkVersion != 0) { + $map['sdk_version'] = $sdkVersion; + } + if ($levelBegin !== '' || $levelEnd !== '') { + if ($levelBegin !== '' && $levelEnd !== '') { + $levelBegin = intval($levelBegin); + $levelEnd = intval($levelEnd); + if ($levelBegin > $levelEnd) { + $this->error('角色等级范围错误'); + } + $map['role_level'] = ['between', [$levelBegin, $levelEnd]]; + } elseif ($levelBegin !== '' && $levelEnd === '') { + $levelBegin = intval($levelBegin); + $map['role_level'] = ['egt', $levelBegin]; + } elseif ($levelBegin === '' && $levelEnd !== '') { + $levelEnd = intval($levelEnd); + $map['role_level'] = ['elt', $levelEnd]; + } + } + list($beginTime, $endTime) = $this->getBetweenTime($time); + $map['begin_time'] = $beginTime; + $map['end_time'] = $endTime; + $conditions = json_encode($map,TRUE); + $addtime = time(); + $data1 = [ + 'logid' => 'quota_'.time(), + 'promote_id' => PID, + 'type' => '/Home/Query/promoteQuota', + '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 achievement_data_export() { $time = I('time', date('Y-m-d')); @@ -1863,15 +2040,142 @@ class DownloadController extends BaseController { case "平台币充值": $this->orderlistExcelInfo($id,$map); break; - case "玩家行为日志"; + case "玩家行为日志": $this->playactionExcelInfo($id,$map); break; + case "推广员指标": + $this->promotequotaExcelInfo($id,$map); + break; + case "推广员详情": + $this->promotequotaDtlExcelInfo($id,$map); + break; default: break; } } + public function promotequotaDtlExcelInfo($id,$map) { + $xlsName = "推广员详情"; + $xlsCell = array( + array('user_account','玩家账号'), + array('promote_account','推广账号'), + array('game_name','游戏名称'), + array('sdk_version','平台'), + array('server_name','游戏区服'), + array('role_name','角色名'), + array('role_level','等级'), + array('create_time','创建时间'), + ); + $records = M('user_play_info', 'tab_')->where($map)->order('create_time desc')->select(); + foreach ($records as $key => $value) { + //订单隐藏算法 + $orderLen = strlen($value['user_account']); + $strLen = 3; + $hideChar = ''; + + if ($orderLen <= 8) { $strLen = 2;} + for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { + $hideChar .= '*'; + } + + $records[$key]['user_account'] = substr($value['user_account'], 0, $strLen) . $hideChar . substr($value['user_account'], $orderLen - $strLen); + } + $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 promotequotaExcelInfo($tid,$map) { + $xlsName = "推广员指标"; + $xlsCell = array( + array('account','账号'), + array('real_name','姓名'), + array('game_name','游戏名称'), + array('sdk_version_text','平台'), + array('server_name','游戏区服'), + array('role_num','角色数量'), + ); + $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['role_level'])) { + $params['role_level'] = $map['role_level']; + unset($map['role_level']); + } + if(!empty($map['parentsinfo'])) { + $parent = json_decode($map['parentsinfo'],TRUE); + unset($map['parentsinfo']); + } + // if(!empty($map['currentDisplay'])) { + // $currentDisplay = $map['currentDisplay']; + // unset($map['currentDisplay']); + // } + $params['begin_time'] = $map['begin_time']; + $params['end_time'] = $map['end_time']; + //var_dump($params); + $records = []; + $promoteRepository = new PromoteRepository(); + $createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params); + $selfParams = $params; + $selfParams['isContainSubs'] = false; + $selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams); + $game = $this->getgame($map); + $record = [ + 'id' => $parent['id'], + 'account' => $parent['account'], + 'real_name' => mb_strlen($parent['real_name'],'utf-8') == 2 ? mb_substr($parent['real_name'],0,1,'utf-8').'*':mb_substr($parent['real_name'],0,1,'utf-8').'**', + 'level' => $parent['level'], + 'game_name' => $game['game_name'], + 'sdk_version_text' => $game['sdk_version_text'], + 'server_name' => $game['server_name'], + 'role_num' => $selfCreateRoleCountList[$parent['id']], + 'current_display' => $currentDisplay, + ]; + $records[] = $record; + foreach ($promotes as $promote) { + $id = $promote['id']; + $record = [ + 'id' => $id, + 'account' => $promote['account'], + 'real_name' => mb_strlen($promote['real_name'],'utf-8') == 2 ? mb_substr($promote['real_name'],0,1,'utf-8').'*':mb_substr($promote['real_name'],0,1,'utf-8').'**', + 'level' => $promote['level'], + 'game_name' => $game['game_name'], + 'sdk_version_text' => $game['sdk_version_text'], + 'server_name' => $game['server_name'], + 'role_num' => $createRoleCountList[$id], + 'current_display' => '', + ]; + $records[] = $record; + } + $xlsData = []; + foreach ($records as $key1 => $value1) { + $value1['account'] = $this->encryption($value1['account']); + $xlsData[] = $value1; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData,$tid); + } + public function playactionExcelInfo($id,$map) { $xlsName = "玩家行为日志"; $xlsCell = array( @@ -3716,6 +4020,55 @@ class DownloadController extends BaseController { return substr($string, 0, $strLen) . $hideChar . substr($string, $orderLen-$strLen); } + + private function getGame($map = []) + { + $gameName = '全部游戏'; + $sdkVersionText = getSDKTypeName(0, true); + $serverName = '--'; + if (isset($map['game_id']) || isset($map['sdk_version'])) { + $where = []; + if (!isset($map['game_id'])) { + $sdkVersionText = getSDKTypeName($map['sdk_version'], true); + } elseif (!isset($map['sdk_version'])) { + $where['id'] = $map['game_id']; + $gameName = M('game', 'tab_')->where($where)->getField('relation_game_name'); + if (isset($map['server_id'])) { + $serverName = $this->getServerName($map['game_id'], 0, $map['server_id']); + } + } else { + $where['id'] = $map['game_id']; + $where['sdk_version'] = $map['sdk_version']; + $gameName = M('game', 'tab_')->where($where)->getField('game_name'); + $sdkVersionText = getSDKTypeName($map['sdk_version'], true); + if (isset($map['server_id'])) { + $serverName = $this->getServerName($map['game_id'], $map['sdk_version'], $map['server_id']); + } + } + } + + $game = [ + 'game_name' => $gameName, + 'sdk_version_text' => $sdkVersionText, + 'server_name' => $serverName, + ]; + return $game; + } + + private function getServerName($gameIds, $serverVersion, $serverId) + { + $map['_string'] = '1 = 1'; + if ($gameIds) { + $map['game_id'] = $gameIds; + } + if ($serverVersion) { + $map['server_version'] = $serverVersion; + } + if ($serverId) { + $map['server_id'] = $serverId; + } + return M('server', 'tab_')->where($map)->getField('server_name'); + } } diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php index 8ecbce4d2..1587d16b5 100644 --- a/Application/Home/Controller/FinanceController.class.php +++ b/Application/Home/Controller/FinanceController.class.php @@ -119,7 +119,8 @@ class FinanceController extends BaseController $income = $model->field("sum(if(pay_time < $thisDay, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as history_income, sum(if(pay_time >= $thisMonth, if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as this_month_income, sum(if((pay_time >= $yesterday and pay_time < $thisDay), if(selle_ratio > 0, pay_amount * selle_ratio, 0), 0)) as yesterday_income, - sum(if(pay_time < $thisDay, if(selle_status = 0, pay_amount * selle_ratio, 0), 0)) as balance") + sum(if(pay_time < $thisDay, if(selle_status = 0, pay_amount * selle_ratio, 0), 0)) as balance, + sum(if(selle_status = 0, pay_amount, 0)) as not_withdrawn_amount") ->where($map) ->find(); @@ -127,10 +128,41 @@ class FinanceController extends BaseController $value = bcdiv($value, 100, 2); } + $withdrawMap['promote_id'] = $this->loginPromote['id']; + $withdrawMap['status'] = ['neq', 2]; + + //已提现总额 + $income['withdrawn_amount'] = M('withdraw', 'tab_')->field('sum(sum_money) as withdrawn_amount')->where($withdrawMap)->find()['withdrawn_amount']; + + $withdrawns = M('withdraw', 'tab_')->field('settlement_begin_time, settlement_end_time') + ->where($withdrawMap) + ->select(); + + $days = []; + if (!empty($withdrawns)) { + foreach ($withdrawns as $withdrawn) { + $thisDays = []; + if (empty($withdrawn['settlement_begin_time'])) { + if ($begTime < $withdrawn['settlement_end_time']) { + if ($endTime <= $withdrawn['settlement_end_time']) { + $thisEndTime = $endTime; + } else { + $thisEndTime = $withdrawn['settlement_end_time']; + } + $thisDays = $this->getDayList($begTime, $thisEndTime); + } + } else { + $thisDays = $this->getDayList($withdrawn['settlement_begin_time'], $withdrawn['settlement_end_time']); + } + $days = array_merge($days, $thisDays); + } + } + $days = array_unique($days); + $map['pay_time'] = ['between', [$begTime, $endTime]]; $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') + sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as income, selle_status') ->where($map) ->group('day') ->select(); @@ -140,13 +172,16 @@ class FinanceController extends BaseController $records[] = [ 'day' => $date, 'income' => bcdiv($data[$day], 100, 2), + 'selle_status_text' => (in_array($day, $days) ? '已提现' : '未提现'), 'url' => U('settlementDtl', array('begtime' => $day, 'endtime' => $day)) ]; } } + $settlementCycle = ($this->loginPromote['settlement_type'] == 1 ? '周结' : '月结'); $this->assign('income', $income); $this->assign('listData', $records); + $this->assign('settlementCycle', $settlementCycle); $this->assign('initBegTime', $initBegTime); $this->assign('initEndTime', $initEndTime); $this->assign('yesterday', date('Y-m-d', $yesterday)); @@ -625,45 +660,25 @@ class FinanceController extends BaseController $this->error('参数异常'); } - $settlementBeginTime = $withdraw['settlement_begin_time']; - $settlementEndTime = $withdraw['settlement_end_time']; - $withdraw['create_time'] = date('Y-m-d H:i:s', $withdraw['create_time']); - $withdraw['settlement_end_time'] = date('Y-m-d H:i:s', $withdraw['settlement_end_time']); - $withdraw['status'] = FinanceController::$withdrawStatus[$withdraw['status']]; - - if (empty($withdraw['game_ratio'])) { - $map['_string'] = '1 = 2'; - } else { - $gameRatios = json_decode($withdraw['game_ratio'], true); - $gameIds = array_keys($gameRatios); - $map['game_id'] = ['in', $gameIds]; - $map['pay_time'] = ['between', [$settlementBeginTime, $settlementEndTime]]; - } - if ($withdraw['settlement_type'] != 3) { - $map['withdraw_id'] = $withdrawId; - } - - $data = M('spend', 'tab_') - ->field('game_id,game_name,if(selle_ratio >= 0,selle_ratio,0) as selle_ratio,pay_way,sum(pay_amount) as pay_amount_all,sum(if(selle_ratio > 0,pay_amount * selle_ratio,0)) as income') - ->where($map) - ->group('game_id') - ->order('game_id') - ->select(); - if (!empty($data)) { - foreach ($data as &$list) { - $list['income'] = '0.00'; - if (isset($gameRatios[$list['game_id']])) { - foreach ($gameRatios[$list['game_id']] as $gameIncome) { - $income = bcdiv(bcmul($gameIncome['sum_amount'], $gameIncome['selle_ratio'], 2), 100, 2); - $list['income'] = bcadd($list['income'], $income, 2); - } - } - } - } - - $this->assign('withdraw', $withdraw); - $this->assign('listData', $data); - $this->assign('promoteData', $this->loginPromote); + $statementMap['ext_field'] = $withdraw['widthdraw_number']; + $statementMap['statement_type'] = 1; + $statement = M('statement', 'tab_')->where($statementMap)->find(); + if (empty($statement)) { + $this->error('未生成下游结算单'); + } + + $statement['first_party_info'] = json_decode($statement['first_party_info'], 1);//甲方 + $statement['second_party_info'] = json_decode($statement['second_party_info'], 1);//乙方 + $statement['statement_info'] = json_decode($statement['statement_info'], 1);//结算记录 + //收款方 + $statement['receive_company'] = ($statement['pay_type'] ? $statement['first_party_info']['partner'] : $statement['second_party_info']['partner']); + $all_sum_money = array_sum(array_column($statement['statement_info'], 'sum_money'));//合计平台总额 + $all_pay_amount = array_sum(array_column($statement['statement_info'], 'pay_amount'));//合计结算金额 + $big_all_sum_money = convertAmountToCn($statement['statement_money']);//大写 + $this->assign('big_all_sum_money', $big_all_sum_money); + $this->assign('all_sum_money', $all_sum_money); + $this->assign('all_pay_amount', $all_pay_amount); + $this->assign('data', $statement); $this->assign('meta_title', $metaTitle); $this->assign('modelList', $modelList); $this->display(); diff --git a/Application/Home/Controller/HomeController.class.php b/Application/Home/Controller/HomeController.class.php index eea52d404..4dd36a07b 100644 --- a/Application/Home/Controller/HomeController.class.php +++ b/Application/Home/Controller/HomeController.class.php @@ -154,8 +154,8 @@ class HomeController extends Controller $this->error('该链接已被禁'); } + $applyService = new ApplyService(); if ($code != '') { - $applyService = new ApplyService(); $data = $applyService->decodeApplyCode($code); $result = $applyService->checkApplyCode($data, ApplyService::ENCRYPT_TYPE_LANDING_PAGE); if (!$result['status']) { @@ -173,6 +173,7 @@ class HomeController extends Controller $columns = [ 'id', 'sdk_version', + 'apply_auth', 'icon', 'screenshot', 'relation_game_id', @@ -193,6 +194,11 @@ class HomeController extends Controller $map = ['id' => intval($gameId)]; $game = M('game', 'tab_')->field($columns)->where($map)->find(); + $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); + if (!$applyService->checkSociatyPerm($promote, $game)) { + $this->error('该链接已经停止使用'); + } + if ($game['sdk_version'] == 1 && $isIOS) { $map = []; $map['relation_game_id'] = $game['relation_game_id']; @@ -207,6 +213,9 @@ class HomeController extends Controller $apply = M('apply', 'tab_')->field(['game_id', 'enable_status', 'promote_id']) ->where(['promote_id' => $promoteId, 'game_id' => $game['id']]) ->find(); + if (!$apply) { + $this->error('该链接已经停止使用'); + } $game['icon'] = get_cover($game['icon'], 'path'); $gameSource = M('GameSource', 'tab_')->field(['create_time', 'org_plist_url', 'is_new_sdk'])->where(array('game_id' => $game['id']))->find(); diff --git a/Application/Home/Controller/PackageController.class.php b/Application/Home/Controller/PackageController.class.php index f881c67a7..b7c4160a5 100644 --- a/Application/Home/Controller/PackageController.class.php +++ b/Application/Home/Controller/PackageController.class.php @@ -40,8 +40,9 @@ class PackageController extends Controller if ($isBlack) { $this->redirect("package/downloadError", ['message' => '该链接已被禁']); } + + $applyService = new ApplyService(); if ($code != '') { - $applyService = new ApplyService(); $data = $applyService->decodeApplyCode($code); $result = $applyService->checkApplyCode($data, ApplyService::ENCRYPT_TYPE_DOWNLOAD); if (!$result['status']) { @@ -59,7 +60,16 @@ class PackageController extends Controller $map['promote_id'] = $promoteId; $columns = ['game_id', 'promote_id', 'promote_account', 'pack_url', 'plist_url', 'status', 'enable_status']; $apply = M('apply','tab_')->field($columns)->where($map)->find(); - $game = M('game','tab_')->field(['id', 'game_name', 'sdk_version'])->where(['id' => $apply['game_id']])->find(); + if (!$apply) { + $this->redirect("package/downloadError", ['message' => '该链接已经停止使用']); + } + + $promote = M('promote', 'tab_')->field(['id', 'parent_id', 'chain', 'level'])->where(['id' => $promoteId])->find(); + $game = M('game','tab_')->field(['id', 'game_name', 'sdk_version', 'apply_auth'])->where(['id' => $apply['game_id']])->find(); + if (!$applyService->checkSociatyPerm($promote, $game)) { + $this->redirect("package/downloadError", ['message' => '该链接已经停止使用']); + } + if (Request::isMobile()) { if (!Request::isAndroid() && $game['sdk_version'] == 1) { diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index aa5387634..f38b1595d 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -100,7 +100,6 @@ class QueryController extends BaseController } } $map['tab_spend.pay_time'] = ['between', [$begTime, $endTime - 1]]; - $map['tab_spend.is_check'] = ['neq', 2]; $data = []; $count = 0; @@ -2210,4 +2209,272 @@ class QueryController extends BaseController $this->ajaxReturn($data); } + + //推广员指标管理 + public function promoteQuota() + { + $nowTime = date('Y-m-d', time()); + $defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime; + $time = I('time', $defaultTime); + if (!empty($time)) { + $defaultTime = $time; + } + $sdkVersion = I('sdk_version', 0); + $relationGameId = I('relation_game_id', 0); + $serverId = I('server_id', 0); + $parentId = I('parent_id', 0); + $promoteId = I('promote_id', 0); + $levelBegin = I('level_begin', ''); + $levelEnd = I('level_end', ''); + $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 = '自己'; + } + $searchLevel = $parent['level'] + 1; + $searchLevelName = $promoteService->getLevelName($searchLevel); + + $games = get_promote_serach_game(); + + $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $parent['id']])->select(); + + $map = ['parent_id' => $parent['id']]; + if ($promoteId > 0) { + $map['id'] = $promoteId; + } + + $query = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level'])->where($map); + list($promotes, $pagination, $count) = $this->paginate($query); + $ids = array_column($promotes, 'id'); + + $rows = []; + if (count($ids) > 0) { + $rows = M('promote', 'tab_') + ->field(['id', 'chain']) + ->where(['chain' => ['like', [$parent['chain'] . $parent['id'] . '/%']], 'level' => ['gt', $parent['level'] + 1]]) + ->select(); + } + + $basicPromotes = []; + foreach ($ids as $id) { + foreach ($rows as $row) { + $needChain = $parent['chain'] . $parent['id'] . '/' . $id . '/'; + if (strpos($row['chain'], $needChain) !== false) { + $basicPromotes[$row['id']] = $id; + } + } + } + $params = [ + 'isContainSubs' => true, + 'basicPromotes' => $basicPromotes, + ]; + if ($relationGameId != 0 || $sdkVersion != 0) { + $gameIds = gameSearch($relationGameId, $sdkVersion); + $params['game_id'] = ['in', $gameIds]; + } + if ($serverId > 0) { + $params['server_id'] = $serverId; + } + $where = $params; + if ($sdkVersion != 0) { + $where['sdk_version'] = $sdkVersion; + } + $game = $this->getGame($where); + + if ($levelBegin !== '' || $levelEnd !== '') { + if ($levelBegin !== '' && $levelEnd !== '') { + $levelBegin = intval($levelBegin); + $levelEnd = intval($levelEnd); + if ($levelBegin > $levelEnd) { + $this->error('角色等级范围错误'); + } + $params['role_level'] = ['between', [$levelBegin, $levelEnd]]; + } elseif ($levelBegin !== '' && $levelEnd === '') { + $levelBegin = intval($levelBegin); + $params['role_level'] = ['egt', $levelBegin]; + } elseif ($levelBegin === '' && $levelEnd !== '') { + $levelEnd = intval($levelEnd); + $params['role_level'] = ['elt', $levelEnd]; + } + } + list($beginTime, $endTime) = $this->getBetweenTime($time); + $params['begin_time'] = $beginTime; + $params['end_time'] = $endTime; + + $records = []; + $promoteRepository = new PromoteRepository(); + $createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params); + + if (I('p', 1) == 1) { + $selfParams = $params; + $selfParams['isContainSubs'] = false; + $selfCreateRoleCountList = $promoteRepository->getCreateRoleCountByIds([$parent['id']], $selfParams); + $record = [ + 'id' => $parent['id'], + 'account' => $parent['account'], + 'real_name' => mb_strlen($parent['real_name'],'utf-8') == 2 ? mb_substr($parent['real_name'],0,1,'utf-8').'*':mb_substr($parent['real_name'],0,1,'utf-8').'**', + 'level' => $parent['level'], + 'game_name' => $game['game_name'], + 'sdk_version_text' => $game['sdk_version_text'], + 'server_name' => $game['server_name'], + 'role_num' => $selfCreateRoleCountList[$parent['id']], + 'current_display' => $currentDisplay, + ]; + $records[] = $record; + } + foreach ($promotes as $promote) { + $id = $promote['id']; + $record = [ + 'id' => $id, + 'account' => $promote['account'], + 'real_name' => mb_strlen($promote['real_name'],'utf-8') == 2 ? mb_substr($promote['real_name'],0,1,'utf-8').'*':mb_substr($promote['real_name'],0,1,'utf-8').'**', + 'level' => $promote['level'], + 'game_name' => $game['game_name'], + 'sdk_version_text' => $game['sdk_version_text'], + 'server_name' => $game['server_name'], + 'role_num' => $createRoleCountList[$id], + 'current_display' => '', + ]; + $records[] = $record; + } + + $this->assign('prevParentId', $prevParentId); + $this->assign('searchLevelName', $searchLevelName); + $this->assign('games', $games); + $this->assign('parent', $parent); + $this->assign('subPromotes', $subPromotes); + $this->assign('records', $records); + $this->assign('pagination', $pagination); + $this->assign('parentId', $parentId); + $this->assign('count', $count); + $this->assign('time', $defaultTime); + $this->assign('meta_title', '推广员指标'); + $this->display(); + } + + public function quotaDtl() + { + $nowTime = date('Y-m-d', time()); + $defaultTime = date('Y-m-d', strtotime('-6 day', time())) . " 至 " . $nowTime; + $time = I('time', $defaultTime); + $relationGameId = I('relation_game_id', 0); + $sdkVersion = I('sdk_version', 0); + $serverId = I('server_id', 0); + $roleLevelBegin = intval(I('level_begin', 0)); + $roleLevelEnd = intval(I('level_end', 0)); + $promoteId = I('promote_id', 0); + $isSelf = I('is_self', 0); + + if ($relationGameId != 0 || $sdkVersion != 0) { + $gameIds = gameSearch($relationGameId, $sdkVersion); + $map['game_id'] = ['in', $gameIds]; + } + if ($serverId != 0) { + $map['server_id'] = $serverId; + } + 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]]; + } + list($beginTime, $endTime) = $this->getBetweenTime($time); + $map['create_time'] = ['between', [$beginTime, $endTime]]; + if ($promoteId) { + if ($isSelf) { + $map['promote_id'] = $promoteId; + } else { + $promote = M('promote', 'tab_')->field(['id', 'chain'])->where(array('id' => $promoteId))->find(); + $promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"]; + $promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promoteId; + $map['promote_id'] = ['in', $promoteIds]; + } + } else { + $map = '1 = 2'; + } + + $query = M('user_play_info', 'tab_')->where($map)->order('create_time desc'); + list($records, $pagination, $count) = $this->paginate($query); + foreach ($records as $key => $value) { + //订单隐藏算法 + $orderLen = strlen($value['user_account']); + $strLen = 3; + $hideChar = ''; + + if ($orderLen <= 8) { + $strLen = 2; + } + + for ($i = 0; $i < $orderLen - $strLen * 2; $i++) { + $hideChar .= '*'; + } + + $records[$key]['user_account'] = substr($value['user_account'], 0, $strLen) . $hideChar . substr($value['user_account'], $orderLen - $strLen); + } + + $this->assign('records', $records); + $this->assign('pagination', $pagination); + $this->assign('count', $count); + $this->display(); + } + + private function getGame($map = []) + { + $gameName = '全部游戏'; + $sdkVersionText = getSDKTypeName(0, true); + $serverName = '--'; + if (isset($map['game_id']) || isset($map['sdk_version'])) { + $where = []; + if (!isset($map['game_id'])) { + $sdkVersionText = getSDKTypeName($map['sdk_version'], true); + } elseif (!isset($map['sdk_version'])) { + $where['id'] = $map['game_id']; + $gameName = M('game', 'tab_')->where($where)->getField('relation_game_name'); + if (isset($map['server_id'])) { + $serverName = $this->getServerName($map['game_id'], 0, $map['server_id']); + } + } else { + $where['id'] = $map['game_id']; + $where['sdk_version'] = $map['sdk_version']; + $gameName = M('game', 'tab_')->where($where)->getField('game_name'); + $sdkVersionText = getSDKTypeName($map['sdk_version'], true); + if (isset($map['server_id'])) { + $serverName = $this->getServerName($map['game_id'], $map['sdk_version'], $map['server_id']); + } + } + } + + $game = [ + 'game_name' => $gameName, + 'sdk_version_text' => $sdkVersionText, + 'server_name' => $serverName, + ]; + return $game; + } + + private function getServerName($gameIds, $serverVersion, $serverId) + { + $map['_string'] = '1 = 1'; + if ($gameIds) { + $map['game_id'] = $gameIds; + } + if ($serverVersion) { + $map['server_version'] = $serverVersion; + } + if ($serverId) { + $map['server_id'] = $serverId; + } + return M('server', 'tab_')->where($map)->getField('server_name'); + } } diff --git a/Application/Home/View/default/Finance/index.html b/Application/Home/View/default/Finance/index.html index 39dc54177..63f96312b 100644 --- a/Application/Home/View/default/Finance/index.html +++ b/Application/Home/View/default/Finance/index.html @@ -33,6 +33,11 @@
  • 昨日收益

    ¥{$income.yesterday_income}
  • 账户余额

    ¥{$income.balance}
  • +
      +
    • 已提现总金额

      ¥{$income.withdrawn_amount}
    • +
    • 未提现金额

      ¥{$income.not_withdrawn_amount}
    • +
    • 结算周期

      {$settlementCycle}
    • +
    @@ -61,6 +66,7 @@ 时间 收益 + 提现状态 操作 @@ -70,6 +76,7 @@ {$data.day} {$data.income} + {$data.selle_status_text} 明细 diff --git a/Application/Home/View/default/Finance/settlementOrder.html b/Application/Home/View/default/Finance/settlementOrder.html index 0f57aa709..44a5c81df 100644 --- a/Application/Home/View/default/Finance/settlementOrder.html +++ b/Application/Home/View/default/Finance/settlementOrder.html @@ -52,80 +52,68 @@
    @@ -136,19 +124,20 @@
    - +
    - - - - - - - - - + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    游戏名称流水现金分成基数平台币分成基数绑定币分成基数合作方分成金额结算时间产品平台总额补点比例分成比例税费费率结算金额(元)
    @@ -156,36 +145,73 @@
    {$vo.game_name}{$vo.pay_amount_all}{$vo.pay_amount_all}0{$vo.pay_amount_all}0{$vo.pay_amount_all}0{$vo.income}
    -{$item.type_name}{$item.sum_money}--{$item.sum_money}
    {$item.statement_begin_time}-{$item.statement_end_time}{$item.game_name}{$item.pay_amount}{$item.second_ratio}%{$item.fax_ratio}%{$item.sum_money}
    总计-{$data.pay_amount}0--{$data.statement_money}0
    本月分成总金额(人民币大写):----{$big_all_sum_money}
    +
    + +
    +
    diff --git a/Application/Home/View/default/Finance/withdrawRecord.html b/Application/Home/View/default/Finance/withdrawRecord.html index b033492d5..75bd0c642 100644 --- a/Application/Home/View/default/Finance/withdrawRecord.html +++ b/Application/Home/View/default/Finance/withdrawRecord.html @@ -197,7 +197,7 @@ 提现明细 - 汇款证明 + diff --git a/Application/Home/View/default/GameDivide/index.html b/Application/Home/View/default/GameDivide/index.html index 3542f4717..8a45d0f72 100644 --- a/Application/Home/View/default/GameDivide/index.html +++ b/Application/Home/View/default/GameDivide/index.html @@ -192,7 +192,6 @@ 游戏类型 平台 混服情况 - 玩家折扣 分成比例 @@ -210,7 +209,6 @@ {$vo.game_type_name} {:getSDKTypeName($vo['sdk_version'])} - {$vo.ratio}% diff --git a/Application/Home/View/default/Public/promote_base.html b/Application/Home/View/default/Public/promote_base.html index 4233edb55..1c44f3efa 100644 --- a/Application/Home/View/default/Public/promote_base.html +++ b/Application/Home/View/default/Public/promote_base.html @@ -72,6 +72,7 @@ 充值玩家 团队/推广员业绩 + 推广员指标 diff --git a/Application/Home/View/default/Query/promoteQuota.html b/Application/Home/View/default/Query/promoteQuota.html new file mode 100644 index 000000000..f98ada7c1 --- /dev/null +++ b/Application/Home/View/default/Query/promoteQuota.html @@ -0,0 +1,189 @@ + + + + + + +
    +
    +
    +
    当前位置:数据管理>{$meta_title}
    +
    + + {$meta_title} +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + +
    推广员游戏名称平台游戏区服角色数量操作

    暂无数据

    {$record.account}({$record.real_name}) + + [{$record['current_display']}] + + {$record.game_name}{$record.sdk_version_text}{$record.server_name}{$record.role_num} + + 查看下级 + + + 查看详情 + + 查看详情 + +
    + +
    +
    + + 导出 + + {$pagination} +
    +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/Application/Home/View/default/Query/quotaDtl.html b/Application/Home/View/default/Query/quotaDtl.html new file mode 100644 index 000000000..3182ec4e7 --- /dev/null +++ b/Application/Home/View/default/Query/quotaDtl.html @@ -0,0 +1,100 @@ + + + + + + + +
    +
    + 返回 +
    +
    +
    +
    当前位置:数据管理>推广员指标>查看详情
    +
    + + 查看详情 +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    玩家帐号推广账号游戏名称平台游戏区服角色名等级创建时间

    暂无数据

    {$record.user_account}{$record.promote_account}{$record.game_name}{:getSDKTypeName($record['sdk_version'])}{$record.server_name}{$record.role_name}{$record.role_level} + + {$record.play_time|date='Y-m-d H:i:s',###} + + {$record.create_time|date='Y-m-d H:i:s',###} + +
    + +
    +
    + + 导出 + + {$pagination} +
    +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/Data/update.sql b/Data/update.sql index 22f32d69e..6c14c5713 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1074,6 +1074,22 @@ CREATE TABLE `sys_document_pop_rules` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; +--会长设置推广配置-- + +CREATE TABLE `tab_sociaty_games` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `promote_id` int(11) NOT NULL COMMENT '会长ID', + `game_id` int(11) NOT NULL COMMENT '游戏ID', + `status` tinyint(1) NOT null DEFAULT '0' COMMENT '状态 0 禁用 1 启用', + `create_time` int(10) NOT NULL DEFAULT '0' COMMENT '创建时间', + `update_time` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT '工会授权游戏'; + +--游戏会长申请权限-- +ALTER TABLE `tab_game` + ADD COLUMN `apply_auth` INT(11) NULL DEFAULT '1' COMMENT '申请权限(1为全部可申请2为部分会长可申请)' AFTER `game_detail_cover`; + -- 2020-01-14 -- cxj ALTER TABLE `tab_promote_game_ratio` @@ -1114,7 +1130,7 @@ ADD COLUMN `auto_review_withdraw_updated_time` int(10) NOT NULL DEFAULT 0 COMMEN ALTER TABLE `tab_promote` ADD INDEX `auto_review_withdraw_status`(`auto_review_withdraw_status`) USING BTREE; --- 奖罚记录 +-- 2020-02-10 yulingwei 奖罚记录 CREATE TABLE `tab_reward_record` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `reward_type` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '奖罚类型 1奖励 2惩罚', @@ -1148,6 +1164,8 @@ CREATE TABLE `tab_company_info` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COMMENT='内部公司信息'; + +-- 2020-02-10 liaojinling 会长押金 CREATE TABLE `tab_president_deposit` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', `promote_id` varchar(60) NOT NULL COMMENT '会长ID', @@ -1165,3 +1183,12 @@ CREATE TABLE `tab_president_deposit` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='会长押金'; +-- 2020-02-10 yulingwei 推广工会管理 新增属性类型 +ALTER TABLE `tab_promote_belong` +MODIFY COLUMN `company_belong` tinyint(1) UNSIGNED NOT NULL DEFAULT 3 COMMENT '工会归属:0-内团;1-外团 2-分发联盟 3 无' AFTER `verify_status`, +MODIFY COLUMN `company_relation` tinyint(1) UNSIGNED NOT NULL DEFAULT 2 COMMENT '工会关系:0-自主开发及维护;1-只维护 2 无' AFTER `company_belong`; +ADD COLUMN `company_type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '工会类型 1公司 2个人' AFTER `can_view_recharge`; + +-- 2020-02-10 cxj 推广提现--新增审核模式 +ALTER TABLE `tab_withdraw` +ADD COLUMN `review_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '审核模式:1-人工审核 2-自动审核';