diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php
index 6cda8d817..0904b917b 100644
--- a/Application/Admin/Common/extend.php
+++ b/Application/Admin/Common/extend.php
@@ -1986,6 +1986,138 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_
}
+//下游工会对账单导出
+function excelSpecialComplementEmplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money) {
+
+ header("Content-type: text/html; charset=utf-8");
+ error_reporting(E_ALL);
+ ini_set('display_errors', TRUE);
+ ini_set('display_startup_errors', TRUE);
+
+ define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '
');
+
+ Vendor("PHPExcel.PHPExcel");
+ $objPHPExcel = new \PHPExcel();
+ $objReader = \PHPExcel_IOFactory::createReader('Excel5');
+
+ //设置模板文件
+ $objPHPExcel = $objReader->load("Public/Admin/excel/down_stream.xls");
+
+ $statement_begin_time = date('Y.m.d', $data['statement_begin_time']);//对账开始时间
+ $statement_end_time = date('Y.m.d',$data['statement_end_time']);//对账截止时间
+
+ $objPHPExcel->getActiveSheet()->setCellValue('A1', "《 {$data['company_name']} 》结算单\n({$statement_begin_time}-{$statement_end_time})");
+ if ($data['withdraw_type'] == '2') {
+ $objPHPExcel->getActiveSheet()->setCellValue('D2','补点比例');
+ }
+ if ($data['withdraw_type'] == 3) {
+ $objPHPExcel->getActiveSheet()->setCellValue('E2','特殊补点比例');
+ }
+
+ $line = 3;
+ $pay_amount_str = "=SUM(F3:";
+ $plat_amount_str = "=SUM(C3:";
+ foreach ($data['statement_info'] as $key => $value) {
+ $objPHPExcel->getActiveSheet()->insertNewRowBefore($line,1);
+ $objPHPExcel->getActiveSheet()->removeConditionalStyles();
+
+ $objPHPExcel->getActiveSheet()->setCellValue('A'.$line, $value['statement_begin_time'].'-'.$value['statement_end_time']);
+ if ($value['statement_type'] > 0) {//罚款
+ $product_name = $value['game_name'];
+ $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, '-');
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, '-');
+ if ($value['statement_type'] == 1) {
+ $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, "-".$value['pay_amount']);
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, "-".$value['sum_money']);
+ }else{
+ $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['pay_amount']);
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']);
+ }
+ } else {//游戏
+ $product_name = $value['game_name'];
+
+ $objPHPExcel->getActiveSheet()->getStyle('D'.$line)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
+ $objPHPExcel->getActiveSheet()->getStyle('E'.$line)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_000);
+ $objPHPExcel->getActiveSheet()->getStyle('C'.$line)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
+ if($data['withdraw_type'] != 3) {
+
+
+ if($value['increment_ratio'] == 0){
+ $value['increment_ratio'] = 0;
+ }else{
+ $value['increment_ratio'] = number_format($value['first_ratio']);
+ }
+ }
+ if($value['ratio'] == 0) {
+ $value['ratio'] = 0;
+ }else{
+ $value['ratio'] = number_format($value['ratio']);
+ }
+ if($value['fax_ratio'] == 0) $value['fax_ratio'] = 0;
+
+
+ if ($data['withdraw_type'] == 2) {
+ $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $value['increment_ratio'] . '%');
+ }else{
+ $objPHPExcel->getActiveSheet()->setCellValue('D'.$line, $value['ratio'] . '%');
+ }
+
+
+ if ($data['withdraw_type'] != 3) {
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['fax_ratio'] . '%');
+ } else {
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.$line, $value['increment_ratio'] . '%');
+ }
+
+ $objPHPExcel->getActiveSheet()->setCellValue('C'.$line, $value['pay_amount']);
+ // $objPHPExcel->getActiveSheet()->setCellValue('F'.$line, $value['sum_money']);
+
+ if ($data['withdraw_type'] != 3) {
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.$line,"=C{$line}*D{$line}*(1-E{$line})");
+ } else {
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.$line,"=C{$line}*E{$line}");
+ }
+ }
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.$line, $product_name);
+ $line++;
+ }
+
+ $objPHPExcel->getActiveSheet()->setCellValue('C'.($line), $plat_amount_str."C".($line-1).")");//合计-平台总额
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.($line), $pay_amount_str."F".($line-1).")");//合计-结算金额
+
+
+ // $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']);//联系人
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+5), $data['pay_company']['link_phone']."\t");//联系电话
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+6), $data['receive_company']['invoice_content']);//开票项目
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($line+7), $data['receive_company']['invoice_type']);//发票类型
+
+ //乙方信息
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+3), $data['receive_company']['partner']);//乙方
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+4), $data['receive_company']['link_man']);//联系人
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+5), $data['receive_company']['link_phone']."\t");//联系电话
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+6), $data['receive_company']['address']);//邮寄地址
+// $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $value['pay_amount']);//请汇入此账号
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+8), $data['receive_company']['payee_name']);//户名
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['receive_company']['bank_account']."\t");//银行账号
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['receive_company']['opening_bank']);//开户行
+
+ $fileName = "{$data['company_name']}&{$data['my_company']}-对账单{$statement_begin_time}-{$statement_end_time}";
+// dd($fileName);
+ ob_end_clean();//清除缓冲区,避免乱码
+ header('pragma:public');
+ header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
+ header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
+ $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
+ $objWriter->save('php://output');
+ exit;
+
+}
+
+
//下游工会对账单导出
function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money) {
diff --git a/Application/Admin/Controller/CompanyStatementController.class.php b/Application/Admin/Controller/CompanyStatementController.class.php
index f0924ebfd..3895bd401 100644
--- a/Application/Admin/Controller/CompanyStatementController.class.php
+++ b/Application/Admin/Controller/CompanyStatementController.class.php
@@ -80,6 +80,12 @@ class CompanyStatementController extends ThinkController
$typeflag = 2;//周结
$map["withdraw_type"] = ["in",[0,2]];
}
+
+ if($_REQUEST['withdraw_type'] == 3){
+ $typeflag = 3;//特殊补点
+ $map["withdraw_type"] = 3;
+ }
+
}
if (isset($_REQUEST['withdraw_type2'])) {
if($_REQUEST['withdraw_type2'] == 2){
@@ -97,6 +103,22 @@ class CompanyStatementController extends ThinkController
$map['withdraw_type'] = ["in",[0,1]];
}
}
+
+ if($_REQUEST['withdraw_type2'] == 3){
+ if ($typeflag == 3 || !$typeflag) {
+ $map["withdraw_type"] = 3;
+ } else {
+ $map["withdraw_type"] = 999; //两者不一搜索为空
+ }
+
+ } else {
+
+ if($typeflag == 3) {
+ $map["withdraw_type"] = 999; //两者不一搜索为空
+ }
+ }
+
+
}
//其他
if(isset($_REQUEST['company_type'])){
@@ -122,12 +144,14 @@ class CompanyStatementController extends ThinkController
if(isset($_REQUEST['confirm_status'])){
$map['confirm_status'] = $_REQUEST['confirm_status'];
}
+
// $this->checkListOrCountAuthRestMap($map);//导出权限
//条件end
$data = M("company_statement","tab_")
->field("id,withdraw_type,company_name,company_belong,statement_begin_time,statement_end_time,statement_money,platform_amount,verify_status,verify_log,confirm_status,confirm_log,op_time,remark")
->where($map)
->order("FIELD(verify_status,0,1,-1,2,3,-2,-3),id desc")->page($page,$row)->select();
+
foreach($data as $k => &$v) {
$v['statement_begin_time'] = date('Y.m.d',$v['statement_begin_time']);
@@ -138,8 +162,8 @@ class CompanyStatementController extends ThinkController
$v["valid"] = "{$v['statement_begin_time']}-{$v['statement_end_time']}";
- $v['withdraw_type_1'] = ($v['withdraw_type'] == 1 ? "月结" : ($v['withdraw_type'] == 3 ?"特殊补点" : "周结"));
- $v['withdraw_type_2'] = ($v['withdraw_type'] == 2 ? "补点" :"正常结算");
+ $v['withdraw_type_1'] = ($v['withdraw_type'] == 1 ? "月结" : ($v['withdraw_type'] == 3 ?"其他" : "周结"));
+ $v['withdraw_type_2'] = ($v['withdraw_type'] == 2 ? "补点" : ($v['withdraw_type'] == 3 ?"特殊补点" : "正常结算"));
$v['verify_log'] = json_decode($v['verify_log'], true);
$v['confirm_log'] = json_decode($v['confirm_log'], true);
@@ -443,10 +467,12 @@ class CompanyStatementController extends ThinkController
//导出
public function export()
{
+
if(!isset($_REQUEST['id'])) $this->error("参数错误");
$id = $_REQUEST['id'];
$data = M("CompanyStatement","tab_")->where(['id' => $id])->find();
+
$data['first_party_info'] = json_decode($data['first_party_info'], 1);//甲方
$data['second_party_info'] = json_decode($data['second_party_info'], 1);//乙方
$data['statement_info'] = json_decode($data['statement_info'], 1);//结算记录
@@ -481,7 +507,33 @@ class CompanyStatementController extends ThinkController
} else {
//下游
// if($dbres["company_type"] == 1){
+
+ if ($data['withdraw_type'] == 3 && $data['company_type'] == 2) {
+
+ $dbres = M("CompanyStatement","tab_")->where(['id' => $id])->find();
+ if($dbres['pay_type'] == 2){
+ //乙方收款
+ $dbres['company_info'] = $dbres['second_party_info'];
+ }else{
+ $dbres['company_info'] = $dbres['first_party_info'];
+ }
+ unset($dbres['second_party_info']);
+ unset($dbres['first_party_info']);
+
+ $dbres=[$dbres];
+
+ $this->assign("title","下游个人特殊补点");
+ $this->exportSpecialComplement($dbres,1);
+
+ } else if ($data['withdraw_type'] == 3 && $data['company_type'] != 2){
+ excelSpecialComplementEmplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money);
+ }
+ else {
+
excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money);
+
+ }
+
// }else{
// $data['statement_begin_time'] = date('Ymd',$data['statement_begin_time']);
// $data['statement_end_time'] = date('Ymd',$data['statement_end_time']);
@@ -492,6 +544,105 @@ class CompanyStatementController extends ThinkController
// }
}
}
+
+ public function exportSpecialComplement(&$infolist,$is_export) {
+
+ $line = 1;
+ $count = [];
+ //获取对接人
+ foreach($infolist as $k=>&$v){
+ $infolist[$k]['reward'] = 0;
+ $infolist[$k]['fine'] = 0;
+ $v['statement_info'] = json_decode($v['statement_info'],true);
+ $v['company_info'] = json_decode($v['company_info'],true);
+ $v['statement_begin_time'] = date('Y.m.d',$v['statement_begin_time']);
+ $v['statement_end_time'] = date('Y.m.d',$v['statement_end_time']);
+ $v['company_info']['nickname'] = $v['statement_info'][0]['real_name'];
+
+ if (isset($v['company_info']['company_type'])) {
+ if($v['company_info']['company_type'] == 1) {
+ $v['company_info']['company_type_str'] = '公司';
+ } elseif($v['company_info']['company_type'] == 2){
+ $v['company_info']['company_type_str'] = '个人';
+ }
+ }
+
+ if (isset($v['company_info']['company_belong'])) {
+ $v['company_info']['company_belong_str'] = getCompanyBlong($v['company_info']['company_belong']);
+ }
+
+ if (isset($v['company_info']['develop_type'])) {
+ $v['company_info']['company_relation_str'] = getCompanyRelation($v['company_info']['develop_type']);
+ }
+
+ $cline = $line+1;
+ if($is_export){
+ $v['statement_money'] = "=";
+ }
+
+ $row = 0;
+ 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(isset($val['ratio'])){
+ $val['increment_ratio'] = 0;
+ }else{
+ $val['ratio'] = 0;
+ }
+ }
+
+ if($is_export){
+ if($v['withdraw_type'] != 3) {
+ $val['sum_money'] = "=K{$line}*(L{$line}+M{$line})";
+ } else {
+ $val['sum_money'] = "=K{$line}*(M{$line})";
+ }
+// $val['sum_money'] = "=J{$line}*(K{$line}+L{$line})";
+ $v['statement_money'] .= "N{$line}+";
+ }else{
+ $count['platform_amount'] += $val['pay_amount'];
+ $count['sum_money'] += $val['sum_money'];
+ }
+ }
+ // if($is_export){
+ // //J3*(K3+L3)+M3-N3
+ // if($va['statement_type'] > 0){ //罚款服务器费用
+ // $va['sum_money'] = "=J{$line}";
+ // }else{
+ // $va['sum_money'] = "=J{$line}*(K{$line}+L{$line})+M{$line}-N{$line}";
+ // }
+ // }else{
+ // $count['platform_amount'] += $va['pay_amount'];
+ // $count['sum_money'] += $va['sum_money'];
+ // }
+ }
+ $v['row'] = $row;
+ if($is_export){
+
+ if($v['withdraw_type'] != 3) {
+ $v['statement_money'] .="N{$cline}-O{$cline}";
+ } else {
+ $v['statement_money'] = substr($v['statement_money'],0,strlen($v['statement_money'])-1);
+ }
+// dump($v['statement_money']);die();
+ }
+ }
+
+ if($is_export){
+ $count["platform_amount"] = "=SUM(K2:K".$line.")";
+ $count["sum_money"] = "=SUM(Q2:Q".$line.")";
+ }
+ $this->assign("data",$infolist);
+ $this->assign("count",$count);
+ $this->assign("is_export",$is_export);
+ $this->display("CompanyStatementPool/viewPuPool");
+
+ }
+
//汇总
public function pool()
{
diff --git a/Application/Admin/View/CompanyStatement/lists.html b/Application/Admin/View/CompanyStatement/lists.html
index 944bbb1cc..13d7f6a50 100644
--- a/Application/Admin/View/CompanyStatement/lists.html
+++ b/Application/Admin/View/CompanyStatement/lists.html
@@ -124,6 +124,8 @@
+
+