From 3b2dd36d736d98b9e99fdb6ad82be7aef3aa171f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Fri, 9 Apr 2021 14:43:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=80=E6=97=A5=E6=B8=B8?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ctmobilefirst/controllers/api.php | 47 +++++++++++ .../ctmobilefirst/models/api_model.php | 82 +++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/application/third_party/ctmobilefirst/controllers/api.php b/application/third_party/ctmobilefirst/controllers/api.php index cc658f95..865b59e2 100644 --- a/application/third_party/ctmobilefirst/controllers/api.php +++ b/application/third_party/ctmobilefirst/controllers/api.php @@ -239,6 +239,53 @@ class Api extends CI_Controller { echo json_encode($result); } + + /** + * @description: 一日游价格表 + * @param {*} + * @return {*} + * @Date Changed: + */ + public function getDaytripPriceList(){ + if (isset($_GET["param"])){ + $param = str_replace("'","''",$_GET["param"]); + $list = $this->api_model->getDaytripPriceList($param); + if (count($list)==1){ + echo "1"; + }else{ + //echo "2"; + $str_th=""; + $str_td=""; + foreach ($list as $row) { + $PKP_AdultPrice = $row->PKP_AdultPrice; + $PKP_AdultSpecialPrice = $row->PKP_AdultSpecialPrice; + if ($PKP_AdultPrice!=$PKP_AdultSpecialPrice && $PKP_AdultSpecialPrice>0){ + $PKP_AdultPrice=$PKP_AdultSpecialPrice; + } + $PKP_AdultPrice = $this->currency->convert_moneny_by_char($PKP_AdultPrice,"USD"); + $PKP_PersonStart = $row->PKP_PersonStart; + $PKP_PersonStop = $row->PKP_PersonStop; + //'根据数据生成显示内容 + if ($PKP_PersonStart == $PKP_PersonStop){ + $str_th .= " ".$PKP_PersonStart." Person"; + } + else if ($PKP_PersonStop=="1000") { + $str_th .= " >".$PKP_PersonStart." Person"; + } + else{ + $str_th .= " ".$PKP_PersonStart." - ".$PKP_PersonStop." Person"; + } + + $str_td .=" $ ".$PKP_AdultPrice.""; + } + + echo ''.$str_th.''.$str_td.'
'; + } + }else{ + echo ""; + } + } + } /* End of file Api.php */ diff --git a/application/third_party/ctmobilefirst/models/api_model.php b/application/third_party/ctmobilefirst/models/api_model.php index bc4ed864..92aeaf67 100644 --- a/application/third_party/ctmobilefirst/models/api_model.php +++ b/application/third_party/ctmobilefirst/models/api_model.php @@ -299,6 +299,88 @@ class Api_model extends CI_Model { } } + + /** + * @description: 获取一日游价格列表 + * @param {*} $pagcode + * @return {*} + * @Date Changed: + */ + function getDaytripPriceList($pagcode){ + //1.先根据编码获取SN + $sql = "select top 1 PAG_SN from BIZ_PackageInfo p1 + inner join BIZ_PackageInfo2 p2 on p1.PAG_SN = p2.PAG2_PAG_SN + where p1.pag_dei_sn = ? + and p2.PAG2_LGC = ? + and p1.PAG_Code = ? + and p2.PAG2_Check = 2 + AND (isnull(P1.DeleteFlag,0) <>1) "; + $query = $this->HT->query($sql,array($this->dei_sn,$this->CTLGC,$pagcode)); + if ($query->num_rows()>0){ + //2.根据SN获取获取一个供应商的ID,不然所有供应商的价格都出来了。 + $pagsn = $query->row()->PAG_SN; + $sql = "select top 10 PAG_DefaultVEI_SN,pkp_vei_sn ,* + from BIZ_PackagePrice + left join BIZ_PackageInfo on BIZ_PackageInfo.PAG_DefaultVEI_SN=BIZ_PackagePrice.PKP_VEI_SN + and BIZ_PackageInfo.PAG_SN = BIZ_PackagePrice.PKP_PAG_SN + where PKP_PAG_SN =? + order by isnull( BIZ_PackageInfo.PAG_DefaultVEI_SN,0) desc ,PKP_InvalidDate desc"; + $query = $this->HT->query($sql,array($pagsn)); + if ($query->num_rows()>0){ + $veisn = $query->row()->pkp_vei_sn; + if (!empty($query->row()->PAG_DefaultVEI_SN)){ + $veisn = $query->row()->PAG_DefaultVEI_SN; + } + }else{ + $veisn=0; + } + + //3.根据供应商ID获取对应价格列表 + $sql = "SELECT isnull(PKP_AdultPrice, 0) AS PKP_AdultPrice + ,isnull(PKP_AdultSpecialPrice, 0) AS PKP_AdultSpecialPrice + ,PKP_PersonStart + ,PKP_PersonStop + FROM BIZ_PackagePrice + WHERE PKP_PAG_SN = ? + AND PKP_VEI_SN = ? + AND getdate() BETWEEN pkp_validdate AND pkp_invaliddate + and Checked=2 + ORDER BY PKP_PersonStart "; + $query = $this->HT->query($sql,array($pagsn,$veisn)); + if (!$query->num_rows()>0){ + //如果今年没价格,获取去年的价格 + $nowYear = date('Y'); + for ($i=1;$i<5;$i++){ + $price_pyears = $nowYear-$i ."-1-1"; + $price_pyears_2 = $nowYear-$i . "-12-31"; + $sql = "SELECT isnull(PKP_AdultPrice, 0) AS PKP_AdultPrice + ,isnull(PKP_AdultSpecialPrice, 0) AS PKP_AdultSpecialPrice + ,PKP_PersonStart + ,PKP_PersonStop + FROM BIZ_PackagePrice + WHERE PKP_PAG_SN = ? + AND PKP_VEI_SN = ? + AND pkp_validdate BETWEEN '".$price_pyears."' AND '".$price_pyears_2."' "; + $query = $this->HT->query($sql,array($pagsn,$veisn)); + if ($query->num_rows()>0){ + break; + } + } + + } + + if ($query->num_rows()>0){ + //4.价格列表返回 + return $query->result(); + }else { + return null; + } + + }else{ + return null; + } + } + } /* End of file Api_model.php */