|
|
|
|
@ -93,7 +93,6 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
public function alipay_notice()
|
|
|
|
|
{
|
|
|
|
|
$resp_arr = $this->input->post();
|
|
|
|
|
log_message('error','Alipay Original Notice :'.json_encode($resp_arr));
|
|
|
|
|
$asyns_resp = $this->check($resp_arr);
|
|
|
|
|
// 未得到结果
|
|
|
|
|
if (empty($asyns_resp->data->out_trade_no)) {
|
|
|
|
|
@ -124,16 +123,16 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
,$buyer
|
|
|
|
|
);
|
|
|
|
|
// 查询payer
|
|
|
|
|
$this->AlipayTradeQueryContentBuilder->setTradeNo($asyns_resp->data->trade_no);
|
|
|
|
|
if ($asyns_resp->data->out_trade_no) {
|
|
|
|
|
$this->AlipayTradeQueryContentBuilder->setOutTradeNo($asyns_resp->data->out_trade_no);
|
|
|
|
|
}
|
|
|
|
|
$response = $this->Query($this->AlipayTradeQueryContentBuilder);
|
|
|
|
|
$resp_arr = (Array) $response;
|
|
|
|
|
$query_resp = $this->check($resp_arr);
|
|
|
|
|
if (strcmp(strval($response->trade_status), "TRADE_SUCCESS") == 0) {
|
|
|
|
|
$this->Alipay_note_model->update_query($response->trade_no,$response->buyer_logon_id);
|
|
|
|
|
}
|
|
|
|
|
// $this->AlipayTradeQueryContentBuilder->setTradeNo($asyns_resp->data->trade_no);
|
|
|
|
|
// if ($asyns_resp->data->out_trade_no) {
|
|
|
|
|
// $this->AlipayTradeQueryContentBuilder->setOutTradeNo($asyns_resp->data->out_trade_no);
|
|
|
|
|
// }
|
|
|
|
|
// $response = $this->Query($this->AlipayTradeQueryContentBuilder);
|
|
|
|
|
// $resp_arr = (Array) $response;
|
|
|
|
|
// $query_resp = $this->check($resp_arr);
|
|
|
|
|
// if (strcmp(strval($response->trade_status), "TRADE_SUCCESS") == 0) {
|
|
|
|
|
// $this->Alipay_note_model->update_query($response->trade_no,$response->buyer_logon_id);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
// 返回状态码200
|
|
|
|
|
echo "success";
|
|
|
|
|
@ -269,17 +268,17 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
function aopclientRequestExecute($request,$ispage=false) {
|
|
|
|
|
|
|
|
|
|
$aop = new AopClient ();
|
|
|
|
|
$aop->gatewayUrl = $this->gateway_url;
|
|
|
|
|
$aop->appId = $this->appid;
|
|
|
|
|
$aop->rsaPrivateKey = $this->private_key;
|
|
|
|
|
$aop->gatewayUrl = $this->gateway_url;
|
|
|
|
|
$aop->appId = $this->appid;
|
|
|
|
|
$aop->rsaPrivateKey = $this->private_key;
|
|
|
|
|
$aop->alipayrsaPublicKey = $this->alipay_public_key;
|
|
|
|
|
$aop->apiVersion ="1.0";
|
|
|
|
|
$aop->postCharset = $this->charset;
|
|
|
|
|
$aop->format= $this->format;
|
|
|
|
|
$aop->signType=$this->signtype;
|
|
|
|
|
$aop->apiVersion = "1.0";
|
|
|
|
|
$aop->postCharset = $this->charset;
|
|
|
|
|
$aop->format = $this->format;
|
|
|
|
|
$aop->signType = $this->signtype;
|
|
|
|
|
// 开启页面信息输出
|
|
|
|
|
$aop->debugInfo=true;
|
|
|
|
|
$result = null;
|
|
|
|
|
$aop->debugInfo = true;
|
|
|
|
|
$result = null;
|
|
|
|
|
if($ispage)
|
|
|
|
|
{
|
|
|
|
|
$result = $aop->pageExecute($request,"post");
|
|
|
|
|
@ -290,8 +289,6 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
$result = $aop->Execute($request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 打开后,将报文写入log文件 cht test
|
|
|
|
|
// log_message('error',"\r\n\r\nResponse: \r\n".var_export($result,true));
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -465,32 +462,9 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
$request = new AlipayTradeQueryRequest();
|
|
|
|
|
$request->setBizContent ( $biz_content );
|
|
|
|
|
|
|
|
|
|
$response = $this->aopclientRequestExecute ($request);
|
|
|
|
|
$response = $this->aopclientRequestExecute ($request,true);
|
|
|
|
|
$response = $response->alipay_trade_query_response;
|
|
|
|
|
|
|
|
|
|
// test asyns
|
|
|
|
|
// $resp_arr = (Array) $response;
|
|
|
|
|
// $asyns_resp = $this->check($resp_arr);
|
|
|
|
|
// if (strcmp(strval($response->trade_status), "TRADE_SUCCESS") == 0) {
|
|
|
|
|
// $this->Alipay_note_model->save_alipay(
|
|
|
|
|
// strval($response->trade_no)
|
|
|
|
|
// ,strval($response->out_trade_no)
|
|
|
|
|
// ,"CNY"
|
|
|
|
|
// ,strval($response->total_amount)
|
|
|
|
|
// ,NULL
|
|
|
|
|
// ,NULL
|
|
|
|
|
// ,strval($response->send_pay_date)
|
|
|
|
|
// ,strval($response->send_pay_date)
|
|
|
|
|
// ,json_encode($response)
|
|
|
|
|
// ,strval("pay")
|
|
|
|
|
// ,strval($response->code)
|
|
|
|
|
// ,strval($response->trade_status)
|
|
|
|
|
// ,NULL
|
|
|
|
|
// ,strval($response->buyer_logon_id)
|
|
|
|
|
// );
|
|
|
|
|
// $query = $this->query_pay_result($asyns_resp->data);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -513,6 +487,33 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 对账单
|
|
|
|
|
* 流程:
|
|
|
|
|
* * 获取对账单下载地址
|
|
|
|
|
* * 下载对账单
|
|
|
|
|
* * 解压,获取明细表
|
|
|
|
|
* * 分析明细表,入库
|
|
|
|
|
* @author LYT <lyt@hainatravel.com>
|
|
|
|
|
* @date 2017-10-10
|
|
|
|
|
* @param [type] $date 按天yyyy-MM-dd;按月yyyy-MM
|
|
|
|
|
*/
|
|
|
|
|
public function get_billfile($date=NULL)
|
|
|
|
|
{
|
|
|
|
|
$request = new AlipayDataDataserviceBillDownloadurlQueryRequest();
|
|
|
|
|
$request->setBizContent("{" .
|
|
|
|
|
"\"bill_type\":\"trade\"," .
|
|
|
|
|
"\"bill_date\":\"2017-09\"" .
|
|
|
|
|
"}");
|
|
|
|
|
$response = $this->aopclientRequestExecute ($request);
|
|
|
|
|
// var_dump($response);
|
|
|
|
|
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
|
|
|
|
|
var_dump($response->$responseNode);
|
|
|
|
|
// $resultCode = $result->$responseNode->code;
|
|
|
|
|
// if(!empty($resultCode)&&$resultCode == 10000){
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验签方法
|
|
|
|
|
* @param $arr 验签支付宝返回的信息,使用支付宝公钥。
|
|
|
|
|
@ -527,8 +528,7 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
|
|
|
|
|
$aop = new AopClient();
|
|
|
|
|
$aop->alipayrsaPublicKey = $this->alipay_public_key;
|
|
|
|
|
// $ret->check = $result = $aop->rsaCheckV1($arr, $this->alipay_public_key, $this->signtype);
|
|
|
|
|
$ret->check = $result = true;
|
|
|
|
|
$ret->check = $result = $aop->rsaCheckV1($arr, $this->alipay_public_key, $this->signtype);
|
|
|
|
|
if ($result === false) {
|
|
|
|
|
log_message('error','Alipay sign ERROR ! orderId:'.$arr_obj->out_trade_no.'; dealId:'.$arr_obj->trade_no . "; Original return:".json_encode($arr)."; ");
|
|
|
|
|
return $ret;
|
|
|
|
|
|