wesley 6 vuotta sitten
vanhempi
commit
0f282d8ecf

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

xqd xqd xqd
@@ -10,6 +10,8 @@
 namespace App\Http\Controllers\Admin\User;
 
 use App\Http\Controllers\Admin\Controller;
+use App\Models\CallListModel;
+use App\Models\CompanyContactsModel;
 use App\Models\ThreadsProgressModel;
 use App\Models\UserThreadsModel;
 use Illuminate\Http\Request;
@@ -39,6 +41,7 @@ class ThreadsController extends Controller
                 ->orWhere('regNo', 'like', '%' . $search['keyword'] . '%')
                 ->orWhere('companyName', 'like', '%' . $search['keyword'] . '%');
         })->where('ower_id',$user_id)->orderBy('updated_at','desc')->paginate(16);
+
         return view('admin.user.threads.index', compact('list'));
     }
 
@@ -116,4 +119,24 @@ class ThreadsController extends Controller
             return $this->showWarning("操作失败");
         }
     }
+
+    /*
+     * 添加到AI电话拨打列表
+     * */
+    public function addCallList(Request $request){
+        $thread_ids =  $request->get('contact_ids');
+        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]);
+                    ThreadsProgressModel::create(['threads_id'=>$thread->id,'remark'=>'添加到AI电话列表']);
+                }
+
+            }
+        }
+        return 200;
+    }
 }

+ 42 - 0
app/Models/CallListModel.php

xqd
@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Models;
+
+use App\Models\BaseModel;
+
+/**
+ * @description 通话纪录
+ * @author  system;
+ * @version    1.0
+ * @date 2018-11-27 03:15:47
+ *
+ */
+class CallListModel extends BaseModel
+{
+    /**
+     * 数据表名
+     *
+     * @var string
+     *
+     */
+    protected $table = 'call_list';
+    /**
+     * 主键
+     */
+    protected $primaryKey = 'id';
+
+    //分页
+    protected $perPage = PAGE_NUMS;
+
+    /**
+     * 可以被集体附值的表的字段
+     *
+     * @var string
+     */
+    protected $fillable = [
+        'phone',
+        'sync',
+        'ip'
+    ];
+
+}

+ 7 - 0
app/Models/UserThreadsModel.php

xqd
@@ -67,4 +67,11 @@ class UserThreadsModel extends BaseModel
         return $this->hasMany('App\Models\ThreadsProgressModel','threads_id');
     }
 
+    /***
+     * 获取线索最新跟进
+     * @return string
+     */
+    public function latestProgress(){
+        return ThreadsProgressModel::where('threads_id',$this->id)->count()?ThreadsProgressModel::where('threads_id',$this->id)->latest()->first()->remark:'暂无跟进';
+    }
 }

+ 1 - 1
database/migrations/2018_11_27_031943_create_call_list_table.php

xqd
@@ -16,7 +16,7 @@ class CreateCallListTable extends Migration
         Schema::create('call_list', function (Blueprint $table) {
             $table->increments('id');
             $table->string('phone',15)->comment('电话号码');
-            $table->string('ip',32)->comment('拨打IP');
+            $table->string('ip',32)->nullable()->comment('拨打IP');
             $table->tinyInteger('sync')->comment('是否拨打:1:是;0:否');
 
             $table->timestamps();

+ 66 - 8
resources/views/admin/user/threads/index.blade.php

xqd xqd xqd xqd
@@ -28,25 +28,27 @@
                                 </form>
                             </div>
 
-                            {{--@if(role('User/Threads/create'))--}}
-                            {{--<div class="col-sm-8 pull-right">--}}
-                            {{--<a href="{{ U('User/Threads/create')}}" class="btn btn-primary pull-right">添加</a>--}}
-                            {{--</div>--}}
-                            {{--@endif--}}
+                            @if(role('User/Threads/addCallList'))
+                                <div class="col-sm-8 pull-right">
+                                    <span id="addCallList" class="btn btn-primary pull-right fa fa-phone"
+                                          style="display: none">添加到电话列表</span>
+                                </div>
+                            @endif
                         </div>
                     </div>
 
                     <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                         <thead>
                         <tr>
-
+                            <th><label><input type="checkbox" id="checkAll"> 全选</label>
+                            </th>
                             <th class="sorting" data-sort="id"> ID</th>
                             <th class="sorting"> 联系方式</th>
                             <th class="sorting" data-sort="ower_id"> 线索拥有者</th>
                             <th class="sorting">企业名称</th>
                             <th class="sorting">企业网址</th>
                             <th class="sorting">注册资本</th>
-                            <th class="sorting" data-sort="status"> 线索状态</th>
+                            <th class="sorting"> 最新跟进</th>
                             <th class="sorting" data-sort="created_at"> 领取时间</th>
                             <th width="22%">相关操作</th>
                         </tr>
@@ -56,6 +58,10 @@
                             @foreach($list as $key => $item)
                                 <tr>
 
+                                    <td>
+                                        <label><input class="contacts" name='contact_id[]' type="checkbox"
+                                                      value="{{ $item->id }}"></label>
+                                    </td>
                                     <td>{{ $item->id }}</td>
                                     <td>{{ $item->contact?$item->contact->phone:'暂无联系人信息' }}</td>
                                     <td>{{ $item->ower->real_name }}</td>
@@ -65,7 +71,7 @@
                                     <td><a href="http://{{ $item->company->website }}"
                                            target="_blank">{{ $item->company->website }}</a></td>
                                     <td>{{ $item->company->regCapital }}</td>
-                                    <td>{{ $item->status }}</td>
+                                    <td>{{ $item->latestProgress() }}</td>
                                     <td>{{ $item->created_at }}</td>
                                     <td>
                                         @if(role('User/Threads/update'))
@@ -108,4 +114,56 @@
             </div>
         </div>
     </div>
+@endsection
+
+@section('js')
+    <script type="text/javascript">
+        /*电话全选功能*/
+        var items = $('.contacts')
+        $('#checkAll').click(function () {
+            isChecked = $(this).prop('checked')
+            items.prop('checked', isChecked)
+            if (isChecked == true) {
+                $('#addCallList').show()
+            } else {
+                $('#addCallList').hide()
+            }
+        })
+
+        items.click(function () {
+            checkedLength = $('.contacts:checked').length
+            if (checkedLength) {
+                $('#addCallList').show()
+            } else {
+                $('#addCallList').hide()
+            }
+            if (items.length == checkedLength) {
+                $('#addCallList').show()
+            } else {
+                $('#checkAll').prop('checked', false)
+            }
+        })
+
+        /*添加选择的电话到拨打列表*/
+        $('#addCallList').click(function () {
+            contact_ids = []
+            csrf_token = "{{ csrf_token() }}"
+            $('.contacts:checked').each(function () {
+                contact_ids.push($(this).val())
+            })
+            $.ajax({
+                type:'post',
+                url:'{{ U('User/Threads/addCallList') }}',
+                data:{contact_ids:contact_ids,_token:csrf_token},
+                success:function (data) {
+                    if(data == 200){
+                        window.location.href =window.location.href
+                    }
+                }
+
+            })
+
+            console.log(contact_ids)
+        })
+    </script>
 @endsection