From 233ff82e2de8f96447137dcf5955b45d1e1f404e Mon Sep 17 00:00:00 2001 From: lyt Date: Mon, 9 Sep 2019 17:58:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20iPaylinks=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E8=AE=B0=E5=BD=95=E5=BD=95=E5=85=A5=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F,=20=E4=B8=BA=E4=BA=86=E8=A7=A3=E5=86=B3=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E6=B2=A1=E6=9C=89=E6=8E=A5=E6=94=B6=E5=88=B0?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E9=80=9A=E7=9F=A5=E6=97=B6=E7=9A=84=E7=B4=A7?= =?UTF-8?q?=E6=80=A5=E8=AE=A2=E5=8D=95=E5=BD=95=E5=85=A5.=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E6=83=85=E5=86=B5=E4=B8=8D=E4=BD=BF=E7=94=A8=E6=AD=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/third_party/pay/controllers/report.php | 126 ++++++++++++++++--- 1 file changed, 108 insertions(+), 18 deletions(-) diff --git a/webht/third_party/pay/controllers/report.php b/webht/third_party/pay/controllers/report.php index 2a99cc1b..9b3d8202 100644 --- a/webht/third_party/pay/controllers/report.php +++ b/webht/third_party/pay/controllers/report.php @@ -168,6 +168,7 @@ class Report extends CI_Controller public function ipaylinks_excel() { $this->load->model('IPayLinks_model'); + $this->load->model('Note_model'); set_time_limit(0); // 解析excel $target_folder = $this->input->get_post("f"); @@ -175,6 +176,9 @@ class Report extends CI_Controller log_message('error','ipaylinks excel POST: ' . $target_folder . $this->input->get_post("fjson")); $statement_folder = FCPATH.'download_statement\statement_files\\' . $target_folder; if ( ! is_dir($statement_folder)) { + + log_message('error','is not dir' . $statement_folder); + return; } $files = $files ? $files : array_values(array_diff(scandir($statement_folder), array('.', '..'))); @@ -195,6 +199,7 @@ class Report extends CI_Controller continue; } $settlement_record = $this->read_ipaylinks_excel($file_path); + if (empty($settlement_record)) { continue; } @@ -208,24 +213,40 @@ class Report extends CI_Controller $old_info = $this->IPayLinks_model->get_money_t(trim($settle['pn_invoice'])); } } - $warrant["PR_AccreditNo"] = trim($settle['pn_invoice']); - $warrant["PR_payType"] = 15018; - $warrant["PR_entryCurrency"] = trim($settle['entry_currency']); - $warrant["PR_entryAmount"] = bcadd(floatval($settle['entry_security']), floatval($settle['entry_basic'])); - $warrant["PR_COLI_SN"] = !empty($old_info) ? $old_info[0]->GAI_COLI_SN : NULL; - $warrant["PR_currency"] = trim($settle['currency']); - $warrant["PR_amount"] = trim($settle['order_amount']); - $warrant["PR_orderType"] = $orderid_info ? $orderid_info->ordertype : NULL; - $warrant["PR_fee"] = bcadd(trim($settle['service_fee']), trim($settle['transaction_fee'])); - $warrant["PR_paymentTime"] = trim($settle['complete_date']); - $warrant["PR_dealType"] = trim($settle['data_type']); - $warrant["PR_orderId"] = trim($settle['orderid']); - $warrant["PR_rate"] = trim($settle['settlement_rate']); - $warrant["PR_status"] = ""; - $warrant["PR_buyerName"] = ""; - $warrant["PR_buyerEmail"] = ""; - $this->Report_model->new_report($warrant); - $warrant = NULL; + $this->Note_model->save_ipl( + strval(trim($settle['pn_invoice'])) + ,strval(trim($settle['orderid'])) + ,strval(trim($settle['currency'])) + ,strval($settle['payment_type'])=="消费" ? strval(trim($settle['order_amount'])) : "-".$settle['order_amount'] + ,NULL + ,NULL + ,strval(trim($settle['complete_date'])) + ,strval(trim($settle['complete_date'])) + ,json_encode($settle) + ,strval($settle['payment_type'])=="消费" ? "pay" : "refund" + ,"0000" + ,"" + ,strval(substr($settle["payer"],0,49)) + ,strval($settle["email"]) + ); + // $warrant["PR_AccreditNo"] = trim($settle['pn_invoice']); + // $warrant["PR_payType"] = 15018; + // $warrant["PR_entryCurrency"] = trim($settle['entry_currency']); + // $warrant["PR_entryAmount"] = bcadd(floatval($settle['entry_security']), floatval($settle['entry_basic'])); + // $warrant["PR_COLI_SN"] = !empty($old_info) ? $old_info[0]->GAI_COLI_SN : NULL; + // $warrant["PR_currency"] = trim($settle['currency']); + // $warrant["PR_amount"] = trim($settle['order_amount']); + // $warrant["PR_orderType"] = $orderid_info ? $orderid_info->ordertype : NULL; + // $warrant["PR_fee"] = bcadd(trim($settle['service_fee']), trim($settle['transaction_fee'])); + // $warrant["PR_paymentTime"] = trim($settle['complete_date']); + // $warrant["PR_dealType"] = trim($settle['data_type']); + // $warrant["PR_orderId"] = trim($settle['orderid']); + // $warrant["PR_rate"] = trim($settle['settlement_rate']); + // $warrant["PR_status"] = ""; + // $warrant["PR_buyerName"] = ""; + // $warrant["PR_buyerEmail"] = ""; + // $this->Report_model->new_report($warrant); + // $warrant = NULL; $update_cnt++; } $settlement_record = null; // reset @@ -260,6 +281,60 @@ class Report extends CI_Controller /**取得最大的列号*/ $allColumn = $currentSheet->getHighestColumn(); + /**取得一共有多少行*/ + $allRow = $currentSheet->getHighestRow(); + $col_titles = $this->ipaylinks_col_title(); + /**从第二行开始输出,因为excel表中第一行为列名*/ + for($currentRow = 2;$currentRow <= $allRow;$currentRow++){ + $row_tmp = array(); + /**从第A列开始输出*/ + for($currentColumn= 'A';$currentColumn<= "Z"; $currentColumn++){ + /**ord()将字符转为十进制数*/ + $val = trim($currentSheet->getCellByColumnAndRow(ord($currentColumn) - 65,$currentRow)->getValue()); + if ( ! isset($col_titles[$currentColumn])) { + continue; + } + $col_mean = $col_titles[$currentColumn]; + if($col_mean == 'data_type' && in_array($val, $this->ipaylinks_noStore_dealType()) ) // strcasecmp('清算', $val) !== 0 + { + break; + } + if ($col_mean == 'orderid' && strcasecmp('-', $val) === 0) { + break; + } + $row_tmp[$col_mean] = $val; + } + if ($row_tmp['payment_type']!='消费') { + $row_tmp['orderid']=$row_tmp['raw_order']; + } + if (isset($row_tmp['order_amount'])) { + $tarr1[] = $row_tmp; + } + } + return $tarr1; + } + + public function read_ipaylinks_excel2($filePath) + { + $tarr1=array(); + $this->load->library('PHPExcel'); + $PHPExcel = new PHPExcel(); + /**默认用excel2007读取excel,若格式不对,则用之前的版本进行读取*/ + $PHPReader = new PHPExcel_Reader_Excel2007(); + if(!$PHPReader->canRead($filePath)){ + $PHPReader = new PHPExcel_Reader_Excel5(); + if(!$PHPReader->canRead($filePath)){ + echo 'no Excel'; + return ; + } + } + $PHPExcel = $PHPReader->load($filePath); + /**读取excel文件中的第一个工作表*/ + $currentSheet = $PHPExcel->getSheet(0); + + /**取得最大的列号*/ + $allColumn = $currentSheet->getHighestColumn(); + /**取得一共有多少行*/ $allRow = $currentSheet->getHighestRow(); $col_titles = $this->ipaylinks_col_title(); @@ -287,6 +362,21 @@ class Report extends CI_Controller return $tarr1; } public function ipaylinks_col_title() + { + return array( + "A" => "orderid", + "B" => "pn_invoice", + "C" => "complete_date", + "D" => "require_date", + "E" => "currency", + "F" => "order_amount", + "H" => "payer", + "M" => "raw_order", + "N" => "payment_type", + "R" => "email" + ); + } + public function ipaylinks_col_title2() { return array( "A" => "complete_date", From d24f215a3938aa8e2890a82a64a3835a23d3ad71 Mon Sep 17 00:00:00 2001 From: lyt Date: Mon, 9 Sep 2019 18:00:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=89=88=E6=9C=AC:=20?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E4=B8=AA=E7=89=88=E6=9C=AC=E4=BB=85=E5=81=9A?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E5=8A=9F=E8=83=BD=E7=9A=84=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/third_party/pay/controllers/report.php | 126 +++---------------- 1 file changed, 18 insertions(+), 108 deletions(-) diff --git a/webht/third_party/pay/controllers/report.php b/webht/third_party/pay/controllers/report.php index 9b3d8202..2a99cc1b 100644 --- a/webht/third_party/pay/controllers/report.php +++ b/webht/third_party/pay/controllers/report.php @@ -168,7 +168,6 @@ class Report extends CI_Controller public function ipaylinks_excel() { $this->load->model('IPayLinks_model'); - $this->load->model('Note_model'); set_time_limit(0); // 解析excel $target_folder = $this->input->get_post("f"); @@ -176,9 +175,6 @@ class Report extends CI_Controller log_message('error','ipaylinks excel POST: ' . $target_folder . $this->input->get_post("fjson")); $statement_folder = FCPATH.'download_statement\statement_files\\' . $target_folder; if ( ! is_dir($statement_folder)) { - - log_message('error','is not dir' . $statement_folder); - return; } $files = $files ? $files : array_values(array_diff(scandir($statement_folder), array('.', '..'))); @@ -199,7 +195,6 @@ class Report extends CI_Controller continue; } $settlement_record = $this->read_ipaylinks_excel($file_path); - if (empty($settlement_record)) { continue; } @@ -213,40 +208,24 @@ class Report extends CI_Controller $old_info = $this->IPayLinks_model->get_money_t(trim($settle['pn_invoice'])); } } - $this->Note_model->save_ipl( - strval(trim($settle['pn_invoice'])) - ,strval(trim($settle['orderid'])) - ,strval(trim($settle['currency'])) - ,strval($settle['payment_type'])=="消费" ? strval(trim($settle['order_amount'])) : "-".$settle['order_amount'] - ,NULL - ,NULL - ,strval(trim($settle['complete_date'])) - ,strval(trim($settle['complete_date'])) - ,json_encode($settle) - ,strval($settle['payment_type'])=="消费" ? "pay" : "refund" - ,"0000" - ,"" - ,strval(substr($settle["payer"],0,49)) - ,strval($settle["email"]) - ); - // $warrant["PR_AccreditNo"] = trim($settle['pn_invoice']); - // $warrant["PR_payType"] = 15018; - // $warrant["PR_entryCurrency"] = trim($settle['entry_currency']); - // $warrant["PR_entryAmount"] = bcadd(floatval($settle['entry_security']), floatval($settle['entry_basic'])); - // $warrant["PR_COLI_SN"] = !empty($old_info) ? $old_info[0]->GAI_COLI_SN : NULL; - // $warrant["PR_currency"] = trim($settle['currency']); - // $warrant["PR_amount"] = trim($settle['order_amount']); - // $warrant["PR_orderType"] = $orderid_info ? $orderid_info->ordertype : NULL; - // $warrant["PR_fee"] = bcadd(trim($settle['service_fee']), trim($settle['transaction_fee'])); - // $warrant["PR_paymentTime"] = trim($settle['complete_date']); - // $warrant["PR_dealType"] = trim($settle['data_type']); - // $warrant["PR_orderId"] = trim($settle['orderid']); - // $warrant["PR_rate"] = trim($settle['settlement_rate']); - // $warrant["PR_status"] = ""; - // $warrant["PR_buyerName"] = ""; - // $warrant["PR_buyerEmail"] = ""; - // $this->Report_model->new_report($warrant); - // $warrant = NULL; + $warrant["PR_AccreditNo"] = trim($settle['pn_invoice']); + $warrant["PR_payType"] = 15018; + $warrant["PR_entryCurrency"] = trim($settle['entry_currency']); + $warrant["PR_entryAmount"] = bcadd(floatval($settle['entry_security']), floatval($settle['entry_basic'])); + $warrant["PR_COLI_SN"] = !empty($old_info) ? $old_info[0]->GAI_COLI_SN : NULL; + $warrant["PR_currency"] = trim($settle['currency']); + $warrant["PR_amount"] = trim($settle['order_amount']); + $warrant["PR_orderType"] = $orderid_info ? $orderid_info->ordertype : NULL; + $warrant["PR_fee"] = bcadd(trim($settle['service_fee']), trim($settle['transaction_fee'])); + $warrant["PR_paymentTime"] = trim($settle['complete_date']); + $warrant["PR_dealType"] = trim($settle['data_type']); + $warrant["PR_orderId"] = trim($settle['orderid']); + $warrant["PR_rate"] = trim($settle['settlement_rate']); + $warrant["PR_status"] = ""; + $warrant["PR_buyerName"] = ""; + $warrant["PR_buyerEmail"] = ""; + $this->Report_model->new_report($warrant); + $warrant = NULL; $update_cnt++; } $settlement_record = null; // reset @@ -281,60 +260,6 @@ class Report extends CI_Controller /**取得最大的列号*/ $allColumn = $currentSheet->getHighestColumn(); - /**取得一共有多少行*/ - $allRow = $currentSheet->getHighestRow(); - $col_titles = $this->ipaylinks_col_title(); - /**从第二行开始输出,因为excel表中第一行为列名*/ - for($currentRow = 2;$currentRow <= $allRow;$currentRow++){ - $row_tmp = array(); - /**从第A列开始输出*/ - for($currentColumn= 'A';$currentColumn<= "Z"; $currentColumn++){ - /**ord()将字符转为十进制数*/ - $val = trim($currentSheet->getCellByColumnAndRow(ord($currentColumn) - 65,$currentRow)->getValue()); - if ( ! isset($col_titles[$currentColumn])) { - continue; - } - $col_mean = $col_titles[$currentColumn]; - if($col_mean == 'data_type' && in_array($val, $this->ipaylinks_noStore_dealType()) ) // strcasecmp('清算', $val) !== 0 - { - break; - } - if ($col_mean == 'orderid' && strcasecmp('-', $val) === 0) { - break; - } - $row_tmp[$col_mean] = $val; - } - if ($row_tmp['payment_type']!='消费') { - $row_tmp['orderid']=$row_tmp['raw_order']; - } - if (isset($row_tmp['order_amount'])) { - $tarr1[] = $row_tmp; - } - } - return $tarr1; - } - - public function read_ipaylinks_excel2($filePath) - { - $tarr1=array(); - $this->load->library('PHPExcel'); - $PHPExcel = new PHPExcel(); - /**默认用excel2007读取excel,若格式不对,则用之前的版本进行读取*/ - $PHPReader = new PHPExcel_Reader_Excel2007(); - if(!$PHPReader->canRead($filePath)){ - $PHPReader = new PHPExcel_Reader_Excel5(); - if(!$PHPReader->canRead($filePath)){ - echo 'no Excel'; - return ; - } - } - $PHPExcel = $PHPReader->load($filePath); - /**读取excel文件中的第一个工作表*/ - $currentSheet = $PHPExcel->getSheet(0); - - /**取得最大的列号*/ - $allColumn = $currentSheet->getHighestColumn(); - /**取得一共有多少行*/ $allRow = $currentSheet->getHighestRow(); $col_titles = $this->ipaylinks_col_title(); @@ -362,21 +287,6 @@ class Report extends CI_Controller return $tarr1; } public function ipaylinks_col_title() - { - return array( - "A" => "orderid", - "B" => "pn_invoice", - "C" => "complete_date", - "D" => "require_date", - "E" => "currency", - "F" => "order_amount", - "H" => "payer", - "M" => "raw_order", - "N" => "payment_type", - "R" => "email" - ); - } - public function ipaylinks_col_title2() { return array( "A" => "complete_date", From cbbf93c03abd562804ad4be68cd953f8641aff3b Mon Sep 17 00:00:00 2001 From: lyt Date: Thu, 12 Sep 2019 15:48:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20iPaylinks=20refund=20APP=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webht/third_party/pay/controllers/iPayLinksService.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webht/third_party/pay/controllers/iPayLinksService.php b/webht/third_party/pay/controllers/iPayLinksService.php index a92a29d0..b80ba304 100644 --- a/webht/third_party/pay/controllers/iPayLinksService.php +++ b/webht/third_party/pay/controllers/iPayLinksService.php @@ -604,7 +604,7 @@ class IPayLinksService extends CI_Controller // APP 组的退款查不到原始收款记录 $pure_orderid = strstr($parent_order,"_",true); $pure_orderid = $pure_orderid===false ? $parent_order : $pure_orderid; - if (empty($parent_note) && true === $this->IPayLinks_model->if_APP_order($pure_orderid) ) { + if (true === $this->IPayLinks_model->if_APP_order($pure_orderid) ) { $parent_note = $parent_payment; // 补充字段 $parent_note->IPL_orderId = $parent_order . '_B'; @@ -903,12 +903,13 @@ class IPayLinksService extends CI_Controller bcscale(2); /** 退款成功 */ if (isset($asyns_resp->data->refundOrderId) && strcmp($asyns_resp->data->resultCode, '2') == 0) { + $notice_time = $asyns_resp->data->completeTime=='' ? time() : strtotime($asyns_resp->data->completeTime); $this->Note_model->save_refund( strval($asyns_resp->data->dealId) , strval($asyns_resp->data->orderId) , strval("-" . bcdiv(floatval($asyns_resp->data->refundAmount), 100)) , strval(date('Y-m-d H:i:s',strtotime($asyns_resp->data->refundTime))) - , strval(date('Y-m-d H:i:s',strtotime($asyns_resp->data->completeTime))) + , strval(date('Y-m-d H:i:s',$notice_time)) , $asyns_resp->data->resultCode , null , json_encode($asyns_resp->data)