...
|
...
|
@@ -43,7 +43,34 @@ class AdminFaultController extends AdminBaseController{ |
|
|
|
|
|
//结束计费
|
|
|
public function bill_error(){
|
|
|
$id=$this->request->param('id');
|
|
|
|
|
|
$fault=Db::name('fault')->where('id',$id)->find();
|
|
|
|
|
|
$order=Db::name('order')->where(['users_id'=>$fault['users_id'],'state'=>1])->find();
|
|
|
if (empty($order)){
|
|
|
$this->error('没有未完成订单');
|
|
|
}else{
|
|
|
$time=ceil(($fault['create_time']-$order['start_time'])/3600);
|
|
|
$getPrice=new OrderController();
|
|
|
$price=$getPrice->getPrice($order['start_time'],$fault['create_time']);
|
|
|
$data=[
|
|
|
'end_time'=>$fault['create_time'],
|
|
|
'time'=>$time,
|
|
|
'price'=>$price,
|
|
|
'state'=>2
|
|
|
];
|
|
|
try{
|
|
|
Db::startTrans();
|
|
|
Db::name('order')->where('id',$order['id'])->update($data);
|
|
|
Db::name('fault')->where('id',$id)->update(['state'=>3]);
|
|
|
}catch (\Exception $exception){
|
|
|
Db::rollback();
|
|
|
$this->error('错误:'.$exception->getMessage());
|
|
|
}
|
|
|
Db::commit();
|
|
|
$this->success('处理完成');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|