[+]收款后执行HT任务;

[+]仅更新部分状态的商务订单为13-新订单(已支付);
关闭ipaylinks批量查询接口;
收款记录匹配到多个订单不处理;
支持手工录入APP组的收款;
转移收款记录时包括手工录入交易号的记录;
feature/trippest
lyt 7 years ago
parent 5ab9632f89
commit c434f2ed99

@ -15,10 +15,9 @@ $config['currency'] = "USD";
$config['token_url'] = "https://api.paypal.com/v1/oauth2/token";
$config['web_profiles_url'] = "https://api.paypal.com/v1/payment-experience/web-profiles/";
$config['webhooks_url'] = "https://api.paypal.com/v1/notifications/webhooks";
$config['payment_url'] = "https://api.paypal.com/v1/payments/payment/";
$config['sale_url'] = "https://api.paypal.com/v1/payments/sale/";
// $config['activities_url'] = "https://api.paypal.com/v1/activities/activities";
// $config['reporting_url'] = "https://api.paypal.com/v1/reporting/transactions";
$config['payment_url'] = "https://api.paypal.com/v1/payments/payment";
$config['sale_url'] = "https://api.paypal.com/v1/payments/sale";
$config['activities_url'] = "https://api.paypal.com/v1/activities/activities";
$config['return_url'] = "https://www.chinahighlights.com";
$config['cancel_url'] = "https://www.chinahighlights.com";

@ -402,20 +402,16 @@ class AlipayTradeService extends CI_Controller
$ht_memo
);
// 更新订单主表付款方式,防止没访问thankyou-train.asp
if (empty($advisor_info->COLI_PayManner)) {
$this->Alipay_model->update_paymanner($GAI_COLI_SN);
}
if ($advisor_info->COLI_Department == 10) {
$this->Alipay_model->update_paymanner($GAI_COLI_SN);
// 把订单状态设置为13-新订单已支付
$this->Alipay_model->update_biz_coli_state($GAI_COLI_SN, 13);
}
}
}
//更新还没有填的客邮和交易号de收款记录传统订单
elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) {
$ht_memo = '交易号(自动录入):' . $item->ALI_dealId;
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
$this->Alipay_model->add_tour_account_info(
$gai_sn = $this->Alipay_model->add_tour_account_info(
$GAI_COLI_SN,
$item->ALI_orderAmount,
$item->ALI_acquiringTime,
@ -430,6 +426,8 @@ 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);
}
}

@ -286,6 +286,18 @@ class IPayLinksService extends CI_Controller
$this->output->set_content_type('application/json')->set_output(json_encode(simplexml_load_string($resp)));
return;
}
public function query_refund($refund_order_id)
{
$this->query_info_arr["queryOrderId"] = $this->create_guid();
$this->query_info_arr["orderId"] = $refund_order_id;
$this->query_info_arr['mode'] = '1';
$this->query_info_arr['type'] = '2';
$this->query_info_arr["signMsg"] = $this->generate_sign($this->query_info_arr);
$resp = $this->curl($this->queryUrl,$this->query_info_arr);
$resp_obj = simplexml_load_string($resp);
$this->output->set_content_type('application/json')->set_output(json_encode(simplexml_load_string($resp)));
return;
}
public function query_pay_list($day_offset = 3)
{
@ -432,9 +444,23 @@ class IPayLinksService extends CI_Controller
//CHTAPP订单添加记录前判断是否有记录以前的APP版本没有交易号只能拿金额来判断
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP') {
//只判断前6位字符CHTAPP-fr CHTAPP-jp等各语种都属于APP订单
// $this->IPayLinks_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), $item->pn_payment_date, $item->pn_payment_date, $item->pn_payment_date, '', $item->pn_payer_email, $item->IPL_dealId, $ht_memo);
// if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) { //只修改APP组的订单状态并且订单进度是我的订单
// $this->IPayLinks_model->update_biz_coli_state($GAI_COLI_SN, 8); //把订单状态改为已付款
$this->IPayLinks_model->add_account_info_forAPP(
$GAI_COLI_SN,
$advisor_info->COLI_ID,
$item->IPL_orderAmount,
$item->IPL_completeTime,
mb_strtoupper($item->currencyCode),
$ssje,
$item->IPL_completeTime,
$item->IPL_completeTime,
$item->IPL_acquiringTime,
$item->IPL_payerName,
$item->IPL_payerEmail,
$item->IPL_dealId,
$ht_memo);
// if ($advisor_info->COLI_WebCode == 'CHTAPP' && $advisor_info->COLI_State == 11) {
// //只修改APP组的订单状态并且订单进度是我的订单
// $this->IPayLinks_model->update_biz_coli_state($GAI_COLI_SN, 13); //把订单状态改为已付款
// }
} else {
$this->IPayLinks_model->add_account_info(
@ -452,10 +478,8 @@ class IPayLinksService extends CI_Controller
$item->IPL_dealId,
$ht_memo
);
if ($advisor_info->COLI_Department == 10) {
// 把订单状态设置为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);
@ -466,7 +490,7 @@ class IPayLinksService extends CI_Controller
elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) {
$ht_memo = '交易号(自动录入):' . $item->IPL_dealId;
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
$this->IPayLinks_model->add_tour_account_info(
$gai_sn = $this->IPayLinks_model->add_tour_account_info(
$GAI_COLI_SN,
$item->IPL_orderAmount,
$item->IPL_acquiringTime,
@ -482,6 +506,8 @@ class IPayLinksService extends CI_Controller
);
//添加汉特的订单提醒
$this->IPayLinks_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->IPL_currencyCode) . $item->IPL_orderAmount);
// 添加HT任务
$this->IPayLinks_model->exec_addToTask($gai_sn);
}
}
@ -951,7 +977,7 @@ class IPayLinksService extends CI_Controller
$neworder = $this->input->post('pn_invoice');
$data['note'] = $this->Note_model->note($pn_txn_id, $pn_id);
$orderid_info = $this->analysis_orderid($data['note'][0]->IPL_orderId);
$orderid_info = $this->analysis_orderid($data['note']->IPL_orderId);
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
if ($orderid_info->ordertype === 'T') {
@ -1056,25 +1082,26 @@ class IPayLinksService extends CI_Controller
//修改订单名
public function note_modal_save() {
$data = array();
$pn_txn_id = $this->input->post('pn_txn_id');
$pn_invoice = $this->input->post('pn_invoice');
if (!empty($pn_txn_id) && !empty($pn_invoice)) {
$orderid_info = $this->analysis_orderid($pn_invoice);
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
$advisor_info = $this->IPayLinks_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype);
if (!empty($advisor_info)) {
$this->Note_model->set_invoice($pn_txn_id, $pn_invoice);
$this->batch_send_note($pn_txn_id);
echo json_encode('修改成功!');
return true;
}
}
}
echo json_encode('没找到数据!');
$this->gai_modal_save();
// $data = array();
// $pn_txn_id = $this->input->post('pn_txn_id');
// $pn_invoice = $this->input->post('pn_invoice');
// if (!empty($pn_txn_id) && !empty($pn_invoice)) {
// $orderid_info = $this->analysis_orderid($pn_invoice);
// if (!empty($orderid_info)) {
// $orderid_info = json_decode($orderid_info);
// $advisor_info = $this->IPayLinks_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype);
// if (!empty($advisor_info)) {
// $this->Note_model->set_invoice($pn_txn_id, $pn_invoice);
// $this->batch_send_note($pn_txn_id);
// echo json_encode('修改成功!');
// return true;
// }
// }
// }
// echo json_encode('没找到数据!');
return;
}
@ -1106,6 +1133,7 @@ class IPayLinksService extends CI_Controller
*/
public function get_refund_list($daylength=3)
{
return false; // ipaylinks的批量查询接口已关闭
bcscale(2);
$ret = array();
$list = $this->refund_list_info($daylength);

@ -18,7 +18,7 @@ class Alipay_model extends CI_Model {
$fieldsql = $orderinfo == false ? '' : " ,* ";
//先查商务订单B,APP订单A、再查传统订单T
if ($ordertype == 'B' || $ordertype == 'A') {
$sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID =?";
$query = $this->HT->query($sql, array($COLI_ID));
@ -26,7 +26,7 @@ class Alipay_model extends CI_Model {
}
//后查传统订单的原因是因为传统订单的订单号去掉外联名字首字母后可能会和商务订单的重合。
if (empty($result) && ($ordertype == 'T')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID like '%$COLI_ID'";
$query = $this->HT->query($sql);
@ -36,7 +36,7 @@ class Alipay_model extends CI_Model {
//查传统订单add_code网前实时支付会先生成一个临时订单号存在add_code里如订单45103248
if (empty($result) && ($ordertype == 'M')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_AddCode =? ";
$query = $this->HT->query($sql, array($COLI_ID));
@ -44,7 +44,7 @@ class Alipay_model extends CI_Model {
}
if (empty($result) && ($ordertype == 'M')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where
EXISTS (
@ -60,7 +60,7 @@ class Alipay_model extends CI_Model {
//订单号查询不到尝试使用团号查询
if (empty($result) && $ordertype == 'B') {
$sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_GroupCode like '%-$COLI_ID%'";
$query = $this->HT->query($sql);
@ -68,10 +68,14 @@ class Alipay_model extends CI_Model {
}
//团号查询不到尝试使用客人邮箱查询(预订多次的老客户得按日期新旧排序,取最新的数据)
if (!empty($result)) {
if (!empty($result) && is_array($result) ) {
//print_r($result[0]);
//die();
$result = $result[0];
if (count($result) > 1) {
$result = array();
} else {
$result = $result[0];
}
}
return $result;
@ -119,7 +123,7 @@ class Alipay_model extends CI_Model {
$sql = "
UPDATE BIZ_ConfirmLineInfo
SET COLI_State = ?
WHERE COLI_SN = ?
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));
return $query;
@ -217,7 +221,7 @@ class Alipay_model extends CI_Model {
) VALUES (?,15015,?,?,?,?,?,?,?,?,?,?,0,0)";
$query = $this->HT->query($sql, array($GAI_AccreditNo, $GAI_COLI_SN, $GAI_SQJE, $GAI_SQDate, $GAI_SQJECurrency, $GAI_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo));
$insertid = $this->HT->last_id('GroupAccountInfo');
return $query;
return $insertid;
}
//更新线路提醒
@ -299,4 +303,15 @@ class Alipay_model extends CI_Model {
$query = $this->HT->query($sql, array($paymanner, $COLI_SN));
return $query;
}
/** JJH: 添加订单收款记录之后执行 */
public function exec_addToTask($GAI_SN)
{
$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;
$query = $this->HT->query($sql);
return $query;
}
}

@ -18,7 +18,7 @@ class IPayLinks_model extends CI_Model {
$fieldsql = $orderinfo == false ? '' : " ,* ";
//先查商务订单B,APP订单A、再查传统订单T
if ($ordertype == 'B' || $ordertype == 'A') {
$sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode, COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode, COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID =?";
$query = $this->HT->query($sql, array($COLI_ID));
@ -26,7 +26,7 @@ class IPayLinks_model extends CI_Model {
}
//后查传统订单的原因是因为传统订单的订单号去掉外联名字首字母后可能会和商务订单的重合。
if (empty($result) && ($ordertype == 'T')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID like '%$COLI_ID'";
$query = $this->HT->query($sql);
@ -36,7 +36,7 @@ class IPayLinks_model extends CI_Model {
//查传统订单add_code网前实时支付会先生成一个临时订单号存在add_code里如订单45103248
if (empty($result) && ($ordertype == 'M')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_AddCode =? ";
$query = $this->HT->query($sql, array($COLI_ID));
@ -44,7 +44,7 @@ class IPayLinks_model extends CI_Model {
}
if (empty($result) && ($ordertype == 'M')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where
EXISTS (
@ -60,7 +60,7 @@ class IPayLinks_model extends CI_Model {
//订单号查询不到尝试使用团号查询
if (empty($result) && $ordertype == 'B') {
$sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_GroupCode like '%-$COLI_ID%'";
$query = $this->HT->query($sql);
@ -68,10 +68,14 @@ class IPayLinks_model extends CI_Model {
}
//团号查询不到尝试使用客人邮箱查询(预订多次的老客户得按日期新旧排序,取最新的数据)
if (!empty($result)) {
if (!empty($result) && is_array($result) ) {
//print_r($result[0]);
//die();
$result = $result[0];
if (count($result) > 1) {
$result = array(); // 找到多条匹配的订单记录时,不处理
} else {
$result = $result[0];
}
}
return $result;
@ -119,20 +123,20 @@ class IPayLinks_model extends CI_Model {
$sql = "
UPDATE BIZ_ConfirmLineInfo
SET COLI_State = ?
WHERE COLI_SN = ?
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));
return $query;
}
//添加收款记录(商务订单),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) {
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) {
//先判断是否有这条数据
$sql = "
IF NOT EXISTS(
SELECT TOP 1 1
FROM BIZ_GroupAccountInfo
WHERE GAI_COLI_SN = ? AND GAI_SQJE=?
WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') and DeleteFlag=0
)
INSERT INTO BIZ_GroupAccountInfo (
GAI_COLI_SN
@ -141,6 +145,7 @@ class IPayLinks_model extends CI_Model {
,GAI_SQJE
,GAI_SQDate
,GAI_SQJECurrency
,GAI_SSJE
,GAI_SSDate
,GAI_AccountDate
,GAI_SubmitDate
@ -150,8 +155,8 @@ class IPayLinks_model extends CI_Model {
,GAI_Memo
,GAI_State
,DeleteFlag
) VALUES (?,?,15010,?,?,?,?,?,?,?,?,?,?,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_SSDate, $GAI_AccountDate, $GAI_SubmitDate, $GAI_CusName, $GAI_CusEmail, $GAI_AccreditNo, $GAI_Memo));
) VALUES (?,?,15018,?,?,?,?,?,?,?,?,?,?,?,0,0)";
$query = $this->HT->query($sql, array($GAI_AccreditNo, $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));
$insertid = $this->HT->last_id('BIZ_GroupAccountInfo');
return $query;
}
@ -197,7 +202,7 @@ class IPayLinks_model extends CI_Model {
IF NOT EXISTS(
SELECT TOP 1 1
FROM GroupAccountInfo
WHERE GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%'
WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') AND DeleteFlag=0
)
INSERT INTO GroupAccountInfo (
GAI_COLI_SN
@ -218,7 +223,7 @@ class IPayLinks_model extends CI_Model {
) VALUES (?,15018,?,?,?,?,?,?,?,?,?,?,?,0,0)";
$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));
$insertid = $this->HT->last_id('GroupAccountInfo');
return $query;
return $insertid;
}
//更新线路提醒
@ -309,9 +314,11 @@ class IPayLinks_model extends CI_Model {
//根据交易号获取收款记录(传统订单)
public function get_money_t($pn_invoice) {
$sql = "SELECT GroupAccountInfo.*
$like = $this->HT->escape_like_str($pn_invoice);
$sql = "SELECT COLI_ID,GroupAccountInfo.*
from GroupAccountInfo
where GAI_Type='15018' and DeleteFlag=0 and GAI_AccreditNo=?
inner join ConfirmLineInfo coli on COLI_SN=GAI_COLI_SN
where GAI_Type='15018' and GroupAccountInfo.DeleteFlag=0 and (GAI_AccreditNo=? or GAI_Memo like '%$like%')
";
$query = $this->HT->query($sql, array($pn_invoice));
$result = $query->result();
@ -319,9 +326,11 @@ class IPayLinks_model extends CI_Model {
}
//根据交易号获取收款记录(商务订单)
public function get_money_b($pn_invoice) {
$sql = "SELECT BIZ_GroupAccountInfo.*
$like = $this->HT->escape_like_str($pn_invoice);
$sql = "SELECT COLI_ID,BIZ_GroupAccountInfo.*
from BIZ_GroupAccountInfo
where GAI_Type='15018' and DeleteFlag=0 and GAI_AccreditNo=?
inner join BIZ_ConfirmLineInfo on COLI_SN=GAI_COLI_SN
where GAI_Type='15018' and BIZ_GroupAccountInfo.DeleteFlag=0 and (GAI_AccreditNo=? or GAI_Memo like '%$like%')
";
$query = $this->HT->query($sql, array($pn_invoice));
$result = $query->result();
@ -353,4 +362,14 @@ class IPayLinks_model extends CI_Model {
$query = $this->HT->query($sql, array($deadId));
return $query;
}
/** JJH: 添加订单收款记录之后执行 */
public function exec_addToTask($GAI_SN)
{
$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;
$query = $this->HT->query($sql);
return $query;
}
}

@ -3,15 +3,19 @@
<p>已录入订单 <?php echo!empty($old_order) ? $old_order : ""; ?></p>
<table class="table table-hover table-bordered">
<thead>
<th>订单号</th>
<th>申请金额/币种</th>
<th>实收金额</th>
</thead>
<?php foreach ($gai_info as $key => $value) { ?>
<tr>
<td><?php echo $gai_info[0]->GAI_SQJE; ?>&nbsp;<?php echo $gai_info[0]->GAI_SQJECurrency; ?></td>
<td><?php echo $gai_info[0]->GAI_SSJE; ?>&nbsp;CNY</td>
<td><?php echo $value->COLI_ID; ?></td>
<td><?php echo $value->GAI_SQJE; ?>&nbsp;<?php echo $value->GAI_SQJECurrency; ?></td>
<td><?php echo $value->GAI_SSJE; ?>&nbsp;CNY</td>
</tr>
<?php } ?>
</table>
<p>撤回以上订单收款记录, 并转移到订单: </p>
<p>撤回以上订单收款记录, 并转移到订单: (手动录入的不会撤回) </p>
<?php } ?>
<div class="input-group">
<input type="text" class="form-control" id="pn_invoice" name="pn_invoice" value="<?php echo $new_order; ?>" placeholder="输入订单号" >

@ -48,4 +48,5 @@
</dl>
<input type="hidden" name="pn_txn_id" id="pn_txn_id" value="<?php echo $note->IPL_dealId; ?>" />
<input type="hidden" name="pn_id" id="pn_id" value="<?php echo $note->IPL_sn; ?>" />
</form>

@ -189,6 +189,21 @@ class Index extends CI_Controller {
echo ('更新了' . ($result_count) . '条记录');
}
public function get_transactions_detail_by_paymentToken()
{
$token = $this->input->post("t");
$base = $this->base(0);
// $post = "METHOD=GetTransactionDetails&VERSION=100.0&TRANSACTIONID=$token";
// $post = "METHOD=GetExpressCheckoutDetails&VERSION=124.0&TOKEN=$token";
$token = str_replace(' ', 'T', $token) . 'Z';
$post = "METHOD=TransactionSearch&VERSION=100.0&TRANSACTIONCLASS=ALL&STARTDATE=$token";
$detail = $this->call($base, $post);
var_dump($detail);
return;
}
//根据交易号获取交易详细信息
public function get_transactions_detail($redirect = 0) {
//从数据库提取一条还没有更新交易详情的记录获取交易号
@ -804,10 +819,8 @@ class Index extends CI_Controller {
$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');
if ($advisor_info->COLI_Department == 10) {
// 把订单状态设置为13-新订单已支付
$this->Paypal_model->update_biz_coli_state($GAI_COLI_SN, 13);
}
}
}
//更新还没有填的客邮和交易号de收款记录传统订单
@ -815,9 +828,11 @@ class Index extends CI_Controller {
$ht_memo = '交易号(自动录入):' . $item->pn_txn_id;
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
$ssje = $this->Paypal_model->get_ssje($item->pn_mc_gross, '15002', mb_strtoupper($item->pn_mc_currency));
$this->Paypal_model->add_tour_account_info($GAI_COLI_SN, $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, $item->pn_payer_email, $item->pn_txn_id, $ht_memo);
$gai_sn = $this->Paypal_model->add_tour_account_info($GAI_COLI_SN, $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, $item->pn_payer_email, $item->pn_txn_id, $ht_memo);
//添加汉特的订单提醒
$this->Paypal_model->update_coli_introduction($GAI_COLI_SN, '已支付 ' . mb_strtoupper($item->pn_mc_currency) . $item->pn_mc_gross);
// 添加HT任务
$this->Paypal_model->exec_addToTask($gai_sn);
}
}
@ -927,25 +942,26 @@ class Index extends CI_Controller {
//修改订单名
public function note_modal_save() {
$data = array();
$pn_txn_id = $this->input->post('pn_txn_id');
$pn_invoice = $this->input->post('pn_invoice');
if (!empty($pn_txn_id) && !empty($pn_invoice)) {
$orderid_info = $this->analysis_orderid($pn_invoice);
if (!empty($orderid_info)) {
$orderid_info = json_decode($orderid_info);
$advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype);
if (!empty($advisor_info)) {
$this->Note_model->set_invoice($pn_txn_id, $pn_invoice);
$this->send_note($pn_txn_id);
echo json_encode('修改成功!');
return true;
}
}
}
echo json_encode('没找到数据!');
$this->gai_modal_save();
// $data = array();
// $pn_txn_id = $this->input->post('pn_txn_id');
// $pn_invoice = $this->input->post('pn_invoice');
// if (!empty($pn_txn_id) && !empty($pn_invoice)) {
// $orderid_info = $this->analysis_orderid($pn_invoice);
// if (!empty($orderid_info)) {
// $orderid_info = json_decode($orderid_info);
// $advisor_info = $this->Paypal_model->get_order($orderid_info->orderid, false, $orderid_info->ordertype);
// if (!empty($advisor_info)) {
// $this->Note_model->set_invoice($pn_txn_id, $pn_invoice);
// $this->send_note($pn_txn_id);
// echo json_encode('修改成功!');
// return true;
// }
// }
// }
// echo json_encode('没找到数据!');
}
//关闭note通知用于手动处理通知后

@ -19,7 +19,7 @@ class Paypal_model extends CI_Model {
$fieldsql = $orderinfo == false ? '' : " ,* ";
//先查商务订单B,APP订单A、再查传统订单T
if ($ordertype == 'B' || $ordertype == 'A') {
$sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID =?";
$query = $this->HT->query($sql, array($COLI_ID));
@ -27,7 +27,7 @@ class Paypal_model extends CI_Model {
}
//后查传统订单的原因是因为传统订单的订单号去掉外联名字首字母后可能会和商务订单的重合。
if (empty($result) && ($ordertype == 'T')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID like '%$COLI_ID'";
$query = $this->HT->query($sql);
@ -37,7 +37,7 @@ class Paypal_model extends CI_Model {
//查传统订单add_code网前实时支付会先生成一个临时订单号存在add_code里如订单45103248
if (empty($result) && ($ordertype == 'M')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_AddCode =? ";
$query = $this->HT->query($sql, array($COLI_ID));
@ -45,7 +45,7 @@ class Paypal_model extends CI_Model {
}
if (empty($result) && ($ordertype == 'M')) {
$sql = "SELECT TOP 1 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where
EXISTS (
@ -61,7 +61,7 @@ class Paypal_model extends CI_Model {
//订单号查询不到尝试使用团号查询
if (empty($result) && $ordertype == 'B') {
$sql = "SELECT TOP 1 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_GroupCode like '%-$COLI_ID%'";
$query = $this->HT->query($sql);
@ -69,10 +69,14 @@ class Paypal_model extends CI_Model {
}
//团号查询不到尝试使用客人邮箱查询(预订多次的老客户得按日期新旧排序,取最新的数据)
if (!empty($result)) {
if (!empty($result) && is_array($result) ) {
//print_r($result[0]);
//die();
$result = $result[0];
if (count($result) > 1) {
$result = array();
} else {
$result = $result[0];
}
}
return $result;
@ -120,7 +124,7 @@ class Paypal_model extends CI_Model {
$sql = "
UPDATE BIZ_ConfirmLineInfo
SET COLI_State = ?
WHERE COLI_SN = ?
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));
return $query;
@ -133,7 +137,7 @@ class Paypal_model extends CI_Model {
IF NOT EXISTS(
SELECT TOP 1 1
FROM BIZ_GroupAccountInfo
WHERE GAI_COLI_SN = ? AND GAI_SQJE=?
WHERE GAI_COLI_SN = ? AND GAI_SQJE=? AND DeleteFlag=0
)
INSERT INTO BIZ_GroupAccountInfo (
GAI_COLI_SN
@ -166,7 +170,7 @@ class Paypal_model extends CI_Model {
IF NOT EXISTS(
SELECT TOP 1 1
FROM BIZ_GroupAccountInfo
WHERE GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%'
WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') AND DeleteFlag=0
)
INSERT INTO BIZ_GroupAccountInfo (
GAI_COLI_SN
@ -199,7 +203,7 @@ class Paypal_model extends CI_Model {
IF NOT EXISTS(
SELECT TOP 1 1
FROM GroupAccountInfo
WHERE GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%'
WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%') and DeleteFlag=0
)
INSERT INTO GroupAccountInfo (
GAI_COLI_SN
@ -220,7 +224,7 @@ class Paypal_model extends CI_Model {
) VALUES (?,15002,?,?,?,?,?,?,?,?,?,?,?,0,0)";
$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));
$insertid = $this->HT->last_id('GroupAccountInfo');
return $query;
return $insertid;
}
//更新线路提醒
@ -254,10 +258,6 @@ class Paypal_model extends CI_Model {
return $query;
}
public function note_list() {
}
public function save_paypal_msg($pm_transaction_id, $pm_orderid, $pm_item_name, $pm_money, $pm_currency, $pm_payer, $pm_payer_email, $pm_payer_status, $pm_memo, $pm_payment_date, $pm_pay_type) {
$sql = "INSERT INTO paypal_msg (
pm_transaction_id
@ -554,4 +554,15 @@ class Paypal_model extends CI_Model {
$query = $this->HT->query($sql, array($deadId));
return $query;
}
/** JJH: 添加订单收款记录之后执行 */
public function exec_addToTask($GAI_SN)
{
$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;
$query = $this->HT->query($sql);
return $query;
}
}

@ -266,7 +266,6 @@
}
function show_gai_modal(pn_txn_id, pn_id, new_order) {
$('#modal_set_gai').modal('show');
var url = '/webht.php/apps/paypal/index/gai_modal/' + pn_txn_id + '/' + pn_id;
if (new_order) url += '/' + new_order;
$.ajax({

@ -30,7 +30,7 @@
<dl class="dl-horizontal">
<dt>订单号</dt>
<dd>
<dd>
<div class="input-group">
<input type="text" class="form-control" id="pn_invoice" name="pn_invoice" value="<?php echo!empty($pn_invoice) ? $pn_invoice : $note->pn_invoice; ?>">
<span class="input-group-btn">
@ -66,4 +66,5 @@
</dl>
<input type="hidden" name="pn_txn_id" id="pn_txn_id" value="<?php echo $note->pn_txn_id ?>" />
</form>
<input type="hidden" name="pn_id" id="pn_id" value="<?php echo $note->pn_sn; ?>" />
</form>

Loading…
Cancel
Save