渠道流水计算

master
sunke 5 years ago
commit 7f169dc211

@ -13,6 +13,21 @@ use Admin\Model\WithdrawModel;
*/
class QueryController extends ThinkController
{
public $pay_way_name = [ //无费率默认平台必 即是费率为0
'-1' => 'bind_pay', //绑币支付
'0' => 'ptb_pay', //平台币支付
'1' => 'alipay', //支付宝
'2' => 'wei_xin',
'3' => 'wei_xin',
'4' => 'weixin',
'5' => 'ptb_pay',
'6' => 'jft', //竣付通
'7' => 'ptb_pay',
'8' => 'ptb_pay',
'9' => 'sqpay', //双乾支付-支付宝
'10' => 'sqpay', //双乾支付-银联
'15' => 'sqpay', //双乾支付-快捷
];
//生成提现单号
public function produceWithdrawNumber()
{
@ -1562,8 +1577,57 @@ class QueryController extends ThinkController
$pagecount = M()->table('('.$count.') as a')->count();
foreach($data as $key => $value) {
$mytime = $value['my_time'];
$nextMonth = date('Y-m',strtotime("$mytime + 1 month"));
$game_id = $value['game_id'];
$gameInfo = M('game','tab_')->where(['id'=>$game_id])->getField('game_name');
$gameName = substr($gameInfo,0,strpos($gameInfo,'('));
$gameMap['game_name'] = ['like','%'.$gameName.'%'];
$gameIdArr = M('game','tab_')->field('id')->where($gameMap)->select();
$gameNameIdArr = [];
foreach($gameIdArr as $gameKey => $gameValue){
$gameNameIdArr[] = $gameValue['id'];
}
$promote_id = $value['promote_id'];
$pay_status = 1;
$promoteInfo = M('promote','tab_')->where(['id'=>$promote_id])->find();
$level = $promoteInfo['level'];
if($promote_id != 0) {
if ($level == 1) {
$rootPromoteId = $promote_id;
$where['promote_id'] = $promote_id;
}else {
$chain = $promoteInfo['chain'];
$chainArr = explode('/',$chain);
$rootPromoteId = $chainArr[1];
$where1['chain'] = array('like', '%/' . $rootPromoteId. '/%');
$promoteIdInfo = M('promote','tab_')->field('id')->where($where1)->select();
$promoteIdArr = [];
foreach($promoteIdInfo as $key2 => $v1) {
$promoteIdArr[] = $v1['id'];
}
$where['promote_id'] = ['in',$promoteIdArr];
}
}else {
$where['promote_id'] = 0;
}
$where['game_id'] = ['in',$gameNameIdArr];
$where['pay_status'] = 1;
$begTime = strtotime($mytime);
$endTime = strtotime($nextMonth);
$where['pay_time'] = ['between',[$begTime,$endTime]];
$spendInfo = M('spend','tab_')->field('pay_amount,pay_way')->where($where)->select();
$initNum = 0;
foreach($spendInfo as $key1 => $spendValue) {
$pay_way = $spendValue['pay_way'];
$channel_rate = $this->getChannelConfig($pay_way) / 100;
$initNum += $spendValue['pay_amount'] * $channel_rate;
}
$data[$key]['pay_amount'] = $value['pay_amount'] - $initNum;
// if ($value['games_ratio']) {
// $data[$key]['upstream'] = $value['pay_amount'] * ($value['games_ratio']*0.01);
// } else {
@ -1802,4 +1866,229 @@ class QueryController extends ThinkController
$this->display('auto_review');
}
}
public function getChannelConfig($pay_way = 0,$config=false) {
if(!$config) {
$payWayName = $this->pay_way_name[$pay_way];
$toolConfig = M('tool','tab_')->where(['name'=>$payWayName])->find();
$config = json_decode($toolConfig['config'],true);
if(empty($config['channel_rate'])){
$channel_rate = 0;
}else {
$channel_rate = $config['channel_rate'];
}
}else {
foreach($this->pay_way_name as $key => $value) {
$name = $value;
$toolConfig = M('tool','tab_')->where(['name'=>$name])->find();
$config = json_decode($toolConfig['config'],true);
if(empty($config['channel_rate'])){
$channel_rate[$key] = 0;
}else {
$channel_rate[$key] = $config['channel_rate'];
}
}
}
return $channel_rate;
}
public function detailList($p = 1) {
$mytime = $_REQUEST['my_time'];
$nextMonth = date('Y-m',strtotime("$mytime + 1 month"));
$game_id = $_REQUEST['game_id'];
$gameInfo = M('game','tab_')->where(['id'=>$game_id])->getField('game_name');
$gameName = substr($gameInfo,0,strpos($gameInfo,'('));
$gameMap['game_name'] = ['like','%'.$gameName.'%'];
$gameIdArr = M('game','tab_')->field('id')->where($gameMap)->select();
$gameNameIdArr = [];
foreach($gameIdArr as $gameKey => $gameValue){
$gameNameIdArr[] = $gameValue['id'];
}
$promote_id = $_REQUEST['promote_id'];
$promoteInfo = M('promote','tab_')->where(['id'=>$promote_id])->find();
$level = $promoteInfo['level'];
if($promote_id != 0) {
if ($level == 1) {
$rootPromoteId = $promote_id;
$map['promote_id'] = $promote_id;
}else {
$chain = $promoteInfo['chain'];
$chainArr = explode('/',$chain);
$rootPromoteId = $chainArr[1];
$where1['chain'] = array('like', '%/' . $rootPromoteId. '/%');
$promoteIdInfo = M('promote','tab_')->field('id')->where($where1)->select();
$promoteIdArr = [];
foreach($promoteIdInfo as $key2 => $v1) {
$promoteIdArr[] = $v1['id'];
}
$map['promote_id'] = ['in',$promoteIdArr];
}
}else {
$map['promote_id'] = 0;
}
$pay_status = 1;
$map['game_id'] = ['in',$gameNameIdArr];
// $map['promote_id'] = ['in',$promoteIdArr];
$map['pay_status'] = 1;
$begTime = strtotime($mytime);
$endTime = strtotime($nextMonth);
$map['pay_time'] = ['between',[$begTime,$endTime]];
$spendInfo = M('spend','tab_')->field('pay_amount,pay_way')->where($map)->select();
$initZfbNum = 0;
$initWxsmNum = 0;
$initWxNum = 0;
$initPlatformCoinNum = 0;
$initBindNum = 0;
$initSqNum = 0;
$initWftNum = 0;
$initJbyNum = 0;
$initJftNum = 0;
$initappleNum = 0;
$initJzNum = 0;
$initSqzfbNum = 0; //双乾支付-支付宝
$initSqylNum = 0; //双乾支付-银联
$initSqkjNum = 0; // 双乾支付-快捷
$initZfbNumTotal = 0;
$initWxsmNumTotal = 0;
$initWxNumTotal = 0;
$initPlatformCoinNumTotal = 0;
$initBindNumTotal = 0;
$initSqNumTotal = 0;
$initWftNumTotal = 0;
$initJbyNumTotal = 0;
$initJftNumTotal = 0;
$initappleNumTotal = 0;
$initJzNumTotal = 0;
$initSqzfbNumTotal = 0; //双乾支付-支付宝
$initSqylNumTotal = 0; //双乾支付-银联
$initSqkjNumTotal = 0; // 双乾支付-快捷
$detailInfoTotal = [];
foreach($spendInfo as $key => $value) {
$pay_way = $value['pay_way'];
$pay_amount = $value['pay_amount'];
$channel_rate = $this->getChannelConfig($pay_way) / 100;
switch($pay_way) {
case -1:
$initBindNumTotal += $pay_amount ; //总流水
$initBindNum += $channel_rate * $pay_amount; //总扣费
$afterBindNum = $initBindNumTotal - $initBindNum;
break;
case 0:
$initPlatformCoinNumTotal += $pay_amount ;
$initPlatformCoinNum += $channel_rate * $pay_amount;
$afterPlatformCoinNum = $initPlatformCoinNumTotal - $initPlatformCoinNum;
break;
case 1:
$initZfbNumTotal += $pay_amount ;
$initZfbNum += $channel_rate * $pay_amount;
$afterZfbNum = $initZfbNumTotal - $initZfbNum;
break;
case 2:
$initWxsmNumTotal += $pay_amount ;
$initWxsmNum += $channel_rate * $pay_amount;
$afterWxsmNum = $initWxsmNumTotal - $initWxsmNum;
break;
case 3:
$initWxNumTotal += $pay_amount ;
$initWxNum += $channel_rate * $pay_amount;
$afterWxNum = $initWxNumTotal - $initWxNum;
break;
case 4:
$initWftNumTotal += $pay_amount ;
$initWftNum += $channel_rate * $pay_amount;
$afterWftNum = $initWftNumTotal - $initWftNum;
break;
case 5:
$initJbyNumTotal += $pay_amount ;
$initJbyNum += $channel_rate * $pay_amount;
$afterJbyNum = $initJbyNumTotal - $initJbyNum;
break;
case 6:
$initJftNumTotal += $pay_amount ;
$initJftNum += $channel_rate * $pay_amount;
$afterJftNum = $initJftNumTotal - $initJftNum;
break;
case 7:
$initappleNumTotal += $pay_amount;
$initappleNum += $channel_rate * $pay_amount;
$afterappleNum = $initappleNumTotal - $initappleNum;
break;
case 8:
$initJzNumTotal += $pay_amount;
$initJzNum += $channel_rate * $pay_amount;
$afterappleNum = $initappleNumTotal - $initappleNum;
break;
case 9:
$initSqzfbNumTotal += $pay_amount;
$initSqzfbNum += $channel_rate * $pay_amount;
$afterSqzfbNum = $initSqzfbNumTotal - $initSqzfbNum;
break;
case 10:
$initSqylNumTotal += $pay_amount;
$initSqylNum += $channel_rate * $pay_amount;
$afterSqylNum = $initSqylNumTotal - $initSqylNum;
break;
case 15:
$initSqkjNumTotal += $pay_amount;
$initSqkjNum += $channel_rate * $pay_amount;
$afterSqkjNum = $initSqkjNumTotal - $initSqkjNum;
break;
default:
break;
}
}
$detailInfoTotal['bindtotal'] = $initBindNumTotal;
$detailInfoTotal['platformcointotal'] = $initPlatformCoinNumTotal;
$detailInfoTotal['zfbtotal'] = $initZfbNumTotal;
$detailInfoTotal['wxsmtotal'] = $initWxsmNumTotal;
$detailInfoTotal['wxtotal'] = $initWxNumTotal;
$detailInfoTotal['wfttotal'] = $initWftNumTotal;
$detailInfoTotal['jbytotal'] = $initJbyNumTotal;
$detailInfoTotal['jfttotal'] = $initJftNumTotal;
$detailInfoTotal['appletotal'] = $initappleNumTotal;
$detailInfoTotal['jztotal'] = $initJzNumTotal;
$detailInfoTotal['sqzfbtotal'] = $initSqzfbNumTotal;
$detailInfoTotal['sqyltotal'] = $initSqylNumTotal;
$detailInfoTotal['sqkjtotal'] = $initSqkjNumTotal;
$detailInfoTotal['bind'] = $initBindNum;
$detailInfoTotal['platformcoin'] = $initPlatformCoinNum;
$detailInfoTotal['zfb'] = $initZfbNum;
$detailInfoTotal['wxsm'] = $initWxsmNum;
$detailInfoTotal['wx'] = $initWxNum;
$detailInfoTotal['wft'] = $initWftNum;
$detailInfoTotal['jby'] = $initJbyNum;
$detailInfoTotal['jft'] = $initJftNum;
$detailInfoTotal['apple'] = $initappleNum;
$detailInfoTotal['jz'] = $initJzNum;
$detailInfoTotal['sqzfb'] = $initSqzfbNum;
$detailInfoTotal['sqyl'] = $initSqylNum;
$detailInfoTotal['sqkj'] = $initSqkjNum;
$detailInfoTotal['afterbind'] = $afterBindNum;
$detailInfoTotal['afterplatformcoin'] = $afterPlatformCoinNum;
$detailInfoTotal['afterzfb'] = $afterZfbNum;
$detailInfoTotal['afterwxsm'] = $afterWxsmNum;
$detailInfoTotal['afterwx'] = $afterWxNum;
$detailInfoTotal['afterwft'] = $afterWftNum;
$detailInfoTotal['afterjby'] = $afterJbyNum;
$detailInfoTotal['afterjft'] = $afterJftNum;
$detailInfoTotal['afterapple'] = $afterappleNum;
$detailInfoTotal['afterjz'] = $afterJzNum;
$detailInfoTotal['aftersqzfb'] = $afterSqzfbNum;
$detailInfoTotal['aftersqyl'] = $afterSqylNum;
$detailInfoTotal['aftersqkj'] = $afterSqkjNum;
$rateCon = $this->getChannelConfig(0,true);
$this->assign('ratecon',$rateCon);
$this->assign('data', $detailInfoTotal);
$this->display();
}
}

@ -0,0 +1,149 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>渠道详情</title>
<link href="http://admin.vlcms.com/Public/icon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/module.css">
<link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all">
</head>
<style>
body {
padding: 0px;
}
</style>
<body>
<div id="main" class="main" style="min-height: 342px;width: 92.5%;">
<!-- 标题栏 -->
<div class="cf">
</div>
<!-- 数据列表 -->
<div class="data_list box_mt">
<div class="">
<table>
<!-- 表头 -->
<thead>
<tr>
<th>支付渠道</th>
<th>渠道费率(%)</th>
<th>总流水</th>
<th>渠道费</th>
<th>扣除渠道费用后流水</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<tr>
<td>绑币</td>
<td>{$ratecon['-1']}</td>
<td>{$data.bindtotal}</td>
<td>{$data.bind}</td>
<td>{$data.afterbind}</td>
</tr>
<tr>
<td>平台币</td>
<td>{$ratecon['0']}</td>
<td>{$data.platformcointotal}</td>
<td>{$data.platformcoin}</td>
<td>{$data.afterplatformcoin}</td>
</tr>
<tr>
<td>支付宝</td>
<td>{$ratecon['1']}</td>
<td>{$data.zfbtotal}</td>
<td>{$data.zfb}</td>
<td>{$data.afterzfb}</td>
</tr>
<tr>
<td>微信(扫码)</td>
<td>{$ratecon['2']}</td>
<td>{$data.wxsmtotal}</td>
<td>{$data.wxsm}</td>
<td>{$data.afterwxsm}</td>
</tr>
<tr>
<td>微信app</td>
<td>{$ratecon['3']}</td>
<td>{$data.wxtotal}</td>
<td>{$data.wx}</td>
<td>{$data.afterwx}</td>
</tr>
<tr>
<td>威富通</td>
<td>{$ratecon['4']}</td>
<td>{$data.wfttotal}</td>
<td>{$data.wft}</td>
<td>{$data.afterwft}</td>
</tr>
<tr>
<td>聚宝云</td>
<td>{$ratecon['5']}</td>
<td>{$data.jbytotal}</td>
<td>{$data.jby}</td>
<td>{$data.afterjby}</td>
</tr>
<tr>
<td>竣付通</td>
<td>{$ratecon['6']}</td>
<td>{$data.jfttotal}</td>
<td>{$data.jft}</td>
<td>{$data.afterjft}</td>
</tr>
<tr>
<td>苹果支付</td>
<td>{$ratecon['7']}</td>
<td>{$data.appletotal}</td>
<td>{$data.apple}</td>
<td>{$data.afterapple}</td>
</tr>
<tr>
<td>金猪支付</td>
<td>{$ratecon['8']}</td>
<td>{$data.jztotal}</td>
<td>{$data.jz}</td>
<td>{$data.afterjz}</td>
</tr>
<tr>
<td>双乾支付-支付宝</td>
<td>{$ratecon['9']}</td>
<td>{$data.sqzfbtotal}</td>
<td>{$data.sqzfb}</td>
<td>{$data.aftersqzfb}</td>
</tr>
<tr>
<td>双乾支付-银联</td>
<td>{$ratecon['10']}</td>
<td>{$data.sqyltotal}</td>
<td>{$data.sqyl}</td>
<td>{$data.aftersqyl}</td>
</tr>
<tr>
<td>双乾支付-快捷</td>
<td>{$ratecon['15']}</td>
<td>{$data.sqkjtotal}</td>
<td>{$data.sqkj}</td>
<td>{$data.aftersqkj}</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- <div class="page">
{$_page}
</div> -->

</div>
</body>
</html>

@ -134,7 +134,7 @@
<th>内外团</th>
<th>归属类型</th>
<th>游戏名称</th>
<th>总流水</th>
<th>扣除渠道费后总流水</th>
<th>上游结算流水</th>
<th>下游结算流水</th>
<th>绩优流水</th>
@ -156,7 +156,7 @@
<td>{$data.company_belong}</td>
<td>{$data.company_relation}</td>
<td>{$data.game_names}</td>
<td><div class="tooltip" onclick="getChannelStream(this,{$data.root_id},'{$data.game_names}','{$data.my_time}','{$_GET[\'device\']}')">{$data.pay_amount}<span class="tooltiptext" style="display: none"><span style="margin-left: -10px"></span></span></div></td>
<td><div class="tooltip" onclick="channel_detail('{$data.my_time}','{$data.game_id}','{$data.promote_id}')">{$data.pay_amount}<span class="tooltiptext" style="display: none"><span style="margin-left: -10px"></span></span></div></td>
<td>{$data.upstream}</td>
<td>{$data.downstream}</td>
<td>{$data.highquality}</td>
@ -250,6 +250,23 @@
</block>
<block name="script">
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/layer/extend/layer.ext.js"></script>
<script>
function channel_detail(my_time,game_id,promote_id) {
console.log(my_time)
console.log(game_id)
console.log(promote_id)
layer.open({
type: 2,
title: "总流水-支付渠道明细",
shadeClose: true,
shade: 0.8,
area: ['70%', '80%'],
content: ['admin.php?s=/Query/detaillist/my_time/'+my_time+'/game_id/' + game_id + '/promote_id/' + promote_id + '', 'no']
});
}
</script>
<script>
<volist name=":I('get.')" id="vo">
Think.setValue('{$key}',"{$vo}");

Loading…
Cancel
Save