all(), [ 'province' => 'exists:area,id', // 省 'city' => 'exists:area,id', // 市 'district' => 'exists:area,id', // 区 'word' => 'string|min:3', 'feedbackType' => 'exists:feedback,feedback_type' ]); if ($validator->fails()) { return showJsonErr($validator->errors()->first()); } $feedback = \DB::table('feedback as main') ->join('user as u', 'u.id', '=', 'main.uid') ->select([ 'u.real_name', 'u.nick_name', 'u.mobile', 'u.province', 'u.city', 'u.district', 'main.*' ]) ->orderByDesc('id'); if (!empty($param['province'])) { $feedback->where('province', $param['province']); } if (!empty($param['city'])) { $feedback->where('city', $param['city']); } if (!empty($param['district'])) { $feedback->where('district', $param['district']); } // 关键词查询 if (!empty($param['word'])) { $feedback->where(\DB::raw("concat(real_name,mobile,nick_name)"), 'like', "%{$param['word']}%"); } // 广告标题 if (!empty($param['feedbackType'])) { $feedback->where('main.feedback_type', 'like', "%{$param['feedbackType']}%"); } $res = $feedback->paginate(perPage()); if ($res->isNotEmpty()) { collect($res->items())->each(function ($item, $key) { $item->area = Area::getArea($item->province, $item->city, $item->district); }); } return showJsonSucc(1001, $res); } /** * @author lyh * @date 2019/4/16 * @param Request $request * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response * @description */ public function reply(Request $request) { $validator = \Validator::make($param = $request->all(), [ 'id' => 'required|array', 'audit_remark' => 'required' ]); if ($validator->fails()) { return showJsonErr($validator->errors()->first()); } foreach ($param['id'] as $id) { $feedback = FeedBack::find($id); if (empty($feedback)) { \DB::rollBack(); return showJsonErr('抱歉,该反馈记录不存在'); } $feedback->audit_remark = $param['audit_remark']; $feedback->audit_uid = \Auth::id(); $feedback->audit_at = Carbon::now(); $result = $feedback->save(); if (!$result) { \DB::rollBack(); return showJsonErr('处理反馈失败'); } UserMsg::SendGetui(['title'=>'反馈回复','uid'=>$feedback->uid,'type'=>6,'content'=>$param['audit_remark']]); } return showJsonSucc('回复反馈成功'); } }