<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-06 16:50:44
 技术支持 口号帮
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Http\Controllers\Admin;use App\Http\Controllers\Controller;use App\Models\Product;use App\Models\Report;use App\Models\ReportCategory;use Carbon\Carbon;use Illuminate\Http\Request;use Illuminate\Support\Facades\DB;use PHPUnit\TextUI\ResultPrinter;class ReportController extends Controller{public function index(){$channels=ReportCategory::get(['id','name']);return view('admin.report.index',compact('channels'));}public function data(Request $request,Report $feedback){$O280=$request->get('end_time')<$request->get('start_time');if($O280)goto O28Bodyx2;goto O28Nextx2;O28Bodyx2:$O28AC0=array();$O28AC0['code']=1;$O28AC0['msg']='结束时间不能小于开始时间';$O28AC0['count']='';$O28AC0['data']='';$data=$O28AC0;return response()->json($data);goto O28x1;O28Nextx2:O28x1:DB::connection()->enableQueryLog();$model=$feedback->query();if($request->get('start_time'))goto O28Bodyx4;goto O28Nextx4;O28Bodyx4:$model=$model->where('created_at','>',$request->get('start_time'));goto O28x3;O28Nextx4:O28x3:if($request->get('end_time'))goto O28Bodyx6;goto O28Nextx6;O28Bodyx6:$model=$model->where('created_at','<=',$request->get('end_time'));goto O28x5;O28Nextx6:O28x5:if($request->get('phone'))goto O28Bodyx8;goto O28Nextx8;O28Bodyx8:$phone=$request->get('phone');$model=$model->where('phone','like',"%".$phone."%");goto O28x7;O28Nextx8:O28x7:if($request->get('channel_id'))goto O28Bodyxa;goto O28Nextxa;O28Bodyxa:$model=$model->where(['category_id'=>$request->get('channel_id')]);goto O28x9;O28Nextxa:O28x9:if(isset($request->reply_status))goto O28Bodyxc;goto O28Nextxc;O28Bodyxc:$model=$model->where(['status'=>$request->get('reply_status')]);goto O28xb;O28Nextxc:O28xb:$res=$model->with('category')->orderBy('created_at','desc')->paginate($request->get('limit',$this->pageSize))->toArray();if($res['data'])goto O28Bodyxe;goto O28Nextxe;O28Bodyxe:foreach($res['data']as&$item){$category=$item['category']['name'];unset($item['category']);$item['category']=$category;$product=Product::withTrashed()->find($item['product_id']);$item['product_name']=$product->name;}goto O28xd;O28Nextxe:O28xd:$O28AC0=array();$O28AC0['code']=0;$O28AC0['msg']='正在请求中...';$O28AC0['count']=$res['total'];$O28AC0['data']=$res['data'];$data=$O28AC0;return response()->json($data);}public function destroy(Request $request){$id=$request->get('ids');if(empty($id))goto O28Bodyxg;goto O28Nextxg;O28Bodyxg:return response()->json(['code'=>1,'msg'=>'未选择账户']);goto O28xf;O28Nextxg:Report::whereIn('id',$request->ids)->delete();return response()->json(['code'=>0,'msg'=>'成功']);O28xf:}public function update(Request $request){Report::where(['id'=>$request->id])->update(['deal_at'=>Carbon::now(),'deal_uid'=>auth()->user()->id,'deal_content'=>$request->edit_content,'status'=>2]);return response()->json(['code'=>0,'info'=>'成功']);}}
?>