|
|
|
|
@ -340,7 +340,7 @@ class IPayLinksService extends CI_Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//退款状态默认为已经处理,陆燕在退款前手动通知外联了,系统跳过处理
|
|
|
|
|
if ($item->IPL_payType == 'Refunded') {
|
|
|
|
|
if ($item->IPL_payType == 'refund') {
|
|
|
|
|
$this->Note_model->update_send($item->IPL_dealId, 'send');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
@ -689,7 +689,7 @@ class IPayLinksService extends CI_Controller
|
|
|
|
|
* @date 2017-08-17
|
|
|
|
|
* @param mix $resp API返回的原始xml或异步返回的post数组
|
|
|
|
|
*/
|
|
|
|
|
protected function verify_sign($resp=NULL)
|
|
|
|
|
protected function verify_sign($resp=NULL, $sign=true)
|
|
|
|
|
{
|
|
|
|
|
$ret = new ArrayObject();
|
|
|
|
|
$ret->check = false;
|
|
|
|
|
@ -710,20 +710,21 @@ class IPayLinksService extends CI_Controller
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$rep_sign = $this->generate_sign((array)$respObject);
|
|
|
|
|
if (strcmp($rep_sign,$respObject->signMsg)) {
|
|
|
|
|
log_message('error','iPayLinks sign ERROR ! orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId . "; Original return:".$resp."; From: ".$ref);
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
// partnerId
|
|
|
|
|
if (strcmp($respObject->partnerId, $this->pay_info_arr['partnerId'])) {
|
|
|
|
|
log_message("error", " iPayLinks ERROR partnerId verify failed ".$respObject->partnerId." !== ".$this->pay_info_arr['partnerId'].'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$ref);
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
// resultCode payment failed
|
|
|
|
|
|
|
|
|
|
if (strcmp(strval($respObject->resultCode), "0000")) {
|
|
|
|
|
log_message('error',"iPayLinks payment failed! error code:".$respObject->resultCode."; result Msg: ".$respObject->resultMsg.'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$ref);
|
|
|
|
|
if ($sign === true) {
|
|
|
|
|
$rep_sign = $this->generate_sign((array)$respObject);
|
|
|
|
|
if (strcmp($rep_sign,$respObject->signMsg)) {
|
|
|
|
|
log_message('error','iPayLinks sign ERROR ! orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId . "; Original return:".$resp."; From: ".$ref);
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
// partnerId
|
|
|
|
|
if (strcmp($respObject->partnerId, $this->pay_info_arr['partnerId'])) {
|
|
|
|
|
log_message("error", " iPayLinks ERROR partnerId verify failed ".$respObject->partnerId." !== ".$this->pay_info_arr['partnerId'].'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$ref);
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
// resultCode payment failed
|
|
|
|
|
if (strcmp(strval($respObject->resultCode), "0000")) {
|
|
|
|
|
log_message('error',"iPayLinks payment failed! error code:".$respObject->resultCode."; result Msg: ".$respObject->resultMsg.'; orderId:'.$respObject->orderId.'; dealId:'.$respObject->dealId."; From: ".$ref);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$ret->check = true;
|
|
|
|
|
return $ret;
|
|
|
|
|
@ -776,7 +777,7 @@ class IPayLinksService extends CI_Controller
|
|
|
|
|
} else {
|
|
|
|
|
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
|
if (200 !== $httpStatusCode) {
|
|
|
|
|
log_message('error', " iPayLinks Request html Status Code: ".$error_message."; curl postBodyString: ".substr($postBodyString, 0, -1));
|
|
|
|
|
log_message('error', " iPayLinks Request html Status Code: ".$httpStatusCode."; curl postBodyString: ".substr($postBodyString, 0, -1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
@ -954,4 +955,91 @@ class IPayLinksService extends CI_Controller
|
|
|
|
|
var_dump($ssje);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 每天请求一次,批量取回退款记录保存
|
|
|
|
|
* @author LYT <lyt@hainatravel.com>
|
|
|
|
|
* @date 2017-11-06
|
|
|
|
|
*/
|
|
|
|
|
public function get_refund_list($daylength=3)
|
|
|
|
|
{
|
|
|
|
|
bcscale(2);
|
|
|
|
|
$ret = array();
|
|
|
|
|
$list = $this->refund_list_info($daylength);
|
|
|
|
|
foreach ($list as $key => $refund) {
|
|
|
|
|
if ($refund->stateCode == 1) continue;
|
|
|
|
|
$ret[] = $this->Note_model->save_refund(
|
|
|
|
|
strval($refund->dealId)
|
|
|
|
|
, strval($refund->orderId)
|
|
|
|
|
, strval("-" . bcdiv(floatval($refund->refundAmount), 100))
|
|
|
|
|
, strval(date('Y-m-d H:i:s',strtotime($refund->refundTime)))
|
|
|
|
|
, strval(date('Y-m-d H:i:s',strtotime($refund->completeTime)))
|
|
|
|
|
, $refund->stateCode
|
|
|
|
|
, "0000"
|
|
|
|
|
, json_encode($refund)
|
|
|
|
|
, "refund"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
echo "Got record count: " . count($ret);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 批量取回退款记录
|
|
|
|
|
* @author LYT <lyt@hainatravel.com>
|
|
|
|
|
* @date 2017-11-03
|
|
|
|
|
*/
|
|
|
|
|
public function refund_list_info($daylength)
|
|
|
|
|
{
|
|
|
|
|
$this->query_info_arr["queryOrderId"] = $this->create_guid();
|
|
|
|
|
$this->query_info_arr['mode'] = '2';
|
|
|
|
|
$this->query_info_arr['type'] = '2';
|
|
|
|
|
$this->query_info_arr["beginTime"] = date('Ymd000000', strtotime("-$daylength days"));
|
|
|
|
|
$this->query_info_arr["endTime"] = date('Ymd235959');
|
|
|
|
|
$this->query_info_arr["signMsg"] = $this->generate_sign($this->query_info_arr);
|
|
|
|
|
|
|
|
|
|
$resp = $this->curl($this->queryUrl,$this->query_info_arr);
|
|
|
|
|
|
|
|
|
|
$query_resp = $this->verify_sign($resp, false);
|
|
|
|
|
|
|
|
|
|
// 未得到结果
|
|
|
|
|
if (false === $query_resp->data) {
|
|
|
|
|
// echo "No record.";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$refund_list = $query_resp->data->refundDetails->detail;
|
|
|
|
|
foreach ($refund_list as $key => $refund) {
|
|
|
|
|
// 由于ipaylinks批量查询的bug,这里要用单笔查询校对
|
|
|
|
|
$this_info = $this->get_refund($refund->refundOrderId);
|
|
|
|
|
if ($this_info !== false) {
|
|
|
|
|
$refund->stateCode = $this_info->stateCode;
|
|
|
|
|
$refund->refundTime = $this_info->refundTime;
|
|
|
|
|
$refund->completeTime = $this_info->completeTime;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $refund_list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 单笔查询退款信息
|
|
|
|
|
* ipaylinks的批量查询有问题,所以这个需要用单笔查询确认信息
|
|
|
|
|
* @author LYT <lyt@hainatravel.com>
|
|
|
|
|
* @date 2017-11-06
|
|
|
|
|
* @param string $refund_order_id 退款信息中的refundOrderId
|
|
|
|
|
*/
|
|
|
|
|
public function get_refund($refund_order_id)
|
|
|
|
|
{
|
|
|
|
|
$this->query_info_arr["queryOrderId"] = $this->create_guid();
|
|
|
|
|
$this->query_info_arr["orderId"] = $refund_order_id;
|
|
|
|
|
$this->query_info_arr['mode'] = '1';
|
|
|
|
|
$this->query_info_arr['type'] = '2';
|
|
|
|
|
$this->query_info_arr["signMsg"] = $this->generate_sign($this->query_info_arr);
|
|
|
|
|
$resp = $this->curl($this->queryUrl,$this->query_info_arr);
|
|
|
|
|
$query_resp = $this->verify_sign($resp, false);
|
|
|
|
|
// 未得到结果
|
|
|
|
|
if (false === $query_resp->data) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return $query_resp->data->refundDetails->detail;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|