wesley 6 years ago
parent
commit
9c0bf919dd

+ 112 - 0
app/Http/Controllers/Admin/Call/RecordsController.php

xqd
@@ -0,0 +1,112 @@
+<?php
+/**
+ *  通话纪录
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-11-27 03:15:47
+ *
+ */
+namespace App\Http\Controllers\Admin\Call;
+use App\Http\Controllers\Admin\Controller;
+use Illuminate\Http\Request;
+use App\Repositories\Base\Criteria\OrderBy;
+use App\Repositories\Call\Records\Criteria\MultiWhere;
+use App\Repositories\Call\RecordsRepository;
+
+class RecordsController extends Controller
+{
+    private $repository;
+
+    public function __construct(RecordsRepository $repository) {
+        if(!$this->repository) $this->repository = $repository;
+    }
+
+    /**
+     * 列表页
+     */
+    function index(Request $request) {
+        $search['keyword'] = $request->input('keyword');
+        $query = $this->repository->pushCriteria(new MultiWhere($search));
+
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+        $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
+        }else{
+            $query = $query->pushCriteria(new OrderBy('updated_at','DESC'));
+        }
+        $list = $query->paginate(16);
+        return view('admin.call.records.index',compact('list'));
+    }
+
+
+    /**
+     * 添加
+     */
+    public function create(Request $request)
+    {
+        if($request->method() == 'POST') {
+            return $this->_createSave();
+        }
+        return view('admin.call.records.edit');
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _createSave(){
+        $data = (array) request('data');
+        $id = $this->repository->create($data);
+        if($id) {
+            $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
+            $url[] = array('url'=>U( 'Call/Records/create'),'title'=>'继续添加');
+            $this->showMessage('添加成功',$url);
+        }else{
+            $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
+            return $this->showWarning('添加失败',$url);
+        }
+    }
+    
+    /**
+     * 修改
+     */
+    public function update(Request $request) {
+        if($request->method() == 'POST') {
+            return $this->_updateSave();
+        }
+        $data = $this->repository->find($request->get('id'));
+        return view('admin.call.records.edit',compact('data'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _updateSave() {
+        $data = (array) request('data');
+        $ok = $this->repository->update(request('id'),$data);
+        if($ok) {
+            $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
+            return $this->showMessage('操作成功',urldecode(request('_referer')));
+        }else{
+            $url[] = array('url'=>U( 'Call/Records/index'),'title'=>'返回列表');
+            return $this->showWarning('操作失败',$url);
+        }
+    }
+
+    public function view(Request $request) {
+        $data = $this->repository->find(request('id'));
+        return view('admin.call.records.view',compact('data'));
+    }
+
+
+    
+    /**
+     * 删除
+     */
+    public function destroy(Request $request) {
+        $bool = $this->repository->destroy($request->get('id'));
+        if($bool) {
+            return  $this->showMessage('操作成功');
+        }else{
+            return  $this->showWarning("操作失败");
+        }
+    }
+}

+ 8 - 2
app/Http/Controllers/Admin/User/ThreadsController.php

xqd
@@ -50,10 +50,16 @@ class ThreadsController extends Controller
     {
         $data['ower_id'] = \Auth::guard('admin')->user()->id;
         $data['company_id'] = $request->get('company_id');
+        $data['contact_id'] = $request->get('contact_id');
         $data['status'] = 0;
-        $id = $this->repository->create($data);
+        $res = $this->repository->create($data);
 
-        if ($id) {
+        /*添加跟进备注*/
+        if($request->get('remark')){
+            ThreadsProgressModel::create(['threads_id'=>$res->id,'remark'=>$request->get('remark')]);
+        }
+
+        if ($res) {
             $url[] = array('url' => U('User/Threads/index'), 'title' => '我的线索');
             $this->showMessage('添加成功', $url);
         } else {

+ 42 - 0
app/Models/CallRecordsModel.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 CallRecordsModel extends BaseModel
+{
+    /**
+     * 数据表名
+     *
+     * @var string
+     *
+     */
+    protected $table = 'call_records';
+    /**
+    主键
+     */
+    protected $primaryKey = 'id';
+
+    //分页
+    protected $perPage = PAGE_NUMS;
+
+    /**
+     * 可以被集体附值的表的字段
+     *
+     * @var string
+     */
+    protected $fillable = [
+                           'phone',
+                           'start_time',
+                           'end_time',
+                           'record_path',
+                           'hangup_dispostion',
+                           'ip'
+                          ];
+
+}

+ 39 - 0
app/Repositories/Call/Records/Criteria/MultiWhere.php

xqd
@@ -0,0 +1,39 @@
+<?php
+namespace App\Repositories\Call\Records\Criteria;
+use App\Repositories\Base\Criteria;
+use App\Repositories\Contracts\RepositoryInterface as Repository;
+
+class MultiWhere extends Criteria {
+
+    private $search = [];
+
+    /**
+     * MultiWhere constructor.
+     * @param array $search
+     *
+     */
+    public function __construct(array $search)
+    {
+        $this->search = $search;
+    }
+
+    /**
+    * @param $model
+    * @param RepositoryInterface $repository
+    * @return mixed
+    */
+    public function apply($model, Repository $repository)
+    {
+          if(isset($this->search['keyword']) && $this->search['keyword']) {
+                                    $model = $model->where('id','like','%'.$this->search['keyword'].'%')
+ ->orWhere('phone','like','%'.$this->search['keyword'].'%')
+ ->orWhere('start_time','like','%'.$this->search['keyword'].'%')
+ ->orWhere('end_time','like','%'.$this->search['keyword'].'%')
+ ->orWhere('record_path','like','%'.$this->search['keyword'].'%')
+ ->orWhere('hangup_dispostion','like','%'.$this->search['keyword'].'%')
+ ->orWhere('ip','like','%'.$this->search['keyword'].'%')
+;}
+         return $model;
+    }
+
+}

+ 21 - 0
app/Repositories/Call/RecordsRepository.php

xqd
@@ -0,0 +1,21 @@
+<?php
+/**
+ *   通话纪录
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-11-27 03:15:47
+ *
+ */
+namespace App\Repositories\Call;
+
+use App\Repositories\Base\Repository;
+
+
+class RecordsRepository extends Repository {
+
+    public function model() {
+        return \App\Models\CallRecordsModel::class;
+    }
+
+    
+}

+ 38 - 0
database/migrations/2018_11_27_023610_create_call_records_table.php

xqd
@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateCallRecordsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('call_records', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('phone','15')->comment('电话号码');
+            $table->dateTime('start_time')->comment('拨打时间');
+            $table->dateTime('end_time')->comment('结束时间');
+            $table->string('record_path','255')->comment('录音地址');
+            $table->string('hangup_dispostion','128')->comment('挂断原因');
+            $table->string('ip','32')->comment('拨打IP');
+
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('call_records');
+    }
+}

+ 35 - 0
database/migrations/2018_11_27_031943_create_call_list_table.php

xqd
@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateCallListTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('call_list', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('phone',15)->comment('电话号码');
+            $table->string('ip',32)->comment('拨打IP');
+            $table->tinyInteger('sync')->comment('是否拨打:1:是;0:否');
+
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('call_list');
+    }
+}

+ 115 - 0
resources/views/admin/call/records/edit.blade.php

xqd
@@ -0,0 +1,115 @@
+@extends('admin.layouts.app')
+
+@section('content')
+
+    <?php
+    if (!isset($data)) $data = array();
+    if (!$data && session("data")) {
+        $data = session("data");
+    }
+    if (!$data && session('_old_input')) {
+        $data = session("_old_input");
+    }
+    ?>
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>通话纪录</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+                        </a>
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    @if(role('Call/Records/index'))
+                        <div class="row">
+                            <div class="col-sm-10 pull-right">
+                                <a href="{{ U('Call/Records/index')}}" class="btn btn-sm btn-primary pull-right">返回列表</a>
+                            </div>
+                        </div>
+                    @endif
+
+                    <div class="row">
+                        <div class="col-lg-10">
+                            <form name="form_product" id="form-validation" action=""
+                                  class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
+
+                                    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">电话号码</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_phone" name="data[phone]" class="form-control" value="{{ $data['phone'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">拨打时间</label>
+                                    
+                   <div class="col-sm-9">
+  <input name="data[start_time]" class="form-control laydate-icon help-block m-b-none" style="width:200px; height:34px;" value="{{ $data['start_time'] or ''}}" placeholder="拨打时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" aria-invalid="false"> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">结束时间</label>
+                                    
+                   <div class="col-sm-9">
+  <input name="data[end_time]" class="form-control laydate-icon help-block m-b-none" style="width:200px; height:34px;" value="{{ $data['end_time'] or ''}}" placeholder="结束时间" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" aria-invalid="false"> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">录音地址</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_record_path" name="data[record_path]" class="form-control" value="{{ $data['record_path'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">挂断原因</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_hangup_dispostion" name="data[hangup_dispostion]" class="form-control" value="{{ $data['hangup_dispostion'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">拨打IP</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_ip" name="data[ip]" class="form-control" value="{{ $data['ip'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>
+
+                                <div class="form-group row">
+                                    <label class="col-form-label col-sm-3">&nbsp;</label>
+                                    <div class="col-sm-9">
+                                        <input type="hidden" name="_referer"
+                                               value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
+                                        <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
+                                        <input type="submit" class="btn btn-success" style="margin-right:20px;">
+                                        <input type="reset" class="btn btn-default">
+                                    </div>
+                                </div>
+
+                            </form>
+                        </div>
+                        <!-- /.col-lg-10 -->
+                    </div>
+                    <!-- /.row -->
+                </div>
+            </div>
+        </div>
+    </div>
+
+@endsection

+ 109 - 0
resources/views/admin/call/records/index.blade.php

xqd
@@ -0,0 +1,109 @@
+@extends('admin.layouts.app')
+
+@section('content')
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>通话纪录</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+                        </a>
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <div class="form-group">
+                        <div class="row">
+                            <div class="col-sm-4">
+                                <form method="GET" action="" accept-charset="UTF-8">
+                                    <div class="input-group">
+                                        <input type="text" class="form-control" value="{{Request::get('keyword')}}"
+                                               placeholder="请输入关键词"
+                                               name="keyword">
+                                        <span class="input-group-append">
+                                                <button type="submit" class="btn btn-primary"
+                                                        style="height: 100%">搜索</button>
+                                            </span>
+                                    </div>
+                                </form>
+                            </div>
+
+                            @if(role('Call/Records/create'))
+                                <div class="col-sm-8 pull-right">
+                                    <a href="{{ U('Call/Records/create')}}" class="btn btn-primary pull-right">添加</a>
+                                </div>
+                            @endif
+                        </div>
+                    </div>
+
+                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
+                        <thead>
+                        <tr>
+                            
+            <th class="sorting" data-sort="id"> ID </th>
+            <th class="sorting" data-sort="phone"> 电话号码 </th>
+            <th class="sorting" data-sort="start_time"> 拨打时间 </th>
+            <th class="sorting" data-sort="end_time"> 结束时间 </th>
+            <th class="sorting" data-sort="record_path"> 录音地址 </th>
+            <th class="sorting" data-sort="hangup_dispostion"> 挂断原因 </th>
+            <th class="sorting" data-sort="ip"> 拨打IP </th>
+                            <th width="22%">相关操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @if(isset($list))
+                            @foreach($list as $key => $item)
+                                <tr>
+                                    
+            <td>{{ $item->id }}</td>
+            <td>{{ $item->phone }}</td>
+            <td>{{ $item->start_time }}</td>
+            <td>{{ $item->end_time }}</td>
+            <td>{{ $item->record_path }}</td>
+            <td>{{ $item->hangup_dispostion }}</td>
+            <td>{{ $item->ip }}</td>
+                                    <td>
+                                        @if(role('Call/Records/update'))
+                                            <button class="btn btn-sm btn-success"
+                                                    onclick="window.location.href='{{ U('Call/Records/update',['id'=>$item->id])}}' ">
+                                                修改
+                                            </button>
+
+                                        @endif
+
+                                        @if(role('Call/Records/destroy'))
+                                            <a class="btn btn-sm btn-danger"
+                                               href="{{ U('Call/Records/destroy',['id'=>$item->id])}}"
+                                               onclick="return confirm('你确定执行删除操作?');">删除</a>
+                                        @endif
+
+                                        @if(role('Call/Records/view'))
+                                            <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Call/Records/view',['id'=>$item->id])}}'});"
+                                                    class="btn btn-sm btn-primary ">查看
+                                            </button>
+                                        @endif
+                                    </td>
+                                </tr>
+                            @endforeach
+                        @endif
+
+                        </tbody>
+                    </table>
+                    <div class="row">
+                        <div class="col-sm-6">
+                            <div class="dataTables_info" id="DataTables_Table_0_info"
+                                 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}
+                                条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。
+                            </div>
+                        </div>
+                        <div class="col-sm-6">
+                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+                                {!! $list->setPath('')->appends(Request::all())->render() !!}
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+@endsection

+ 53 - 0
resources/views/admin/call/records/view.blade.php

xqd
@@ -0,0 +1,53 @@
+@extends('admin.layouts.app')
+
+@section('content')
+    <div class="row">
+        <div class="ibox-content">
+            <div class="list-group">
+                                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">电话号码</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['phone'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">拨打时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['start_time'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">结束时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['end_time'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">录音地址</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['record_path'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">挂断原因</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['hangup_dispostion'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">拨打IP</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['ip'] or ''}}</p>
+                                                 
+               </div>
+            </div>
+        </div>
+    </div>
+@endsection

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

xqd
@@ -51,11 +51,11 @@
                                 <th>
                                     <select name="regCapital" class="form-control filter_company">
                                         <option value="">注册资本</option>
-                                        <option value="50">小于50万</option>
-                                        <option value="50">50~100万</option>
-                                        <option value="100">100~500万</option>
-                                        <option value="100">500~1000万</option>
-                                        <option value="100">1000万以上</option>
+                                        <option value="-50">小于50万</option>
+                                        <option value="50-100">50~100万</option>
+                                        <option value="100-500">100~500万</option>
+                                        <option value="500-1000">500~1000万</option>
+                                        <option value="1000-">1000万以上</option>
                                     </select>
                                 </th>
                                 <th>

+ 15 - 8
resources/views/admin/company/info/view.blade.php

xqd xqd xqd
@@ -243,7 +243,8 @@
                                     <h3>联系方式:</h3>
                                 </div>
                                 <div class="col-md-10">
-                                    <ul class="sortable-list connectList agile-list ui-sortable" style="height: 780px;overflow-y: scroll">
+                                    <ul class="sortable-list connectList agile-list ui-sortable"
+                                        style="height: 780px;overflow-y: scroll">
                                         @if(count($contacts))
                                             @foreach($contacts as $item)
                                                 <li class="success-element">
@@ -261,7 +262,7 @@
                                                         </div>
 
                                                         @if(!$data->isThread())
-                                                            <a href='{{ U('User/Threads/create',['company_id'=>$data->id])}}'
+                                                            <a href='{{ U('User/Threads/create',['company_id'=>$data->id,'contact_id'=>$item->id])}}'
                                                                class="btn btn-primary btn-rounded btn-block">领取线索</a>
                                                         @endif
                                                     </div>
@@ -270,12 +271,18 @@
                                         @else
                                             <li class="success-element">
                                                 @if(!$data->isThread())
-                                                    <div class="agile-detail" style="text-align: center">
-                                                    <textarea name="remark" id="" style="width: 100%;height: 100px"
-                                                              placeholder="备注..."></textarea>
-                                                        <a href='{{ U('User/Threads/create',['company_id'=>$data->id])}}'
-                                                           class="btn btn-primary btn-rounded btn-block">领取线索</a>
-                                                    </div>
+                                                    <form action="{{U('User/Threads/create')}}" method="get">
+                                                        <div class="agile-detail" style="text-align: center">
+                                                            <textarea name="remark" id=""
+                                                                      style="width: 100%;height: 100px"
+                                                                      placeholder="备注..."></textarea>
+                                                            <input type="hidden" name="company_id"
+                                                                   value="{{$data->id}}">
+                                                            <button type="submit"
+                                                                    class="btn btn-primary btn-rounded btn-block">领取线索
+                                                            </button>
+                                                        </div>
+                                                    </form>
                                                 @endif
                                             </li>
                                         @endif