diff --git a/application/third_party/trainsystem/controllers/api.php b/application/third_party/trainsystem/controllers/api.php index fc1c9598..9cbb365c 100644 --- a/application/third_party/trainsystem/controllers/api.php +++ b/application/third_party/trainsystem/controllers/api.php @@ -143,14 +143,37 @@ class api extends CI_Controller{ } //发邮件给外联 - function send_mail_to_wl($subject,$body,$coli_id){ + function send_mail_to_wl($subject=null,$body=null,$coli_id=null){ + header('Access-Control-Allow-Origin:*'); + header('Access-Control-Allow-Methods:POST, GET'); + header('Access-Control-Max-Age:0'); + header('Access-Control-Allow-Headers:x-requested-with, Content-Type'); + header('Access-Control-Allow-Credentials:true'); $fromName = "cyc"; $fromEmail = "cyc@hainatravel.com"; - //获取该订单的操作员的邮箱以及姓名 - $info = $this->BIZ_train_model->get_operatorInfo($coli_id); - $toName = $info[0]->OPI_Name; - $toEmail = $info[0]->OPI_Email; - $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body); + if(empty($coli_id)){ + $toName = 'Sharon'; + $toEmail = 'Sharon@hainatravel.com'; + $fromEmail = $this->input->get_post('concatEmail'); + $body = $this->input->get_post('addrequest'); + if(empty($fromEmail) && empty($body)){ + exit('error'); + } + }else{ + //获取该订单的操作员的邮箱以及姓名 + $info = $this->BIZ_train_model->get_operatorInfo($coli_id); + $toName = $info[0]->OPI_Name; + $toEmail = $info[0]->OPI_Email; + } + + $obj = $this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body); + + if($obj){ + exit('{"status":"200","reason":"邮件发送成功"}'); + }else{ + header("HTTP/1.1 404 Not Found"); + exit('{"status":"404","reason":"邮件发送失败"}'); + } } //导出账单api