我创建了一个寄宿家庭网站的预订系统,我使用codeigniter 3为这个项目,但客户给了我一些复杂的条件,以实现预订,并需要计算价格房间明智的,并在最后这些房间的总数。
我很困惑写代码为以下情况下,我需要显示价格为每个房间根据以下条件:
我将数据存储为会话中的杂项数组
用于房间
[selectedRoom] => Array
(
[0] => Mud House (Neel Kutir)
[1] => Mud House (Lal Kutir)
[2] => Standard AC Room
[3] => Deluxe AC Room
)
字符串
成人(下划线前为房间名称,下划线后为成人人数)
[adults] => Array
(
[0] => Mud House (Neel Kutir)_1
[1] => Mud House (Lal Kutir)_1
[2] => Standard AC Room_1
[3] => Deluxe AC Room_1
)
型
在下面的数组中,我存储了
[dateRange] => Array
(
[0] => 2023-12-29,
[1] => 2023-12-30,
[2] => 2023-12-31
)
型
在下面的数组中,我将数据存储为
数据的格式为{房间名称}{孩子总数}{孩子数系列}_{年龄组如斜线前是开始年份,斜线后是结束年份}
[kids_age] => Array
(
[0] => Mud House (Neel Kutir)_2_1_5/8
[1] => Mud House (Neel Kutir)_2_2_8/12
[2] => Mud House (Lal Kutir)_2_1_1/4
[3] => Mud House (Lal Kutir)_2_2_8/12
[4] => Standard AC Room_2_1_1/4
[5] => Standard AC Room_2_2_5/8
[6] => Deluxe AC Room_2_1_8/12
[7] => Deluxe AC Room_2_2_5/8
)
型
以下是需要实现的条件
如果房间是“泥屋(尼尔库蒂尔)”或“泥屋(尼尔库蒂尔)”,那么价格计算将是这样的
如果预订是一晚
for adult price will be like
adult = 1850 (for 1 Night Per Person )
kids = 1850 (for 1 Night Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 1850)
or if kid age is (between 8 to 12 years then the price is 75% of 1850)
or if kid age is (above 12 years then the price is 1850)
型
如果预订是2晚f
or adult price will be like
adult = 1500 (for 2 Nights Per Person )
kids = 1500 (for 2 Nights Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 1500)
or if kid age is (between 8 to 12 years then the price is 75% of 1500)
or if kid age is (above 12 years then the price is 1850)
型
如果预订3晚或以上
adult price will be like
adult = 1350 (for 3 Nights or above Per Person )
kids = 1350 (for 3 Nights or above Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 1350)
or if kid age is (between 8 to 12 years then the price is 75% of 1350)
or if kid age is (above 12 years then the price is 1350)
型
如果房间是“标准空调房”,那么价格计算将像
如果预订是一晚
for adult price will be like
adult = 2050 (for 1 Night Per Person )
kids = 2050 (for 1 Night Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 2050)
or if kid age is (between 8 to 12 years then the price is 75% of 2050)
or if kid age is (above 12 years then the price is 2050)
型
如果预订是2晚
for adult price will be like
adult = 1700 (for 2 Nights Per Person )
kids = 1700 (for 2 Nights Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 1700)
or if kid age is (between 8 to 12 years then the price is 75% of 1700)
or if kid age is (above 12 years then the price is 1700)
型
如果预订3晚或以上
for adult price will be like
adult = 1550 (for 3 Nights or above Per Person )
kids = 1550 (for 3 Nights or above Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 1550)
or if kid age is (between 8 to 12 years then the price is 75% of 1550)
or if kid age is (above 12 years then the price is 1550)
型
如果房间是“豪华空调房”,那么价格计算将像
如果预订是一晚
for adult price will be like
adult = 3350 (for 1 Night Per Person )
kids = 3350 (for 1 Night Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 3350)
or if kid age is (between 8 to 12 years then the price is 75% of 3350)
or if kid age is (above 12 years then the price is 3350)
型
如果预订是2晚
for adult price will be like
adult = 3000 (for 2 Nights Per Person )
kids = 3000 (for 2 Nights Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 3000)
or if kid age is (between 8 to 12 years then the price is 75% of 3000)
or if kid age is (above 12 years then the price is 3000)
如果预订3晚或以上
for adult price will be like
adult = 2850 (for 3 Nights or above Per Person )
kids = 2850 (for 3 Nights or above Per Person )
and
if kid age is (between 1 to 4 years then the price is 0)
or if kid age is (between 5 to 8 years then the price is 50% of 2850)
or if kid age is (between 8 to 12 years then the price is 75% of 2850)
or if kid age is (above 12 years then the price is 2850)
1条答案
按热度按时间c0vxltue1#
首先创建一个数组,将每个房间的成人数量和孩子的年龄分组:
字符串
这给出了一个
$guests_per_room
数组,看起来像这样:型
然后用这个来计算每个房间的总数和最终总数:
型
您的问题不清楚多晚房价是否也应该乘以天数。如果需要,请调整。