From bbcd1aae2fc1973dfe178765dde15c52ddf10b5c Mon Sep 17 00:00:00 2001 From: lyt Date: Fri, 16 Mar 2018 17:51:51 +0800 Subject: [PATCH] =?UTF-8?q?alipay=20=E4=BA=BA=E6=B0=91=E5=B8=81=E6=94=B6?= =?UTF-8?q?=E6=AC=BE,=20=E5=95=86=E5=8A=A1=E8=AE=A2=E5=8D=95=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E7=BE=8E=E9=87=91=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pay/controllers/AlipayTradeService.php | 9 +++++++++ webht/third_party/pay/models/Alipay_model.php | 20 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/webht/third_party/pay/controllers/AlipayTradeService.php b/webht/third_party/pay/controllers/AlipayTradeService.php index 4b7aebe4..d04f01b6 100644 --- a/webht/third_party/pay/controllers/AlipayTradeService.php +++ b/webht/third_party/pay/controllers/AlipayTradeService.php @@ -292,6 +292,11 @@ class AlipayTradeService extends CI_Controller return $result; } + /*! + * 定时执行 + * 处理异步通知: 解析订单号, 邮件外联/客人; 插入付款记录 + * @author LYT + */ public function send_alipay($pn_txn_id = false) { $data = array(); @@ -369,6 +374,7 @@ class AlipayTradeService extends CI_Controller //没有分配订单之前先添加付款记录,这个过程可能会执行多次,必须在添加记录前查找是否有数据 if (!empty($orderid_info)) { $currencyCode = str_replace("CNY", "RMB", trim(mb_strtoupper($item->ALI_currencyCode))); + $USD_amount = $this->Alipay_model->get_USD($item->ALI_orderAmount, $currencyCode); //更新还没有填的客邮和交易号de收款记录(商务订单) if (isset($advisor_info->order_type) && $advisor_info->order_type == 0) { $ht_memo = '交易号(自动录入):' . $item->ALI_dealId; @@ -387,6 +393,7 @@ class AlipayTradeService extends CI_Controller $item->ALI_orderAmount, $item->ALI_completeTime, $currencyCode, + $USD_amount, $item->ALI_completeTime, $item->ALI_completeTime, $item->ALI_acquiringTime, @@ -698,4 +705,6 @@ var_dump($response->$responseNode); ); } + + } diff --git a/webht/third_party/pay/models/Alipay_model.php b/webht/third_party/pay/models/Alipay_model.php index 48821bc3..70510309 100644 --- a/webht/third_party/pay/models/Alipay_model.php +++ b/webht/third_party/pay/models/Alipay_model.php @@ -157,7 +157,7 @@ class Alipay_model extends CI_Model { } //添加收款记录(商务订单) - public function add_account_info($GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { + public function add_account_info($GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_Money, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { //先判断是否有这条数据 $sql = " @@ -173,6 +173,7 @@ class Alipay_model extends CI_Model { ,GAI_SQJE ,GAI_SQDate ,GAI_SQJECurrency + ,GAI_Money ,GAI_SSDate ,GAI_AccountDate ,GAI_SubmitDate @@ -182,8 +183,8 @@ class Alipay_model extends CI_Model { ,GAI_Memo ,GAI_State ,DeleteFlag - ) VALUES (?,?,15015,?,?,?,?,?,?,?,?,?,?,0,0)"; - $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); + ) VALUES (?,?,15015,?,?,?,?,?,?,?,?,?,?,?,0,0)"; + $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_Money, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); return $query; } @@ -274,4 +275,17 @@ class Alipay_model extends CI_Model { $query = $this->HT->query($sql, array($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_Web, $frominfo, $M_RelatedInfo, $M_State)); return $query; } + /*! + * 调用数据库函数,转换为美金 + */ + public function get_USD($amount, $currency='RMB') + { + $sql = "SELECT dbo.ConvertCurrencyToCurrency(?,?,?,?) as ssje"; + $query = $this->HT->query($sql, array(1, mb_strtolower($currency), 'usd', $amount)); + $result = $query->result(); + if ( ! empty($result)) { + return $result[0]->ssje; + } + return 0; + } }