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

add stop equipment

... ... @@ -126,24 +126,26 @@ class AdminEquipmentController extends AdminBaseController{
public function unUse(){
/*解除设备占用*/
$id=$this->request->param('id');
$eq=Db::name('equipment')->where('id',$id)->find();
dump($eq);
/*查找对应订单*/
$map['eq_name']=$eq['name'];
$order=\db('order')->where($map)->find();
dump($order);
//Db::name('equipment')->where('id',$id)->update(['use'=>0]);
/*结束订单*/
$data['end_time']=time();
$data['price']=action('Order/getPrice',[$order['users_id'],$order['start_time'],time()]);
// $data['price']= $Order->getPrice($order['users_id'],$order['start_time'],time());
dump($data);
// \db('order')->where($map)->update();
$info=action('Order/getPrice',[$order['users_id'],$order['start_time'],time()]);
$data['state']=2;
$data['price']=$info['price'];
$data['time']=$info['time'];
Db::startTrans();
try{
Db::name('equipment')->where('id',$id)->update(['use'=>0]);
\db('order')->where($map)->update($data);
} catch (\Exception $e){
Db::rollback();
$this->error('操作失败!');
}
\db('order')->where($map)->update($data);
}
... ...