diff --git a/application/controllers/information.php b/application/controllers/information.php index 1b56f46a..4cb4a37f 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -25,7 +25,10 @@ class Information extends CI_Controller $this->load->model('recommends_and_tips_model'); $this->load->model('trippest_model'); //trippest产品 $this->load->model('Feedback_model'); + $this->load->model('Price_model'); + $this->load->model('PrimeLinePrice_model'); $this->load->library('Amplib'); //加载AMP处理类 + $this->load->library('Currency'); $this->load->library('html_optimize_lib'); //加载HTML优化类 } @@ -992,6 +995,167 @@ class Information extends CI_Controller var_dump($feedback_newest_content); } + public function test_price() + { + $price_rule = '
#ah-8,st,2#
#ah-8,st,2#
'; + $price_tag_list = $this->parse_price_tag($price_rule); + var_dump($price_tag_list); + } + + /*! + * 页面中有价格标签,查出价格并替换内容 + * @author LiaoYijun + * @date 2023-05-12 + * @param string $price_content 包含价格标签的内容 + * @return array 包含价格与占位符的数组 + */ + public function parse_price_tag($price_content) + { + $price_item_array = $this->price_pregmatch($price_content); + $price_tag_list = []; + if (!empty($price_item_array)) { + foreach ($price_item_array as $price_item) { + $price_date = !empty($price_item->price_date) ? $price_item->price_date : date('Y-m-d', time() + 86400 * 7); //当前时间7天后的价格 + $price_number = ''; + //优先读取新的价格体系 + $price = $this->PrimeLinePrice_model->search($price_item->cli_no, 1, $price_item->cli_grade, $price_item->person_size, $price_date); + if (!empty($price)) { + switch (strtoupper($price_item->price_people)) { + case 'A': + $price_number = $price->PLP_AdultUnitPrice; + break; + case 'C': + $price_number = $price->PLP_ChildUnitPrice; + break; + case 'B': + $price_number = $price->PLP_BabyUnitPrice; + break; + case 'R': + $price_number = $price->PLP_RoomDiffPrice; + break; + case 'AR': + $price_number = $price->PLP_AdultUnitPrice + $price->PLP_RoomDiffPrice; //成人加单间房差 + break; + default : + $price_number = $price->PLP_AdultUnitPrice; + } + } else { + $price = $this->Price_model->search($price_item->cli_no, 1, $price_item->cli_grade, false, $price_date); + if (!empty($price)) { + + switch (strtoupper($price_item->price_people)) { + case 'A': + switch ($price_item->person_size) { + case '1': + $price_number = $price->CLP_OneAdultPriceRMB; + break; + case '2'://25 + $price_number = $price->CLP_TwoToFiveAdultPriceRMB; + break; + case '6'://69 + $price_number = $price->CLP_SixToNineAdultPriceRMB; + break; + case '10': + $price_number = $price->CLP_OverTenAdultPriceRMB; + break; + default: + $price_number = $price->CLP_TwoToFiveAdultPriceRMB; + } + break; + case 'C': + $price_number = 0; + break; + case 'B': + $price_number = 0; + break; + case 'R': + switch ($price_item->person_size) { + case '1': + $price_number = $price->CLP_OneRoomDiffPriceRMB; + break; + case '2'://25 + $price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB; + break; + case '6'://69 + $price_number = $price->CLP_SixToNineRoomDiffPriceRMB; + break; + case '10': + $price_number = $price->CLP_OverTenRoomDiffPriceRMB; + break; + default: + $price_number = $price->CLP_TwoToFiveRoomDiffPriceRMB; + } + break; + case 'AR'://成人加单间房差 + $price_number = 0; + break; + default : + $price_number = 0; + } + } + } + $site_money = $this->currency->GetSiteMoney($price_number, 'USD'); + $site_money = $this->currency->calc_show_price($site_money); + //把金额格式化为带有逗号(,)方便阅读,如 12,345 + $price_number = is_numeric($price_number) ? number_format($site_money) : $price_number; + if (!empty($price_number)) { + $price_tag = [ + 'placeholder' => $price_item->placeholder, + 'price_number' => $price_number, + ]; + $price_tag_list[] = $price_tag; + } + } + } + return $price_tag_list; + } + + //使用正则匹配出价格标签,返回一个价格数组 + private function price_pregmatch($content) { + $price_array = array(); + $temp_array = array(); + $result = false; + //#ah-1,lx,2,2016-01-23,A# + //线路代号,等级(st标准、lx豪华、ec经济),人等,时间,人型(A成人、C小孩、B婴儿、R单间房差、AR成人+房差) + preg_match_all('^#[a-zA-Z0-9,-]+#^', $content, $temp_array); + foreach ($temp_array[0] as $item) { + $placeholder = $item; + $item = str_replace('#', '', $item); + $price_array = explode(',', $item); + $cli_no = !empty($price_array[0]) ? $price_array[0] : false; //线路代号 + if (empty($cli_no)) { + continue; //没有设置线路代号则进入下一条 + } + $cli_grade = !empty($price_array[1]) ? $price_array[1] : false; //标准7001、豪华7002、经济7003 + switch (strtoupper($cli_grade)) { + case 'ST': + $cli_grade = '7001'; + break; + case 'LX': + $cli_grade = '7002'; + break; + case 'EC': + $cli_grade = '7003'; + break; + default :$cli_grade = '7001'; + } + $person_size = (!empty($price_array[2]) && is_numeric($price_array[2])) ? $price_array[2] : 2; //人等1,2-5,6-9,10,默认2人等 + //为了兼容以前的人等方式,把算数人等转换为单数 25=>2 + switch ($person_size) { + case '25': + $person_size = '2'; + break; + case '69': + $person_size = '6'; + break; + } + $price_date = !empty($price_array[3]) ? $price_array[3] : false; //价格时间 + $price_people = !empty($price_array[4]) ? $price_array[4] : 'A'; //A成人、C小孩、B婴儿、R单间房差 + $result[] = (object) array('placeholder' => $placeholder, 'cli_no' => $cli_no, 'cli_grade' => $cli_grade, 'person_size' => $person_size, 'price_date' => $price_date, 'price_people' => $price_people); + } + return $result; + } + public function make_www_cache_gh($device, $information, $recommand_information) { $data = array(); @@ -1380,6 +1544,16 @@ class Information extends CI_Controller true ); $information->ic_content = str_replace('', $gp_form_content, $information->ic_content); + + $price_tag_list = $this->parse_price_tag($information->ic_content); + + foreach ($price_tag_list as $price_tag) { + $information->ic_content = str_replace( + $price_tag['placeholder'], + $price_tag['price_number'], + $information->ic_content + ); + } } // why-us 相关的标签 $why_us_mobile = $this->load->view($template_path . '-why-us-mobile', false, true); diff --git a/application/libraries/Currency.php b/application/libraries/Currency.php new file mode 100644 index 00000000..fb145c04 --- /dev/null +++ b/application/libraries/Currency.php @@ -0,0 +1,203 @@ +CI = & get_instance(); + log_message('debug', "Language Tags Class Initialized"); + $this->GetCurrencyRate(); + } + + function GetCurrencyRate() { + $this->HT = $this->CI->load->database('HT', TRUE); + $sql = "SELECT CRI_BuyIn / 100.00 AS tmpExRate, \n" + . " CRI_Code \n" + . "FROM tourmanager.dbo.CurrencyRateInfo \n" + . "WHERE CRI_Code IN ('USD', 'EUR', 'RUB') \n" + . " AND GETDATE() BETWEEN CRI_Start AND CRI_Stop"; + $query = $this->HT->query($sql); + foreach ($query->result() as $item) { + switch ($item->CRI_Code) { + case 'USD': + $this->USD_Rate = $item->tmpExRate; + break; + case 'EUR': + $this->EUR_Rate = $item->tmpExRate; + break; + case 'RUB': + $this->RUB_Rate = $item->tmpExRate; + break; + } + } +// echo $this->USD_Rate . '
'; +// echo $this->EUR_Rate . '
'; +// echo $this->RUB_Rate . '
'; + return $query->result(); + } + + //根据人民币转换成站点对应的货币 + public function GetSiteMoney($RMB, $fromCurrency) { + if (!is_numeric($RMB)) + { + return $RMB; + } + + $result = $RMB; + if (is_numeric($RMB)) { + switch ($fromCurrency) { + case 'USD': + $result = $RMB / $this->USD_Rate; + break; + case 'EUR': + $result = $RMB / $this->EUR_Rate; + break; + case 'RUB': + $result = $RMB / $this->RUB_Rate; + break; + } + } + return ceil($result); + } + + //把美金转换为人民币 + public function get_USD_RMB_SUM($USD) { + + if (!is_numeric($USD))return $USD; + $result = $USD; + $result = $USD * $this->USD_Rate; + return ceil($result); + } + + /** + * 返回站点的汇率。 + * + * @author lmr + */ + public function get_site_currencyrate() { + switch (CONST_SITE_CURRENCY) { + case 'USD': + return $this->USD_Rate; + case 'EUR': + return $this->EUR_Rate; + case 'RUB': + return $this->RUB_Rate; + default: + return 1; + } + } + + /** + * 返回带money_char的价格。 + * + * @param $money Int 价格. + * @return String 带货币符号的价格。 + */ + public function get_money_char($money='') { + + switch (CONST_SITE_CODE) { + case 'JP': + return $money.'元'; + case 'GM': + return '€'.$money; + case 'VC': + return $money.'€'; + case 'VAC': + return '$'.$money; + case 'RU': + return '$'.$money; + case 'IT': + return '€'.$money; + case 'SHT': + return '$'.$money; + default: + return '$'.$money; + } + } + + /** + * 返回带money_char的价格。 + * + * @param $money Int 价格. + * @return String 带货币符号的价格。 + */ + public function get_site_money_with_char($money='') { + return $this->get_money_char($this->GetSiteMoney($money)); + } + + + /** + * RMB换算成指定货币。 + * @param int money RMB + * @param string char 货币代号:usd,eur + * @return int 换算价格 + */ + public function convert_moneny_by_char($money,$char='') + { + switch (strtolower($char)) + { + case 'usd': + return ceil($money/$this->USD_Rate); + case 'eur': + return ceil($money/$this->EUR_Rate); + } + return $money; + } + + /** + * 尾数取"9"的定价规则 + * 在正负误差值小于或等于16的前提下, + * 保证展示价格的个位数和十位数统一取"99" + * 当展示价格的个位数和十位数取"99"的正负误差大于16时, + * 通过四舍五入加价实现个位数取"9" + * 详细规则见GitLab issue #12 统一网前展示价格的标准 + */ + public function calc_show_price($value=0) { + if (empty($value)) return 0; + if (!is_numeric($value)) return $value; + + $val_len = strlen($value); + + if ($val_len == 1) return 9; + + $discount = 16; + $val_pow = pow(10, $val_len - 1); + + $min_val = $val_pow - 1; + $max_val = $min_val + $val_pow; + $max_diff = abs($value - $max_val); + $min_diff = abs($value - $min_val); + + if (min($max_diff, $min_diff) > $discount) { + $calc_val = floor($value / 10) * 10 + 9; + } else { + $calc_val = $max_diff > $min_diff ? $min_val : $max_val; + } + return $calc_val; + } + /** + * 获取设置的信用卡卡费 + */ + public function cardfee(){ + $sql = "SELECT TOP 1 * FROM dbo.SystemSettingInfo WHERE (SSI_Code = 1021001)"; + + $this->HT = $this->CI->load->database('HT', TRUE); + $query = $this->HT->query($sql); + $row = $query->row(); + if (isset($row)){ + return $row->SSI_UserValue; + }else{ + return 0; + } + + } +} diff --git a/application/models/Price_model.php b/application/models/Price_model.php new file mode 100644 index 00000000..d464f15b --- /dev/null +++ b/application/models/Price_model.php @@ -0,0 +1,77 @@ +HT = $this->load->database('HT', TRUE); + } + + public function init() { + $this->topnum = false; + $this->cli_no = false; + $this->person_size = false; + $this->cli_grade = false; + $this->clp_pricetype = false; + $this->price_date = false; + $this->orderby = ' ORDER BY cli.CLI_Grade ASC, clp.CLP_PriceStartDate ASC,clp.CLP_PriceType DESC '; + } + + public function search($cli_no, $topnum = false, $cli_grade = false, $clp_pricetype = false, $price_date = false) { + $this->init(); + $this->topnum = empty($topnum) ? false : $topnum; + $this->cli_no = ' AND cli.CLI_NO = ' . $this->HT->escape($cli_no); + $this->cli_grade = empty($cli_grade) ? false : ' AND cli.CLI_Grade = ' . $this->HT->escape($cli_grade); + $this->clp_pricetype = empty($clp_pricetype) ? false : ' AND clp.CLP_PriceType = ' . $this->HT->escape($clp_pricetype); + $this->price_date = empty($price_date) ? false : " AND '$price_date 00:00:00' BETWEEN clp.CLP_PriceStartDate AND clp.CLP_PriceEndDate "; + return $this->get_list(); + } + + public function get_list() { + $this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT "; + $sql .= " + cli.CLI_SN + ,cli.CLI_NO + ,clp.CLP_SN + ,clp.CLP_OneAdultPriceRMB + ,clp.CLP_TwoToFiveAdultPriceRMB + ,clp.CLP_SixToNineAdultPriceRMB + ,clp.CLP_OverTenAdultPriceRMB + ,clp.CLP_PriceType + ,cli.CLI_Grade + ,clp.CLP_PriceStartDate + ,clp.CLP_PriceEndDate + FROM CustomerLinePrice clp + INNER JOIN CustomerLineInfo cli + ON cli.CLI_SN = clp.CLP_CLI_SN + WHERE 1 = 1 + AND cli.CLI_State IN (1005003 ,1005004) + "; + $this->cli_no ? $sql.=$this->cli_no : false; + $this->cli_grade ? $sql.=$this->cli_grade : false; + $this->clp_pricetype ? $sql.=$this->clp_pricetype : false; + $this->price_date ? $sql.=$this->price_date : false; + $this->orderby ? $sql.=$this->orderby : false; + $query = $this->HT->query($sql); + //print_r($this->HT->queries); + if ($this->topnum === 1) { + if ($query->num_rows() > 0) { + $row = $query->row(); + return $row; + } else { + return FALSE; + } + } else { + return $query->result(); + } + } + +} diff --git a/application/models/PrimeLinePrice_model.php b/application/models/PrimeLinePrice_model.php new file mode 100644 index 00000000..18fd518b --- /dev/null +++ b/application/models/PrimeLinePrice_model.php @@ -0,0 +1,110 @@ +HT = $this->load->database('HT', TRUE); + } + + public function init() { + $this->topnum = false; + $this->cli_no = false; + $this->person_size = false; + $this->cli_grade = false; + $this->price_date = false; + $this->orderby = ' ORDER BY plp.PLP_Level ASC,plp.PLP_IsWeekPrice DESC,plp.PLP_AdultUnitPrice DESC '; + } + + public function search($cli_no, $topnum = false, $cli_grade = false, $person_size = false, $price_date = false, $DEI_SN = 28) { + $this->init(); + $this->cli_no = $cli_no; + $this->topnum = empty($topnum) ? false : $topnum; + $this->cli_grade = empty($cli_grade) ? false : $this->cli_grade = ' AND cli.CLI_Grade = ' . $this->HT->escape($cli_grade); + $this->person_size = empty($person_size) ? false : $this->person_size = " AND $person_size BETWEEN plp.PLP_PersonGradeDown AND plp.PLP_PersonGradeUp "; + if (!empty($price_date)) { + $this->price_date = " AND '$price_date 00:00:00' BETWEEN plp.PLP_StartDate AND plp.PLP_EndDate "; + $week_day = (int) date('w', strtotime($price_date)); //获取当前时间的星期号,用于判断周末价 + $this->price_date .=" + AND ( + (plp.PLP_IsWeekPrice=1 AND plp.PLP_WeekDefine LIKE '%$week_day%') + OR (plp.PLP_IsWeekPrice=0) + ) + "; + } + $this->DEI_SN = $DEI_SN; + return $this->get_list(); + } + + public function get_list() { + $this->topnum ? $sql = "SELECT TOP " . $this->topnum : $sql = "SELECT "; + $sql .= " + cli.CLI_SN + ,cli.CLI_NO + ,cli.CLI_Grade + ,plp.PLP_SN + ,plp.PLP_CLI_SN + ,plp.PLP_Season + ,plp.PLP_Area + ,plp.PLP_StartDate + ,plp.PLP_EndDate + ,plp.PLP_PersonGradeDown + ,plp.PLP_PersonGradeUp + ,plp.PLP_AdultUnitCost + ,plp.PLP_AdultUnitPrice + ,plp.PLP_RoomDiffPrice + ,plp.PLP_ChildRate + ,plp.PLP_BabyRate + ,plp.PLP_ChildUnitPrice + ,plp.PLP_BabyUnitPrice + ,plp.PLP_Level + ,plp.PLP_IsWeekPrice + ,plp.PLP_WeekDefine + ,plp.PLP_PriceDate + ,plp.PLP_PersonNum + ,plp.PLP_VEI_SN + ,plp.PLP_Year + ,plp.PLP_VPPI_SN + ,plp.PLP_VPPD_SN + ,plp.PLP_Creator + ,plp.PLP_CreateDate + ,plp.PLP_LastEditor + ,plp.PLP_LastEditDate + FROM PrimeLinePrice plp + INNER JOIN CustomerLineInfo cli + ON cli.CLI_SN = plp.PLP_CLI_SN + WHERE 1 = 1 + AND cli.CLI_DEI_SN=? + AND plp.PLP_Year IS NOT NULL + AND cli.CLI_NO = ? + AND cli.CLI_State IN (1005003 ,1005004) + "; + + $this->person_size ? $sql.=$this->person_size : false; + $this->price_date ? $sql.=$this->price_date : false; + $this->cli_grade ? $sql.=$this->cli_grade : false; + $this->orderby ? $sql.=$this->orderby : false; + + $query = $this->HT->query($sql,array($this->DEI_SN,$this->cli_no)); + if ($this->topnum === 1) { + if ($query->num_rows() > 0) { + $row = $query->row(); + return $row; + } else { + return FALSE; + } + } else { + return $query->result(); + } + } + +} diff --git a/application/third_party/order/views/confirm_order.php b/application/third_party/order/views/confirm_order.php index 32dd0ea2..bf3fa68d 100644 --- a/application/third_party/order/views/confirm_order.php +++ b/application/third_party/order/views/confirm_order.php @@ -354,6 +354,13 @@ label.gender:hover { background: #ad1818; color: #fff; } +select.gender_pick {border: 1px solid #d1d1d1; + border-radius: 4px; + height: 50px; + font-size: 19px; + box-shadow: inset 0 1px 3px rgb(0 0 0 / 10%); + padding: 0 15px; + width: auto;} @@ -393,21 +400,12 @@ label.gender:hover {

Traveler 1

-
- - - - -
+
- +