getAbnormalModel()->find($params['abnormal_id']); if (!$abnormal) { $this->apiError('异常原因不存在,请重新选择'); } $worker = $this->getWorkerModel()->find($workerId); $model = $this->getOrderAbnormalModel(); $model->order_id = $params['order_id']; $model->status = 0; $model->abnormal_id = $params['abnormal_id']; $model->abnormal_title = $abnormal->title; $model->detail = $params['detail']; $model->type = 2; $model->admin_user = $worker->name; $model->admin_id = $workerId; $model->save(); return true; } /** * 获取订单异常详情 * @param int $workerId * @param int $orderId */ public function getOrderAbnormal(int $workerId, int $orderId) { return $this->getOrderAbnormalModel() ->where('order_id', $orderId) ->where('admin_id', $workerId) ->where('type', 2) ->field([ 'id', 'order_id', 'abnormal_id', 'abnormal_title', 'detail', 'create_time', ]) ->find(); } }