wesley 6 年之前
父节点
当前提交
75903fc64d

+ 118 - 40
app/Http/Controllers/Admin/Call/ListController.php

xqd xqd xqd xqd 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;
@@ -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();
@@ -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'));
     }
 
 
@@ -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');
@@ -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;
+    }
+
+
 }

+ 0 - 1
app/Http/Controllers/Admin/User/ThreadsController.php

xqd
@@ -187,7 +187,6 @@ class ThreadsController extends Controller
         $thread_ids = $request->get('threads_ids');
 
         $threads = UserThreadsModel::whereIn('id', $thread_ids)->get();
-
         $fileds =$request->get('check_fields');
 
         return Excel::download(new ThreadsExport($threads, $fileds), '我的线索.xlsx');

+ 2 - 1
app/Models/CallListModel.php

xqd
@@ -36,7 +36,8 @@ class CallListModel extends BaseModel
     protected $fillable = [
         'phone',
         'ip',
-        'sync'
+        'sync',
+        'label'
     ];
 
 }

+ 2 - 1
app/Models/UserThreadsModel.php

xqd
@@ -38,7 +38,8 @@ class UserThreadsModel extends BaseModel
         'contact_id',
         'company_id',
         'status',
-        'remark'
+        'remark',
+        'label'
     ];
 
     /**

+ 32 - 0
database/migrations/2019_01_04_135752_add_label_to_user_threads_table.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddLabelToUserThreadsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('user_threads', function (Blueprint $table) {
+            $table->string('label',255)->after('remark')->nullable()->comment('标签');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('user_threads', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 32 - 0
database/migrations/2019_01_04_135822_add_label_to_call_list_table.php

xqd
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddLabelToCallListTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('call_list', function (Blueprint $table) {
+            $table->string('label',255)->after('sync')->nullable()->comment('标签');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('call_list', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 2 - 26
resources/views/admin/call/records/index.blade.php

xqd xqd xqd
@@ -14,7 +14,7 @@
                 <div class="ibox-content">
                     <div class="form-group">
 
-                        @if(role('Call/Records/addCallList'))
+                        @if(role('Call/List/syncAdd'))
                             <div class="col-sm-8 pull-right">
                                 <span class="btn btn-primary pull-right fa fa-phone" data-toggle="modal"
                                       data-target="#myModal2" style="display: none">添加到待导列表</span>
@@ -98,30 +98,6 @@
 
                 </div>
 
-                {{--<table class="table table-striped table-bordered table-hover dataTables-example dataTable">--}}
-                {{--<tr>--}}
-                {{--<th> 过滤条件</th>--}}
-                {{--<form method="GET" action="" accept-charset="UTF-8" id="filter_records">--}}
-                {{--<th>--}}
-
-                {{--</th>--}}
-
-                {{--<th>--}}
-
-                {{--</th>--}}
-
-                {{--<th>--}}
-
-
-                {{--</th>--}}
-
-                {{--<th>--}}
-
-                {{--</th>--}}
-                {{--</form>--}}
-                {{--</tr>--}}
-                {{--</table>--}}
-
                 <div id="records-list">
                     @include('admin.call.records.data')
                 </div>
@@ -242,7 +218,7 @@
 
             $.ajax({
                 type: 'post',
-                url: '{{ U('Call/Records/addCallList') }}',
+                url: '{{ U('Call/List/syncAdd') }}',
                 data: {_token: csrf_token, ip: ip,contact_phones: contact_phones},
                 success: function (data) {
                     if (data == 200) {

+ 37 - 15
resources/views/admin/company/collection/data.blade.php

xqd xqd
@@ -20,26 +20,26 @@
             <tr>
 
                 <td>{{ $item->id }}</td>
-                <td><a href="{{ U('Company/Info/view',['id'=>$item->id])}}">{{ $item->company_name }}</a></td>
+                <td>
+                    <a href="{{ U('Company/Info/view',['id'=>$item->id])}}">{{ $item->company_name }}</a>
+                    <span onclick="showContacts(this,{{$item->id}})" class="pull-right text-info" style="cursor: pointer">展开</span>
+                </td>
                 <td>{{ $item->reg_no }}</td>
                 <td>{{ $item->legal_person }}</td>
                 <td>{{ $item->open_status }}</td>
                 <td>{{ $item->start_date }}</td>
                 <td>{{ $item->reg_capital }}</td>
-                {{--<td>--}}
-                    {{--@if(role('Company/Info/update') && !$item->isThread())--}}
-                        {{--<button class="btn btn-sm btn-success"--}}
-                                {{--onclick="window.location.href='{{ U('User/Threads/create',['company_id'=>$item->id])}}' ">--}}
-                            {{--领取线索--}}
-                        {{--</button>--}}
-                    {{--@endif--}}
-
-                    {{--@if(role('Company/Info/view'))--}}
-                        {{--<a href="{{ U('Company/Info/view',['id'=>$item->id])}}"--}}
-                           {{--class="btn btn-sm btn-primary "> 查看</a>--}}
-                    {{--@endif--}}
-                {{--</td>--}}
             </tr>
+            @if($item->contacts()->count())
+                @foreach($item->contacts()->get() as $contact)
+                    <tr style="display: none" class="contact_{{$item->id}}">
+                        <td><input class="contactlist" name='contact_id[]' type="checkbox"
+                                   value="{{ $contact->id }}" data-id="{{ $contact->id }}"></td>
+                        <td>联系人:{{ $contact->linkman }}</td>
+                        <td>电话: {{ $contact->phone }}</td>
+                    </tr>
+                @endforeach
+            @endif
         @endforeach
     @endif
 
@@ -59,4 +59,26 @@
             {!! $list->setPath('')->appends(Request::all())->render() !!}
         </div>
     </div>
-</div>
+</div>
+
+    <script type="text/javascript">
+        /*显示联系人*/
+        function showContacts(data,id) {
+            if($('.contact_'+id).is(':hidden')){
+                $('.contact_'+id).show()
+                $(data).text('隐藏')
+                $(data).removeClass('text-info')
+                $(data).addClass('text-warning')
+
+
+            }else {
+                $('.contact_'+id).hide()
+                $(data).text('显示')
+                $(data).removeClass('text-warning')
+                $(data).addClass('text-info')
+
+            }
+
+        }
+
+</script>

+ 120 - 7
resources/views/admin/company/collection/index.blade.php

xqd xqd xqd xqd
@@ -45,12 +45,19 @@
 
                             </div>
 
-                            {{--@if(role('Company/Info/collection'))--}}
-                            {{--<div class="col-sm-8 pull-right">--}}
-                            {{--<span class="btn btn-warning pull-right" onclick="save_collection()">保存为我的公海--}}
-                            {{--</span>--}}
-                            {{--</div>--}}
-                            {{--@endif--}}
+                            <div class="col-sm-8 pull-right">
+                                @if(role('Call/Threads/create'))
+                                    <span class="btn btn-info pull-right fa fa-user" id="addthread" style="display: none">
+                                        添加到我的线索
+                                    </span>
+
+                                @endif
+
+                                @if(role('Call/List/syncAdd'))
+                                    <span class="btn btn-primary pull-right fa fa-phone" data-toggle="modal"
+                                          data-target="#myModal2" style="display: none">添加到待导列表</span>
+                                @endif
+                            </div>
 
                         </div>
                     </div>
@@ -125,7 +132,7 @@
 
                                         <span class="input-group-append">
                                                 <button type="button" class="btn btn-sm btn-default"
-                                                       onclick="filter_company()">搜索</button>
+                                                        onclick="filter_company()">搜索</button>
                                             </span>
                                     </div>
                                 </th>
@@ -140,6 +147,53 @@
                 </div>
             </div>
         </div>
+
+
+        <div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content animated flipInY">
+                    <div class="modal-header">
+                        <h4 class="modal-title">选择拨打的IP</h4></div>
+                    <small class="font-bold">
+                        <div class="modal-body">
+                            <div class="ibox float-e-margins">
+                                <div class="ibox-content">
+                                    <select name="ip" class="form-control" id="ip">
+                                        <option value="172.31.20.181">172.31.20.181</option>
+                                        <option value="172.31.20.182">172.31.20.182</option>
+                                        <option value="172.31.20.183">172.31.20.183</option>
+                                        <option value="172.31.20.184">172.31.20.184</option>
+                                        <option value="172.31.20.185">172.31.20.185</option>
+                                        <option value="172.31.20.186">172.31.20.186</option>
+                                        <option value="172.31.20.187">172.31.20.187</option>
+                                        <option value="172.31.20.188">172.31.20.188</option>
+
+                                    </select>
+
+                                    <div class="form-group">
+                                        <label class="control-label col-sm-3">&nbsp;</label>
+                                        <div class="col-sm-9">
+                                            <input type="submit" class="btn btn-success" style="margin-right:20px;"
+                                                   id="addCallList">
+                                            <input type="reset" class="btn btn-default">
+                                        </div>
+                                    </div>
+
+                                </div>
+                            </div>
+                        </div>
+                        <div class="modal-footer">
+                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
+                        </div>
+                    </small>
+                </div>
+                <small class="font-bold">
+                </small>
+            </div>
+            <small class="font-bold">
+            </small>
+        </div>
+
     </div>
 @endsection
 
@@ -172,5 +226,64 @@
 
         });
 
+
+        var checkedIds = [];
+
+        $('body').on('click', '.contactlist', function () {
+            checkedLength = $('.contactlist:checked').length
+            if (checkedLength) {
+                $('#addthread').show()
+                $('.fa-phone').show()
+            } else {
+                $('#addthread').hide()
+                $('.fa-phone').hide()
+            }
+            saveChecked($(this))
+        });
+        /*保存选中的项*/
+        function saveChecked(e) {
+            if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
+                checkedIds.push(e.data("id"));
+            } else {
+                for (var i = 0; i < checkedIds.length; i++) {
+                    if (e.data("id") == checkedIds[i]) {
+                        checkedIds.splice(i, 1);
+                        break;
+                    }
+                }
+            }
+        }
+
+
+        /*添加选择的电话到待导列表*/
+        $('#addCallList').click(function () {
+            contact_ids = checkedIds;
+            csrf_token = "{{ csrf_token() }}";
+            ip = $('#ip').val()
+
+            $.ajax({
+                type: 'post',
+                url: '{{ U('Call/List/syncAdd') }}',
+                data: {_token: csrf_token, ip: ip, contact_ids: contact_ids},
+                success: function (data) {
+                    if (data == 200) {
+                        layer.msg('导入成功', {
+                            icon: 1,
+                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
+                        }, function () {
+                            window.location.href = window.location.href
+                        });
+
+                    }
+                }
+
+            })
+        });
+
+        /*添加到待导列表*/
+        $('body').on('click', '#addCallList', function () {
+
+        })
+
     </script>
 @endsection

+ 19 - 18
resources/views/admin/user/threads/index.blade.php

xqd xqd xqd xqd
@@ -16,17 +16,18 @@
                 <div class="ibox-content">
                     <div class="form-group">
 
-                        @if(role('User/Threads/addCallList'))
-                            <div class="col-sm-8 pull-right">
-                                    <span class="btn btn-primary pull-right fa fa-phone"
-                                          data-toggle="modal"
-                                          data-target="#myModal2" style="display: none">添加到待导列表</span>
-
-                                <span class="btn btn-success pull-right fa fa-table"
-                                      style="display: none" data-toggle="modal"
-                                      data-target="#myModal1">导出到Excel</span>
-                            </div>
-                        @endif
+                        <div class="col-sm-8 pull-right">
+
+
+                                <span class="btn btn-primary pull-right fa fa-phone"
+                                      data-toggle="modal"
+                                      data-target="#myModal2" style="display: none">添加到待导列表</span>
+
+                            <span class="btn btn-success pull-right fa fa-table"
+                                  style="display: none" data-toggle="modal"
+                                  data-target="#myModal1">导出到Excel</span>
+                        </div>
+
                     </div>
                 </div>
 
@@ -52,7 +53,7 @@
                                            name="keyword">
                                     <span class="input-group-append">
                                                 <button type="button" class="btn btn-sm btn-default"
-                                                       onclick="filter_threads()">搜索</button>
+                                                        onclick="filter_threads()">搜索</button>
                                             </span>
                                 </div>
 
@@ -323,16 +324,16 @@
             checkedLength = $('.contacts:checked').length
 
             if (checkedLength) {
-                $('#addCallList').show()
+                $('.fa-phone').show()
                 $('.fa-table').show()
             } else {
-                $('#addCallList').hide()
+                $('.fa-phone').hide()
                 $('.fa-table').hide()
             }
 
             if (items.length == checkedLength) {
                 $('#checkAll').prop('checked', true)
-                $('#addCallList').show()
+                $('.fa-phone').show()
                 $('.fa-table').show()
             } else {
                 $('#checkAll').prop('checked', false)
@@ -377,14 +378,14 @@
 
         /*添加选择的电话到拨打列表*/
         $('#addCallList').click(function () {
-            contact_ids = checkedIds
+            thread_ids = checkedIds
             csrf_token = "{{ csrf_token() }}"
             ip = $('#ip').val()
 
             $.ajax({
                 type: 'post',
-                url: '{{ U('User/Threads/addCallList') }}',
-                data: {_token: csrf_token, ip: ip,contact_ids: contact_ids},
+                url: '{{ U('Call/List/syncAdd') }}',
+                data: {_token: csrf_token, ip: ip, thread_ids: thread_ids},
                 success: function (data) {
                     if (data == 200) {
                         layer.msg('导入成功', {