diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index 627ac868..34b10ce0 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -1263,6 +1263,19 @@ class Index extends CI_Controller { //根据订单号查找外联信息, 从临时表 $advisor_info_from_tmp = $this->Paypal_model->get_order($orderid_info->orderid, false, 'M', $handpick); + + if (empty($advisor_info)) { + if ($orderid_info->ordertype === 'T') { + $parent_order_info = $this->Paypal_model->get_money_t($parent_txn_id); + } else { + $parent_order_info = $this->Paypal_model->get_money_B($parent_txn_id); + } + if ( ! empty($parent_order_info)) { + $advisor_info = $this->Paypal_model->get_order($parent_order_info[0]->COLI_ID, false, $orderid_info->ordertype, $handpick); + $orderid_info = $this->analysis_orderid("{$parent_order_info[0]->COLI_ID}_{$orderid_info->ordertype}"); + $orderid_info = json_decode($orderid_info); + } + } /** * 传统订单, 网站支付 * @author LYT diff --git a/webht/third_party/paypal/models/paypal_model.php b/webht/third_party/paypal/models/paypal_model.php index f2278b71..68672dce 100644 --- a/webht/third_party/paypal/models/paypal_model.php +++ b/webht/third_party/paypal/models/paypal_model.php @@ -33,7 +33,7 @@ class Paypal_model extends CI_Model { order by CHARINDEX('$COLI_ID', COLI_ID) "; $query = $this->HT->query($sql); $result = $query->result(); - if ($handpick === TRUE) { + if ($handpick === TRUE && count($result) > 0) { $result = array($result[0]); } } @@ -598,22 +598,25 @@ class Paypal_model extends CI_Model { } //根据交易号获取收款记录(传统订单) public function get_money_t($pn_invoice) { - $sql = "SELECT GroupAccountInfo.* - from GroupAccountInfo - where DeleteFlag=0 and GAI_AccreditNo=? + $sql = "SELECT cli.COLI_ID, gai.* + from GroupAccountInfo gai + LEFT JOIN ConfirmLineInfo AS cli ON cli.COLI_SN =GAI_COLI_SN + where gai.DeleteFlag=0 and gai.GAI_AccreditNo=? "; $query = $this->HT->query($sql, array($pn_invoice)); + // log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . PHP_EOL . var_export($this->HT->last_query(), 1)); $result = $query->result(); return $result; } //根据交易号获取收款记录(商务订单) public function get_money_b($pn_invoice, $find_memo = true) { $find_memo_sql = $find_memo === true ? " OR GAI_Memo='$pn_invoice' " : ""; - $sql = "SELECT BIZ_GroupAccountInfo.* + $sql = "SELECT GAI_COLI_ID AS COLI_ID, BIZ_GroupAccountInfo.* from BIZ_GroupAccountInfo where DeleteFlag=0 and ( GAI_AccreditNo=? $find_memo_sql ) "; $query = $this->HT->query($sql, array($pn_invoice)); + // log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . PHP_EOL . var_export($this->HT->last_query(), 1)); $result = $query->result(); return $result; }