From 00de50264d83bd6d8d0c82b134a46fc08a97cded Mon Sep 17 00:00:00 2001 From: lyt Date: Thu, 22 Aug 2019 09:25:21 +0800 Subject: [PATCH] =?UTF-8?q?Trippest=E8=87=AA=E5=8A=A8=E6=A0=B8=E5=AF=B9?= =?UTF-8?q?=E8=B4=A6=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/config/database.php | 2 +- .../controllers/vendor_money.php | 120 +++++++++++ .../models/vendor_money_model.php | 107 ++++++++++ .../views/order_report_precheck.php | 197 ++++++++++++++++++ .../views/vendor_money_sum.php | 1 + 5 files changed, 426 insertions(+), 1 deletion(-) create mode 100644 webht/third_party/trippestOrderSync/views/order_report_precheck.php diff --git a/webht/config/database.php b/webht/config/database.php index 3a7d8aae..564717fb 100644 --- a/webht/config/database.php +++ b/webht/config/database.php @@ -45,4 +45,4 @@ require 'C:/database_conn.php'; /* End of file database.php */ -/* Location: ./application/config/database.php */ \ No newline at end of file +/* Location: ./application/config/database.php */ diff --git a/webht/third_party/trippestOrderSync/controllers/vendor_money.php b/webht/third_party/trippestOrderSync/controllers/vendor_money.php index 828cde12..d12a1814 100644 --- a/webht/third_party/trippestOrderSync/controllers/vendor_money.php +++ b/webht/third_party/trippestOrderSync/controllers/vendor_money.php @@ -252,6 +252,126 @@ class Vendor_money extends CI_Controller { $objWriter->save('php://output'); } + public function report_precheck() + { + $data = array(); + $data['default_date1'] = date('Y-m-01', strtotime("last month")); + $data['default_date2'] = date('Y-m-d H:i:s', mktime(0,0,0,date('m'),1,date('Y'))-1); + $vendor_sourcetype = $this->trippest->vendor_sourcetype(); + $data['default_vendor'] = array_keys($vendor_sourcetype); + $this->load->view('order_report_precheck', $data); + } + + public function precheck() + { + $this->permission->is_admin(true); + $ret = array(); + $date_range = $this->input->post("date_range"); + preg_match_all('/\d{4}\-\d{2}\-\d{2}/', $date_range, $date_range_arr); + if (empty($date_range_arr[0])) { + return $this->settlement(); + } + $start_date = $date_range_arr[0][0]; + $end_date =$date_range_arr[0][1] . " 23:59:59"; + if ($end_date == null) { + $end_date = date("Y-m-d H:i:s", strtotime("+1 month", strtotime($start_date))-1); + } + $ret['default_date1'] = $start_date; + $ret['default_date2'] = $end_date; + $vendors = $this->input->post("vendors"); + $ret['default_vendor'] = $vendors; + $vendor_sourcetype = $this->trippest->vendor_sourcetype(); + // price [Trippest receipts & agency receipts] + $ret['price_error'] = $this->money_model->get_precheck_price_error($start_date, $end_date, implode(',' ,$vendors)); + // cost + $HT_combine_cost = $this->money_model->get_combine_cost($start_date, $end_date, implode(',' ,$vendors)); + $cost_error = array(); + $ht_no_match = array(); + $xls_no_match = array(); + // $config['upload_path'] = FCPATH.'download_statement\temp_files'; + $config['upload_path'] = 'download_statement/temp_files'; + // $config['file_name'] = "1.xls"; + $config['encrypt_name'] = true; + if ( ! is_dir($config['upload_path'])) { + mkdir($config['upload_path'], 0777, true); + } + $config['allowed_types'] = 'xls|xlsx'; + $config['max_size'] = 0; + $this->load->library('upload', $config); + if ( ! $this->upload->do_upload('upload_cost')) + { + $ret['error_msg'] = $this->upload->display_errors(); + } + else + { + $upload_data = array('upload_data' => $this->upload->data()); + $read_path = $upload_data['upload_data']['full_path']; + $xls_data=array(); + $this->load->library('PHPExcel'); + $PHPExcel = new PHPExcel(); + /**默认用excel2007读取excel,若格式不对,则用之前的版本进行读取*/ + $PHPReader = new PHPExcel_Reader_Excel2007(); + if(!$PHPReader->canRead($read_path)){ + $PHPReader = new PHPExcel_Reader_Excel5(); + if(!$PHPReader->canRead($read_path)){ + echo 'no Excel'; + return ; + } + } + $PHPExcel = $PHPReader->load($read_path); + /**读取excel文件中的第一个工作表*/ + $currentSheet = $PHPExcel->getSheet(0); + /**取得最大的列号*/ + // $allColumn = $currentSheet->getHighestColumn(); + $allColumn = 'B'; + /**取得一共有多少行*/ + $allRow = $currentSheet->getHighestRow(); + $col_titles = array('A' => 'group_name', 'B' => 'group_cost'); + /**从第3行开始输出,因为excel表中第一行为列名*/ + for($currentRow = 3;$currentRow <= $allRow;$currentRow++){ + $row_tmp = array(); + /**从第A列开始输出*/ + for($currentColumn= 'A';$currentColumn<= $allColumn; $currentColumn++){ + /**ord()将字符转为十进制数*/ + $val = $currentSheet->getCellByColumnAndRow(ord($currentColumn) - 65,$currentRow)->getValue(); + $col_mean = $col_titles[$currentColumn]; + $row_tmp[$col_mean] = $val; + } + if (isset($row_tmp['group_name']) && !empty($row_tmp['group_name'])) { + $xls_data[] = $row_tmp; + } + } + $all_xls_group_name = array_column($xls_data, 'group_name'); + $all_ht_group_no = array_column($HT_combine_cost, 'GCI_combineNo'); + $not_in_ht = array_diff($all_xls_group_name, $all_ht_group_no); + $not_in_xls = array_diff($all_ht_group_no, $all_xls_group_name); + foreach ($HT_combine_cost as $kht => $ht_cost) { + if (in_array($ht_cost['GCI_combineNo'], $not_in_xls) + && !in_array(strtolower($ht_cost['GCI_combineNo']),array('cancel', 'forbidden')) + ) { + $ht_no_match[] = $ht_cost; + } + foreach ($xls_data as $kxls => $xls_cost) { + if ($xls_cost['group_name'] == $ht_cost['GCI_combineNo'] + && strval($ht_cost['cost']) != strval($xls_cost['group_cost']) + ) { + $cost_error[] = array_merge($ht_cost, $xls_cost); + } + } + } + foreach ($xls_data as $kxls => $xls_cost) { + if (in_array($xls_cost['group_name'], $not_in_ht)) { + $xls_no_match[] = $xls_cost; + } + } + unlink($upload_data['upload_data']['full_path']); + } + $ret['cost_error'] = $cost_error; + $ret['ht_no_match'] = $ht_no_match; + $ret['xls_no_match'] = $xls_no_match; + return $this->load->view('order_report_precheck', $ret); + } + } /* End of file vendor_money.php */ diff --git a/webht/third_party/trippestOrderSync/models/vendor_money_model.php b/webht/third_party/trippestOrderSync/models/vendor_money_model.php index 6831d222..b4a901d4 100644 --- a/webht/third_party/trippestOrderSync/models/vendor_money_model.php +++ b/webht/third_party/trippestOrderSync/models/vendor_money_model.php @@ -326,6 +326,113 @@ class Vendor_money_model extends CI_Model { return $query->result_array(); } + public function get_combine_cost($start_date, $end_date, $all_vendor) + { + $sql = "SELECT group_cost.GCI_VEI_SN vendor_code,GCI_combineNo, + (SELECT isnull(SUM(CONVERT(float, isnull(gcod.GCOD_sumMoney,0))),0) + FROM GroupCombineOperationDetail gcod + WHERE gcod.GCOD_GCI_combineNo=GCI_combineNo + AND gcod.GCOD_operationType<> 'otherReceives' + ) AS cost + FROM + (SELECT DISTINCT isnull(gci.GCI_combineNo,'1') GCI_combineNo, + GCI_VEI_SN + FROM GroupCombineInfo gci + WHERE 1=1 + AND GCI_VEI_SN IN ($all_vendor) + AND EXISTS + ( SELECT 1 + FROM CK_GroupInfo + WHERE CGI_Checked=1 + AND CGI_GRI_SN=GCI_GRI_SN + AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date') + ) AS group_cost + order by GCI_combineNo desc"; + $query = $this->HT->query($sql); + return $query->result_array(); + } + + public function get_precheck_price_error($start_date, $end_date, $all_vendor) + { + $sql = "SELECT + data_tmp.TLD_total_price-(HT_haina_receipt+HT_agency_receipt) as 'total_price_err', --总团款差额 (账单减HT)', + case data_tmp.COLI_OPI_ID when 435 + then data_tmp.TLD_total_price-HT_agency_receipt + else data_tmp.TLD_agency_receipt-HT_agency_receipt + end as 'agency_receipt_err', --地接代收差额 (账单减HT)', + case data_tmp.COLI_OPI_ID when 435 + then TLD_total_price-HT_agency_receipt + else TLD_total_price-TLD_agency_receipt-HT_haina_receipt + end as 'HT_receipt_err' --海纳收差额 (账单减HT)' + ,(select top 1 GCI_combineNo from groupcombineinfo where gci_gri_sn=data_tmp.GRI_SN) as combineNo + ,* from + ( + select + gri.GRI_Name, + (select isnull(SUM(cast(GCI_priceCNY as decimal(10,2))),0) from GroupCombineInfo where GCI_GRI_SN=COLI_GRI_SN) as TLD_total_price, + (select isnull(SUM(cast(GCI_agencyReceipt as decimal(10,2))),0) from GroupCombineInfo where GCI_GRI_SN=COLI_GRI_SN) as TLD_agency_receipt, + (select isnull(SUM(cast(GAI_SSJE as decimal(10,2))),0) from BIZ_GroupAccountInfo where GAI_COLI_SN=COLI_SN + and GAI_Type in (" . PAY_OTHER . ") + and GAI_VEI_SN in ($all_vendor) + and DeleteFlag=0 + ) as HT_agency_receipt, + (select isnull(SUM(cast(GAI_SSJE as decimal(10,2))),0) from BIZ_GroupAccountInfo where GAI_COLI_SN=COLI_SN + and GAI_Type not in (" . PAY_OTHER . ") + and DeleteFlag=0 + --and isnull(GAI_VEI_SN,0) in (0,) + ) as HT_haina_receipt, + (select isnull(SUM(tourcost),0) from report_tour + inner join BIZ_ConfirmLineDetail on COLD_SN=RPT_COLD_SN and COLD_PlanVEI_SN in ($all_vendor) + where ordernumber=COLI_ID ) AS cost + ,coli.COLI_OPI_ID + ,gri.GRI_SN + --,* + from + --CK_GroupInfo cgi inner join + GRoupInfo gri --on CGI_GRI_SN=GRI_SN + inner join BIZ_ConfirmLineInfo coli on COLI_GRI_SN=GRI_SN + inner join report_order ro on ro.ordernumber=COLI_ID + where 1=1 + --and CGI_ArriveDate BETWEEN '$start_date' and '$end_date' + and exists ( + select 1 from OperatorInfo where OPI_DEI_SN=30 and OPI_SN=COLI_OPI_ID + ) + and ro.orderstats=1 + and GRI_OrderType=227002 + and exists ( + select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=coli.COLI_SN + and DeleteFlag=0 + and COLD_PlanVEI_SN in ($all_vendor) + and COLD_StartDate BETWEEN '$start_date' and '$end_date' + ) + ) as data_tmp + where 1=1 + -- 总团款不相等 + and data_tmp.TLD_total_price-(HT_haina_receipt+HT_agency_receipt)<>0 + -- 地接代收不相等:同步 + OR ( + data_tmp.COLI_OPI_ID=435 and HT_haina_receipt<>0 and TLD_agency_receipt<>0 + and data_tmp.TLD_total_price-HT_agency_receipt<>0 + ) + -- 地接代收不相等:自营 + OR ( + data_tmp.COLI_OPI_ID<>435 --and HT_haina_receipt<>0 and TLD_agency_receipt<>0 + and data_tmp.TLD_agency_receipt-HT_agency_receipt<>0 + ) + -- 海纳收不相等:同步 + OR ( + data_tmp.COLI_OPI_ID=435 + and (HT_haina_receipt<>0 or TLD_total_price-HT_agency_receipt<>0) + ) + -- 海纳收不相等:自营 + OR ( + data_tmp.COLI_OPI_ID<>435 + and TLD_total_price-TLD_agency_receipt-HT_haina_receipt<>0 + )"; + $query = $this->HT->query($sql); + return $query->result_array(); + } + } /* End of file vendor_money.php */ diff --git a/webht/third_party/trippestOrderSync/views/order_report_precheck.php b/webht/third_party/trippestOrderSync/views/order_report_precheck.php new file mode 100644 index 00000000..f9a20b77 --- /dev/null +++ b/webht/third_party/trippestOrderSync/views/order_report_precheck.php @@ -0,0 +1,197 @@ + + + + + Trippest & 地接账单预审核 + + + + + + + + + + + + + + +
+

+
+
+ +
+ + + + +
+
+
+ +
+ +
+
+ +
+
+ + + ( 务必上传与所选 [ 发团日期 ,地接社 ]相对应的成本文件. ) +
+
+
+

+ + + + + + + + + + + + + + + + + + + + $ep) { ?> + + + + + + + + + + + + + +
团款异常:
HT团号拼团号 + 总团款差额 +

= 账单总团款 - ( HT收款 + HT代收 )

+
+ 地接代收差额 +

= 账单代收 - HT代收

+
+ 海纳收差额 +

= 账单收款 - HT收款

+
账单:总团款账单:地接代收HT:海纳收款HT:地接代收
+ + +
+ + +

+ + + + + + + + + + + + + + + $ec) { ?> + + + + + + + $ht) { ?> + + + + + + + $xls) { ?> + + + + + + + +
成本异常:
拼团号HT成本账单成本
未找到
未找到
+ +
+ + + + + + diff --git a/webht/third_party/trippestOrderSync/views/vendor_money_sum.php b/webht/third_party/trippestOrderSync/views/vendor_money_sum.php index 13ce8818..45ed8b27 100644 --- a/webht/third_party/trippestOrderSync/views/vendor_money_sum.php +++ b/webht/third_party/trippestOrderSync/views/vendor_money_sum.php @@ -40,6 +40,7 @@

Trippest & 地接账单结算

+ 预审核»