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/application/third_party/ctmobilefirst/models/api_model.php

277 lines
11 KiB
PHTML

4 years ago
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Api_model extends CI_Model {
public function __construct()
{
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
}
var $dei_sn = 17; //组别ID
var $CTLGC = 104; //语种
/**
* @description: 根据一日游code获取对应人数的成人价格
* @param {string} $pagecode 线路代码
* @param int $personnum 人数
* @return:
*/
function getDaytripsPrice($pagcode, $personnum)
{
$sql = "select top 1 isnull(PKP_AdultPrice,0) as PKP_AdultPrice,isnull(PKP_AdultSpecialPrice,0) as PKP_AdultSpecialPrice
,PAG_DefaultVEI_SN
from BIZ_PackagePrice
inner join BIZ_PackageInfo on BIZ_PackageInfo.PAG_SN = BIZ_PackagePrice.PKP_PAG_SN
and BIZ_PackagePrice.PKP_VEI_SN = BIZ_PackageInfo.PAG_DefaultVEI_SN
where (BIZ_PackageInfo.PAG_Code = ?) AND (pag_dei_sn= ? )
and ? between PKP_PersonStart and PKP_PersonStop and CONVERT(varchar(12),getdate(),111) between pkp_validdate and pkp_invaliddate
order by isnull( BIZ_PackageInfo.PAG_DefaultVEI_SN,0) desc,PKP_PriceGrade ";
$param = array($pagcode,$this->dei_sn, $personnum);
$query = $this->HT->query($sql, $param);
if ($query->num_rows() > 0) {
return $query->row();
} else {
//'第二种有默认供应商但是没有当前日期价格的时候
$sql = "select top 1 isnull(PKP_AdultPrice,0) as PKP_AdultPrice,isnull(PKP_AdultSpecialPrice,0) as PKP_AdultSpecialPrice
,PAG_DefaultVEI_SN
from BIZ_PackagePrice
inner join BIZ_PackageInfo on BIZ_PackageInfo.PAG_SN = BIZ_PackagePrice.PKP_PAG_SN
and BIZ_PackagePrice.PKP_VEI_SN = BIZ_PackageInfo.PAG_DefaultVEI_SN
where (BIZ_PackageInfo.PAG_Code = ? ) AND (pag_dei_sn= ? )
and ? between PKP_PersonStart and PKP_PersonStop
order by pkp_invaliddate desc,PKP_PriceGrade ";
$query = $this->HT->query($sql, $param);
if ($query->num_rows() > 0) {
return $query->row();
}else{
//'第三种没有默认供应商但是有当前日期价格的时候
$sql = "select top 1 isnull(PKP_AdultPrice,0) as PKP_AdultPrice,isnull(PKP_AdultSpecialPrice,0) as PKP_AdultSpecialPrice
,PAG_DefaultVEI_SN
from BIZ_PackagePrice
inner join BIZ_PackageInfo on BIZ_PackageInfo.PAG_SN = BIZ_PackagePrice.PKP_PAG_SN
where (BIZ_PackageInfo.PAG_Code = ? ) AND (pag_dei_sn= ? )
and ? between PKP_PersonStart and PKP_PersonStop and CONVERT(varchar(12),getdate(),111) between pkp_validdate and pkp_invaliddate
order by isnull( BIZ_PackageInfo.PAG_DefaultVEI_SN,0) desc,PKP_PriceGrade ";
$query = $this->HT->query($sql, $param);
if ($query->num_rows() > 0) {
return $query->row();
}else{
//'第四种无默认供应商无当前日期价格
$sql = "select top 1 isnull(PKP_AdultPrice,0) as PKP_AdultPrice,isnull(PKP_AdultSpecialPrice,0) as PKP_AdultSpecialPrice
,PAG_DefaultVEI_SN
from BIZ_PackagePrice
inner join BIZ_PackageInfo on BIZ_PackageInfo.PAG_SN = BIZ_PackagePrice.PKP_PAG_SN
where (BIZ_PackageInfo.PAG_Code = ? ) AND (pag_dei_sn= ? )
and ? between PKP_PersonStart and PKP_PersonStop
order by pkp_invaliddate desc,PKP_PriceGrade ";
if ($query->num_rows() > 0) {
return $query->row();
}else {
return null;
}
}
}
}
}
/**
* @description: 获取精华线路价格2人等
* @param {*}
* @return {*}
* @Date Changed:
*/
function getTourPrice($cli_no){
$CLI_SN = "";
$reust = "";
//'新的GP没有设置以前的2-5人等价格导致读不出价格。把Gp价格放前面计算
$sql = "select top 1 CLI_SN,CLI_PackageClass from CustomerLineInfo
where CLI_NO=? and CLI_State=1005004
AND (CLI_DEI_SN= ? )";
$query = $this->HT->query($sql,array($cli_no,$this->dei_sn));
if (!$query->num_rows()>0){
return null;
}else{
$row = $query->row();
if (isset($row)){
$CLI_SN = $row->CLI_SN;
}
//'获取线路是否有travelbuddy,也就是有固定的发团日期
$fut_sql = "SELECT count(*) as CountBuddy FROM FixedGroupDate WHERE FGD_CLI_SN='".$CLI_SN."'";
$futQuery = $this->HT->query($fut_sql);
$futrow = $futQuery->row();
$fut_CountBuddy = $futrow->CountBuddy;
if ($fut_CountBuddy>0){
//读取GP价格
$gpSql ="SELECT TOP 1 FGD_AdultPrice,FGD_Departure,
isnull(FGD_ProAdultPrice,0) as FGD_ProAdultPrice
FROM FixedGroupDate
WHERE (FGD_Departure >= GETDATE())
AND (FGD_CLI_SN = ".$CLI_SN.") AND (FGD_State = 1) ORDER BY FGD_AdultPrice";
$gpquery = $this->HT->query($gpSql);
if ($gpquery->num_rows()>0){
$gpRow = $gpquery->row();
$FGD_AdultPrice = $gpRow->FGD_AdultPrice;
$FGD_ProAdultPrice = $gpRow->FGD_ProAdultPrice;
if ($FGD_ProAdultPrice>0){
$reust = $FGD_ProAdultPrice; //促销价
}else{
$reust=$FGD_AdultPrice;
}
}
}else {
//普通线路价格
$sql = "select top 1
CLI_SN,CLP_TwoToFiveAdultPrice,CLI_PackageClass
FROM CustomerLineInfo INNER JOIN
CustomerLinePrice ON CustomerLineInfo.CLI_SN = CustomerLinePrice.CLP_CLI_SN INNER JOIN
CustomerLineInfo2 ON CustomerLineInfo.CLI_SN = CustomerLineInfo2.CLI2_CLI_SN
where CLI_SN= ? and CLI2_LGC=? and (CLP_Area=1 or CLP_Area=2)
and CLI_State = 1005004 ORDER BY CLP_TwoToFiveAdultPrice";
$query = $this->HT->query($sql,array($CLI_SN,$this->CTLGC));
if ($query->num_rows()>0){
$reust = $query->row()->CLP_TwoToFiveAdultPrice;
}
}
}
return $reust;
}
/**
* @description: 一日游列表,包含信息平台和HT
* @param {*} $whereHT HT的查询条件
* @param {*} $whereInfo 信息平台的查询条件
* @return {*}
* @Date Changed:
*/
function getDaytripList($whereHT="",$whereInfo=""){
$sql = "select * from(
select * from(
SELECT p2.PAG2_Name as title
,P1.PAG_Code as code
,'' as url
,isnull(p2.PAG2_ImageURL,'') as pic1
,isnull((select top 1 PAP_ImageURL from BIZ_PackagePic where PAP_PII_SN=p2.PAG2_PII_SN),'') as pic2
,'2' as sortby
FROM dbo.BIZ_PackageInfo P1
INNER JOIN dbo.BIZ_PackageInfo2 p2 ON P1.PAG_SN = p2.PAG2_PAG_SN
INNER JOIN dbo.CItyInfo2 ON P1.PAG_CII_SN = dbo.CItyInfo2.CII2_CII_SN AND dbo.CItyInfo2.CII2_LGC = 1
WHERE (p2.PAG2_LGC = 104)
AND (p1.pag_dei_sn = 17)
AND (p2.PAG2_Check = 2)
AND (isnull(P1.DeleteFlag,0) <>1) ".$whereHT."
) Tmp
UNION ALL
SELECT * from (
select ic_url_title as title
,(select top 1 im_value from infoMetas where im_key='meta_product_code' and im_ic_id=ic_id) as code
,ic_url as url , ic_photo as pic1
,(select top 1 im_value from infoMetas where im_key='meta_addon_picture_mobile' and im_ic_id=ic_id) as pic2
,'1' as sortby
FROM dbo.infoContents
inner join infoStructures on ic_id=is_ic_id
WHERE is_sitecode='chinatravel' ".$whereInfo."
--and ic_status=1
) as t
) tball
where 1=1
ORDER BY tball.sortBy ASC
";
$query = $this->HT->query($sql);
return $query->result();
}
/**
* @description: HT获取一日游列表
* @param {*} $city 一日游城市 ,默认必须有城市,不然太多
* @param {*} $where 其它条件
* @return {*}
* @Date Changed:
*/
function getDaytripListHT($city="beijing",$where=""){
$sql = " select * from(
SELECT p2.PAG2_Name
,p2.PAG2_Intro
,P1.PAG_NeedTime
,P1.PAG_SN
,P1.PAG_Leve
,p2.PAG2_Order
,P1.PAG_Code
,p2.PAG2_Attraction
,CItyInfo2.CII2_Name
,isnull((select top 1 PAP_ImageURL from BIZ_PackagePic where PAP_PII_SN=p2.PAG2_PII_SN),'') as NewListImage
,isnull(p2.PAG2_ImageURL,'') as NewListImage2
,dbo.GetFullPathByPII_SN(p2.PAG2_PII_SN, 2) AS picpath
,p2.PAG2_Title
,p1.PAG_Type
,pag2_summary
FROM dbo.BIZ_PackageInfo P1
INNER JOIN dbo.BIZ_PackageInfo2 p2 ON P1.PAG_SN = p2.PAG2_PAG_SN
INNER JOIN dbo.CItyInfo2 ON P1.PAG_CII_SN = dbo.CItyInfo2.CII2_CII_SN AND dbo.CItyInfo2.CII2_LGC = 1
WHERE (p2.PAG2_LGC = ?)
AND (p1.pag_dei_sn = ?)
AND (p2.PAG2_Check = 2)
AND (isnull(P1.DeleteFlag,0) <>1)
) Tmp
where 1=1 ";
if ($city!=""){
$sql .= " AND (CII2_Name ='".$city."')";
}
// $sql .= "and PAG_Code in ('SHALC-1','SHALC-7')";
$sql .= " order by isnull(pag2_order,0) desc,pag_code ";
// echo ($sql);
$param = array($this->CTLGC,$this->dei_sn);
$query = $this->HT->query($sql,$param);
return $query->result();
}
/**
* @description: 获取子类信息列表
* @param {type} $parentid父类的Id
* @return:
* @Date Changed:
*/
function getGuideList($parentid){
if ($parentid < 0 ) {
return null;
}
$sql = "
SELECT is_sort,ic_url,ic_url_title,ic_title, substring(convert(nvarchar(2000),ic_content),0,1000) as ic_summary,ic_photo
,(select top 1 im_value from infoMetas where im_key='meta_addon_picture' and im_ic_id=ic_id) as pic2
FROM dbo.infoContents
inner join infoStructures on ic_id=is_ic_id
WHERE is_sitecode='chinatravel'
and is_parent_id = ?
";
//and ic_status=1
$qurey = $this->HT->query($sql,array($parentid));
return $qurey->result();
}
4 years ago
}
/* End of file Api_model.php */