You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
information-system/webht/third_party/trippestOrderSync/models/send_operation_model.php

136 lines
5.0 KiB
PHTML

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Send_operation_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->info = $this->load->database('INFO', TRUE);
}
public function daytour_order_ready_for_send($COLI_ID="", $date, $time_flag="no_send_state")
{
$today = date('Y-m-d 16:00:00');
switch ($time_flag) {
case 'try1':
$send_state = " ";
break;
case 'try2':
$send_state = " and (TPSL_sendState=1 OR TPSL_logTime > '$today') ";
break;
case 'handle':
$send_state = " and (TPSL_sendState=1) ";
break;
case '':
default:
$send_state = "";
break;
}
$send_state_sql = " and not exists (
select TPSL_SN from InfoManager.dbo.trippest_sms_log
where TPSL_COLI_SN=coli.COLI_SN
$send_state
) ";
$top = " TOP 1 ";
$sms_state = "";
if ($time_flag == "no_send_state") {
$send_state_sql = "";
$top = "";
$sms_state = " ,(select top 1 TPSL_sendState from InfoManager.dbo.trippest_sms_log
where TPSL_COLI_SN=coli.COLI_SN and TPSL_sendContent like '%'+GCOD_startDate+'%'
order by TPSL_sendState desc
) as send_state";
}
$search_sql = " AND GCI_travelDate ='$date' ";
if ($COLI_ID !== "") {
$search_sql = " AND COLI_ID='" . $COLI_ID . "'";
}
$sql = "SELECT $top GroupCombineOperationDetail.GCOD_SN,COLI_SN,COLI_ID,COLI_groupCode
,GUT_POST,GUT_TEL
,PAG_ExtendType,PAG_Code
,g.GUT_FirstName,g.GUT_LastName
,gci.*
,GCOD_startDate,GCOD_operationType,GCOD_dutyName,GCOD_dutyTel,GCOD_creatTime
$sms_state
FROM BIZ_ConfirmLineInfo coli
INNER JOIN BIZ_ConfirmLineDetail cold ON COLD_COLI_SN=COLI_SN
INNER JOIN BIZ_GUEST g ON g.GUT_SN=COLI_GUT_SN
and GUT_TEL is not null and GUT_TEL<>'' and GUT_POST<>''
INNER JOIN BIZ_PackageInfo pag ON pag.PAG_SN=COLD_ServiceSN
LEFT JOIN GroupCombineInfo gci ON COLI_GRI_SN=GCI_GRI_SN
LEFT JOIN GroupCombineOperationDetail ON GCOD_GCI_combineNo=GCI_combineNo
AND GCOD_operationType='guiderOperations'
WHERE 1=1
$search_sql
AND GCI_combineNo not IN ('cancel','forbidden')
AND '39009'<>PAG_ExtendType
$send_state_sql
ORDER BY GCI_travelDate, COLI_SN
";
$query = $this->HT->query($sql);
return $query->result();
}
public function insert_trippest_sms_log($column)
{
$this->info->insert("trippest_sms_log", $column);
return $this->info->insert_id();
}
public function update_trippest_sms_log($where, $column)
{
if ($where == "" || empty($column)) {
return false;
}
$update_str = $this->info->update_string('trippest_sms_log', $column, $where);
$update_exc = $this->info->query($update_str);
return $update_exc;
}
/** 暂时不用了 */
public function if_order_sent($COLI_SN, $msgType='guide')
{
$sql = "SELECT *
FROM [infomanager].[dbo].[trippest_sms_log]
where [TPSL_COLI_SN]=$COLI_SN
and [TPSL_sendState]=1
and TPSL_msgType='$msgType'
";
return $this->info->query($sql)->row();
}
/*
* 发送邮件
*/
function SendMail($fromName, $fromEmail, $toName, $toEmail, $subject, $body) {
$sql = "INSERT INTO tourmanager.dbo.Email_AutomaticSend \n"
. " ( \n"
. " M_ReplyToName, M_ReplyToEmail, M_ToName, M_ToEmail, M_Title, M_Body, M_Web, \n"
. " M_FromName, M_State \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, N?, ?, ?, 0 \n"
. " ) ";
$query = $this->info->query($sql,
array(substr($fromName, 0, 127), $fromEmail, substr($toName, 0, 127), $toEmail, $subject, $body, 'trippest SMS send fail', 'chinahighlighgts')
);
return $query;
}
function order_sms_list($COLI_SN=0)
{
$sql = "SELECT *
FROM [infomanager].[dbo].[trippest_sms_log]
where [TPSL_COLI_SN]=$COLI_SN
order by TPSL_logTime ";
return $this->HT->query($sql)->result();
}
}
/* End of file send_operation_model.php */
/* Location: ./webht/third_party/trippestOrderSync/models/send_operation_model.php */