diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 7cc7e1fd0..7b558b442 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1830,7 +1830,7 @@ function getCompanyList() { //上游cp对账单导出 function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_sum_money) { - header("Content-type: text/html; charset=gb2312"); + header("Content-type: text/html; charset=utf-8"); error_reporting(E_ALL); ini_set('display_errors', TRUE); ini_set('display_startup_errors', TRUE); @@ -1901,10 +1901,15 @@ function excelUpStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_all_ $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+3), $data['pay_company']['bank_account']); $objPHPExcel->getActiveSheet()->setCellValue("J" . ($line+4), $data['pay_company']['opening_bank']); + $statement_begin_time = date('Y.m.d', $data['statement_begin_time']);//对账开始时间 + $statement_end_time = date('Y.m.d',$data['statement_end_time']);//对账截止时间 + + $fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['partner']}-对账单{$statement_begin_time}-{$statement_end_time}"; + ob_end_clean();//清除缓冲区,避免乱码 header('pragma:public'); - header('Content-type:application/vnd.ms-excel;charset=utf-8;name="上游结算单.xls"'); - header("Content-Disposition:attachment;filename=上游结算单.xls");//attachment新窗口打印inline本窗口打印 + 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; @@ -1929,8 +1934,8 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al //设置模板文件 $objPHPExcel = $objReader->load("Public/Admin/excel/down_stream.xls"); - $statement_begin_time = set_show_time($data['statement_begin_time']);//对账开始时间 - $statement_end_time = set_show_time($data['statement_end_time']);//对账截止时间 + $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']} 》结算单 ({$statement_begin_time}-{$statement_end_time}"); @@ -1983,11 +1988,12 @@ function excelDownStreamTemplate($data, $all_sum_money, $all_pay_amount, $big_al $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+9), $data['second_party_info']['bank_account']);//银行账号 $objPHPExcel->getActiveSheet()->setCellValue('E'.($line+10), $data['second_party_info']['opening_bank']);//开户行 - $filename = '下游结算单'; + $fileName = "{$data['second_party_info']['partner']}&{$data['first_party_info']['jfCompany']}-对账单{$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="15415.xls"'); - header("Content-Disposition:attachment;filename=$filename.xls");//attachment新窗口打印inline本窗口打印 + 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; diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index 77dbd2e24..a92e4fd6f 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -354,4 +354,28 @@ class AjaxController extends ThinkController{ } + function getPromoteCompanyList() { + + $map = []; + if ($_REQUEST['withdraw_number']) { + $map['widthdraw_number'] = $_REQUEST['withdraw_number']; + } +// var_dump($map);die(); + if ($_REQUEST['company_id']) { + $map['company_id'] = $_REQUEST['company_id']; + } + + $data = M("withdraw","tab_") + ->field("widthdraw_number,promote_account,tab_promote_company.id as company_id,company_name,tab_withdraw.settlement_type,mobile_phone,real_name,bank_card,account_openin,address,game_ratio,bank_account") + ->join("left join tab_promote on tab_withdraw.promote_id=tab_promote.id") + ->join("left join tab_promote_company on tab_promote.company_id=tab_promote_company.id") + ->where($map) + ->select(); + + + $this->ajaxReturn(['data'=>$data]); +// return $data; + + } + } \ No newline at end of file diff --git a/Application/Admin/View/Statement/createCpStatement.html b/Application/Admin/View/Statement/createCpStatement.html index 3a1df1843..ebca6d47e 100644 --- a/Application/Admin/View/Statement/createCpStatement.html +++ b/Application/Admin/View/Statement/createCpStatement.html @@ -644,14 +644,23 @@ var sort = $(this).data("change"); var val = $(this).val(); + var vdata = eval("DATAOBJ."+sort);//原先值 + var dom = $(this); + if(!CHECK.number.test(val)){ layer.msg('结算单中的罚款和税率必须是数字'); - $(this).val(0); + dom.val(vdata); return false; } + var str = "DATAOBJ."+sort+"='"+val+"';"; if(sort != 'fine'){ + if(val > 100 || val < 0){ + layer.msg('结算单中的税率不允许大于100和小于0'); + dom.val(vdata); + return false; + } eval(str); var index = $(this).data("index"); var td = DATAOBJ.statement_info[index]; diff --git a/Application/Admin/View/Statement/editCpStatement.html b/Application/Admin/View/Statement/editCpStatement.html index 61da150d9..588cd1514 100644 --- a/Application/Admin/View/Statement/editCpStatement.html +++ b/Application/Admin/View/Statement/editCpStatement.html @@ -456,91 +456,61 @@ } }) }, - deepCompare(x, y) { - var i, l, leftChain, rightChain; - function compare2Objects(x, y) { - var p; - if (isNaN(x) && isNaN(y) && typeof x === 'number' && typeof y === 'number') { - return true; - } - if (x === y) { - return true; - } - if ((typeof x === 'function' && typeof y === 'function') || - (x instanceof Date && y instanceof Date) || - (x instanceof RegExp && y instanceof RegExp) || - (x instanceof String && y instanceof String) || - (x instanceof Number && y instanceof Number)) { - return x.toString() === y.toString(); - } - if (!(x instanceof Object && y instanceof Object)) { - return false; - } - if (x.isPrototypeOf(y) || y.isPrototypeOf(x)) { - return false; - } - if (x.constructor !== y.constructor) { - return false; - } - if (x.prototype !== y.prototype) { - return false; - } - if (leftChain.indexOf(x) > -1 || rightChain.indexOf(y) > -1) { - return false; + floatAdd(a,b){ + return Math.round(a*100+b*100)/100; + }, + floatCut(a,b){ + return Math.round(a*100-b*100)/100; + }, + CompanyKeyName:{ + id:"公司表id", + partner:"公司名称", + link_man:'联系人', + link_phone:"联系电话", + address:'邮寄地址', + company_tax_no:'公司税号', + payee_name:'名称', + bank_account:"银行账号", + opening_bank:"开户行" + }, + checkCompanyKey(type,key){ + //获取公司名 + var company = ''; + if(key == "payee_name" || key == "bank_account" || key == "opening_bank"){ + if((DATAOBJ.statement_type == 0 && type == "first_party_info") || (DATAOBJ.statement_type == 1 && type == "second_party_info")){ + company = "收款方"; } - for (p in y) { - if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) { - return false; - } else if (typeof y[p] !== typeof x[p]) { - return false; - } + if((DATAOBJ.statement_type == 0 && type == "second_party_info")|| (DATAOBJ.statement_type == 1 && type == "first_party_info")){ + company = "付款方"; } - for (p in x) { - if (y.hasOwnProperty(p) !== x.hasOwnProperty(p)) { - return false; - } else if (typeof y[p] !== typeof x[p]) { - return false; - } - switch (typeof (x[p])) { - case 'object': - case 'function': - - leftChain.push(x); - rightChain.push(y); - - if (!compare2Objects(x[p], y[p])) { - return false; - } - - leftChain.pop(); - rightChain.pop(); - break; - - default: - if (x[p] !== y[p]) { - return false; - } - break; - } + }else{ + if(type == "first_party_info"){ + company = "甲方"; + }else{ + company = "乙方"; } - - return true; } - - if (arguments.length < 1) { - return true; + //获取键名 + try { + var keyname = company+PUBLIC.CompanyKeyName[key]; + } catch (error) { + var keyname = false; } - for (i = 1, l = arguments.length; i < l; i++) { - - leftChain = []; //Todo: this can be cached - rightChain = []; - - if (!compare2Objects(arguments[0], arguments[i])) { - return false; - } + //验证 + if(DATAOBJ[type][key] ===''){ + layer.msg(keyname+"不能为空"); + return false; + } + if(key == "link_phone" && !CHECK.mobile.test(DATAOBJ[type][key])){ + layer.msg(keyname+"格式错误"); + return false; + } + if(key == "bank_account" && !CHECK.BankNo.test(DATAOBJ[type][key])){ + layer.msg(keyname+"格式错误"); + return false; } return true; - } + }, } //数据类 @@ -570,37 +540,20 @@ } //验证甲方信息 for (const key in DATAOBJ.first_party_info) { - var t = DATAOBJ.first_party_info; - if (t[key] === '') { - layer.msg('甲方信息不全,请先补全 code:' + key); - return false; - } - if (key == "link_phone" && !CHECK.mobile.test(t[key])) { - layer.msg('甲方联系人手机号格式错误'); - return false; - } - if (key == "bank_account" && !CHECK.BankNo.test(t[key])) { - layer.msg('甲方银行卡号格式错误'); - return false; + var t = DATAOBJ.first_party_info; + var flag = PUBLIC.checkCompanyKey("first_party_info",key); + if(!flag){ + return flag; } } //乙方 for (const key in DATAOBJ.second_party_info) { - var t = DATAOBJ.second_party_info; - if (!t[key] || t[key] == '') { - layer.msg('乙方信息不全,请先补全 code:' + key); - return false; - } - if (key == "link_phone" && !CHECK.mobile.test(t[key])) { - layer.msg('乙方联系人手机号格式错误'); - return false; - } - if (key == "bank_account" && !CHECK.BankNo.test(t[key])) { - layer.msg('乙方银行卡号格式错误'); - return false; + var t = DATAOBJ.second_party_info; + var flag = PUBLIC.checkCompanyKey("second_party_info",key); + if(!flag){ + return flag; } } - console.log(DATAOBJ); layer.load(2); $("#createStatement").off("click");//自我解绑 @@ -633,56 +586,67 @@ }, statementchange() { $(".statementchange").off("blur"); - $(".statementchange").on("blur", function () { - + $(".statementchange").on("blur",function(){ var sort = $(this).data("change"); var val = $(this).val(); - if (!CHECK.number.test(val)) { + var vdata = eval("DATAOBJ."+sort);//原先值 + var dom = $(this); + + if(!CHECK.number.test(val)){ layer.msg('结算单中的罚款和税率必须是数字'); - $(this).val(0); + dom.val(vdata); return false; } - var str = "DATAOBJ." + sort + "='" + val + "';"; + + var str = "DATAOBJ."+sort+"='"+val+"';"; - if (sort != 'fine') { + if(sort != 'fine'){ + if(val > 100 || val < 0){ + layer.msg('结算单中的税率不允许大于100和小于0'); + dom.val(vdata); + return false; + } eval(str); var index = $(this).data("index"); var td = DATAOBJ.statement_info[index]; - if ($(this).attr("name") == "first_ratio") { - td['second_ratio'] = 100 - val; + if( $(this).attr("name") == "first_ratio"){ + td['second_ratio'] = 100-val; } - if ($(this).attr("name") == "second_ratio") { - td['first_ratio'] = 100 - val; + if( $(this).attr("name") == "second_ratio"){ + td['first_ratio'] = 100-val; } - if (DATAOBJ.statement_type == 0) { - var ratio = td['first_ratio'] / 100; - } else { - var ratio = td['second_ratio'] / 100; + if(DATAOBJ.statement_type == 0){ + var ratio = td['first_ratio']/100; + }else{ + var ratio = td['second_ratio']/100; } - DATAOBJ.statement_count['sum_money'] -= td['sum_money']; - - td['sum_money'] = Math.floor((td['pay_amount'] * (100 - td['promote_ratio']) / 100 * ratio * (100 - td['fax_ratio']) / 100) * 100) / 100; - DATAOBJ.statement_count['sum_money'] += (td['sum_money'] - 0); - } else { - DATAOBJ.fine = Math.floor(DATAOBJ.fine * 100) / 100; - if (val > DATAOBJ.statement_count['sum_money']) { + DATAOBJ.statement_count['sum_money'] = PUBLIC.floatCut(DATAOBJ.statement_count['sum_money'],td['sum_money']); + + td['sum_money'] = Math.round((td['pay_amount']*(100-td['promote_ratio'])/100*ratio*(100-td['fax_ratio'])/100)* 100) / 100 ; + + DATAOBJ.statement_count['sum_money']=PUBLIC.floatAdd(DATAOBJ.statement_count['sum_money'],td['sum_money']); + + }else{ + DATAOBJ.fine = Math.round(DATAOBJ.fine * 100) / 100 ; + if(!CHECK.money.test(val)){ + layer.msg('罚款金额格式错误'); + $(this).val(DATAOBJ.fine); + return false; + } + if(val > DATAOBJ.statement_count['sum_money']){ layer.msg('罚款金额过大,总计不允许为负数'); $(this).val(DATAOBJ.fine); return false; } - - DATAOBJ.statement_count['sum_money'] = (DATAOBJ.statement_count['sum_money'] - 0 + DATAOBJ.fine); - DATAOBJ.statement_count['pay_amount'] = (DATAOBJ.statement_count['pay_amount'] - 0 + DATAOBJ.fine); + console.log(str); + DATAOBJ.statement_count['sum_money'] =PUBLIC.floatAdd(DATAOBJ.statement_count['sum_money'],DATAOBJ.fine); + DATAOBJ.statement_count['pay_amount'] = PUBLIC.floatAdd(DATAOBJ.statement_count['pay_amount'],DATAOBJ.fine); eval(str); - DATAOBJ.statement_count['sum_money'] = DATAOBJ.statement_count['sum_money'] - DATAOBJ.fine; - DATAOBJ.statement_count['pay_amount'] = DATAOBJ.statement_count['pay_amount'] - DATAOBJ.fine; - + DATAOBJ.statement_count['sum_money'] =PUBLIC.floatCut(DATAOBJ.statement_count['sum_money'],DATAOBJ.fine); + DATAOBJ.statement_count['pay_amount'] = PUBLIC.floatCut(DATAOBJ.statement_count['pay_amount'],DATAOBJ.fine); } - DATAOBJ.statement_count['pay_amount'] = Math.floor(DATAOBJ.statement_count['pay_amount'] * 100) / 100; - DATAOBJ.statement_count['sum_money'] = Math.floor(DATAOBJ.statement_count['sum_money'] * 100) / 100; - TPLSHOW.showStatementList(true); }) } diff --git a/Application/Admin/View/StatementMangement/createDownstreamOrder.html b/Application/Admin/View/StatementMangement/createDownstreamOrder.html index 1e15b5239..80857897f 100644 --- a/Application/Admin/View/StatementMangement/createDownstreamOrder.html +++ b/Application/Admin/View/StatementMangement/createDownstreamOrder.html @@ -246,6 +246,26 @@ $("#settlement_type_value").val(data.data.settlement_type); $("#bank_account_name").val(data.data.bank_account); + var add = ''; + $("#company_name").empty(); + $.ajax({ + url: "{:U('Ajax/getPromoteCompanyList')}", + type: "get", + data: {withdraw_number: ext_field}, + dataType: 'json', + success: function (response) { + add +=''; + data = response.data; + console.log(data) + for (var i in data){ + add += "" + } + $("#company_name").empty(); + $("#company_name").append(add); + $("#company_name").select2(); + } + }); + $("#jfCompany").val(data.data.yfpartner); $("#jfCompany").next().text(data.data.yfpartner); $("#jfPerson").val(data.data.yflink_man); @@ -348,6 +368,26 @@ $("#settlement_type_value").val(data.data.settlement_type); $("#bank_account_name").val(data.data.bank_account); + var add = ''; + $("#ext_field").empty(); + $.ajax({ + url: "{:U('Ajax/getPromoteCompanyList')}", + type: "get", + data: {company_id: ext_field}, + dataType: 'json', + success: function (response) { + add +=''; + data = response.data; + console.log(data) + for (var i in data){ + add += "" + } + $("#ext_field").empty(); + $("#ext_field").append(add); + $("#ext_field").select2(); + } + }); + $("#jfCompany").val(data.data.yfpartner); $("#jfCompany").next().text(data.data.yfpartner); $("#jfPerson").val(data.data.yflink_man);