|
|
|
@ -0,0 +1,153 @@
|
|
|
|
|
<?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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End of file Api_model.php */
|