wxpay:下载账单之后即调用通知处理

feature/pay
lyt 6 years ago
parent 11da5662e6
commit 263c4e97ba

@ -56,6 +56,7 @@ class PaymentService extends CI_Controller {
public function send_notify($opn_id=NULL, $old_ssje=NULL)
{
ignore_user_abort(true);
$output = "处理交易记录:<br>";
$data = array();
$show_index = 0;
//优先处理指定的交易号,用于修正交易号直接发送通知
@ -254,11 +255,12 @@ class PaymentService extends CI_Controller {
//显示处理记录
if (empty($opn_id)) {
echo ++$show_index . ' ' . $item->OPN_transactionId . '<br/>';
$output .= (++$show_index) . ' ' . $item->OPN_transactionId . '<br/>';
}
}
return;
echo $output;
return $output;
// return $this->output->set_content_type('application/json')->set_output(json_encode($data));
}

@ -91,6 +91,7 @@ class WxpayService extends CI_Controller {
foreach ($all_account as $account) {
$this->download_bill($account);
}
async_curl("https://www.mycht.cn/webht.php/apps/pay/paymentservice/send_notify");
return;
}

@ -63,6 +63,45 @@ function getaqiMonth($url){
return false;
}
}
/*!
* @Author: LYT
* @Date: 2019-06-27 10:32:11
* @Desc: 异步的curl,1秒超时,被请求的地址需要设置: ignore_user_abort(true);
*/
function async_curl($url, $second = 1)
{
$ch = curl_init();
$curlVersion = curl_version();
$ua = "Webht (".PHP_OS.") PHP/".PHP_VERSION." CURL/".$curlVersion['version']." " . "AsyncJob";
//设置超时
curl_setopt($ch, CURLOPT_TIMEOUT, $second);
curl_setopt($ch,CURLOPT_URL, $url);
if(stripos($url,"https://")!==FALSE){
curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
} else {
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,TRUE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,2);//严格校验
}
curl_setopt($ch,CURLOPT_USERAGENT, $ua);
//设置header
curl_setopt($ch, CURLOPT_HEADER, FALSE);
//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//运行curl
$data = curl_exec($ch);
if (curl_errno($ch) && !in_array(curl_errno($ch),array(0,28)) ) {
log_message('error',"Webht Async Curl Call 出错,错误码:" . curl_errno($ch) . ": " . curl_error($ch) . ", url: " . $url);
}
if (!in_array(curl_getinfo($ch, CURLINFO_HTTP_CODE),array(0,200)) ) {
log_message('error', "Webht Async Curl Call Request html Status Code: ".curl_getinfo($ch, CURLINFO_HTTP_CODE)."; curl url: ".$url);
}
curl_close($ch);
return $data;
}
/*
* 把数组元素组合为字符串
* $container:用来包含元素的符号

@ -164,6 +164,7 @@ class Wxpay_call
log_message('error',"curl出错错误码:$error " . curl_error($ch));
curl_close($ch);
}
return;
}

Loading…
Cancel
Save