trippest 整理model

feature/pay
lyt 7 years ago
parent bcd90a5faa
commit eaedc2bfcf

@ -50,7 +50,6 @@ class TulanduoApi extends CI_Controller
public function __construct(){
parent::__construct();
$this->load->model('Orders_model');
$this->load->model('Order_insert');
$this->load->model('TuLanDuo_queryContentBuilder', 'tld_order');
$this->load->helper('array');
@ -75,8 +74,8 @@ class TulanduoApi extends CI_Controller
->setKey($this->key)
->setPageSize(20)
->setPageIndex(1)
->setStartTravelDate("2018-04-18")
->setEndTravelDate("2018-04-18")
->setStartTravelDate("2018-04-19") // test
->setEndTravelDate("2018-04-19")
// ->setStartOrderDate("2018-04-13")
// ->setEndOrderDate("2018-04-13")
;
@ -117,7 +116,7 @@ class TulanduoApi extends CI_Controller
preg_match('^[a-zA-Z]+\-[0-9\-]+^', $this->characet($vo['routeName'], "UTF-8"), $temp_array);
if (empty($temp_array) && isset($this->pag_no_tmp()[$vo['routeName']])) {
// 旧的数据没有线路代号
$PAG_Code = $pag_sub = $this->pag_no_tmp()[$vo['routeName']];
$PAG_Code = $this->pag_no_tmp()[$vo['routeName']];
$split_code = explode("-", $PAG_Code);
$PAG_Code = $split_code[0] . "-" . $split_code[1];
isset($split_code[2]) ? $pag_sub=$split_code[2] : null;
@ -190,17 +189,17 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
$this->Orders_model->biz_confirm_detail_save();
/** VendorArrangeState */
$vendor_contact = $this->Orders_model->get_vendorContact($this->Orders_model->COLD_PlanVEI_SN);
$this->Order_insert->VAS_GRI_SN = $this->Orders_model->GRI_SN ? $this->Orders_model->GRI_SN : null;
$this->Order_insert->VAS_VEI_SN = $this->Orders_model->COLD_PlanVEI_SN;
$this->Order_insert->VAS_IsSendSucceed = 1;
$this->Order_insert->VAS_IsConfirm = $vo['orderStatus'];
$this->Order_insert->VAS_IsCancel = 0;
$this->Order_insert->VAS_SendTime = $vo['orderDate'];
$this->Order_insert->VAS_ConfirmTime = $vo['orderStatus'] == 1 ? $vo['orderDate'] : null;
$this->Order_insert->VAS_LMI_SN = !empty($vendor_contact) ? $vendor_contact->LMI_SN : null;
$this->Order_insert->VAS_FaxNo = !empty($vendor_contact) ? $vendor_contact->LMI_AutoFax : null;
$this->Order_insert->VAS_VendorEmail = !empty($vendor_contact) ? $vendor_contact->LMI_ListMail : null;
$this->Order_insert->vendorarrangestate_save();
$this->Orders_model->VAS_GRI_SN = $this->Orders_model->GRI_SN ? $this->Orders_model->GRI_SN : null;
$this->Orders_model->VAS_VEI_SN = $this->Orders_model->COLD_PlanVEI_SN;
$this->Orders_model->VAS_IsSendSucceed = 1;
$this->Orders_model->VAS_IsConfirm = $vo['orderStatus'];
$this->Orders_model->VAS_IsCancel = 0;
$this->Orders_model->VAS_SendTime = $vo['orderDate'];
$this->Orders_model->VAS_ConfirmTime = $vo['orderStatus'] == 1 ? $vo['orderDate'] : null;
$this->Orders_model->VAS_LMI_SN = !empty($vendor_contact) ? $vendor_contact->LMI_SN : null;
$this->Orders_model->VAS_FaxNo = !empty($vendor_contact) ? $vendor_contact->LMI_AutoFax : null;
$this->Orders_model->VAS_VendorEmail = !empty($vendor_contact) ? $vendor_contact->LMI_ListMail : null;
$this->Orders_model->vendorarrangestate_save();
$cnt++;
}
@ -257,7 +256,7 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
$this->Order_update->coli_where_update = " COLI_SN=" . $order->GCI_COLI_SN;
$coli_update_column = array(
"COLI_Memo" => $order->COLI_Memo . "\r\n" . $detail_jsonResp->orderDetail->orderRemark
,"COLI_OrderDetailText" => $order->COLI_OrderDetailText . "\r\n" . $allDetails_to_HT // 调度信息加上以便在HT界面上显示 todo
,"COLI_OrderDetailText" => $order->COLI_OrderDetailText . "\r\n" . $allDetails_to_HT
);
$this->Order_update->biz_confirmlineinfo_update($coli_update_column);
/** BIZ_ConfirmLineDetail */ // nothing to update
@ -472,7 +471,6 @@ log_message('error','in GCI ' . json_decode($resp)->responseData->orderId);
$reponse = curl_exec($ch);
$eval_resp = json_decode($reponse);
log_message('error', " curl postBodyString: ".json_encode($postBody));
if (curl_errno($ch) || $eval_resp->status == 0) {
log_message('error', "curl error code: ".curl_error($ch) . $eval_resp->errMsg . "; curl postBodyString: ".json_encode($postBody));
} else {

File diff suppressed because it is too large Load Diff

@ -16,16 +16,6 @@ class Order_update extends CI_Model {
$this->COLI_TouristLGC = $this->config->item('Site_ServiceLGC');
$this->COLI_OrderStartDate = null;
$this->COLI_Keywords = NULL;
switch ($this->check_device()) {
case 'mobile':
$this->COLI_OrderSource = '62003';
break;
case 'tablet':
$this->COLI_OrderSource = '62002';
break;
default:
$this->COLI_OrderSource = '62001';
}
}
public $coli_where_update = "";
@ -61,9 +51,6 @@ class Order_update extends CI_Model {
return $update_exc;
}
public function combineoperation_exist($combineNo='', $operation="")
{
if( ! $combineNo) { return false; }
@ -76,37 +63,6 @@ class Order_update extends CI_Model {
return $query->result();
}
public function get_SN_by_vendorOrderId($vendorOrderId)
{
$sql = "SELECT TOP 1 coli.COLI_GRI_SN,coli.COLI_SN,gci.GCI_SN
FROM BIZ_GroupCombineInfo gci
INNER JOIN BIZ_ConfirmLineInfo coli ON coli.COLI_SN=gci.GCI_COLI_SN
WHERE gci.GCI_VendorOrderId='$vendorOrderId'";
$query = $this->HT->query($sql);
if ($query->row()) {
$this->BIZ_COLI_SN = $query->row()->COLI_SN;
$this->GRI_SN = $query->row()->COLI_GRI_SN;
$this->GCI_SN = $query->row()->GCI_SN;
return $query->row();
}
return NULL;
}
public function get_SN_by_groupCode($code)
{
$sql = "SELECT top 1 COLI_SN,GRI_SN
FROM BIZ_ConfirmLineInfo coli
LEFT JOIN GRoupInfo gri ON coli.COLI_GRI_SN=gri.GRI_SN
WHERE gri.GRI_No LIKE '$code%'";
$query = $this->HT->query($sql);
if ($query->row()) {
$this->BIZ_COLI_SN = $query->row()->COLI_SN;
$this->GRI_SN = $query->row()->GRI_SN;
return $query->row();
}
return NULL;
}
public function update_confirmLineInfo()
{
$sql = "UPDATE BIZ_ConfirmLineInfo SET
@ -122,75 +78,6 @@ class Order_update extends CI_Model {
return $this->query;
}
/*
* 生成订单号
* 根据系统时间生成精确到0.0001微秒
*/
function MakeOrderNumber() {
return str_replace('.', '', sprintf('%11.4f', gettimeofday(TRUE)));
}
/**
* 生成商务订单号
*/
function biz_make_order_number() {
/*
$date = date('ymd',time());
$sql = "SELECT MAX( \n"
. " CONVERT( \n"
. " INT, \n"
. " CASE \n"
. " WHEN ISNUMERIC(RIGHT(COLI_ID, 3)) = 0 THEN LEFT(RIGHT(COLI_ID, 4), 3) \n"
. " ELSE RIGHT(COLI_ID, 3) \n"
. " END \n"
. " ) \n"
. " ) AS SN \n"
. "FROM dbo.BIZ_ConfirmLineInfo \n"
. "WHERE (LEFT(COLI_ID, 6) = ?)";
$query = $this->HT->query($sql,array($date));
$id = $query->row()->SN;
if (is_null($id)||empty($id))
{
$id = 0;
}
$ids = $date.(sprintf('%03d',(int)$id+1));
return $ids;
*/
//call $conn
include('c:/database_conn.php');
$connection = array(
'UID' => $db['HT']['username'],
'PWD' => $db['HT']['password'],
'Database' => 'tourmanager',
'ConnectionPooling' => 1,
'CharacterSet' => 'utf-8',
'ReturnDatesAsStrings' => 1
);
$conn = sqlsrv_connect($db['HT']['hostname'], $connection);
$stmt = sqlsrv_query($conn, "declare @ccid varchar(20);exec dbo.SP_GetBIZOrderNo @ccid out;select @ccid as ccid;");
if ($stmt === false) {
echo "Error in executing statement 3.\n";
die(print_r(sqlsrv_errors(), true));
} else {
//存储过程中每一个select都会产生一个结果集取某个结果集就需要从第一个移动到需要的那个结果集
//如果结果集为空就移到下一个
while (sqlsrv_has_rows($stmt) !== TRUE) {
sqlsrv_next_result($stmt);
}
$result_object = array();
while ($row = sqlsrv_fetch_object($stmt)) {
$result_object[] = $row;
}
sqlsrv_free_stmt($stmt);
sqlsrv_close($conn);
return($result_object[0]->ccid);
}
}
/**
*
* 更新订单状态(商务订单)
@ -229,206 +116,6 @@ class Order_update extends CI_Model {
return $stmt;
}
/**
*
* 插入收款记录
*
*/
public function insert_acc_info($order_id) {
//获取订单
$sql = "Select Top 1 COLI_SN,COLI_ID,COLI_PayManner,COLI_Price From BIZ_ConfirmLineInfo Where COLI_ID = ?";
$query = $this->HT->query($sql, array($order_id));
$order_info = $query->row();
//插入记录
$sql = "INSERT INTO BIZ_GroupAccountInfo \n"
. " ( \n"
. " GAI_COLI_SN, \n"
. " GAI_COLI_ID, \n"
. " GAI_Type, \n"
. " GAI_SQJE, \n"
. " GAI_SQDate, \n"
. " GAI_SSJE, \n"
. " GAI_SQJECurrency, \n"
. " GAI_SSDate, \n"
. " GAI_CusName, \n"
. " GAI_CusEmail, \n"
. " GAI_Memo \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ? \n"
. " )";
$query = $this->HT->query($sql, array($order_info->COLI_SN,
$order_info->COLI_ID,
$order_info->COLI_PayManner,
$order_info->COLI_Price,
date('Y-m-d H:i:s'),
$order_info->COLI_Price,
$this->config->item('Site_Currency'),
date('Y-m-d H:i:s'),
"", "", " "));
}
function GetNationalityID($nationalityName) {
if (!$nationalityName) {
return 0;
}
if (is_numeric($nationalityName)) {
return $nationalityName;
} else {
$sql = "SELECT TOP 1 ci2.COI2_COI_SN \n"
. "FROM COuntryInfo2 ci2 \n"
. "WHERE ci2.COI2_Country = ? ";
$query = $this->HT->query($sql, array($nationalityName));
if ($query->result()) {
$row = $query->row();
return $row->COI2_COI_SN;
} else {
return 0;
}
}
}
function GetNationalityName($nationalityID) {
if (!is_numeric($nationalityID)) {
return $nationalityID;
} else {
$sql = "SELECT TOP 1 ci2.COI2_Country \n"
. "FROM COuntryInfo2 ci2 \n"
. "WHERE ci2.COI2_LGC = 2 \n"
. " AND ci2.COI2_COI_SN = ? ";
$query = $this->HT->query($sql, array($nationalityID));
if ($query->result()) {
$row = $query->row();
return $row->COI2_Country;
} else {
return $nationalityID;
}
}
}
/**
*
* 获取商务订单信息
* @param string $order_id 订单id
* @return mixed 订单信息
*
*/
public function get_flight_order_by_id($order_id) {
$sql = "SELECT DISTINCT cli.COLI_ID, \n"
. " cli.COLI_Price, \n"
. " bg.GUT_FirstName, \n"
. " bg.GUT_LastName, \n"
. " bg.GUT_Email, \n"
. " bg.GUT_Email2, \n"
. " bpe.BPE_SN, \n"
. " bpe.BPE_GuestType, \n"
. " bpe.BPE_FirstName, \n"
. " bpe.BPE_MiddleName, \n"
. " bpe.BPE_LastName, \n"
. " bpe.BPE_GuestType, \n"
. " bpe.BPE_Passport, \n"
. " cld.COLD_Count, \n"
. " foi.FlightsNo, \n"
. " foi.DepartureDate, \n"
. " foi.DepartureTime, \n"
. " foi.ArrivalTime, \n"
. " cli.COLI_PayManner, \n"
. " cli.COLI_State, \n"
. " cli.COLI_sourcetype, \n"
. " foi.Cabin, \n"
. " foi.DepartAirport, \n"
. " foi.ArrivalAirport, \n"
. " cld.COLD_SN, \n"
. " foi.DepartureCity, \n"
. " foi.ArrivalCity, \n"
. " bg.GUT_TEL, \n"
. " bg.GUT_NationalityID, \n"
. " cli.COLI_OrderDetailText, \n"
. " bpe.BPE_imageSrc, \n"
. " cli.COLI_Cost, \n"
. " cld.COLD_TotalPrice, \n"
. " cld.COLD_TotalCost \n"
. "FROM BIZ_ConfirmLineInfo cli \n"
. " INNER JOIN BIZ_ConfirmLineDetail cld \n"
. " ON cli.COLI_SN = cld.COLD_COLI_SN \n"
. " INNER JOIN BIZ_GUEST bg \n"
. " ON bg.GUT_SN = cli.COLI_GUT_SN \n"
. " INNER JOIN BIZ_BookPeopleList bpl \n"
. " ON bpl.BPL_COLD_SN = cld.COLD_SN \n"
. " INNER JOIN BIZ_BookPeople bpe \n"
. " ON bpl.BPL_BPE_SN = bpe.BPE_SN \n"
. " INNER JOIN BIZ_FlightsOrderInfo foi \n"
. " ON foi.FOI_COLD_SN = cld.COLD_SN \n"
. "WHERE cli.COLI_ID = ? AND isnull(cld.deleteflag,0) = 0 ";
$query = $this->HT->query($sql, array($order_id));
return $query->result();
}
/**
*
* 获取机票订单乘员列表
* @param string $order_id 订单id
* @return mixed 订单信息
*
*/
public function get_bpe_list_by_id($order_id) {
$sql = "SELECT DISTINCT bpe.BPE_SN, \n"
. " bpe.BPE_FirstName, \n"
. " bpe.BPE_MiddleName, \n"
. " bpe.BPE_LastName, \n"
. " bpe.BPE_Passport \n"
. "FROM BIZ_BookPeople bpe \n"
. " INNER JOIN BIZ_BookPeopleList bpl \n"
. " ON bpe.BPE_SN = bpl.BPL_BPE_SN \n"
. " INNER JOIN BIZ_ConfirmLineDetail cold \n"
. " ON bpl.BPL_COLD_SN = cold.COLD_SN \n"
. " INNER JOIN BIZ_ConfirmLineInfo coli \n"
. " ON coli.COLI_SN = cold.COLD_COLI_SN \n"
. "WHERE coli.COLI_ID = ?";
$query = $this->HT->query($sql, array($order_id));
//echo('<!--'.$this->HT->compile_binds($sql,array($order_id)).'-->');
return $query->result();
}
/**
*
* 获取机票电子票号
* @param array bpe_sn 乘客sn数组
* @return mixed 机票票号
*
*/
public function get_ticket_no($bpe_sn) {
if (is_array($bpe_sn)) {
$instr = join(',', $bpe_sn);
} elseif (is_string($bpe_sn)) {
$instr = $bpe_sn;
} else {
$instr = 0;
}
$sql = "SELECT DISTINCT ftn.FTN_FilghtsNo, \n"
. " ftn.FTN_TicketNo, \n"
. " ftn.FTN_GuestNo \n"
. "FROM BIZ_FlightsTicketNo ftn \n"
. "WHERE ftn.FTN_GuestNo IN (" . $instr . ")";
$query = $this->HT->query($sql);
return $query->result();
}
/*
* 发送邮件
*/
function SendMail($fromName, $fromEmail, $toName, $toEmail, $subject, $body) {
$sql = "INSERT INTO Email_AutomaticSend \n"
@ -446,148 +133,4 @@ class Order_update extends CI_Model {
return $query;
}
/**
*
* 返回成行订单
* 条件1订单类型
* 天剑2网站来源
*
*/
public function get_order_info($COLI_sourcetype, $COLI_WebCode, $biz = true) {
if ($biz) {
$sql = "SELECT TOP 200 c.COLI_WebCode, \n"
. " c.COLI_ID, \n"
. " c.COLI_ConfirmDate, \n"
. " c.COLI_ApplyDate, \n"
. " ISNULL(c.COLI_IsSuccess, 0) AS success \n"
. "FROM BIZ_ConfirmLineInfo c \n"
. "WHERE c.COLI_sourcetype = ? \n"
. " AND c.COLI_WebCode = ? \n"
. "ORDER BY \n"
. " c.COLI_SN DESC";
$query = $this->HT->query($sql, array($COLI_sourcetype, $COLI_WebCode));
} else {
$sql = "SELECT TOP 200 c.COLI_WebCode, \n"
. " c.COLI_ID, \n"
. " c.COLI_ConfirmDate, \n"
. " c.COLI_ApplyDate, \n"
. " CASE WHEN c.COLI_Sended = 5 THEN 1 ELSE 0 END AS success \n"
. "FROM ConfirmLineInfo c \n"
. "WHERE c.COLI_sourcetype = ? \n"
. " AND c.COLI_WebCode = ? \n"
. "ORDER BY \n"
. " c.COLI_SN DESC";
$query = $this->HT->query($sql, array($COLI_sourcetype, $COLI_WebCode));
}
$this->sql = $this->HT->queries;
return $query->result();
}
//传统订单支付之后,插入新的订单信息
public function insert_daytrip_order($coli_sn, $pay_manner, $gri_sn, $state, $deleteflag) {
//获取订单
$order_info_sql = "
SELECT confirmlineinfotmp.COLI_OrderPrice,
memberinfotmp.MEI_FirstName,
memberinfotmp.MEI_LastName,
memberinfotmp.MEI_Mail
FROM memberinfotmp
INNER JOIN customerlisttmp
ON memberinfotmp.mei_sn = customerlisttmp.cul_cui_sn
INNER JOIN confirmlineinfotmp
ON customerlisttmp.cul_coli_sn = confirmlineinfotmp.coli_sn
WHERE (customerlisttmp.cul_coli_sn = ? )";
$query = $this->HT->query($order_info_sql, array($coli_sn));
$order_info = $query->row();
//插入记录
$sql = "INSERT INTO GroupAccountInfoTmp
(
GAI_COLI_SN,
GAI_SQJE,
GAI_SQDate,
GAI_CusName,
GAI_CusEmail,
GAI_SQJECurrency,
GAI_Type,
LastEditTime,
GAI_GRI_SN,
GAI_State,
DeleteFlag
)
VALUES (?,?,?,?,?,?,?,?,?,?,?)";
$query = $this->HT->query($sql, array($coli_sn,
$order_info->COLI_OrderPrice,
date('Y-m-d H:i:s'),
$order_info->MEI_FirstName . " " . $order_info->MEI_LastName,
$order_info->MEI_Mail,
$this->config->item('Site_Currency'),
$pay_manner,
date('Y-m-d H:i:s'),
$gri_sn,
$state,
$deleteflag
)
);
}
//来源终端 tablet mobile desktop
public function check_device() {
if (isset($_SERVER['HTTP_USER_AGENT'])) {
$ua = $_SERVER['HTTP_USER_AGENT'];
} else {
$ua = '';
}
## This credit must stay intact (Unless you have a deal with @lukasmig or frimerlukas@gmail.com
## Made by Lukas Frimer Tholander from Made In Osted Webdesign.
## Price will be $2
$iphone = strstr(strtolower($ua), 'mobile'); //Search for 'mobile' in user-agent (iPhone have that)
$android = strstr(strtolower($ua), 'android'); //Search for 'android' in user-agent
$windowsPhone = strstr(strtolower($ua), 'phone'); //Search for 'phone' in user-agent (Windows Phone uses that)
if (!function_exists('androidTablet')) {
function androidTablet($ua) { //Find out if it is a tablet
if (strstr(strtolower($ua), 'android')) { //Search for android in user-agent
if (!strstr(strtolower($ua), 'mobile')) { //If there is no ''mobile' in user-agent (Android have that on their phones, but not tablets)
return true;
}
}
}
}
$androidTablet = androidTablet($ua); //Do androidTablet function
$ipad = strstr(strtolower($ua), 'ipad'); //Search for iPad in user-agent
if ($androidTablet || $ipad) { //If it's a tablet (iPad / Android)
return 'tablet';
} elseif ($iphone && !$ipad || $android && !$androidTablet || $windowsPhone) { //If it's a phone and NOT a tablet
return 'mobile';
} else { //If it's not a mobile device
return 'desktop';
}
}
public function ip_limit($ip = "0.0.0.0")
{
if (strcmp($ip, "0.0.0.0") === 0 || empty($ip)) {
return TRUE;
}
$sql = "SELECT COUNT(1) cnt
FROM ConfirmLineInfoTmp
WHERE 1=1
AND COLI_SenderIP = ?
AND DateDiff(dd,COLI_ApplyDate,getdate())=0";
$query = $this->HT->query($sql, array($ip));
$ret = $query->row();
if ($ret->cnt > 50) {
return FALSE;
} else {
return TRUE;
}
}
}

@ -141,6 +141,62 @@ class Orders_model extends CI_Model {
return $query->result();
}
public $VAS_GRI_SN;
public $VAS_VEI_SN;
public $VAS_IsSendSucceed;
public $VAS_IsConfirm;
public $VAS_SendTime;
public $VAS_ConfirmTime;
public $VAS_IsCancel;
public $VAS_LMI_SN;
public $VAS_FaxNo;
public $VAS_VendorEmail;
public function vendorarrangestate_save()
{
$sql = "INSERT INTO VendorArrangeState
(VAS_GRI_SN
,VAS_VEI_SN
,VAS_IsSendSucceed
,VAS_IsConfirm
,VAS_SendTime
,VAS_ConfirmTime
,VAS_IsCancel
,VAS_LMI_SN
,VAS_FaxNo
,VAS_VendorEmail
,Creator
,LastEditTime
,DeleteFlag
) VALUES
(?
,?
,?
,?
,?
,?
,?
,?
,?
,?
,0
,GETDATE()
,0
)";
$query = $this->HT->query($sql, array(
$this->VAS_GRI_SN
,$this->VAS_VEI_SN
,$this->VAS_IsSendSucceed
,$this->VAS_IsConfirm
,$this->VAS_SendTime
,$this->VAS_ConfirmTime
,$this->VAS_IsCancel
,$this->VAS_LMI_SN
,$this->VAS_FaxNo
,$this->VAS_VendorEmail
));
return $query;
}
public $GRI_SN=0; // 团号
public $GRI_No; // 团号
public $GRI_OrderType; // 订单类型

Loading…
Cancel
Save