作者 郭文星

123

... ... @@ -1821,41 +1821,8 @@ class Car extends Base
$newtime=time()-$create_time;
try {
if($newtime<300){
if($newtime<300){
// print_r([$create_time,$newtime]);
$pay_fee = $order['price'];
$rebook_fee = 0;
$res = Db::name("order")->where("id",$id)->update([
"commission_price"=>$rebook_fee,
"rebook"=>1,
"reservation_time" => $reservation_time,
"order_no" => getOrderSn(),
"create_time"=>time()
]);
$this->success("请求成功");
}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;
$res = Db::name("order")->where("id",$id)->update(["commission_price"=>$rebook_fee,"rebook"=>1, "order_no" => getOrderSn(),"create_time"=>time()]);
$this->success("请求成功");
}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;
$res = Db::name("order")->where("id",$id)->update([
... ... @@ -1866,36 +1833,119 @@ class Car extends Base
"create_time"=>time()
]);
$this->success("请求成功");
}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;
$res = Db::name("order")->where("id",$id)->update(["commission_price"=>$rebook_fee,"rebook"=>1, "order_no" => getOrderSn(),"create_time"=>time()]);
$this->success("请求成功");
}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;
$res = Db::name("order")->where("id",$id)->update([
"commission_price"=>$rebook_fee,
"rebook"=>1,
"reservation_time" => $reservation_time,
"order_no" => getOrderSn(),
"create_time"=>time()
]);
$this->success("请求成功");
}
}
$res = Db::name("order")->where("id",$id)->update([
"commission_price"=>$rebook_fee,
"rebook"=>1,
"order_no" => getOrderSn(),
"reservation_time" => $reservation_time,
"create_time"=>time()
]);
$neworder=Db::name("order")->where("id", $id)->find();
$userinfo = Db::name('user')
->where(['id' => $this->auth->id])
->field('id,wx_xcx_openid')
->find();
$notifyURI = $this->doman . '/addons/epay/api/OrderPayNtf';
$params = [
'amount' => $neworder['commission_price'],
'orderid' => $neworder['order_no'],
'type' => 'wechat',
'notifyurl' => $notifyURI,
'method' => 'miniapp',
'openid' => $userinfo['wx_xcx_openid'],
];
$f = \addons\epay\library\Service::submitOrder($params);
$data=[
"pay"=>$f,
"commission_price"=>$neworder['commission_price'],
];
$this->success("请求成功", $data);
} catch (UploadException $e) {
$this->error($e->getMessage());
}
$res = Db::name("order")->where("id",$id)->update([
"commission_price"=>$rebook_fee,
"rebook"=>1,
"order_no" => getOrderSn(),
"reservation_time" => $reservation_time,
"create_time"=>time()
]);
$neworder=Db::name("order")->where("id", $id)->find();
$userinfo = Db::name('user')
->where(['id' => $this->auth->id])
->field('id,wx_xcx_openid')
->find();
}
$notifyURI = $this->doman . '/addons/epay/api/OrderPayNtf';
$params = [
'amount' => $neworder['commission_price'],
'orderid' => $neworder['order_no'],
'type' => 'wechat',
'notifyurl' => $notifyURI,
'method' => 'miniapp',
'openid' => $userinfo['wx_xcx_openid'],
];
$f = \addons\epay\library\Service::submitOrder($params);
$data=[
"pay"=>$f,
"commission_price"=>$neworder['commission_price'],
];
$this->success("请求成功", $data);
/**
* 改签价格计算
* @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());
}
... ...