From 35e95ae11b15d7d97b14598a01751e66abc92d8f Mon Sep 17 00:00:00 2001 From: lyt Date: Wed, 24 Oct 2018 14:07:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E6=97=85=E7=BB=84=E8=AE=A2=E5=8D=95:?= =?UTF-8?q?=E4=BB=BB=E4=BD=95=E7=8A=B6=E6=80=81=E6=94=B6=E6=AC=BE=E5=90=8E?= =?UTF-8?q?=E9=83=BD=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=96=B0=E8=AE=A2=E5=8D=95?= =?UTF-8?q?(=E5=B7=B2=E6=94=AF=E4=BB=98),=E9=87=8D=E5=A4=8D=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=9A=E7=9F=A5=E7=9A=84=E4=B8=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pay/controllers/AlipayTradeService.php | 6 +++-- .../pay/controllers/iPayLinksService.php | 6 +++-- webht/third_party/pay/models/Alipay_model.php | 27 ++++++++++++++++--- .../pay/models/IPayLinks_model.php | 27 ++++++++++++++++--- .../third_party/paypal/controllers/index.php | 8 +++--- .../paypal/models/paypal_model.php | 27 ++++++++++++++++--- 6 files changed, 82 insertions(+), 19 deletions(-) diff --git a/webht/third_party/pay/controllers/AlipayTradeService.php b/webht/third_party/pay/controllers/AlipayTradeService.php index 80b0d260..eeab05f0 100644 --- a/webht/third_party/pay/controllers/AlipayTradeService.php +++ b/webht/third_party/pay/controllers/AlipayTradeService.php @@ -386,6 +386,10 @@ class AlipayTradeService extends CI_Controller // $this->Alipay_model->update_biz_coli_state($GAI_COLI_SN, 8); //把订单状态改为已付款 // } } else { + // 把订单状态设置为13-新订单已支付 + if (false == $this->Alipay_model->if_biz_gai_exists($item->ALI_dealId) ) { + $this->Alipay_model->update_biz_coli_state($GAI_COLI_SN, 13); + } $this->Alipay_model->add_account_info( $GAI_COLI_SN, $advisor_info->COLI_ID, @@ -403,8 +407,6 @@ class AlipayTradeService extends CI_Controller ); // 更新订单主表付款方式,防止没访问thankyou-train.asp $this->Alipay_model->update_paymanner($GAI_COLI_SN); - // 把订单状态设置为13-新订单已支付 - $this->Alipay_model->update_biz_coli_state($GAI_COLI_SN, 13); } } //更新还没有填的客邮和交易号de收款记录(传统订单) diff --git a/webht/third_party/pay/controllers/iPayLinksService.php b/webht/third_party/pay/controllers/iPayLinksService.php index 07154dd8..079f41e8 100644 --- a/webht/third_party/pay/controllers/iPayLinksService.php +++ b/webht/third_party/pay/controllers/iPayLinksService.php @@ -463,6 +463,10 @@ class IPayLinksService extends CI_Controller // $this->IPayLinks_model->update_biz_coli_state($GAI_COLI_SN, 13); //把订单状态改为已付款 // } } else { + // 把订单状态设置为13-新订单已支付 + if (false == $this->IPayLinks_model->if_biz_gai_exists($item->IPL_dealId) ) { + $this->IPayLinks_model->update_biz_coli_state($GAI_COLI_SN, 13); + } $this->IPayLinks_model->add_account_info( $GAI_COLI_SN, $advisor_info->COLI_ID, @@ -478,8 +482,6 @@ class IPayLinksService extends CI_Controller $item->IPL_dealId, $ht_memo ); - // 把订单状态设置为13-新订单已支付 - $this->IPayLinks_model->update_biz_coli_state($GAI_COLI_SN, 13); // 更新订单主表付款方式,防止没访问thankyou-train.asp if (empty($advisor_info->COLI_PayManner)) { $this->IPayLinks_model->update_paymanner($GAI_COLI_SN); diff --git a/webht/third_party/pay/models/Alipay_model.php b/webht/third_party/pay/models/Alipay_model.php index 82deefb8..4e7644bb 100644 --- a/webht/third_party/pay/models/Alipay_model.php +++ b/webht/third_party/pay/models/Alipay_model.php @@ -121,14 +121,33 @@ class Alipay_model extends CI_Model { //修改订单状态 public function update_biz_coli_state($coli_sn, $coli_state) { $sql = " - UPDATE BIZ_ConfirmLineInfo - SET COLI_State = ? - WHERE COLI_SN = ? AND COLI_State in (0,1,11,12,13,14,40,50,60,101,102,999) + IF EXISTS + ( SELECT OPI_DEI_SN + FROM OperatorInfo + INNER JOIN BIZ_ConfirmLineInfo ON OPI_SN=COLI_OPI_ID + WHERE COLI_SN=? AND OPI_DEI_SN=10 + ) + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? + WHERE COLI_SN=? + ELSE + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? WHERE COLI_SN=? + AND COLI_State IN (0,1,11,12,13,14,40,50,60,101,102,999) "; - $query = $this->HT->query($sql, array($coli_state, $coli_sn)); + $query = $this->HT->query($sql, array($coli_sn, $coli_state, $coli_sn, $coli_state, $coli_sn)); return $query; } + public function if_biz_gai_exists($GAI_AccreditNo) + { + $sql = " SELECT TOP 1 1 FROM BIZ_GroupAccountInfo + WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') + AND DeleteFlag=0"; + $result = $this->HT->query($sql, array($GAI_AccreditNo)); + return ($result->num_rows() > 0); + } + //添加收款记录(商务订单),APP会自动增加记录,所以添加前根据金额来判断是否有重复记录 public function add_account_info_forAPP($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) { //先判断是否有这条数据 diff --git a/webht/third_party/pay/models/IPayLinks_model.php b/webht/third_party/pay/models/IPayLinks_model.php index 8ac260b2..ba7a4687 100644 --- a/webht/third_party/pay/models/IPayLinks_model.php +++ b/webht/third_party/pay/models/IPayLinks_model.php @@ -121,14 +121,33 @@ class IPayLinks_model extends CI_Model { //修改订单状态 public function update_biz_coli_state($coli_sn, $coli_state) { $sql = " - UPDATE BIZ_ConfirmLineInfo - SET COLI_State = ? - WHERE COLI_SN = ? and COLI_State in (0,1,11,12,13,14,40,50,60,101,102,999) + IF EXISTS + ( SELECT OPI_DEI_SN + FROM OperatorInfo + INNER JOIN BIZ_ConfirmLineInfo ON OPI_SN=COLI_OPI_ID + WHERE COLI_SN=? AND OPI_DEI_SN=10 + ) + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? + WHERE COLI_SN=? + ELSE + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? WHERE COLI_SN=? + AND COLI_State IN (0,1,11,12,13,14,40,50,60,101,102,999) "; - $query = $this->HT->query($sql, array($coli_state, $coli_sn)); + $query = $this->HT->query($sql, array($coli_sn, $coli_state, $coli_sn, $coli_state, $coli_sn)); return $query; } + public function if_biz_gai_exists($GAI_AccreditNo) + { + $sql = " SELECT TOP 1 1 FROM BIZ_GroupAccountInfo + WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') + AND DeleteFlag=0"; + $result = $this->HT->query($sql, array($GAI_AccreditNo)); + return ($result->num_rows() > 0); + } + //添加收款记录(商务订单),APP会自动增加记录,所以添加前根据金额来判断是否有重复记录 public function add_account_info_forAPP($GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { //先判断是否有这条数据 diff --git a/webht/third_party/paypal/controllers/index.php b/webht/third_party/paypal/controllers/index.php index 36724256..a4d95825 100644 --- a/webht/third_party/paypal/controllers/index.php +++ b/webht/third_party/paypal/controllers/index.php @@ -812,15 +812,17 @@ class Index extends CI_Controller { $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency)); $this->Paypal_model->add_account_info_forAPP($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->pn_txn_id, $ht_memo); if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) { //只修改APP组的订单状态,并且订单进度是我的订单 - $this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 8); //把订单状态改为已付款 + $this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 13); //把订单状态改为已付款 } } else { + // 把订单状态设置为13-新订单已支付 + if (false == $this->Paypal_model->if_biz_gai_exists($item->pn_txn_id) ) { + $this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 13); + } $ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency)); $this->Paypal_model->add_account_info($GAI_COLI_SN, $advisor_info->COLI_ID, $item->pn_mc_gross, $item->pn_payment_date, mb_strtoupper($item->pn_mc_currency), $ssje, $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->pn_txn_id, $ht_memo); // 更新订单主表付款方式,防止没访问thankyou-train.asp $this->Paypal_model->update_paymanner($GAI_COLI_SN, '15010'); - // 把订单状态设置为13-新订单已支付 - $this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 13); } } //更新还没有填的客邮和交易号de收款记录(传统订单) diff --git a/webht/third_party/paypal/models/paypal_model.php b/webht/third_party/paypal/models/paypal_model.php index f65a9675..110d2e70 100644 --- a/webht/third_party/paypal/models/paypal_model.php +++ b/webht/third_party/paypal/models/paypal_model.php @@ -122,14 +122,33 @@ class Paypal_model extends CI_Model { //修改订单状态 public function update_biz_coli_state($coli_sn, $coli_state) { $sql = " - UPDATE BIZ_ConfirmLineInfo - SET COLI_State = ? - WHERE COLI_SN = ? AND COLI_State in (0,1,11,12,13,14,40,50,60,101,102,999) + IF EXISTS + ( SELECT OPI_DEI_SN + FROM OperatorInfo + INNER JOIN BIZ_ConfirmLineInfo ON OPI_SN=COLI_OPI_ID + WHERE COLI_SN=? AND OPI_DEI_SN=10 + ) + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? + WHERE COLI_SN=? + ELSE + UPDATE BIZ_ConfirmLineInfo + SET COLI_State=? WHERE COLI_SN=? + AND COLI_State IN (0,1,11,12,13,14,40,50,60,101,102,999) "; - $query = $this->HT->query($sql, array($coli_state, $coli_sn)); + $query = $this->HT->query($sql, array($coli_sn, $coli_state, $coli_sn, $coli_state, $coli_sn)); return $query; } + public function if_biz_gai_exists($GAI_AccreditNo) + { + $sql = " SELECT TOP 1 1 FROM BIZ_GroupAccountInfo + WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') + AND DeleteFlag=0"; + $result = $this->HT->query($sql, array($GAI_AccreditNo)); + return ($result->num_rows() > 0); + } + //添加收款记录(商务订单),APP会自动增加记录,所以添加前根据金额来判断是否有重复记录 public function add_account_info_forAPP($GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo) { //先判断是否有这条数据