| xqd
@@ -41,37 +41,37 @@ class ThreadsController extends Controller
|
|
|
$search = $request->all();
|
|
|
|
|
|
$search['keyword'] = $request->input('keyword');
|
|
|
- if(is_numeric($search['keyword'])){
|
|
|
+ if (is_numeric($search['keyword'])) {
|
|
|
$list = UserThreadsModel::whereHas('contact', function ($query) use ($search) {
|
|
|
$query->where('phone', 'like', '%' . $search['keyword'] . '%');
|
|
|
- })->where('ower_id',$user_id)->orderBy('updated_at','desc');
|
|
|
+ })->where('ower_id', $user_id)->orderBy('updated_at', 'desc');
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$list = UserThreadsModel::whereHas('company', function ($query) use ($search) {
|
|
|
$query->where('companyName', 'like', '%' . $search['keyword'] . '%')
|
|
|
->orWhere('regNo', 'like', '%' . $search['keyword'] . '%');
|
|
|
- })->where('ower_id',$user_id)->orderBy('updated_at','desc');
|
|
|
+ })->where('ower_id', $user_id)->orderBy('updated_at', 'desc');
|
|
|
}
|
|
|
|
|
|
- if(isset($search['process']) && $search['process'] ==1 ){
|
|
|
+ if (isset($search['process']) && $search['process'] == 1) {
|
|
|
$list = $list->has('progress');
|
|
|
}
|
|
|
|
|
|
- if(isset($search['process']) && $search['process'] == 2){
|
|
|
- $list = $list->has('progress','=',0);
|
|
|
+ if (isset($search['process']) && $search['process'] == 2) {
|
|
|
+ $list = $list->has('progress', '=', 0);
|
|
|
}
|
|
|
|
|
|
$allIds = $list->pluck('id');
|
|
|
- $list = $list->paginate(10);
|
|
|
+ $list = $list->paginate(10);
|
|
|
|
|
|
if ($request->ajax()) {
|
|
|
- $view = view('admin.user.threads.data', compact('list','allIds'))->render();
|
|
|
+ $view = view('admin.user.threads.data', compact('list', 'allIds'))->render();
|
|
|
|
|
|
return response()->json(['html' => $view]);
|
|
|
|
|
|
}
|
|
|
|
|
|
- return view('admin.user.threads.index', compact('list','allIds'));
|
|
|
+ return view('admin.user.threads.index', compact('list', 'allIds'));
|
|
|
}
|
|
|
|
|
|
|
| xqd
@@ -87,8 +87,8 @@ class ThreadsController extends Controller
|
|
|
$res = $this->repository->create($data);
|
|
|
|
|
|
/*添加初始化跟进备注*/
|
|
|
- if($request->get('remark')){
|
|
|
- ThreadsProgressModel::create(['threads_id'=>$res->id,'remark'=>$request->get('remark')]);
|
|
|
+ if ($request->get('remark')) {
|
|
|
+ ThreadsProgressModel::create(['threads_id' => $res->id, 'remark' => $request->get('remark')]);
|
|
|
}
|
|
|
|
|
|
if ($res) {
|
| xqd
@@ -152,18 +152,19 @@ class ThreadsController extends Controller
|
|
|
/*
|
|
|
* 添加到AI电话拨打列表
|
|
|
* */
|
|
|
- public function addCallList(Request $request){
|
|
|
- $thread_ids = $request->get('contact_ids');
|
|
|
+ public function addCallList(Request $request)
|
|
|
+ {
|
|
|
+ $thread_ids = $request->get('contact_ids');
|
|
|
$ip = $request->get('ip');
|
|
|
|
|
|
- foreach ($thread_ids as $thread_id){
|
|
|
+ foreach ($thread_ids as $thread_id) {
|
|
|
$thread = $this->repository->find($thread_id);
|
|
|
- if($thread->contact()->count()){
|
|
|
- $phone = $thread->contact->phone;
|
|
|
- $hasAdd = CallListModel::where('phone',$phone)->where('sync',0)->count();
|
|
|
- if(!$hasAdd){
|
|
|
- CallListModel::create(['phone'=>$phone,'sync'=>0,'ip'=>$ip]);
|
|
|
- ThreadsProgressModel::create(['threads_id'=>$thread->id,'remark'=>'添加到AI电话列表']);
|
|
|
+ if ($thread->contact()->count()) {
|
|
|
+ $phone = $thread->contact->phone;
|
|
|
+ $hasAdd = CallListModel::where('phone', $phone)->where('sync', 0)->count();
|
|
|
+ if (!$hasAdd) {
|
|
|
+ CallListModel::create(['phone' => $phone, 'sync' => 0, 'ip' => $ip]);
|
|
|
+ ThreadsProgressModel::create(['threads_id' => $thread->id, 'remark' => '添加到AI电话列表']);
|
|
|
}
|
|
|
|
|
|
}
|
| xqd
@@ -176,16 +177,19 @@ class ThreadsController extends Controller
|
|
|
* @param Request $request
|
|
|
* @return int|\Symfony\Component\HttpFoundation\BinaryFileResponse
|
|
|
*/
|
|
|
- public function export_threads(Request $request){
|
|
|
+ public function export_threads(Request $request)
|
|
|
+ {
|
|
|
$type = $request->get('type');
|
|
|
if($type){
|
|
|
return 200;
|
|
|
}
|
|
|
|
|
|
- $thread_ids = $request->get('threads_ids');
|
|
|
- \Log::info($thread_ids);
|
|
|
- $threads = UserThreadsModel::whereIn('id',$thread_ids)->get();
|
|
|
+ $thread_ids = $request->get('threads_ids');
|
|
|
+
|
|
|
+ $threads = UserThreadsModel::whereIn('id', $thread_ids)->get();
|
|
|
+
|
|
|
+ $fileds =$request->get('check_fields');
|
|
|
|
|
|
- return Excel::download(new ThreadsExport($threads),'我的线索.xlsx');
|
|
|
+ return Excel::download(new ThreadsExport($threads, $fileds), '我的线索.xlsx');
|
|
|
}
|
|
|
}
|