fix: PayPal退款记录: 重复发邮件

webht/payment
Lei OT 9 months ago
parent 370dfd42e2
commit 18bb1e1e84

@ -1309,6 +1309,7 @@ class Index extends CI_Controller {
//更新正确的订单信息到记录中,以这个为主 //更新正确的订单信息到记录中,以这个为主
$this->Note_model->set_invoice($item->pn_txn_id, $orderid_info->orderid . '_' . $orderid_info->ordertype); $this->Note_model->set_invoice($item->pn_txn_id, $orderid_info->orderid . '_' . $orderid_info->ordertype);
} }
$is_webhook = false;
$payment_fee = 0; $payment_fee = 0;
$refund_amount = 0; $refund_amount = 0;
if (isset($payment_memo->id) && substr($payment_memo->id, 0, 2)==="WH") { if (isset($payment_memo->id) && substr($payment_memo->id, 0, 2)==="WH") {
@ -1367,69 +1368,84 @@ class Index extends CI_Controller {
return false; return false;
} }
//添加邮件发送记录 $this->Note_model->update_send($item->pn_txn_id, 'send-', $item->pn_sn);
if ($item->pn_send !== 'send' && substr($item->pn_send, 0, 5) !== 'send-') { //添加邮件发送记录; webhook不发送邮件, 避免重复
// 客人邮件中的外联落款 if ($is_webhook === false) {
// $web_code = 'cht'; // 默认cht if ($item->pn_send !== 'send' && substr($item->pn_send, 0, 5) !== 'send-'
$web_lgc = 1; ) {
$web_code = strtolower($advisor_info->COLI_WebCode); // 客人邮件中的外联落款
$site_info = $this->config->item('site'); // $web_code = 'cht'; // 默认cht
if (isset($site_info[$web_code])) { $web_lgc = 1;
$site_info = $site_info[$web_code]; $web_code = strtolower($advisor_info->COLI_WebCode);
$item->site = $site_info['site_url']; $site_info = $this->config->item('site');
$web_lgc = $site_info['site_lgc']; if (isset($site_info[$web_code])) {
} $site_info = $site_info[$web_code];
$advisor_detail = $this->Paypal_model->get_advisor_detail($advisor_info->COLI_SN, $advisor_info->OPI_SN, $web_lgc); $item->site = $site_info['site_url'];
$item->advisor_detail = $advisor_detail; $web_lgc = $site_info['site_lgc'];
}
$item->payment_date = isset($item->payment_date) ? $item->payment_date : $item->pn_payment_date; $advisor_detail = $this->Paypal_model->get_advisor_detail($advisor_info->COLI_SN, $advisor_info->OPI_SN, $web_lgc);
$item->advisor_detail = $advisor_detail;
//给外联发送通知邮件 $item->payment_date = isset($item->payment_date) ? $item->payment_date : $item->pn_payment_date;
$fromName = !empty($item->pn_payer) ? $item->pn_payer : '';
$fromEmail = !empty($item->pn_payer_email) ? $item->pn_payer_email : ''; //给外联发送通知邮件
$toName = !empty($opi_firstname) ? $opi_firstname : ''; $fromName = !empty($item->pn_payer) ? $item->pn_payer : '';
$toEmail = !empty($opi_email) ? $opi_email : ''; $fromEmail = !empty($item->pn_payer_email) ? $item->pn_payer_email : '';
$subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->pn_mc_gross . $item->pn_mc_currency . ' / ' . $fromName; $toName = !empty($opi_firstname) ? $opi_firstname : '';
$body = $this->load->view('mail_templete', $item, true); $toEmail = !empty($opi_email) ? $opi_email : '';
$M_RelatedInfo = $item->pn_sn; $subject = $orderid_info->orderid . '_' . $orderid_info->ordertype . ' / ' . $item->pn_mc_gross . $item->pn_mc_currency . ' / ' . $fromName;
$M_AddTime = $item->pn_payment_date; $body = $this->load->view('mail_templete', $item, true);
$M_State = 0; $M_RelatedInfo = $item->pn_sn;
if (!empty($toEmail)) { $M_AddTime = $item->pn_payment_date;
$this->Paypal_model->save_automail($fromName, $fromEmail, $toName, $toEmail, $subject, $body, $M_RelatedInfo, $M_State, $M_AddTime, 'paypal note'); $M_State = 0;
if (!empty($toEmail)) {
$this->Paypal_model->save_automail(
$fromName,
$fromEmail,
$toName,
$toEmail,
$subject,
$body,
$M_RelatedInfo,
$M_State,
$M_AddTime,
'paypal note'
);
}
// 通知客人, 客人邮箱
// $customer_detail = $this->Paypal_model->get_customer_detail($advisor_info->COLI_SN, $orderid_info->ordertype);
$c_fromName = $advisor_detail->fullname ? $advisor_detail->fullname : $opi_firstname;
$opi_email_list = explode(";", $advisor_detail->email); // 解析外联的邮件
$c_fromEmail = isset($opi_email_list[0]) ? trim($opi_email_list[0]) : $opi_email;
$c_toName = $item->pn_payer; // $customer_detail->fullname;
$c_toEmail = $item->pn_payer_email ; // $customer_detail->email;
$c_subject = $item->pn_mc_currency . " " . str_replace('-', '', $item->pn_mc_gross) . " Refunded to your account, booking number " . $item->pn_invoice;
$c_body = $this->load->view('refund_buyer', $item, true);
$c_M_RelatedInfo = $item->pn_sn;
$c_M_AddTime = $item->pn_payment_date;
$c_M_State = 0;
$this->Paypal_model->save_automail(
$c_fromName,
$c_fromEmail,
$c_toName,
$c_toEmail,
$c_subject,
$c_body,
$c_M_RelatedInfo,
$c_M_State,
$c_M_AddTime,
'ChinaHighlights refund receipt');
$this->Note_model->update_send($item->pn_txn_id, 'send-customer', $item->pn_sn);
}
//添加邮件发送记录 end
// 如果已做账, 标记需要通知财务send-to-finance, 通知时间用订单日志记录
// 更新是否需要发送财务
$refund_finance_day = 20;
$now_day = date('d');
$late_entry_date_set = $now_day<$refund_finance_day ? date('Y-m-01', strtotime("-1 month")) : date('Y-m-01');
if ($this->Paypal_model->if_finance_done($advisor_info->COLI_GRI_SN, $late_entry_date_set) === true) {
$this->Note_model->update_send($item->pn_txn_id, 'send-to-finance', $item->pn_sn);
} }
// 通知客人, 客人邮箱
// $customer_detail = $this->Paypal_model->get_customer_detail($advisor_info->COLI_SN, $orderid_info->ordertype);
$c_fromName = $advisor_detail->fullname ? $advisor_detail->fullname : $opi_firstname;
$opi_email_list = explode(";", $advisor_detail->email); // 解析外联的邮件
$c_fromEmail = isset($opi_email_list[0]) ? trim($opi_email_list[0]) : $opi_email;
$c_toName = $item->pn_payer; // $customer_detail->fullname;
$c_toEmail = $item->pn_payer_email ; // $customer_detail->email;
$c_subject = $item->pn_mc_currency . " " . str_replace('-', '', $item->pn_mc_gross) . " Refunded to your account, booking number " . $item->pn_invoice;
$c_body = $this->load->view('refund_buyer', $item, true);
$c_M_RelatedInfo = $item->pn_sn;
$c_M_AddTime = $item->pn_payment_date;
$c_M_State = 0;
$this->Paypal_model->save_automail(
$c_fromName,
$c_fromEmail,
$c_toName,
$c_toEmail,
$c_subject,
$c_body,
$c_M_RelatedInfo,
$c_M_State,
$c_M_AddTime,
'ChinaHighlights refund receipt');
$this->Note_model->update_send($item->pn_txn_id, 'send-customer', $item->pn_sn);
}
//添加邮件发送记录 end
// 如果已做账, 标记需要通知财务send-to-finance, 通知时间用订单日志记录
// 更新是否需要发送财务
$refund_finance_day = 20;
$now_day = date('d');
$late_entry_date_set = $now_day<$refund_finance_day ? date('Y-m-01', strtotime("-1 month")) : date('Y-m-01');
if ($this->Paypal_model->if_finance_done($advisor_info->COLI_GRI_SN, $late_entry_date_set) === true) {
$this->Note_model->update_send($item->pn_txn_id, 'send-to-finance', $item->pn_sn);
} }
$this->Note_model->update_send_case($parent_txn_id, 'send'); $this->Note_model->update_send_case($parent_txn_id, 'send');
return ; return ;

Loading…
Cancel
Save