diff --git a/webht/third_party/pay/controllers/AlipayTradeService.php b/webht/third_party/pay/controllers/AlipayTradeService.php index 1b3beed4..5d23a509 100644 --- a/webht/third_party/pay/controllers/AlipayTradeService.php +++ b/webht/third_party/pay/controllers/AlipayTradeService.php @@ -452,7 +452,7 @@ class AlipayTradeService extends CI_Controller //CHTAPP订单添加记录前判断是否有记录,以前的APP版本没有交易号,只能拿金额来判断 if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") != '-biz') { //只判断前6位字符,CHTAPP-fr CHTAPP-jp等各语种都属于APP订单 - $this->Alipay_model->add_account_info_forAPP( + $insertID = $this->Alipay_model->add_account_info_forAPP( $GAI_COLI_SN, $advisor_info->COLI_ID, $item->ALI_orderAmount, @@ -476,7 +476,7 @@ class AlipayTradeService extends CI_Controller $this->Alipay_model->update_biz_coli_state($GAI_COLI_SN, 13); $this->Alipay_model->insert_biz_order_log($GAI_COLI_SN, 'BS13'); } - $this->Alipay_model->add_account_info( + $insertID = $this->Alipay_model->add_account_info( $GAI_COLI_SN, $advisor_info->COLI_ID, $item->ALI_orderAmount, @@ -495,6 +495,8 @@ class AlipayTradeService extends CI_Controller // 更新订单主表付款方式,防止没访问thankyou-train.asp $this->Alipay_model->update_paymanner($GAI_COLI_SN); } + // 添加HT任务 + $this->payment_model->exec_addToTask($insertID, 227002); } //更新还没有填的客邮和交易号de收款记录(传统订单) elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) { @@ -517,7 +519,7 @@ class AlipayTradeService extends CI_Controller //添加汉特的订单提醒 $this->Alipay_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->ALI_currencyCode) . $item->ALI_orderAmount); // 添加HT任务 - $this->Alipay_model->exec_addToTask($gai_sn); + $this->payment_model->exec_addToTask($gai_sn, 227001); } } @@ -624,7 +626,7 @@ class AlipayTradeService extends CI_Controller $GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0; //CHTAPP订单添加记录前判断是否有记录,以前的APP版本没有交易号,只能拿金额来判断 if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") != '-biz') {//只判断前6位字符,CHTAPP-fr CHTAPP-jp等各语种都属于APP订单 - $is_insert = $this->Alipay_model->add_account_info_forAPP( + $insertID = $this->Alipay_model->add_account_info_forAPP( $GAI_COLI_SN, $advisor_info->COLI_ID, $item->ALI_orderAmount, @@ -639,7 +641,7 @@ class AlipayTradeService extends CI_Controller $item->ALI_dealId, $ht_memo); - if ($is_insert) { + if ($insertID) { $this->Alipay_model->insert_biz_order_log($GAI_COLI_SN, 'Refunded'); $this->payment_model->exec_BIZ_TrainCostAdd($GAI_COLI_SN, $ssje); } @@ -648,7 +650,7 @@ class AlipayTradeService extends CI_Controller if (false == $this->Alipay_model->if_biz_gai_exists($item->ALI_dealId) ) { $this->Alipay_model->insert_biz_order_log($GAI_COLI_SN, 'Refunded'); } - $this->Alipay_model->add_account_info( + $insertID = $this->Alipay_model->add_account_info( $GAI_COLI_SN, $advisor_info->COLI_ID, $item->ALI_orderAmount, @@ -664,6 +666,8 @@ class AlipayTradeService extends CI_Controller $item->ALI_dealId, $ht_memo); } + // 添加HT任务 + $this->payment_model->exec_addToTask($insertID, 227002); } //更新还没有填的客邮和交易号的收款记录(传统订单) elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) { @@ -685,6 +689,8 @@ class AlipayTradeService extends CI_Controller $ht_memo); //添加汉特的订单提醒 $this->Alipay_model->update_coli_introduction($GAI_COLI_SN, '已退款 ' . ($currencyCode) . $item->ALI_orderAmount); + // 添加HT任务 + $this->payment_model->exec_addToTask($gai_sn, 227001); } } diff --git a/webht/third_party/pay/controllers/PaymentService.php b/webht/third_party/pay/controllers/PaymentService.php index 812da87e..2d947036 100644 --- a/webht/third_party/pay/controllers/PaymentService.php +++ b/webht/third_party/pay/controllers/PaymentService.php @@ -202,7 +202,7 @@ class PaymentService extends CI_Controller { // todo: 检测收/退款是否存在 if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") !== '-biz') { /* APP */ - $is_insert = $this->account_model->add_account_info_forAPP( + $insertID = $this->account_model->add_account_info_forAPP( $COLI_SN, $item->OPN_accountMethod, $advisor_info->COLI_ID, @@ -218,7 +218,7 @@ class PaymentService extends CI_Controller { $item->OPN_transactionId, $ht_memo ); - if ($is_refund === true && $is_insert) { + if ($is_refund === true && $insertID) { $this->account_model->exec_BIZ_TrainCostAdd($COLI_SN, $ssje); } if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11 @@ -227,6 +227,8 @@ class PaymentService extends CI_Controller { $this->account_model->update_biz_coli_state($COLI_SN, 8); //把订单状态改为已付款 $this->account_model->insert_biz_order_log($COLI_SN, 'BS8'); } + // 添加HT任务 + $this->account_model->exec_addToTask($insertID, 227002); } else { /* 其他商务订单 */ // 第一次录入收款记录时变更状态,记录日志 @@ -238,7 +240,7 @@ class PaymentService extends CI_Controller { } else if (false!==$is_refund) { $this->account_model->insert_biz_order_log($COLI_SN, 'Refunded'); } - $this->account_model->add_account_info( + $insertID = $this->account_model->add_account_info( $COLI_SN, $item->OPN_accountMethod, $advisor_info->COLI_ID, @@ -256,6 +258,8 @@ class PaymentService extends CI_Controller { ); // 更新订单主表付款方式,防止没访问thankyou-train.asp $this->account_model->update_paymanner($COLI_SN, $item->OPN_accountMethod); + // 添加HT任务 + $this->account_model->exec_addToTask($insertID, 227002); } // 更新note $update_note_column['OPN_accountType'] = 'B'; @@ -281,11 +285,11 @@ class PaymentService extends CI_Controller { if ($is_refund === false) { //添加汉特的订单提醒 $this->account_model->update_coli_introduction($COLI_SN, '已支付 ' . $currencyCode . $item->OPN_orderAmount); - // 收款:添加HT任务 - $this->account_model->exec_addToTask($gai_sn); } + // 收款:添加HT任务 + $this->account_model->exec_addToTask($gai_sn, 227001); // 更新note - $update_note_column['OPN_accountType'] = 'B'; + $update_note_column['OPN_accountType'] = 'T'; $update_note_column['OPN_accountStatus'] = 'recorded'; $update_note_column['OPN_accountTime'] = date('Y-m-d H:i:s'); } diff --git a/webht/third_party/pay/models/Alipay_model.php b/webht/third_party/pay/models/Alipay_model.php index 799f7550..7788bd20 100644 --- a/webht/third_party/pay/models/Alipay_model.php +++ b/webht/third_party/pay/models/Alipay_model.php @@ -204,9 +204,10 @@ class Alipay_model extends CI_Model { ,DeleteFlag ) VALUES (?,?,15015,?,?,?,?,?,?,?,?,?,?,?,0,0)"; $query = $this->HT->query($sql, array($GAI_COLI_SN, $GAI_SQJE, $GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, substr($GAI_AccreditNo,0, 30), $GAI_Memo)); - // $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); + $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); + return $insertid; // return $query; - return $query->num_rows() > 0; + // return $query->num_rows() > 0; // affected_rows() doesn't work with the 'sqlsrv' driver in CI2 // The solution: Upgrade to the latest CodeIgniter 3.0.x version // $ssql = "SELECT 1 as 'exist' from BIZ_GroupAccountInfo where GAI_AccreditNo=? "; @@ -246,7 +247,7 @@ class Alipay_model extends CI_Model { ) VALUES (?,?,15015,?,?,?,?,?,?,?,?,?,?,?,?,0,0)"; $query = $this->HT->query($sql, array(substr($GAI_AccreditNo,0, 30), $GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_Money, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, substr($GAI_AccreditNo,0, 30), $GAI_Memo)); $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); - return $query; + return $insertid; } //添加收款记录(传统订单) @@ -364,12 +365,12 @@ class Alipay_model extends CI_Model { } /** JJH: 添加订单收款记录之后执行 */ - public function exec_addToTask($GAI_SN) + public function exec_addToTask($GAI_SN, $OrderSourceType = 227001) { $sql = " if not exists ( select top 1 1 from Sysautotask where SAT_Type=1 and SAT_SourceSN=$GAI_SN - ) exec SP_AddToSystask 1," . $GAI_SN; + ) exec SP_AddToSystask 1," . $GAI_SN . ", ". $OrderSourceType; $query = $this->HT->query($sql); return $query; } diff --git a/webht/third_party/pay/models/Online_payment_account_model.php b/webht/third_party/pay/models/Online_payment_account_model.php index f741d35f..0481df8e 100644 --- a/webht/third_party/pay/models/Online_payment_account_model.php +++ b/webht/third_party/pay/models/Online_payment_account_model.php @@ -277,7 +277,7 @@ class Online_payment_account_model extends CI_Model { ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); - return $query; + return $insertid; } //添加收款记录(商务订单),APP会自动增加记录,所以添加前根据金额来判断是否有重复记录 @@ -308,9 +308,9 @@ class Online_payment_account_model extends CI_Model { ,DeleteFlag,LastEditTime ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; $query = $this->HT->query($sql, array($GAI_COLI_SN, $GAI_SQJE, $payment_method, $GAI_COLI_SN, $GAI_COLI_ID, $payment_method, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo)); - // $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); - // return $query; - return $query->num_rows() > 0; + $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); + return $insertid; + // return $query->num_rows() > 0; // affected_rows() doesn't work with the 'sqlsrv' driver in CI2 // The solution: Upgrade to the latest CodeIgniter 3.0.x version // $ssql = "SELECT 1 as 'exist' from BIZ_GroupAccountInfo where GAI_AccreditNo=? "; @@ -366,12 +366,13 @@ class Online_payment_account_model extends CI_Model { } /** JJH: 添加订单收款记录之后执行 */ - public function exec_addToTask($GAI_SN) + public function exec_addToTask($GAI_SN, $OrderSourceType =227001) { + if (empty($GAI_SN)) return false; $sql = " if not exists ( select top 1 1 from Sysautotask - where SAT_Type=1 and SAT_SourceSN=$GAI_SN - ) exec SP_AddToSystask 1," . $GAI_SN; + where SAT_Type=1 and SAT_SourceSN=$GAI_SN and SAT_OrderSourceType= $OrderSourceType + ) exec SP_AddToSystask 1," . $GAI_SN . "," . $OrderSourceType; $query = $this->HT->query($sql); return $query; } diff --git a/webht/third_party/paypal/models/paypal_model.php b/webht/third_party/paypal/models/paypal_model.php index 98154af4..c4683558 100644 --- a/webht/third_party/paypal/models/paypal_model.php +++ b/webht/third_party/paypal/models/paypal_model.php @@ -221,9 +221,8 @@ class Paypal_model extends CI_Model { ,DeleteFlag,LastEditTime ) VALUES (?,?,15010,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; $query = $this->HT->query($sql, array($GAI_COLI_SN, $GAI_SQJE, $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,$GAI_API)); - // $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); - log_message('error','test:$query ' . __METHOD__ . ': ' . __LINE__ . PHP_EOL . var_export($query->num_rows(), 1)); - return $query->num_rows() > 0; + $insertid = ($query && $query->num_rows() > 0) ? $this->HT->last_id('BIZ_GroupAccountInfo') : false; + return $insertid; // affected_rows() doesn't work with the 'sqlsrv' driver in CI2 // The solution: Upgrade to the latest CodeIgniter 3.0.x version @@ -265,8 +264,8 @@ class Paypal_model extends CI_Model { ,DeleteFlag,LastEditTime ) VALUES (?,?,15002,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_COLI_ID, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_Money, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo,$GAI_API)); - $insertid = $this->HT->last_id('BIZ_GroupAccountInfo'); - return $query; + $insertid = ($query && $query->num_rows() > 0) ? $this->HT->last_id('BIZ_GroupAccountInfo') : false; + return $insertid; } //添加收款记录(传统订单) @@ -297,7 +296,8 @@ class Paypal_model extends CI_Model { ,DeleteFlag,LastEditTime ) VALUES (?,15002,?,?,?,?,?,?,?,?,?,?,?,?,0,0,GETDATE())"; $query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSJE, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo,$GAI_API)); - $insertid = $this->HT->last_id('GroupAccountInfo'); + $insertid = ($query && $query->num_rows() > 0) ? $this->HT->last_id('GroupAccountInfo') : false; + return $insertid; } @@ -657,13 +657,17 @@ class Paypal_model extends CI_Model { return $query; } - /** JJH: 添加订单收款记录之后执行 */ - public function exec_addToTask($GAI_SN) + /** + * JJH: 添加订单收款记录之后执行 + * @OrderSourceType: 线路订单填写 227001, 商务订单填写227002 + **/ + public function exec_addToTask($GAI_SN, $OrderSourceType =227001) { + if (empty($GAI_SN)) return false; $sql = " if not exists ( select top 1 1 from Sysautotask - where SAT_Type=1 and SAT_SourceSN=$GAI_SN - ) exec SP_AddToSystask 1," . $GAI_SN; + where SAT_Type=1 and SAT_SourceSN=$GAI_SN and SAT_OrderSourceType= $OrderSourceType + ) exec SP_AddToSystask 1," . $GAI_SN . "," . $OrderSourceType; $query = $this->HT->query($sql); return $query; } @@ -674,9 +678,13 @@ class Paypal_model extends CI_Model { **/ public function exec_BIZ_TrainCostAdd($COLI_SN, $ssje) { - $sql = " EXEC dbo.SP_BIZ_TrainCostAdd $COLI_SN, $ssje "; - $query = $this->HT->query($sql); - return $query; + // return false; // todo: 暂时关闭 + log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . ' exec_BIZ_TrainCostAdd' . PHP_EOL . var_export(1, 1)); + $sql = " exec SP_BIZ_TrainCostAdd $COLI_SN,$ssje ;"; + log_message('error','test: ' . __METHOD__ . ': ' . __LINE__ . ' ' . PHP_EOL . var_export($sql, 1)); + $this->HT->query($sql); + return false; + // return $query; } /** 写入商务订单操作记录 */