推广平台>财务管理--更新

master
chenxiaojun 5 years ago
commit fa3a346096

@ -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 . '整';
}

@ -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();

@ -33,6 +33,11 @@
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>昨日收益</p><span>¥{$income.yesterday_income}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi5.png"/></span></div> <div class="text text5"><p>账户余额</p><span>¥{$income.balance}</span></div> </li>
</ul>
<ul style="margin-top: 10px;">
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi1.png"/></span></div> <div class="text text2"><p>已提现总金额</p><span>¥{$income.withdrawn_amount}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi2.png"/></span></div> <div class="text text1"><p>未提现金额</p><span>¥{$income.not_withdrawn_amount}</span></div> </li>
<li><div class="icon"><span class="placeholder-graphic"><img src="__IMG__/20180207/icon_chongzhi3.png"/></span></div> <div class="text text3"><p>结算周期</p><span>{$settlementCycle}</span></div> </li>
</ul>
</div>
<div style="margin-top: 2.4vh;">
<!-- <button class="withdraw" id="withdraw">提现</button>-->
@ -61,6 +66,7 @@
<tr class="odd">
<th>时间</th>
<th>收益</th>
<th>提现状态</th>
<th>操作</th>
</tr>
<empty name="listData">
@ -70,6 +76,7 @@
<tr>
<td>{$data.day}</td>
<td>{$data.income}</td>
<td>{$data.selle_status_text}</td>
<td><a href="{$data.url}">明细</a></td>
</tr>
</volist>

@ -52,80 +52,68 @@
<div class="trunk-content article">
<div class="trunk-search clearfix" style="display: grid;">
<div class="tab detailed-box">
<label class="detailed-title detailed-label">提现订单号:</label>
<label class="detailed-title detailed-label">乙方:</label>
<div class="detailed-content-box">
<span>{$withdraw.widthdraw_number}</span>
<span>{$data['second_party_info']['partner']}</span>
</div>
<label class="detailed-title detailed-label">申请时间:</label>
<label class="detailed-title detailed-label">户名:</label>
<div class="detailed-content-box">
<span>{$withdraw.create_time}</span>
<span>{$data['second_party_info']['bank_account_name']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">会长账号:</label>
<label class="detailed-title detailed-label">提现单号:</label>
<div class="detailed-content-box">
<span>{$withdraw.promote_account}</span>
<span>{$data['ext_field']}</span>
</div>
<label class="detailed-title detailed-label">结算截止时间:</label>
<label class="detailed-title detailed-label">银行账号:</label>
<div class="detailed-content-box">
<span>{$withdraw.settlement_end_time}</span>
<span>{$data['second_party_info']['bank_account']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">状态:</label>
<label class="detailed-title detailed-label">订单类型:</label>
<div class="detailed-content-box">
<span>{$withdraw.status}</span>
<span>{$data['second_party_info']['settlement_type']}</span>
</div>
<label class="detailed-title detailed-label">收款人:</label>
<label class="detailed-title detailed-label">开户行:</label>
<div class="detailed-content-box">
<span>{$promoteData.bank_account}</span>
<span>{$data['second_party_info']['opening_bank']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">开户行:</label>
<label class="detailed-title detailed-label">联系人:</label>
<div class="detailed-content-box">
<span>{$promoteData.bank_name}</span>
<span>{$data['second_party_info']['link_man']}</span>
</div>
<label class="detailed-title detailed-label">银行账号:</label>
<label class="detailed-title detailed-label">邮寄地址:</label>
<div class="detailed-content-box">
<span>{$promoteData.bank_card}</span>
<span>{$data['second_party_info']['address']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">收益金额:</label>
<label class="detailed-title detailed-label">联系电话:</label>
<div class="detailed-content-box">
<span>
<if condition="$withdraw.status eq -1">
0.00
<else/>
{$withdraw.sum_money}
</if>
</span>
<span>{$data['second_party_info']['link_phone']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">奖惩金额:</label>
<label class="detailed-title detailed-label">开票项目:</label>
<div class="detailed-content-box">
<span>0.00</span>
<span>{$data['second_party_info']['invoice_item']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">实际提现金额:</label>
<label class="detailed-title detailed-label"></label>
<div class="detailed-content-box">
<span>
<if condition="$withdraw.status eq -1">
0.00
<else/>
{$withdraw.sum_money}
</if>
<span style="color: red;">(实际提现金额=收益金额+奖惩金额)</span>
</span>
<span></span>
</div>
<label class="detailed-title detailed-label">发票类型:</label>
<div class="detailed-content-box">
<span>{$data['second_party_info']['invoice_type']}</span>
</div>
</div>
</div>
@ -136,19 +124,20 @@
</div>
<div class="trunk-content article">
<div class="tabcon trunk-list">
<table class="table normal_table">
<table class="table normal_table" style="border: 1px solid #ddd;">
<tr class="odd">
<th>游戏名称</th>
<th>流水</th>
<th>现金分成基数</th>
<!-- <th>现金分成比例</th>-->
<th>平台币分成基数</th>
<!-- <th>平台币分成比例</th>-->
<th>绑定币分成基数</th>
<!-- <th>绑定币分成比例</th>-->
<th>合作方分成金额</th>
<th>结算时间</th>
<th >产品</th>
<th >平台总额</th>
<if condition = "$data.second_party_info.settlement_type eq '补点订单'">
<th >补点比例</th>
<else/>
<th >分成比例</th>
</if>
<th >税费费率</th>
<th >结算金额(元)</th>
</tr>
<if condition="true eq empty($listData) or $withdraw.status eq -1">
<if condition="true eq empty($data)">
<tr class="num2">
<td colspan="99" style="text-align: center;height: 45vh;">
<img src="__IMG__/20180207/icon_wushujv2.png"/>
@ -156,36 +145,73 @@
</td>
</tr>
<else/>
<volist name="listData" id="vo">
<tr class="num2">
<td>{$vo.game_name}</td>
<td>{$vo.pay_amount_all}</td>
<if condition="$vo.pay_way neq -1 and $vo.pay_way neq 0">
<td>{$vo.pay_amount_all}</td>
<else/>
<td>0</td>
</if>
<!-- <td>{$vo.selle_ratio}%</td>-->
<if condition="$vo.pay_way eq 0">
<td>{$vo.pay_amount_all}</td>
<else/>
<td>0</td>
</if>
<!-- <td>{$vo.selle_ratio}%</td>-->
<if condition="$vo.pay_way eq -1">
<td>{$vo.pay_amount_all}</td>
<else/>
<td>0</td>
</if>
<!-- <td>{$vo.selle_ratio}%</td>-->
<td>{$vo.income}</td>
</tr>
<volist name="data.statement_info" id="item">
<if condition="$item.statement_type eq 1">
<tr>
<td >-</td>
<td >{$item.type_name}</td>
<td >{$item.sum_money}</td>
<td >-</td>
<td >-</td>
<td >{$item.sum_money}</td>
</tr>
<else/>
<tr>
<td >{$item.statement_begin_time}-{$item.statement_end_time}</td>
<td >{$item.game_name}</td>
<td >{$item.pay_amount}</td>
<td >{$item.second_ratio}%</td>
<td >{$item.fax_ratio}%</td>
<td >{$item.sum_money}</td>
</tr>
</if>
</volist>
<tr>
<td><span>总计</span></td>
<td><span>-</span></td>
<td ><span><if condition="$data.pay_amount neq ''">{$data.pay_amount}<else/>0</if></span></td>
<td>-</td>
<td>-</td>
<td><if condition="$data.statement_money neq ''">{$data.statement_money}<else/>0</if></td>
</tr>
<tr>
<td><span>本月分成总金额(人民币大写)</span></td>
<td>-</td>
<td >-</td>
<td>-</td>
<td>-</td>
<td><if condition="$big_all_sum_money neq ''">{$big_all_sum_money}<else/></if></td>
</tr>
</if>
</table>
</div>
</div>
<div class="trunk-content article">
<div class="trunk-search clearfix" style="display: grid;">
<div class="tab detailed-box">
<label class="detailed-title detailed-label">甲方:</label>
<div class="detailed-content-box">
<span>{$data['first_party_info']['jfCompany']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">联系人:</label>
<div class="detailed-content-box">
<span>{$data['first_party_info']['jfPerson']}</span>
</div>
</div>
<div class="tab detailed-box">
<label class="detailed-title detailed-label">联系电话:</label>
<div class="detailed-content-box">
<span>{$data['first_party_info']['jfTel']}</span>
</div>
</div>
</div>
</div>
<div class="detailed-br"></div>
</div>
</block>

@ -197,7 +197,7 @@
<td>
<a href="{:U('withdrawDtl', array('id'=>$vo['id']))}">提现明细</a>
<if condition="$vo['status'] eq 2">
<a data-href="{:U('download/Remittancecer',['id'=>$vo['id']])}" class="ajax-get">汇款证明</a>
<!-- <a data-href="{:U('download/Remittancecer',['id'=>$vo['id']])}" class="ajax-get">汇款证明</a>-->
<elseif condition="$vo['status'] eq -1"/>
<!-- <span class="renew-review" data-id="{$vo['id']}" style="color: #0bb20c;cursor: pointer;">重新审核</span>-->
</if>

@ -192,7 +192,6 @@
<th>游戏类型</th>
<th>平台</th>
<th>混服情况</th>
<th>玩家折扣</th>
<th>分成比例</th>
</tr>
<empty name="dataList">
@ -210,7 +209,6 @@
<td>{$vo.game_type_name}</td>
<td>{:getSDKTypeName($vo['sdk_version'])}</td>
<td><?=($vo['server_type']==1)?'专服':'混服'?></td>
<td><?=($vo['discount']==10)?'----':($vo['discount'].'折')?></td>
<td>{$vo.ratio}%</td>
</tr>
</volist>

Loading…
Cancel
Save