作者 sgj
1 个管道 的构建 通过 耗费 0 秒

add stop equipment

@@ -126,24 +126,26 @@ class AdminEquipmentController extends AdminBaseController{ @@ -126,24 +126,26 @@ class AdminEquipmentController extends AdminBaseController{
126 public function unUse(){ 126 public function unUse(){
127 /*解除设备占用*/ 127 /*解除设备占用*/
128 $id=$this->request->param('id'); 128 $id=$this->request->param('id');
129 -  
130 $eq=Db::name('equipment')->where('id',$id)->find(); 129 $eq=Db::name('equipment')->where('id',$id)->find();
131 -  
132 - dump($eq);  
133 /*查找对应订单*/ 130 /*查找对应订单*/
134 $map['eq_name']=$eq['name']; 131 $map['eq_name']=$eq['name'];
135 $order=\db('order')->where($map)->find(); 132 $order=\db('order')->where($map)->find();
136 - dump($order);  
137 - //Db::name('equipment')->where('id',$id)->update(['use'=>0]);  
138 /*结束订单*/ 133 /*结束订单*/
139 $data['end_time']=time(); 134 $data['end_time']=time();
140 - $data['price']=action('Order/getPrice',[$order['users_id'],$order['start_time'],time()]);  
141 - // $data['price']= $Order->getPrice($order['users_id'],$order['start_time'],time());  
142 - dump($data);  
143 -  
144 - // \db('order')->where($map)->update();  
145 - 135 + $info=action('Order/getPrice',[$order['users_id'],$order['start_time'],time()]);
  136 + $data['state']=2;
  137 + $data['price']=$info['price'];
  138 + $data['time']=$info['time'];
146 139
  140 + Db::startTrans();
  141 + try{
  142 + Db::name('equipment')->where('id',$id)->update(['use'=>0]);
  143 + \db('order')->where($map)->update($data);
  144 + } catch (\Exception $e){
  145 + Db::rollback();
  146 + $this->error('操作失败!');
  147 + }
  148 + \db('order')->where($map)->update($data);
147 } 149 }
148 150
149 151