自动出票优化整理

hotfix/远程访问多媒体中心
cyc 8 years ago
parent 4c315b31d6
commit 52c765e874

@ -38,36 +38,24 @@ class Auto extends CI_Controller{
$this->load->model("BIZ_train_model");//加载模型
}
public function auto_check_ticket(){
$ticket_info = $this->BIZ_train_model->auto_check_ticket();
print_r($ticket_info);
foreach($ticket_info as $value){
if(strlen($value->GUT_Passport) < 18){
$this->auto_pay_ticket($value->COLI_SN);
}
}
}
//用于自动出票,接收COLI_SN
public function auto_pay_ticket($coli_sn=false){
//用于自动出票
public function auto_pay_ticket(){
date_default_timezone_set('Asia/Shanghai');
// $coli_sn="473013018";
//$coli_sn = $this->input->post("coli_sn");
$list=new StdClass;
$ticket_info = $this->BIZ_train_model->auto_check_ticket();
//print_r($ticket_info);
foreach($ticket_info as $item){
$back_data = 1;
$coli_sn = $item->COLI_SN;
if(!empty($coli_sn)){
$cold_sn=$this->BIZ_train_model->get_cold_sn($coli_sn);
$cold_sn = $this->BIZ_train_model->get_cold_sn($coli_sn);
$coli_id = $this->BIZ_train_model->coli_sn_get_coli_id($coli_sn);
$i = 0;
$list->info=array();
foreach ($cold_sn as $v) {
//print_r(empty($this->BIZ_train_model->auto_check_pullticket($v->COLD_SN)));
//是否已经出过票
if(empty($this->BIZ_train_model->auto_check_pullticket($v->COLD_SN))){
$back_data = 1;
break;
}
//是否已经出过票(通过查询聚合数据判断此订单是否已经请求过聚合)
if(empty($this->BIZ_train_model->get_biz_jol($v->COLD_SN))){
//邮寄的不自动出票
if($v->COLD_SPFS > 1){
//寄送票
$back_data = 0;
@ -76,17 +64,27 @@ class Auto extends CI_Controller{
$list->info[$i]=new StdClass;
$list->info[$i]->people=$this->BIZ_train_model->biz_people($v->COLD_SN);
$list->info[$i]->train=$this->BIZ_train_model->get_biz_foi($v->COLD_SN);
$list->info[$i]->status=$this->BIZ_train_model->get_biz_jol($v->COLD_SN);
//乘客人数大于5人不出票
//print_r($list->info[$i]->people);
//print_r($list->info[$i]->train);
//护照位数大于18位则不自动出票
if(strlen($list->info[$i]->people[$i]->BPE_Passport) >= 18){
$back_data = 0;
break;
}
//乘客人数大于5人不出票
if(count($list->info[$i]->people) > 5){
$back_data = 0;
break;
};
//3小时以内或者大于29天的不出票
if((strtotime($list->info[$i]->train[0]->DepartureTime) - time())/3600 < 3 or (strtotime($list->info[$i]->train[0]->DepartureTime) - time())/24/3600 >29){
$back_data = 0;
break;
}
//金额不能大于1000人民币
if($list->info[$i]->train[0]->adultcost > 1000){
$back_data = 0;
@ -94,6 +92,8 @@ class Auto extends CI_Controller{
}
$i++;
}
}
if($back_data == 0){
echo 0;
return false;
@ -113,8 +113,9 @@ class Auto extends CI_Controller{
}
return false;
}
}
}
//根据汉特订单明细表SN来获取车次乘客信息拼接成聚合提交订单的url
public function submit_juhe_order($cold_sn,$coli_id) {
// $cold_sn=$this->input->get("order");
@ -146,6 +147,7 @@ class Auto extends CI_Controller{
echo json_encode($reback);
return false;
}
//前面做过判断,为什么还要再判断一次
if (count($data['people_list']) > 5) {
//显示错误,用户超过五个
$reback["mes"]="乘客不能超过五个";
@ -201,7 +203,7 @@ class Auto extends CI_Controller{
print_r($url);
print_r($post_data);
die();
// $bakc_json=$this->post_data($url,$post_data);
//$bakc_json=$this->post_data($url,$post_data);
$bakc=json_decode($bakc_json);//json=>obj
$add_data=new StdClass();
@ -222,16 +224,20 @@ class Auto extends CI_Controller{
$reback["order"]=$bakc->result->orderid;
$reback["mes"]="订单提交成功,等待回调";
$this->send_mail_to_wl("订单:{$coli_id} 提交成功","翰特订单号:{$coli_id} ;聚合订单号:{$bakc->result->orderid}");
//聚合返回成功信息后将处理过的订单标记为付款已出票61
$this->BIZ_train_model->update_ticket_state($coli_id);
}else{
$add_data->JOL_JuheOrder=null;
$reback["mes"]= $bakc_json;
$add_data->JOL_Status="e";
$this->send_mail_to_wl("订单:{$coli_id} 提交失败","翰特订单号:{$coli_id}");
}
//聚合返回数据之后记录到聚合订单表
$add_back_data=$this->BIZ_train_model->add_biz_jol($add_data);
return $reback;
}
public function ticket_status($coli_sn="",$jh_id=""){
if(empty($coli_sn)){
$coli_sn = $this->input->get("sn");
@ -266,6 +272,7 @@ class Auto extends CI_Controller{
$list->cols_id = $cols_id[0]->COLI_ID;
$this->load->view("ticket_status",$list);
}
//发邮件给外联
public function send_mail_to_wl($subject,$body){
$this->load->model("Sendmail_model");
@ -273,7 +280,7 @@ class Auto extends CI_Controller{
$fromEmail = "csk@hainatravel.com";
$toName = "ethel";
$toEmail = "ethel@chinahighlights.com";
$this->Sendmail_model->SendGuest($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
}
//发邮件给客人
public function send_mail_to_guest($coli_id,$jh_order){
@ -285,7 +292,7 @@ class Auto extends CI_Controller{
$toEmail = $guest[0]->GUT_Email;
$subject = "auto pay test $jh_order";
$body = "csk test train ticket $jh_order";
$this->Sendmail_model->SendGuest($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
$this->Sendmail_model->SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body);
}
//
public function sub_callback(){

@ -7,16 +7,32 @@ class BIZ_train_model extends CI_Model {
$this->HT = $this->load->database('HT', TRUE);
}
//自动获取符合自动出票要求的订单的coli_sn
function auto_check_ticket($topnum=5){
$sql = "select top $topnum * from BIZ_ConfirmLineInfo bcli left join BIZ_Guest bg on bcli.COLI_GUT_SN = bg.GUT_SN where COLI_ServiceType = '2' and COLI_State ='62' AND bcli.COLI_WebCode='CHT' ORDER BY bcli.COLI_SN DESC";
$sql = "SELECT
top $topnum COLI_SN
FROM
BIZ_ConfirmLineInfo
WHERE
COLI_ServiceType = '2'
AND COLI_State ='62'
AND COLI_WebCode='CHT'
ORDER BY
COLI_SN DESC";
$query = $this->HT->query($sql);
return $query->result();
}
function auto_check_pullticket($coli_sn){
$sql = "SELECT * FROM BIZ_JuheOrderList where JOL_COLD_SN = '$coli_sn'";
//自动出票成功后更新订单的状态
function update_ticket_state($coli_id){
$sql = "UPDATE
BIZ_ConfirmLineInfo
SET
COLI_State = '61'
WHERE
COLI_ID = '$coli_id'";
$query = $this->HT->query($sql);
return $query->row();
return $query;
}
function biz_order_detail($cold_sn) {

@ -0,0 +1,80 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Sendmail_model extends CI_Model {
function __construct()
{
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
function SendMailToTable($fromName,$fromEmail,$toName,$toEmail,$subject,$body)
{
if($this->validEmail($toEmail))
{
$data = array(
"M_ReplyToName" => $fromName, //回复人
"M_ReplyToEmail" => $fromEmail, //回复地址
"M_ToName" => $toName, //收件人名
"M_ToEmail" => $toEmail, //收件邮件地址
"M_Title" => $subject, //主题
"M_Body" => $body, //邮件正文
"M_Web" => "CHT", //所属站点
"M_FromName" => "Chinahighlights.com", //站点名称
"M_State" => 0,
);
$this->HT->insert('Email_AutomaticSend',$data);
return TRUE;
}else{
return FALSE;
}
}
public function validEmail($email){
$isValid = true;
$atIndex = strrpos($email, "@");
if (is_bool($atIndex) && !$atIndex){
$isValid = false;
}else{
$domain = substr($email, $atIndex+1);
$local = substr($email, 0, $atIndex);
$localLen = strlen($local);
$domainLen = strlen($domain);
if ($localLen < 1 || $localLen > 64){
// local part length exceeded
$isValid = false;
}else if ($domainLen < 1 || $domainLen > 255){
// domain part length exceeded
$isValid = false;
}else if ($local[0] == '.' || $local[$localLen-1] == '.'){
// local part starts or ends with '.'
$isValid = false;
}else if (preg_match('/\\.\\./', $local)){
// local part has two consecutive dots
$isValid = false;
}else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)){
// character not valid in domain part
$isValid = false;
}else if (preg_match('/\\.\\./', $domain)){
// domain part has two consecutive dots
$isValid = false;
}else if(!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',str_replace("\\\\","",$local))){
// character not valid in local part unless
// local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/',str_replace("\\\\","",$local))){
$isValid = false;
}
}
/*
不检查是否有DNS解析
if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))){
// domain not found in DNS
$isValid = false;
}
*/
}
return $isValid;
}
}
Loading…
Cancel
Save