@ -23,5 +23,275 @@ class Online_payment_account_model extends CI_Model {
return NULL;
return NULL;
}
}
//根据订单号获取外联邮箱
public function get_order($COLI_ID, $orderinfo = false, $ordertype = 'N', $handpick=false) {
$result = '';
$fieldsql = $orderinfo == false ? '' : " ,* ";
//先查商务订单B,APP订单A、再查传统订单T
if ($ordertype == 'B' || $ordertype == 'A') {
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_PayManner,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_ID =?";
$query = $this->HT->query($sql, array($COLI_ID));
$result = $query->result();
}
//后查传统订单的原因是因为传统订单的订单号去掉外联名字首字母后可能会和商务订单的重合。
if (empty($result) && ($ordertype == 'T')) {
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_State $fieldsql from ConfirmLineInfo
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_AddCode =? ";
$query = $this->HT->query($sql, array($COLI_ID));
$result = $query->result();
}
if (empty($result) && ($ordertype == 'M')) {
$sql = "SELECT TOP 2 1 as order_type, COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode $fieldsql from ConfirmLineInfo cli
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where
EXISTS (
SELECT TOP 1 1
FROM ConfirmLineInfoTmp clit
WHERE clit.COLI_ID = ?
AND cli.COLI_AddCode = CAST(clit.COLI_SN AS VARCHAR(10))
)
";
$query = $this->HT->query($sql, array($COLI_ID));
$result = $query->result();
}
//订单号查询不到尝试使用团号查询
if (empty($result) && $ordertype == 'B') {
$sql = "SELECT TOP 2 0 as order_type,COLI_SN,COLI_ID,OPI_Email,OPI_FirstName,OPI_Name,COLI_WebCode,COLI_Department,COLI_State $fieldsql from BIZ_ConfirmLineInfo
LEFT JOIN OperatorInfo ON COLI_OPI_ID=OPI_SN
where COLI_GroupCode like '%-$COLI_ID%'";
$query = $this->HT->query($sql);
$result = $query->result();
}
//团号查询不到尝试使用客人邮箱查询(预订多次的老客户得按日期新旧排序,取最新的数据)
if (!empty($result) && is_array($result) ) {
//print_r($result[0]);
//die();
if (count($result) > 1) {
$result = array();
} else {
$result = $result[0];
}
}
return $result;
}
public function if_biz_gai_exists($GAI_AccreditNo)
{
$sql = " SELECT TOP 1 1 FROM BIZ_GroupAccountInfo
WHERE (GAI_AccreditNo = ? OR GAI_Memo LIKE '%$GAI_AccreditNo%')