perf: PayPal: APP组退款记录录入后补充记录: 录入`我的支付`; 执行HT任务`SP_AddToSystask`; ACDC付款忽略邮箱地址

webht/payment
Lei OT 3 months ago
parent 102ce623d3
commit 740f1aed0a

@ -638,13 +638,13 @@ class Index extends CI_Controller {
echo 'no';
return;
}
log_message('error',"paypal_webhook" . var_export($raw_post, 1));
$post_data = json_decode($raw_post);
if (
strpos($post_data->event_type, 'COMPLETED') === false
&& strpos($post_data->event_type, 'REFUNDED') === false
&& strpos($post_data->event_type, 'PAYMENT.CAPTURE.DECLINED') === false
) {
log_message('error',"paypal_webhook" . var_export($raw_post, 1));
return;
}
// if ($post_data->event_type != 'PAYMENT.SALE.COMPLETED' && $post_data->event_type != 'PAYMENT.SALE.REFUNDED') {
@ -1144,6 +1144,12 @@ class Index extends CI_Controller {
// continue;
// }
$pay_email = $item->pn_payer_email;
// PayPal ACDC生成的随机邮箱不记录付款信息
if (strpos($pay_email, 'paypal.com') !== false) {
$pay_email = '';
}
//添加支付信息入库
//没有分配订单之前先添加付款记录,这个过程可能会执行多次,必须在添加记录前查找是否有数据
if (!empty($orderid_info)) {
@ -1157,19 +1163,21 @@ class Index extends CI_Controller {
if (isset($advisor_info->order_type) && $advisor_info->order_type == 0) {
$ht_memo = '交易号(自动录入):' . $item->pn_txn_id;
//CHTAPP订单添加记录前判断是否有记录以前的APP版本没有交易号只能拿金额来判断
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") !== '-biz') {//只判断前6位字符CHTAPP-fr CHTAPP-jp等各语种都属于APP订单
$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, $item->pn_payer_email, $item->pn_txn_id, $ht_memo, $GAI_API);
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP' && strstr($advisor_info->COLI_WebCode, "-") !== '-biz') {
//只判断前6位字符CHTAPP-fr CHTAPP-jp等各语种都属于APP订单
$gai_sn = $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, $pay_email, $item->pn_txn_id, $ht_memo, $GAI_API);
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->insert_biz_order_log($GAI_COLI_SN, 'BS8');
}
} else {
// 商务订单, 除了APP
// 把订单状态设置为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);
$this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'BS13');
}
$this->Paypal_model->add_account_info(
$gai_sn = $this->Paypal_model->add_account_info(
$GAI_COLI_SN,
$advisor_info->COLI_ID,
$item->pn_mc_gross,
@ -1181,22 +1189,24 @@ class Index extends CI_Controller {
$item->pn_payment_date,
$item->pn_payment_date,
$item->pn_payer,
$item->pn_payer_email,
$pay_email,
$item->pn_txn_id,
$ht_memo, $GAI_API);
// 更新订单主表付款方式,防止没访问thankyou-train.asp
$this->Paypal_model->update_paymanner($GAI_COLI_SN, '15010');
}
// 添加HT任务
$this->Paypal_model->exec_addToTask($gai_sn, 227002);
}
//更新还没有填的客邮和交易号de收款记录传统订单
elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) {
$ht_memo = '交易号(自动录入):' . $item->pn_txn_id;
$GAI_COLI_SN = isset($advisor_info->COLI_SN) ? $advisor_info->COLI_SN : 0;
$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, $GAI_API);
$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, $pay_email, $item->pn_txn_id, $ht_memo, $GAI_API);
//添加汉特的订单提醒
$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);
$this->Paypal_model->exec_addToTask($gai_sn, 227001);
}
}
@ -1223,7 +1233,7 @@ class Index extends CI_Controller {
if ( ($item->pn_send !== 'send' && false===$is_webhook ) || true===$handpick) {
//给外联发送通知邮件
$fromName = !empty($item->pn_payer) ? $item->pn_payer : '';
$fromEmail = !empty($item->pn_payer_email) ? $item->pn_payer_email : '';
$fromEmail = !empty($pay_email) ? $pay_email : '';
$toName = !empty($opi_firstname) ? $opi_firstname : '';
$toEmail = !empty($opi_email) ? $opi_email : '';
$subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->pn_mc_gross . $item->pn_mc_currency . ' / ' . $fromName;
@ -1350,15 +1360,23 @@ class Index extends CI_Controller {
$ht_memo .= '原收款号:' . $parent_txn_id;
$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订单
$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, $item->pn_payer_email, $item->pn_txn_id, $ht_memo);
//只判断前6位字符CHTAPP-fr CHTAPP-jp等各语种都属于APP订单
if (substr($advisor_info->COLI_WebCode, 0, 6) == 'CHTAPP'
&& strstr($advisor_info->COLI_WebCode, "-") != '-biz'
) {
$insertedID = $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, $item->pn_payer_email, $item->pn_txn_id, $ht_memo);
if ($insertedID) {
$this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'Refunded');
$this->Paypal_model->exec_BIZ_TrainCostAdd($GAI_COLI_SN, $ssje);
}
} else {
if (false == $this->Paypal_model->if_biz_gai_exists($item->pn_txn_id) ) {
$this->Paypal_model->insert_biz_order_log($GAI_COLI_SN, 'Refunded');
}
$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), $USD_amount, $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);
$insertedID = $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), $USD_amount, $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);
}
// 添加HT任务
$this->Paypal_model->exec_addToTask($insertedID, 227002);
}
//更新还没有填的客邮和交易号的收款记录(传统订单)
elseif (isset($advisor_info->order_type) && $advisor_info->order_type == 1) {
@ -1368,6 +1386,8 @@ class Index extends CI_Controller {
$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, 227001);
}
}

Loading…
Cancel
Save