|
@@ -43,7 +43,34 @@ class AdminFaultController extends AdminBaseController{ |
|
@@ -43,7 +43,34 @@ class AdminFaultController extends AdminBaseController{ |
43
|
|
43
|
|
44
|
//结束计费
|
44
|
//结束计费
|
45
|
public function bill_error(){
|
45
|
public function bill_error(){
|
|
|
46
|
+ $id=$this->request->param('id');
|
46
|
|
47
|
|
|
|
48
|
+ $fault=Db::name('fault')->where('id',$id)->find();
|
|
|
49
|
+
|
|
|
50
|
+ $order=Db::name('order')->where(['users_id'=>$fault['users_id'],'state'=>1])->find();
|
|
|
51
|
+ if (empty($order)){
|
|
|
52
|
+ $this->error('没有未完成订单');
|
|
|
53
|
+ }else{
|
|
|
54
|
+ $time=ceil(($fault['create_time']-$order['start_time'])/3600);
|
|
|
55
|
+ $getPrice=new OrderController();
|
|
|
56
|
+ $price=$getPrice->getPrice($order['start_time'],$fault['create_time']);
|
|
|
57
|
+ $data=[
|
|
|
58
|
+ 'end_time'=>$fault['create_time'],
|
|
|
59
|
+ 'time'=>$time,
|
|
|
60
|
+ 'price'=>$price,
|
|
|
61
|
+ 'state'=>2
|
|
|
62
|
+ ];
|
|
|
63
|
+ try{
|
|
|
64
|
+ Db::startTrans();
|
|
|
65
|
+ Db::name('order')->where('id',$order['id'])->update($data);
|
|
|
66
|
+ Db::name('fault')->where('id',$id)->update(['state'=>3]);
|
|
|
67
|
+ }catch (\Exception $exception){
|
|
|
68
|
+ Db::rollback();
|
|
|
69
|
+ $this->error('错误:'.$exception->getMessage());
|
|
|
70
|
+ }
|
|
|
71
|
+ Db::commit();
|
|
|
72
|
+ $this->success('处理完成');
|
|
|
73
|
+ }
|
47
|
}
|
74
|
}
|
48
|
|
75
|
|
49
|
|
76
|
|