作者 郭文星

123

... ... @@ -1901,4 +1901,54 @@ class Car extends Base
}
}
/**
* 改签价格计算
* @return void
*/
public function countrebook(){
$id = $this->request->param("order_id");
$reservation_time = $this->request->param("reservation_time");//预约时间
$order = Db::name("order")->where("id", $id)->find();
$departure_time=substr($reservation_time,0,16);
$refund_time=substr($order['reservation_time'],0,16);
//下单五分钟后五收取手续费
$create_time=$order['create_time'];
$newtime=time()-$create_time;
try {
if($newtime<300){
// print_r([$create_time,$newtime]);
$pay_fee = $order['price'];
$rebook_fee = 0;
}else {
$refund_time=strtotime($refund_time);
$newrefund_time=$refund_time-time();
if($newrefund_time<0){
$this->error("该订单无法改签,时间过期");
}
if($newrefund_time<3600){
$pay_fee = $order['price'];
$rebook_fee = 0;
}else if($newrefund_time>3600 & $newrefund_time<7200){
$pay_fee = $order['price']*0.8;
$rebook_fee = $pay_fee;
}else if($newrefund_time>7200 & $newrefund_time<28800){
$pay_fee = $order['price']*0.9;
$rebook_fee = $pay_fee;
}else if($newrefund_time>28800 & $newrefund_time<43200){
$pay_fee = $order['price']*0.9;
$rebook_fee = $pay_fee;
}else if($newrefund_time>43200){
$pay_fee = $order['price'];
$rebook_fee = 0;
}
}
$data=["rebook_fee"=>$rebook_fee];
$this->success("请求成功", $data);
} catch (UploadException $e) {
$this->error($e->getMessage());
}
}
}
\ No newline at end of file
... ...