正在显示
1 个修改的文件
包含
28 行增加
和
10 行删除
@@ -105,7 +105,7 @@ class OrderController extends HomeBaseController{ | @@ -105,7 +105,7 @@ class OrderController extends HomeBaseController{ | ||
105 | public function getPrice($start_time=1543298302,$end_time=1543303733){ | 105 | public function getPrice($start_time=1543298302,$end_time=1543303733){ |
106 | $cost=Db::name('cost')->where('id',1)->find(); | 106 | $cost=Db::name('cost')->where('id',1)->find(); |
107 | $interval = Db::name('interval')->where('id',1)->find(); | 107 | $interval = Db::name('interval')->where('id',1)->find(); |
108 | - | 108 | + $free=$cost['free']; |
109 | //用了多少天 | 109 | //用了多少天 |
110 | $day=floor(($end_time-$start_time)/86400); | 110 | $day=floor(($end_time-$start_time)/86400); |
111 | $price=$day*1; | 111 | $price=$day*1; |
@@ -137,11 +137,13 @@ class OrderController extends HomeBaseController{ | @@ -137,11 +137,13 @@ class OrderController extends HomeBaseController{ | ||
137 | if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time < $new_start_time && $new_end_time < $stateTime)){ | 137 | if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time < $new_start_time && $new_end_time < $stateTime)){ |
138 | //存在首小时免费 | 138 | //存在首小时免费 |
139 | $price +=(ceil(($new_end_time-$new_start_time)/3600) * $cost['cost']); | 139 | $price +=(ceil(($new_end_time-$new_start_time)/3600) * $cost['cost']); |
140 | + $price-=$cost['cost']; | ||
140 | } | 141 | } |
141 | //与预设时间段的头部重合 | 142 | //与预设时间段的头部重合 |
142 | if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time > $stateTime && $new_end_time < strtotime('24:00:00'))){ | 143 | if (($new_start_time > $endTime && $new_start_time < $stateTime) && ($new_end_time > $stateTime && $new_end_time < strtotime('24:00:00'))){ |
143 | //存在首小时免费 | 144 | //存在首小时免费 |
144 | $price += (ceil(($stateTime-$new_start_time)/3600) * $cost['cost'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price']); | 145 | $price += (ceil(($stateTime-$new_start_time)/3600) * $cost['cost'] + ceil(($new_end_time-$stateTime)/3600) * $interval['price']); |
146 | + $price-=$cost['cost']; | ||
145 | } | 147 | } |
146 | //在预设时间段右边并不与之重合 | 148 | //在预设时间段右边并不与之重合 |
147 | if (($new_start_time > $stateTime && $new_start_time < strtotime('24:00:00')) && ($new_end_time > $new_start_time && $new_end_time < strtotime('24:00:00'))){ | 149 | if (($new_start_time > $stateTime && $new_start_time < strtotime('24:00:00')) && ($new_end_time > $new_start_time && $new_end_time < strtotime('24:00:00'))){ |
@@ -159,25 +161,41 @@ class OrderController extends HomeBaseController{ | @@ -159,25 +161,41 @@ class OrderController extends HomeBaseController{ | ||
159 | +ceil(($new_end_time-$YesterdayStateTime)/3600) * $interval['price']; | 161 | +ceil(($new_end_time-$YesterdayStateTime)/3600) * $interval['price']; |
160 | } | 162 | } |
161 | //昨天预设开始前使用,今天预设结束前停止 | 163 | //昨天预设开始前使用,今天预设结束前停止 |
162 | - if(($new_start_time > (strtotime('00:00:00')-86400) && $new_start_time < $YesterdayEndTime) && ($new_end_time > strtotime('00:00:00') && $new_end_time < $endTime)){ | ||
163 | - $price+= ceil(($YesterdayEndTime-$new_start_time)/3600) * $interval['price'] | ||
164 | - +ceil(($YesterdayStateTime-$YesterdayEndTime)/3600) * $cost['cost'] | ||
165 | - +ceil(($new_end_time-$YesterdayStateTime)/3600) * $interval['price']; | 164 | + if(($new_start_time > $YesterdayEndTime && $new_start_time < $YesterdayStateTime) && ($new_end_time > strtotime('00:00:00') && $new_end_time < $endTime)){ |
165 | + //存在首小时免费 | ||
166 | + $price+= ceil(($YesterdayStateTime-$new_start_time)/3600) * $cost['cost'] | ||
167 | + +ceil(($new_end_time-$YesterdayStateTime)/3600) * $interval['price']; | ||
168 | + | ||
169 | + $price-=$cost['cost']; | ||
166 | } | 170 | } |
167 | //昨天预设开始前使用,今天预设结束后停止 | 171 | //昨天预设开始前使用,今天预设结束后停止 |
172 | + if(($new_start_time > $YesterdayEndTime && $new_start_time < $YesterdayStateTime) && ($new_end_time > $endTime && $new_end_time < $stateTime)){ | ||
173 | + //存在首小时免费 | ||
174 | + $price+= ceil(($YesterdayStateTime-$new_start_time)/3600) * $cost['cost'] | ||
175 | + +ceil(($endTime-$YesterdayStateTime)/3600) * $interval['price'] | ||
176 | + +ceil(($new_end_time-$endTime)/3600) * $cost['cost']; | ||
168 | 177 | ||
169 | - | 178 | + $price-=$cost['cost']; |
179 | + } | ||
170 | //昨天预设开始后使用,今天预设结束前停止 | 180 | //昨天预设开始后使用,今天预设结束前停止 |
171 | - | 181 | + if(($new_start_time > $YesterdayStateTime && $new_start_time < strtotime('00:00:00')) && ($new_end_time > strtotime('00:00:00') && $new_end_time < $endTime)){ |
182 | + $price+= ceil(($new_end_time-$new_start_time)/3600) * $interval['price']; | ||
183 | + } | ||
172 | //昨天预设开始后使用,今天预设结束后停止 | 184 | //昨天预设开始后使用,今天预设结束后停止 |
173 | - | 185 | + if(($new_start_time > $YesterdayStateTime && $new_start_time < strtotime('00:00:00')) && ($new_end_time > $endTime && $new_end_time < $stateTime)){ |
186 | + $price+= ceil(($endTime-$new_start_time)/3600) * $interval['price'] | ||
187 | + +ceil(($new_end_time-$endTime)/3600) * $cost['cost']; | ||
188 | + } | ||
174 | //昨天预设开始后使用,今天预设开始前停止 | 189 | //昨天预设开始后使用,今天预设开始前停止 |
175 | - | 190 | + if(($new_start_time > $YesterdayStateTime && $new_start_time < strtotime('00:00:00')) && ($new_end_time > $stateTime && $new_end_time < ($new_start_time+86400))){ |
191 | + $price+= ceil(($endTime-$new_start_time)/3600) * $interval['price'] | ||
192 | + +ceil(($stateTime-$endTime)/3600) * $cost['cost'] | ||
193 | + +ceil(($new_end_time-$stateTime)/3600) * $interval['price']; | ||
194 | + } | ||
176 | } | 195 | } |
177 | }else{ | 196 | }else{ |
178 | //不跨天 | 197 | //不跨天 |
179 | 198 | ||
180 | - | ||
181 | } | 199 | } |
182 | return $price; | 200 | return $price; |
183 | } | 201 | } |
-
请 注册 或 登录 后发表评论