新增结算公式

master
chenzhi 4 years ago
parent d06cc0ea10
commit 8d156ffb64

@ -218,7 +218,7 @@ class CompanyStatementPoolController extends ThinkController
//获取基本信息
$infolist = M("company_statement_info","tab_")->field("*,'1' as st")->where("pool_id = '{$id}'")->select();
//获取母单
$pool_info = M("company_statement_pool","tab_")->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type')->where("id={$id}")->find();
$pool_info = M("company_statement_pool","tab_")->field('statement_num,create_lack_ids,verify_status,is_payment,withdraw_type,statement_begin_time,statement_end_time')->where("id={$id}")->find();
if(!empty($pool_info['create_lack_ids'])){
$l_ids = $pool_info['create_lack_ids'];
$lack_info = M("company_lack_statement_info","tab_")->field("*,'0' as st")->where("id in ({$l_ids})")->select();
@ -236,7 +236,7 @@ class CompanyStatementPoolController extends ThinkController
//下游公司
$this->viewPcPool($infolist,$is_export);
}else{
$this->viewPuPool($infolist,$is_export);
$this->viewPuPool($infolist,$is_export,$pool_info);
}
}
@ -466,11 +466,12 @@ class CompanyStatementPoolController extends ThinkController
}
//个人汇总结算查看
public function viewPuPool(&$infolist,$is_export){
public function viewPuPool(&$infolist,$is_export,$pool_info){
$line = 1;
$count = [];
$week_line = 2;
$pool_statement_begin_time = date('Y.m.d', $pool_info['statement_begin_time']);
$pool_statement_end_time = date('Y.m.d', $pool_info['statement_end_time']);
//获取对接人
foreach($infolist as $k=>&$v){
$v['statement_info'] = json_decode($v['statement_info'],true);
@ -484,6 +485,7 @@ class CompanyStatementPoolController extends ThinkController
$v['is_payment'] = 1;
}
}
$is_statement = $v['st'] == 1 ? true :false;
$cline = $line+1;
if($is_export){
$v['statement_money'] = "=ROUND(";
@ -495,17 +497,9 @@ class CompanyStatementPoolController extends ThinkController
foreach($v['statement_info'] as $ke=>&$va){
$va['row'] = count($va['game_list']);
$row += count($va['game_list']);
foreach($va['game_list'] as $key=>&$val){
$line ++;
if($v['withdraw_type'] != 3) {
// if(!$val['ratio']&&!$val['increment_ratio']) {
// if(isset($val['ratio'])){
// $val['increment_ratio'] = 0;
// }else{
// $val['ratio'] = 0;
// }
// }
if (!$val['increment_ratio']) {
$val['increment_ratio'] = 0;
}
@ -513,8 +507,25 @@ class CompanyStatementPoolController extends ThinkController
if (!$val['ratio']) {
$val['ratio'] = 0;
}
//上周数据合计
if($val['statement_begin_time'] == $pool_statement_begin_time && $val['statement_end_time'] == $pool_statement_end_time){
$count['pool_week_count'] += $val['pay_amount'];
if($is_export){
$this->setWeekCount($line);
}
}
//本周未结算流水合计
if(!$is_statement){
$count['pool_lack_count'] += $val['pay_amount'];
$count['st_lack_count'] += $val['pay_amount'];
if($is_export){
$this->setlackCount($line);
}
}else{
$count['st_count'] += $val['pay_amount'];
}
}
if($is_export){
if($v['withdraw_type'] != 3) {
@ -525,15 +536,11 @@ class CompanyStatementPoolController extends ThinkController
$v['statement_money'] .= "S{$line}+";
}else{
$count['platform_amount'] += $val['pay_amount'];
// $count['sum_money'] += $val['sum_money'];
}
}
$count['week_money'] += $va['week_amount'];
$count['sum_money'] += $va['week_amount'];
}
// dump($count);
$v['row'] = $row;
@ -543,7 +550,6 @@ class CompanyStatementPoolController extends ThinkController
if($is_export){
if($v['withdraw_type'] != 3) {
// $v['statement_money'] .="P{$cline}-Q{$cline},2)";
$v['statement_money'] = substr($v['statement_money'],0,strlen($v['statement_money'])-1) . ",2)";
} else {
$v['statement_money'] = substr($v['statement_money'],0,strlen($v['statement_money'])-1).",2)";
@ -551,18 +557,80 @@ class CompanyStatementPoolController extends ThinkController
}
}
if($is_export){
if($pool_info["withdraw_type"] != 3){
//上周数据合计
$count["pool_week_count"] = $this->setWeekCount($line,true);
$count["pool_lack_count"] = $this->setlackCount($line,true);
//本周暂不结算合计
$count["st_lack_count"] = '=ROUND(SUMIFS(T2:T'.$line.',Y2:Y'.$line.',"否"),2)';
//本次应支付
$count["st_count"] = '=ROUND(SUMIFS(T2:T'.$line.',Y2:Y'.$line.',"是"),2)';
}
$count["platform_amount"] = "=ROUND(SUM(K2:K".$line."),2)";
$count["week_money"] = "=ROUND(SUM(S2:S".$line."),2)";
$count["sum_money"] = "=ROUND(SUM(T2:T".$line."),2)";
}
// die();
// die();
$this->assign("data",$infolist);
$this->assign("count",$count);
$this->assign("is_export",$is_export);
$this->assign("withdraw_type",$pool_info["withdraw_type"]);
$this->display("CompanyStatementPool/viewPuPool");
}
//导出中上周结算数据计算
protected function setWeekCount($line,$return = false)
{
global $pool_week_str,$pool_week_line;
if(empty($pool_week_str)){
$pool_week_str = "=";
$pool_week_line = 0;
}
if($pool_week_str == "="){
$pool_week_str .= "SUM(K{$line}:";
}else{
if($line - $pool_week_line > 1){
//不连续
$preline = $line-2;
$pool_week_str .= "K{$preline})+SUM(K{$line}:";
}
}
$pool_week_line = $line;
if($return){
$data = $pool_week_str."K{$line})";
unset($pool_week_str,$pool_week_line);
return $data;
}
}
//本周不结算
protected function setlackCount($line,$return = false)
{
global $pool_lack_str,$pool_lack_line;
if(empty($pool_lack_str)){
$pool_lack_str = "=";
$pool_lack_line = 0;
}
if($pool_lack_str == "="){
$pool_lack_str .= "SUM(K{$line}:";
}else{
if($line - $pool_lack_line > 1){
//不连续
$preline = $line-1;
$pool_lack_str .= "K{$preline})+SUM(K{$line}:";
}
}
$pool_lack_line = $line;
if($return){
$data = $pool_lack_str."K{$line})";
unset($pool_lack_str,$pool_lack_line);
return $data;
}
}
//改变结构
public function changeDataStruct($statement_info = [],$is_export = 0,&$week_line = 1) {

@ -308,6 +308,35 @@
</notempty>
</foreach>
<if condition="$withdraw_type neq 3">
<tr>
<td colspan="9" rowspan="3"></td>
<td>上周数据合计:</td>
<td>{$count.pool_week_count}</td>
<td colspan="5" rowspan="3"></td>
<td colspan="3">打款合计:</td>
<td>{$count.sum_money}</td>
<td colspan="6" rowspan="3"></td>
<if condition="!$is_export">
<td rowspan="3"></td>
</if>
</tr>
<tr>
<td>本周未结算流水合计:</td>
<td>{$count.pool_lack_count}</td>
<td colspan="3">本周暂不结算合计:</td>
<td>{$count.st_lack_count}</td>
</tr>
<tr>
<td></td>
<td></td>
<td colspan="3">本次应支付:</td>
<td>{$count.st_count}</td>
</tr>
<else />
<tr>
<td colspan=10 >合计:</td>
<td>{$count.platform_amount}</td>
@ -330,6 +359,10 @@
<td></td>
</if>
</tr>
</if>
</tbody>
</table>
</div>

Loading…
Cancel
Save