|
|
|
@ -330,7 +330,7 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
* 处理异步通知: 解析订单号, 邮件外联/客人; 插入付款记录
|
|
|
|
|
* @author LYT <lyt@hainatravel.com>
|
|
|
|
|
*/
|
|
|
|
|
public function send_alipay($pn_txn_id = false)
|
|
|
|
|
public function send_alipay($pn_txn_id = false, $old_ssje=null)
|
|
|
|
|
{
|
|
|
|
|
$data = array();
|
|
|
|
|
$int = 0;
|
|
|
|
@ -365,7 +365,7 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
|
|
|
|
|
//退款状态默认为已经处理,陆燕在退款前手动通知外联了,系统跳过处理
|
|
|
|
|
if ($item->ALI_payType == 'refund') {
|
|
|
|
|
$this->send_refund($item);
|
|
|
|
|
$this->send_refund($item, $old_ssje);
|
|
|
|
|
// $this->Alipay_note_model->update_send($item->ALI_dealId, 'send');
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -411,6 +411,7 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
if (intval($item->ALI_stateCode)!==1) {
|
|
|
|
|
$ssje = $this->Alipay_model->get_ssje($item->ALI_orderAmount, $currencyCode);
|
|
|
|
|
}
|
|
|
|
|
$ssje = $old_ssje===null ? $ssje : $old_ssje;
|
|
|
|
|
$USD_amount = $this->Alipay_model->get_USD($item->ALI_orderAmount, $currencyCode);
|
|
|
|
|
//更新还没有填的客邮和交易号de收款记录(商务订单)
|
|
|
|
|
if (isset($advisor_info->order_type) && $advisor_info->order_type == 0) {
|
|
|
|
@ -528,7 +529,7 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
* @date 2019-05-09
|
|
|
|
|
* * TODO 线下收款之后产生的退款没有通知
|
|
|
|
|
*/
|
|
|
|
|
public function send_refund($item)
|
|
|
|
|
public function send_refund($item, $old_ssje=null)
|
|
|
|
|
{
|
|
|
|
|
// raw
|
|
|
|
|
$raw = json_decode($item->ALI_memo);
|
|
|
|
@ -566,6 +567,7 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
$currencyCode = str_replace("CNY", "RMB", trim(mb_strtoupper($item->ALI_currencyCode)));
|
|
|
|
|
$currencyCode = mb_strtoupper(trim($currencyCode));
|
|
|
|
|
$ssje = $this->Alipay_model->get_ssje($item->ALI_orderAmount, $currencyCode, '15015');
|
|
|
|
|
$ssje = $old_ssje===null ? $ssje : $old_ssje;
|
|
|
|
|
$USD_amount = $this->Alipay_model->get_USD($item->ALI_orderAmount, $currencyCode);
|
|
|
|
|
//更新还没有填的客邮和交易号de收款记录(商务订单)
|
|
|
|
|
if (isset($advisor_info->order_type) && $advisor_info->order_type == 0) {
|
|
|
|
@ -1051,29 +1053,55 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
|
|
|
|
|
//获取note详情,以便后续修改各项数据
|
|
|
|
|
public function note_modal($pn_txn_id = false, $pn_invoice = false ,$notice_time = false) {
|
|
|
|
|
// $this->permission->is_admin(true);
|
|
|
|
|
// $data = array();
|
|
|
|
|
// $data['IPL_orderId'] = $pn_invoice;
|
|
|
|
|
// if (!empty($pn_txn_id)) {
|
|
|
|
|
// $data['note'] = $this->Alipay_note_model->note($pn_txn_id);
|
|
|
|
|
// if (!empty($data['note'])) {
|
|
|
|
|
// if (!empty($pn_invoice)) {
|
|
|
|
|
// $orderid_info = analysis_orderid($pn_invoice);
|
|
|
|
|
// } else {
|
|
|
|
|
// $orderid_info = analysis_orderid($data['note']->IPL_orderId);
|
|
|
|
|
// }
|
|
|
|
|
// if (!empty($orderid_info)) {
|
|
|
|
|
// $orderid_info = json_decode($orderid_info);
|
|
|
|
|
// $data['order_info'] = $this->Alipay_model->get_order($orderid_info->orderid, true, $orderid_info->ordertype);
|
|
|
|
|
// }
|
|
|
|
|
// $data["paytext"] = $this->payment_status();
|
|
|
|
|
// echo json_encode($this->load->view('alipay_note_setting', $data, true));
|
|
|
|
|
// return true;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// echo json_encode('没找到数据!');
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
$this->permission->is_admin(true);
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['IPL_orderId'] = $pn_invoice;
|
|
|
|
|
if (!empty($pn_txn_id)) {
|
|
|
|
|
$data['note'] = $this->Alipay_note_model->note($pn_txn_id);
|
|
|
|
|
if (!empty($data['note'])) {
|
|
|
|
|
if (!empty($pn_invoice)) {
|
|
|
|
|
$orderid_info = analysis_orderid($pn_invoice);
|
|
|
|
|
} else {
|
|
|
|
|
$orderid_info = analysis_orderid($data['note']->IPL_orderId);
|
|
|
|
|
}
|
|
|
|
|
$orderid_info = analysis_orderid($data['note']->ALI_orderId);
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$orderid_info = json_decode($orderid_info);
|
|
|
|
|
$data['order_info'] = $this->Alipay_model->get_order($orderid_info->orderid, true, $orderid_info->ordertype);
|
|
|
|
|
if ($orderid_info->ordertype === 'T') {
|
|
|
|
|
$data['gai_info'] = $this->Alipay_model->get_money_t($pn_txn_id);
|
|
|
|
|
} elseif ($orderid_info->ordertype === 'B') {
|
|
|
|
|
$data['gai_info'] = $this->Alipay_model->get_money_b($pn_txn_id);
|
|
|
|
|
}
|
|
|
|
|
$data["paytext"] = $this->payment_status();
|
|
|
|
|
echo json_encode($this->load->view('alipay_note_setting', $data, true));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
$data['old_order'] = $data['note']->ALI_orderId;
|
|
|
|
|
$data['new_order'] = $pn_invoice;
|
|
|
|
|
$data['order_info'] = null;
|
|
|
|
|
if ($pn_invoice !== null) {
|
|
|
|
|
$neworder_id = analysis_orderid($pn_invoice);
|
|
|
|
|
$neworder_id = json_decode($neworder_id);
|
|
|
|
|
if ( ! empty($neworder_id)) {
|
|
|
|
|
$data['order_info'] = $this->Alipay_model->get_order($neworder_id->orderid, true, $neworder_id->ordertype);
|
|
|
|
|
}
|
|
|
|
|
echo json_encode('没找到数据!');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$data["paytext"] = $this->payment_status();
|
|
|
|
|
echo json_encode($this->load->view('alipay_note_setting', $data, true));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function note_order_modal($old_order,$pn_invoice = false ,$notice_time = false) {
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['IPL_orderId'] = $pn_invoice;
|
|
|
|
@ -1112,13 +1140,38 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改订单名
|
|
|
|
|
// TODO 支持转移功能
|
|
|
|
|
public function note_modal_save() {
|
|
|
|
|
$data = array();
|
|
|
|
|
$old_ssje = null;
|
|
|
|
|
|
|
|
|
|
$pn_txn_id = $this->input->post('pn_txn_id');
|
|
|
|
|
$pn_invoice = $this->input->post('pn_invoice');
|
|
|
|
|
|
|
|
|
|
$data['note'] = $this->Alipay_note_model->note($pn_txn_id);
|
|
|
|
|
$orderid_info = analysis_orderid($data['note']->ALI_orderId);
|
|
|
|
|
// if (empty($orderid_info) && $data['note']->ALI_payType == 'refund'
|
|
|
|
|
// && true === $this->Alipay_model->if_APP_order($data['note']->ALI_orderId)
|
|
|
|
|
// ) {
|
|
|
|
|
// // APP 组的退款订单是没有后缀的
|
|
|
|
|
// $orderid_info = analysis_orderid($data['note']->ALI_orderId . '_B');
|
|
|
|
|
// }
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
|
$orderid_info = json_decode($orderid_info);
|
|
|
|
|
if ($orderid_info->ordertype === 'T') {
|
|
|
|
|
$data['gai_info'] = $this->Alipay_model->get_money_t(substr($pn_txn_id,0,30));
|
|
|
|
|
if ( ! empty($data['gai_info'])) {
|
|
|
|
|
$old_ssje = $data['gai_info'][0]->GAI_SSJE;
|
|
|
|
|
$this->Alipay_model->delete_money_t(substr($pn_txn_id,0,30));
|
|
|
|
|
}
|
|
|
|
|
} elseif ($orderid_info->ordertype === 'B' || $orderid_info->ordertype === 'A') {
|
|
|
|
|
$data['gai_info'] = $this->Alipay_model->get_money_b(substr($pn_txn_id,0,30));
|
|
|
|
|
if ( ! empty($data['gai_info'])) {
|
|
|
|
|
$old_ssje = $data['gai_info'][0]->GAI_SSJE;
|
|
|
|
|
$this->Alipay_model->delete_money_b(substr($pn_txn_id,0,30));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($pn_txn_id) && !empty($pn_invoice)) {
|
|
|
|
|
$orderid_info = analysis_orderid($pn_invoice);
|
|
|
|
|
if (!empty($orderid_info)) {
|
|
|
|
@ -1126,7 +1179,7 @@ class AlipayTradeService extends CI_Controller
|
|
|
|
|
$advisor_info = $this->Alipay_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype);
|
|
|
|
|
if (!empty($advisor_info)) {
|
|
|
|
|
$this->Alipay_note_model->set_invoice($pn_txn_id, $pn_invoice);
|
|
|
|
|
$this->send_alipay($pn_txn_id);
|
|
|
|
|
$this->send_alipay($pn_txn_id, $old_ssje);
|
|
|
|
|
echo json_encode('修改成功!');
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|