row->order_id; $user_id = $this->row->orders->user_id; $money = $this->row->payment_amount; //退还余额 $user_money = User::where(['id'=>$user_id])->value('balance'); DB::beginTransaction(); try { User::where('id',$user_id)->update(['balance'=>($user_money + $money)]); $res = Order::where('id',$id)->update(['order_status'=>Order::CANCELED]); DB::commit(); } catch ( \Exception $e){ dd($e->getMessage()); DB::rollBack(); return $this->response()->error('操作失败!'); } if($res){ return $this->response()->success('操作成功!')->refresh(); } return $this->response()->error('操作失败!'); } }