|
|
|
@ -833,11 +833,15 @@ class Index extends CI_Controller {
|
|
|
|
|
echo ++$show_index . ' ' . $item->pn_txn_id . '<br/>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$payment_fee = 0;
|
|
|
|
|
// webhook的跳过
|
|
|
|
|
$webhook_memo = json_decode($item->pn_memo);
|
|
|
|
|
$is_webhook = false;
|
|
|
|
|
if (isset($webhook_memo->id) && substr($webhook_memo->id, 0, 2)==="WH") {
|
|
|
|
|
$is_webhook = true;
|
|
|
|
|
$payment_fee = $webhook_memo->resource->transaction_fee->value;
|
|
|
|
|
} else {
|
|
|
|
|
$payment_fee = $webhook_memo->mc_fee;
|
|
|
|
|
}
|
|
|
|
|
if (empty($pn_txn_id) && true === $is_webhook) {
|
|
|
|
|
$this->Note_model->update_send($item->pn_txn_id, 'send-wh', $item->pn_sn);
|
|
|
|
@ -931,7 +935,7 @@ class Index extends CI_Controller {
|
|
|
|
|
|
|
|
|
|
// for trippest tourMaster 2018.05.28
|
|
|
|
|
if ($orderid_info->ordertype == 'TP') {
|
|
|
|
|
$this->trippest_note($orderid_info, $item);
|
|
|
|
|
$this->trippest_note($orderid_info, $item, $webhook_memo);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -953,7 +957,8 @@ class Index extends CI_Controller {
|
|
|
|
|
//添加支付信息入库
|
|
|
|
|
//没有分配订单之前先添加付款记录,这个过程可能会执行多次,必须在添加记录前查找是否有数据
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency));
|
|
|
|
|
// $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency));
|
|
|
|
|
$ssje = $this->Paypal_model->get_ssje_exclude_fee(bcsub($item->pn_mc_gross, $payment_fee), '15002', mb_strtoupper($item->pn_mc_currency));
|
|
|
|
|
$ssje = $old_ssje===NULL ? $ssje : $old_ssje;
|
|
|
|
|
$USD_amount = $this->Paypal_model->get_USD($item->pn_mc_gross, $item->pn_mc_currency);
|
|
|
|
|
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
|
|
|
|
@ -1051,8 +1056,9 @@ class Index extends CI_Controller {
|
|
|
|
|
*/
|
|
|
|
|
public function send_refund($item, $handpick, $old_ssje=NULL)
|
|
|
|
|
{
|
|
|
|
|
$payment_memo = json_decode($item->pn_memo);
|
|
|
|
|
// 找到原始收款交易的订单
|
|
|
|
|
$parent_txn_id = json_decode($item->pn_memo)->parent_txn_id;
|
|
|
|
|
$parent_txn_id = $payment_memo->parent_txn_id;
|
|
|
|
|
$parent_note = $this->Note_model->note($parent_txn_id);
|
|
|
|
|
if (empty($parent_note)) {
|
|
|
|
|
$this->Note_model->update_send($item->pn_txn_id, 'sendfail');
|
|
|
|
@ -1092,11 +1098,22 @@ class Index extends CI_Controller {
|
|
|
|
|
//更新正确的订单信息到记录中,以这个为主
|
|
|
|
|
$this->Note_model->set_invoice($item->pn_txn_id, $orderid_info->orderid . '_' . $orderid_info->ordertype);
|
|
|
|
|
}
|
|
|
|
|
$payment_fee = 0;
|
|
|
|
|
$refund_amount = 0;
|
|
|
|
|
if (isset($payment_memo->id) && substr($payment_memo->id, 0, 2)==="WH") {
|
|
|
|
|
$is_webhook = true;
|
|
|
|
|
$refund_amount = $payment_memo->refund_from_received_amount;
|
|
|
|
|
$payment_fee = $payment_memo->resource->refund_from_transaction_fee->value;
|
|
|
|
|
} else {
|
|
|
|
|
$refund_amount = bcsub($payment_memo->mc_gross, $payment_memo->mc_fee);
|
|
|
|
|
$payment_fee = $payment_memo->mc_fee;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//添加支付信息入库
|
|
|
|
|
//没有分配订单之前先添加付款记录,这个过程可能会执行多次,必须在添加记录前查找是否有数据
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency));
|
|
|
|
|
// $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency));
|
|
|
|
|
$ssje = $this->Paypal_model->get_ssje_exclude_fee($refund_amount, '15002', mb_strtoupper($item->pn_mc_currency));
|
|
|
|
|
$ssje = $old_ssje===NULL ? $ssje : $old_ssje;
|
|
|
|
|
$USD_amount = $this->Paypal_model->get_USD($item->pn_mc_gross, $item->pn_mc_currency);
|
|
|
|
|
//更新还没有填的客邮和交易号de收款记录(商务订单)
|
|
|
|
@ -1200,7 +1217,7 @@ class Index extends CI_Controller {
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function trippest_note($orderid_info, $paypal_msg)
|
|
|
|
|
public function trippest_note($orderid_info, $paypal_msg, $payment_memo)
|
|
|
|
|
{
|
|
|
|
|
$send_type = '';
|
|
|
|
|
$tp_orderid = '';
|
|
|
|
@ -1224,7 +1241,15 @@ class Index extends CI_Controller {
|
|
|
|
|
//更新正确的订单信息到记录中,以这个为主
|
|
|
|
|
$this->Note_model->set_invoice($paypal_msg->pn_txn_id, $ht_tp_order->COLI_ID . '_TP');
|
|
|
|
|
}
|
|
|
|
|
$ssje = $this->Paypal_model->get_ssje($paypal_msg->pn_mc_gross, '15002', mb_strtoupper($paypal_msg->pn_mc_currency));
|
|
|
|
|
$payment_fee = 0;
|
|
|
|
|
if (substr($payment_memo->id, 0, 2)==="WH") {
|
|
|
|
|
$payment_fee = $payment_memo->resource->transaction_fee->value;
|
|
|
|
|
} else {
|
|
|
|
|
$payment_fee = $payment_memo->mc_fee;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// $ssje = $this->Paypal_model->get_ssje($paypal_msg->pn_mc_gross, '15002', mb_strtoupper($paypal_msg->pn_mc_currency));
|
|
|
|
|
$ssje = $this->Paypal_model->get_ssje_exclude_fee(bcsub($paypal_msg->pn_mc_gross, $payment_fee), '15002', mb_strtoupper($paypal_msg->pn_mc_currency));
|
|
|
|
|
$ht_memo = '交易号(自动录入):' . $paypal_msg->pn_txn_id;
|
|
|
|
|
$USD_amount = $this->Paypal_model->get_USD($paypal_msg->pn_mc_gross, $paypal_msg->pn_mc_currency);
|
|
|
|
|
if (false == $this->Paypal_model->if_biz_gai_exists($paypal_msg->pn_txn_id) ) {
|
|
|
|
|