| xqd
@@ -1,14 +1,20 @@
|
|
|
<?php
|
|
|
/**
|
|
|
* 通话列表
|
|
|
- * @author system
|
|
|
- * @version 1.0
|
|
|
- * @date 2018-12-18 16:38:51
|
|
|
+ * @author system
|
|
|
+ * @version 1.0
|
|
|
+ * @date 2018-12-18 16:38:51
|
|
|
*
|
|
|
*/
|
|
|
+
|
|
|
namespace App\Http\Controllers\Admin\Call;
|
|
|
+
|
|
|
use App\Http\Controllers\Admin\Controller;
|
|
|
use App\Models\CallListModel;
|
|
|
+use App\Models\CallRecordsModel;
|
|
|
+use App\Models\CompanyContactsModel;
|
|
|
+use App\Models\ThreadsProgressModel;
|
|
|
+use App\Models\UserThreadsModel;
|
|
|
use Illuminate\Http\Request;
|
|
|
use App\Repositories\Base\Criteria\OrderBy;
|
|
|
use App\Repositories\Call\Lists\Criteria\MultiWhere;
|
| xqd
@@ -18,14 +24,16 @@ class ListController extends Controller
|
|
|
{
|
|
|
private $repository;
|
|
|
|
|
|
- public function __construct(ListRepository $repository) {
|
|
|
- if(!$this->repository) $this->repository = $repository;
|
|
|
+ public function __construct(ListRepository $repository)
|
|
|
+ {
|
|
|
+ if (!$this->repository) $this->repository = $repository;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 列表页
|
|
|
*/
|
|
|
- function index(Request $request) {
|
|
|
+ function index(Request $request)
|
|
|
+ {
|
|
|
$search = $request->all();
|
|
|
|
|
|
$order = array();
|
| xqd
@@ -42,13 +50,13 @@ class ListController extends Controller
|
|
|
$list = $list->paginate(16);
|
|
|
|
|
|
if ($request->ajax()) {
|
|
|
- $view = view('admin.call.list.data', compact('list','allIds'))->render();
|
|
|
+ $view = view('admin.call.list.data', compact('list', 'allIds'))->render();
|
|
|
|
|
|
return response()->json(['html' => $view]);
|
|
|
|
|
|
}
|
|
|
|
|
|
- return view('admin.call.list.index',compact('list','allIds'));
|
|
|
+ return view('admin.call.list.index', compact('list', 'allIds'));
|
|
|
}
|
|
|
|
|
|
|
| xqd
@@ -57,7 +65,7 @@ class ListController extends Controller
|
|
|
*/
|
|
|
public function create(Request $request)
|
|
|
{
|
|
|
- if($request->method() == 'POST') {
|
|
|
+ if ($request->method() == 'POST') {
|
|
|
return $this->_createSave();
|
|
|
}
|
|
|
return view('admin.call.list.edit');
|
| xqd
@@ -66,68 +74,138 @@ class ListController extends Controller
|
|
|
/**
|
|
|
* 保存修改
|
|
|
*/
|
|
|
- private function _createSave(){
|
|
|
- $data = (array) request('data');
|
|
|
+ private function _createSave()
|
|
|
+ {
|
|
|
+ $data = (array)request('data');
|
|
|
$id = $this->repository->create($data);
|
|
|
- if($id) {
|
|
|
- $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
|
|
|
- $url[] = array('url'=>U( 'Call/List/create'),'title'=>'继续添加');
|
|
|
- $this->showMessage('添加成功',$url);
|
|
|
- }else{
|
|
|
- $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
|
|
|
- return $this->showWarning('添加失败',$url);
|
|
|
+ if ($id) {
|
|
|
+ $url[] = array('url' => U('Call/List/index'), 'title' => '返回列表');
|
|
|
+ $url[] = array('url' => U('Call/List/create'), 'title' => '继续添加');
|
|
|
+ $this->showMessage('添加成功', $url);
|
|
|
+ } else {
|
|
|
+ $url[] = array('url' => U('Call/List/index'), 'title' => '返回列表');
|
|
|
+ return $this->showWarning('添加失败', $url);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 修改
|
|
|
*/
|
|
|
- public function update(Request $request) {
|
|
|
- if($request->method() == 'POST') {
|
|
|
+ public function update(Request $request)
|
|
|
+ {
|
|
|
+ if ($request->method() == 'POST') {
|
|
|
return $this->_updateSave();
|
|
|
}
|
|
|
$data = $this->repository->find($request->get('id'));
|
|
|
- return view('admin.call.list.edit',compact('data'));
|
|
|
+ return view('admin.call.list.edit', compact('data'));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存修改
|
|
|
*/
|
|
|
- private function _updateSave() {
|
|
|
- $data = (array) request('data');
|
|
|
- $ok = $this->repository->update(request('id'),$data);
|
|
|
- if($ok) {
|
|
|
- $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
|
|
|
- return $this->showMessage('操作成功',urldecode(request('_referer')));
|
|
|
- }else{
|
|
|
- $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
|
|
|
- return $this->showWarning('操作失败',$url);
|
|
|
+ private function _updateSave()
|
|
|
+ {
|
|
|
+ $data = (array)request('data');
|
|
|
+ $ok = $this->repository->update(request('id'), $data);
|
|
|
+ if ($ok) {
|
|
|
+ $url[] = array('url' => U('Call/List/index'), 'title' => '返回列表');
|
|
|
+ return $this->showMessage('操作成功', urldecode(request('_referer')));
|
|
|
+ } else {
|
|
|
+ $url[] = array('url' => U('Call/List/index'), 'title' => '返回列表');
|
|
|
+ return $this->showWarning('操作失败', $url);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function view(Request $request) {
|
|
|
+ public function view(Request $request)
|
|
|
+ {
|
|
|
$data = $this->repository->find(request('id'));
|
|
|
- return view('admin.call.list.view',compact('data'));
|
|
|
+ return view('admin.call.list.view', compact('data'));
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 删除
|
|
|
*/
|
|
|
- public function destroy(Request $request) {
|
|
|
+ public function destroy(Request $request)
|
|
|
+ {
|
|
|
$bool = $this->repository->destroy($request->get('id'));
|
|
|
- if($bool) {
|
|
|
- return $this->showMessage('操作成功');
|
|
|
- }else{
|
|
|
- return $this->showWarning("操作失败");
|
|
|
+ if ($bool) {
|
|
|
+ return $this->showMessage('操作成功');
|
|
|
+ } else {
|
|
|
+ return $this->showWarning("操作失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function alldelete(Request $request){
|
|
|
+ public function alldelete(Request $request)
|
|
|
+ {
|
|
|
$list_ids = $request->get('list_ids');
|
|
|
CallListModel::destroy($list_ids);
|
|
|
|
|
|
return 200;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加到AI电话拨打列表
|
|
|
+ */
|
|
|
+ public function syncAdd(Request $request)
|
|
|
+ {
|
|
|
+ /*从线索导入*/
|
|
|
+ if (count($request->get('thread_ids'))) {
|
|
|
+ $thread_ids = $request->get('thread_ids');
|
|
|
+ $ip = $request->get('ip');
|
|
|
+
|
|
|
+ foreach ($thread_ids as $thread_id) {
|
|
|
+ $thread = UserThreadsModel::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 (count($request->get('contact_phones'))) {
|
|
|
+ $ids = $request->get('contact_phones');
|
|
|
+
|
|
|
+ $ip = $request->get('ip');
|
|
|
+
|
|
|
+ $phones = CallRecordsModel::whereIn('id', $ids)->get();
|
|
|
+
|
|
|
+ foreach ($phones as $phone) {
|
|
|
+ $hasAdd = CallListModel::where('phone', $phone->phone)->where('sync', 0)->count();
|
|
|
+ if (!$hasAdd) {
|
|
|
+ CallListModel::create(['phone' => $phone->phone, 'sync' => 0, 'ip' => $ip]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*从公海导入*/
|
|
|
+ if (count($request->get('contact_ids'))) {
|
|
|
+ $contact_ids = $request->get('contact_ids');
|
|
|
+ $ip = $request->get('ip');
|
|
|
+
|
|
|
+ foreach ($contact_ids as $contact_id) {
|
|
|
+ $contact = CompanyContactsModel::find($contact_id);
|
|
|
+ $phone = $contact->phone;
|
|
|
+
|
|
|
+ $hasAdd = CallListModel::where('phone', $phone)->where('sync', 0)->count();
|
|
|
+ if (!$hasAdd) {
|
|
|
+ CallListModel::create(['phone' => $phone, 'sync' => 0, 'ip' => $ip]);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 200;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|