wesley 6 年之前
父节点
当前提交
91729f33c3

+ 5 - 3
app/Http/Controllers/Admin/Call/RecordsController.php

xqd
@@ -133,12 +133,14 @@ class RecordsController extends Controller
     public function addCallList(Request $request)
     {
         $ids = $request->get('contact_phones');
-        $phones = CallRecordsModel::whereIn('id',$ids)->get();
+        $ip = $request->get('ip');
+
+        $phones = CallRecordsModel::whereIn('id', $ids)->get();
 
         foreach ($phones as $phone) {
-            $hasAdd = CallListModel::where('phone', $phone)->where('sync', 0)->count();
+            $hasAdd = CallListModel::where('phone', $phone->phone)->where('sync', 0)->count();
             if (!$hasAdd) {
-                CallListModel::create(['phone' => $phone, 'sync' => 0]);
+                CallListModel::create(['phone' => $phone->phone, 'sync' => 0, 'ip' => $ip]);
             }
 
 

+ 29 - 25
app/Http/Controllers/Admin/User/ThreadsController.php

xqd xqd xqd xqd
@@ -41,27 +41,27 @@ 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);
         }
 
-        $list =  $list->paginate(20);
+        $list = $list->paginate(20);
 
         if ($request->ajax()) {
             $view = view('admin.user.threads.data', compact('list'))->render();
@@ -86,8 +86,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) {
@@ -151,16 +151,19 @@ class ThreadsController extends Controller
     /*
      * 添加到AI电话拨打列表
      * */
-    public function addCallList(Request $request){
-        $thread_ids =  $request->get('contact_ids');
-        foreach ($thread_ids as $thread_id){
+    public function addCallList(Request $request)
+    {
+        $thread_ids = $request->get('contact_ids');
+        $ip = $request->get('ip');
+
+        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电话列表']);
+            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电话列表']);
                 }
 
             }
@@ -173,16 +176,17 @@ class ThreadsController extends Controller
      * @param Request $request
      * @return int|\Symfony\Component\HttpFoundation\BinaryFileResponse
      */
-    public function export_threads(Request $request){
-        $type =  $request->get('type');
-        if($type){
+    public function export_threads(Request $request)
+    {
+        $type = $request->get('type');
+        if ($type) {
             return 200;
         }
 
-        $thread_ids =  $request->get('threads_ids');
+        $thread_ids = $request->get('threads_ids');
         \Log::info($thread_ids);
-        $threads =  UserThreadsModel::whereIn('id',$thread_ids)->get();
+        $threads = UserThreadsModel::whereIn('id', $thread_ids)->get();
 
-        return Excel::download(new ThreadsExport($threads),'我的线索.xlsx');
+        return Excel::download(new ThreadsExport($threads), '我的线索.xlsx');
     }
 }

+ 45 - 39
app/Imports/CompanyInfoImport.php

xqd xqd
@@ -4,59 +4,59 @@ namespace App\Imports;
 
 use App\Models\CompanyContactsModel;
 use App\Models\CompanyInfoModel;
+use Illuminate\Contracts\Queue\ShouldQueue;
 use Illuminate\Support\Collection;
 use Maatwebsite\Excel\Concerns\ToCollection;
+use Maatwebsite\Excel\Concerns\WithBatchInserts;
+use Maatwebsite\Excel\Concerns\WithChunkReading;
 
-class CompanyInfoImport implements ToCollection
+class CompanyInfoImport implements ToCollection, WithChunkReading, ShouldQueue
 {
     /**
-    * @param Collection $collection
-    */
+     * @param Collection $collection
+     */
     public function collection(Collection $collection)
     {
-        foreach ($collection as $key => $row){
-            if ($key == 0 ) continue;
-            if(strpos($row[0],'国税局') || strpos($row[0],'税务')){
-//                $isExisted = CompanyInfoModel::where('companyName',$row[3])->first();
-//
-//                if($isExisted){
-//                    $company_id = $isExisted->id;
-//                }else{
-                    $data['companyName'] = $row[3];
-                    $data['legalPerson'] = $row[5];
-                    $data['startDate'] = str_replace('/','-',$row[1]);
-                    $data['regAddr'] = $row[4];
-                    $data['scope'] = $row[7];
-                    $data['industry'] = $row[10];
-                    $data['regNo'] = $row[2];
+        ini_set("memory_limit", "-1");
+        set_time_limit(0);
+        foreach ($collection as $key => $row) {
+            ob_clean();
+            if ($key == 0) continue;
+            if (strpos($row[0], '国税局') || strpos($row[0], '税务')) {
 
-                    $res = CompanyInfoModel::create($data);
-                    $company_id = $res->id;
-//                }
+                $data['companyName'] = $row[3];
+                $data['legalPerson'] = $row[5];
+                $data['startDate'] = str_replace('/', '-', $row[1]);
+                $data['regAddr'] = $row[4];
+                $data['scope'] = $row[7];
+                $data['industry'] = $row[10];
+                $data['regNo'] = $row[2];
 
-                if($row[6]){
+                $res = CompanyInfoModel::create($data);
+                $company_id = $res->id;
+
+                if ($row[6]) {
                     CompanyContactsModel::create([
-                        'company_id'=> $company_id,
-                        'linkman'=> $row[5],
-                        'phone'=> $row[6],
+                        'company_id' => $company_id,
+                        'linkman' => $row[5],
+                        'phone' => $row[6],
                     ]);
                 }
-                if($row[9]){
+                if ($row[9]) {
                     CompanyContactsModel::create([
-                        'company_id'=> $company_id,
-                        'linkman'=> $row[8],
-                        'phone'=> $row[9],
+                        'company_id' => $company_id,
+                        'linkman' => $row[8],
+                        'phone' => $row[9],
                     ]);
                 }
 
 
+            } else {
+                $isExisted = CompanyInfoModel::where('companyName', $row[1])->first();
 
-            }else{
-                $isExisted = CompanyInfoModel::where('companyName',$row[1])->first();
-
-                if($isExisted){
+                if ($isExisted) {
                     $company_id = $isExisted->id;
-                }else{
+                } else {
                     $data['companyName'] = $row[1];
                     $data['legalPerson'] = $row[8];
                     $data['startDate'] = $row[9];
@@ -67,14 +67,20 @@ class CompanyInfoImport implements ToCollection
                 }
 
                 CompanyContactsModel::create([
-                    'company_id'=> $company_id,
-                    'linkman'=> $row[2],
-                    'phone'=> $row[3]?$row[3]:$row[4],
-                    'email'=> $row[5],
-                    'qq'=> $row[6]
+                    'company_id' => $company_id,
+                    'linkman' => $row[2],
+                    'phone' => $row[3] ? $row[3] : $row[4],
+                    'email' => $row[5],
+                    'qq' => $row[6]
                 ]);
             }
 
         }
     }
+
+
+    public function chunkSize(): int
+    {
+        return 2000;
+    }
 }

+ 1 - 1
app/Repositories/Call/RecordsRepository.php

xqd
@@ -20,7 +20,7 @@ class RecordsRepository extends Repository
         return \App\Models\CallRecordsModel::class;
     }
 
-    public function searchRecords(array $search, array $orderby = ['id' => 'desc'], $pagesize = 10)
+    public function searchRecords(array $search, array $orderby = ['id' => 'desc'], $pagesize = 20)
     {
         $currentQuery = $this->model;
         /*企业名称*/

+ 2 - 1
pyshell/mysql_sync_psql.py

xqd
@@ -38,10 +38,11 @@ if __name__ == '__main__':
     # 获取mysql连接
     mysql_conn = mysql_connect('47.94.228.245', 'swdz_crm', 'dbuser', 'BXhKw6JRxMy9FTb2')
 
+    ip = '172.31.20.133'
     # try:
     # 从mysql获取需要导入的电话号码
     mysql_cur = mysql_conn.cursor()
-    mysql_sql_select = "SELECT phone,id from call_list WHERE sync = 0"
+    mysql_sql_select = "SELECT phone,id from call_list WHERE sync = 0 and ip =  '" + ip + "' "
     mysql_cur.execute(mysql_sql_select)
     nums = mysql_cur.fetchall()
 

+ 2 - 1
resources/views/admin/call/records/data.blade.php

xqd
@@ -1,7 +1,8 @@
 <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
     <thead>
     <tr>
-        <th><label><input type="checkbox" id="checkAll"> 全选</label>
+        <th>
+            <label><input type="checkbox" id="checkAll"> 全选</label>
         </th>
         <th class="sorting" data-sort="id"> ID</th>
         <th class="sorting" data-sort="phone"> 电话号码</th>

+ 53 - 11
resources/views/admin/call/records/index.blade.php

xqd xqd xqd xqd xqd
@@ -16,8 +16,7 @@
 
                         @if(role('Call/Records/addCallList'))
                             <div class="col-sm-8 pull-right">
-                                    <span id="addCallList" class="btn btn-primary pull-right fa fa-phone"
-                                          style="display: none">添加到电话列表</span>
+                                    <span class="btn btn-primary pull-right fa fa-phone" data-toggle="modal" data-target="#myModal2" style="display: none">添加到电话列表</span>
                             </div>
                         @endif
                         {{--@if(role('Call/Records/create'))--}}
@@ -73,13 +72,56 @@
 
             </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">
+                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
+                                    class="sr-only">Close</span></button>
+                        <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.133">172.31.20.133</option>
+                                        <option value="172.31.20.134">172.31.20.134</option>
+                                        <option value="172.31.20.135">172.31.20.135</option>
+                                        <option value="172.31.20.136">172.31.20.136</option>
+                                        <option value="172.31.20.137">172.31.20.137</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
 
 @section('js')
     <script type="text/javascript">
         var checkedIds = []
+
         /*电话全选功能*/
         $('body').on('click', '#checkAll', function () {
             items = $('.contacts');
@@ -90,11 +132,10 @@
                 saveChecked($(this))
             });
             if (isChecked == true) {
-                $('#addCallList').show()
+                $('.fa-phone').show()
             } else {
-                $('#addCallList').hide()
+                $('.fa-phone').hide()
             }
-            console.log(checkedIds)
 
         })
 
@@ -103,12 +144,12 @@
 
             checkedLength = $('.contacts:checked').length
             if (checkedLength) {
-                $('#addCallList').show()
+                $('.fa-phone').show()
             } else {
-                $('#addCallList').hide()
+                $('.fa-phone').hide()
             }
             if (items.length == checkedLength) {
-                $('#addCallList').show()
+                $('.fa-phone').show()
             } else {
                 $('#checkAll').prop('checked', false)
             }
@@ -119,13 +160,14 @@
 
         /*添加选择的电话到拨打列表*/
         $('#addCallList').click(function () {
-            contact_phones = checkedIds ;
+            contact_phones = checkedIds;
             csrf_token = "{{ csrf_token() }}";
+            ip = $('#ip').val()
 
             $.ajax({
                 type: 'post',
                 url: '{{ U('Call/Records/addCallList') }}',
-                data: {contact_phones: contact_phones, _token: csrf_token},
+                data: {contact_phones: contact_phones, _token: csrf_token, ip:ip},
                 success: function (data) {
                     if (data == 200) {
                         layer.msg('导入成功', {

+ 10 - 5
resources/views/admin/company/info/view.blade.php

xqd xqd xqd xqd
@@ -22,6 +22,7 @@
         }
 
         .tabs-container ul.nav-tabs li {
+            text-align: center;
             height: 60px;
             width: 20%;
             font-size: 16px;
@@ -44,12 +45,16 @@
             color: #ccc;
         }
 
+        .panel-body h3{
+            border-bottom: 1px solid #ecf2f5;
+            padding: 5px 0;
+        }
         .panel-body h3::before {
             background-color: #0e9aef;
             content: '-';
             color: #0e9aef;
             margin-right: 5px;
-            padding-right: 2px
+            padding-right: 2px;
         }
 
         .dropdown-menu {
@@ -58,9 +63,9 @@
     </style>
 @endsection
 @section('content')
-    <div class="row">
+    <div class="row" style="height: 100%;background-color: #f5f9fc">
         <div class="col-sm-12">
-            <div class="ibox float-e-margins">
+            <div class="ibox float-e-margins" style="height: 100%">
                 <div class="ibox-title">
                     <h5>挖掘线索</h5>
                     <div class="ibox-tools">
@@ -72,8 +77,8 @@
                     </div>
                 </div>
 
-                <div class="ibox-content">
-                    <div class="col-md-11" style="margin: auto">
+                <div class="ibox-content" style="height: 100%">
+                    <div class="col-md-11" style="margin: auto;height: 100%">
                         <div class="row">
                             <div class="col-lg-9 col-md-8">
                                 <div class="row">

+ 49 - 33
resources/views/admin/user/threads/index.blade.php

xqd xqd xqd xqd
@@ -18,8 +18,9 @@
 
                         @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>
+                                    <span class="btn btn-primary pull-right fa fa-phone"
+                                           data-toggle="modal"
+                                          data-target="#myModal2">添加到电话列表</span>
                                 <span id="export_threads" class="btn btn-success pull-right fa fa-table"
                                       style="display: none">导出到Excel</span>
                             </div>
@@ -40,39 +41,11 @@
                                 </select>
                             </th>
 
-                            {{--<th style="width: 40%">--}}
-                            {{--<div class="row">--}}
-
-                            {{--<div class="col-sm-5" id="data_1">--}}
-
-                            {{--<div class="input-group date">--}}
-                            {{--<span class="input-group-addon">--}}
-                            {{--<i class="fa fa-calendar"></i></span>--}}
-                            {{--<input type="text" id="start" class="form-control" placeholder="领取日期"--}}
-                            {{--name="start"--}}
-                            {{--value="{{Request::get('start') ? : ''}}">--}}
-                            {{--</div>--}}
-                            {{--</div>--}}
-                            {{--_--}}
-                            {{--<div class="col-sm-5" id="data_2">--}}
-                            {{--<div class="input-group date">--}}
-                            {{--<span class="input-group-addon">--}}
-                            {{--<i class="fa fa-calendar"></i></span>--}}
-                            {{--<input type="text" id="end" class="form-control" placeholder="领取日期"--}}
-                            {{--name="end"--}}
-                            {{--value="{{Request::get('end') ? : ''}}">--}}
-                            {{--</div>--}}
-                            {{--</div>--}}
-                            {{--</div>--}}
-
-                            {{--</th>--}}
-
-
                             <th>
 
                                 <div class="input-group">
                                     <input type="text" class="form-control" value="{{Request::get('keyword')}}"
-                                           placeholder="请输入企业名称"
+                                           placeholder="请输入企业名称或电话"
                                            name="keyword">
                                     <span class="input-group-append">
                                                 <span class="btn btn-sm btn-default"
@@ -87,11 +60,53 @@
 
                 <div id="threads-list">
                     @include('admin.user.threads.data')
+                </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">
+                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
+                                    class="sr-only">Close</span></button>
+                        <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.133">172.31.20.133</option>
+                                            <option value="172.31.20.134">172.31.20.134</option>
+                                            <option value="172.31.20.135">172.31.20.135</option>
+                                            <option value="172.31.20.136">172.31.20.136</option>
+                                            <option value="172.31.20.137">172.31.20.137</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>
+
     </div>
 @endsection
 
@@ -170,11 +185,12 @@
         $('#addCallList').click(function () {
             contact_ids = checkedIds
             csrf_token = "{{ csrf_token() }}"
+            ip = $('#ip').val()
 
             $.ajax({
                 type: 'post',
                 url: '{{ U('User/Threads/addCallList') }}',
-                data: {contact_ids: contact_ids, _token: csrf_token},
+                data: {contact_ids: contact_ids, _token: csrf_token,ip:ip},
                 success: function (data) {
                     if (data == 200) {
                         layer.msg('导入成功', {