优化导出并聚合数据

master
chenzhi 5 years ago
parent caf432f5d4
commit e1d624fe8b

@ -1896,6 +1896,8 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_
$objPHPExcel->getActiveSheet()->setCellValue('C7', "支付给:".$data['receive_company']['partner']); //增加支付给对应公司
$line = 10;
//记录统计项目
$pay_amount_str = "=";
//增加结算记录
foreach ($data['statement_info'] as $key => $value) {
$objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1)->mergeCells("J$line:K$line");
@ -1920,8 +1922,14 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_
$objPHPExcel->getActiveSheet()->setCellValue('H'.$line, $value['promote_ratio'] . '%');
$objPHPExcel->getActiveSheet()->setCellValue('I'.$line, $value['fax_ratio']. '%');
$objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['pay_amount']);
$objPHPExcel->getActiveSheet()->setCellValue('J'.$line, $value['sum_money']);
// $objPHPExcel->getActiveSheet()->setCellValue('J'.$line, $value['sum_money']);
if ($data['pay_type'] == 2) {
$objPHPExcel->getActiveSheet()->setCellValue('J'.$line, "=E{$line}*(1-H{$line})*G{$line}*(1-I{$line})");
}else{
$objPHPExcel->getActiveSheet()->setCellValue('J'.$line, "=E{$line}*(1-H{$line})*F{$line}*(1-I{$line})");
}
}
$pay_amount_str .= "J{$line}+";
$objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $product_name);
$line++;
@ -1929,9 +1937,11 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_
//合计
$objPHPExcel->getActiveSheet()->setCellValue("E" . ($line), $data['pay_amount']);
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line), $data['statement_money']);
// $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line), $data['statement_money']);
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line), trim($pay_amount_str,"+"));
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+1), $big_all_sum_money); //本月分成总金额(人民币大写)
// $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+1), $big_all_sum_money); //本月分成总金额(人民币大写)
$objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+1), "=J{$line}"); //本月分成总金额(人民币大写)
//收款方
$objPHPExcel->getActiveSheet()->setCellValue("D" . ($line+2), $data['receive_company']['payee_name']);
@ -1985,7 +1995,7 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al
$line = 3;
$pay_amount_str = "=";
foreach ($data['statement_info'] as $key => $value) {
$objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1);
$objPHPExcel->getActiveSheet()->removeConditionalStyles();
@ -2011,18 +2021,20 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al
}
$objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['fax_ratio'] . '%');
$objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['pay_amount']);
$objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']);
// $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']);
$objPHPExcel->getActiveSheet()->setCellValue('F'.$line,"=C{$line}*D{$line}*(1-E{$line})");
}
$objPHPExcel->getActiveSheet()->setCellValue('B'.$line, $product_name);
$pay_amount_str .= "F{$line}+";
$line++;
}
$objPHPExcel->getActiveSheet()->setCellValue('C'.($line), $data['pay_amount']);//合计-平台总额
$objPHPExcel->getActiveSheet()->setCellValue('F'.($line), $data['statement_money']);//合计-结算金额
$objPHPExcel->getActiveSheet()->setCellValue('F'.($line), trim($pay_amount_str,"+"));//合计-结算金额
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), $big_all_sum_money);//大写支付结算金额
// $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), $big_all_sum_money);//大写支付结算金额
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+1), "=F{$line}");//大写支付结算金额
//甲方信息
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+3), $data['pay_company']['partner']);//甲方
$objPHPExcel->getActiveSheet()->setCellValue('B'.($line+4), $data['pay_company']['link_man']);//联系人

@ -365,6 +365,105 @@ class CompanyStatementController extends ThinkController
excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money);
}
}
//汇总
public function pool()
{
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$dbres = $this->DBModel->field("*")->where("id in ({$ids})")->select();
//分单
$basedata = [
"pay_amount"=>0,
"statement_money"=>0,
"platform_amount"=>0,
"statement_ids"=>[],
"statement_begin_time"=>0,
"statement_end_time"=>0,
"fine"=>0,
"reward"=>0,
"company_list"=>[]
];
//
$ups=$basedata;
$downs=$basedata;
$users=$basedata;
foreach ($dbres as $k=>$v) {
if($v['verify_status'] != 3) continue;
if($v['company_belong'] == 9){
//上游
$this->setDf($ups,$v);
}else{
//下游
if($v['company_type'] == 2){
//个人
$this->setDf($users,$v);
}else{
$this->setDf($downs,$v);
}
}
}
dd($ups);
//
}
//设定组合的子操作
protected function setDf(&$savedata,$v)
{
$savedata['statement_ids'][] = $v['id'];
unset($v['id']);
$v['statement_info'] = json_decode( $v['statement_info'],true);
foreach($v['statement_info'] as $ka=>$va){
if($va['statement_type'] == 2){
//奖励
$savedata['reward'] += $va['sum_money'];
unset($v['statement_info'][$ka]);
}else if($va['statement_type'] == 1){
$savedata['fine'] += $va['sum_money'];
unset($v['statement_info'][$ka]);
}
}
if(isset($savedata['company_list'][$v['company_id']])){
//存在游戏合并
$a = &$savedata['company_list'][$v['company_id']];
$a['statement_info'] = array_merge($a['statement_info'],$v['statement_info']);
// dump($a['statement_info']);
$a['platform_amount'] += $v['platform_amount'];
$a['pay_amount'] += $v['pay_amount'];
$a['statement_money'] += $v['statement_money'];
}else{
if($v['pay_type'] == 2){
//乙方收款
$v['company_info'] = $v['second_party_info'];
}else{
$v['company_info'] = $v['first_party_info'];
}
$tdata = [
"company_info"=>$v['company_info'],
"company_name"=>$v['company_name'],
"platform_amount"=>$v['platform_amount'],
"pay_amount"=>$v['pay_amount'],
"statement_money"=>$v['statement_money'],
"statement_info"=>$v['statement_info'],
];
$savedata['company_list'][$v['company_id']] = $tdata;
}
$savedata['pay_amount'] += $v['pay_amount'];
$savedata['statement_money'] += $v['statement_money'];
$savedata['platform_amount'] += $v['platform_amount'];
if($savedata['statement_begin_time'] == 0){
$savedata['statement_begin_time'] = $v['statement_begin_time'];
}elseif($v['statement_begin_time'] < $savedata['statement_begin_time']){
$savedata['statement_begin_time'] = $v['statement_begin_time'];
}
if($savedata['statement_end_time'] == 0){
$savedata['statement_end_time'] = $v['statement_end_time'];
}elseif($v['statement_end_time'] > $savedata['statement_end_time']){
$savedata['statement_end_time'] = $v['statement_end_time'];
}
}
//设定并保存数据
public function OpAuth($info)
{

@ -326,6 +326,9 @@ class CompanyStatementSetController extends Controller {
//金额为0不补点
continue;
}
if($add_data['platform_amount'] <= 0){
return;
}
//添加
if($company_id === false){
//非重算
@ -577,6 +580,9 @@ class CompanyStatementSetController extends Controller {
//金额为0不补点
continue;
}
if($add_data['platform_amount'] <= 0){
return;
}
//添加
if($company_id === false){
//非重算

@ -345,8 +345,8 @@
}
}).get();
if(text.length > 20){
layer.msg("<font style='color:white'>" + '为保证效率暂不支持超过20条的批量操作' + "</font>");
if(text.length > 40){
layer.msg("<font style='color:white'>" + '为保证效率暂不支持超过40条的批量操作' + "</font>");
return;
}
if(text.length < 1){
@ -387,11 +387,15 @@
setTimeout(function(){
window.location.reload();
},1500);
}else{
layer.msg("<font style='color:white'>" + data.info + "</font>");
return false;
}
}
});
}
})
$("#export").click(function () {
var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) {
return $(elem).val();

Loading…
Cancel
Save