wesley 7 سال پیش
والد
کامیت
42a4fe02a1

+ 140 - 0
app/Http/Controllers/Admin/Business/ServiceController.php

xqd
@@ -0,0 +1,140 @@
+<?php
+/**
+ *  企业咨询
+ * @author  system
+ * @version    1.0
+ * @date 2018-08-13 03:08:05
+ *
+ */
+
+namespace App\Http\Controllers\Admin\Business;
+
+use App\Http\Controllers\Admin\Controller;
+use App\Models\BusinessServiceModel;
+use Illuminate\Http\Request;
+use App\Repositories\Base\Criteria\OrderBy;
+use App\Repositories\Business\Criteria\MultiWhere;
+use App\Repositories\Business\ServiceRepository;
+
+class ServiceController extends Controller
+{
+    private $repository;
+
+    public function __construct(ServiceRepository $repository)
+    {
+        if (!$this->repository) $this->repository = $repository;
+    }
+
+    function index(Request $request)
+    {
+        $search['keyword'] = $request->input('keyword');
+        $search['status'] = $request->input('status');
+        $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('id', 'DESC'))->pushCriteria(new OrderBy('status', 'asc'));
+        }
+        $list = $query->paginate(10);
+        return view('admin.business.service.index', compact('list'));
+    }
+
+
+    /**
+     * 添加
+     *
+     */
+    public function create(Request $request)
+    {
+        if ($request->method() == 'POST') {
+            return $this->_createSave();
+        }
+        return view('admin.business.service.edit');
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _createSave()
+    {
+        $data = (array)request('data');
+        $id = $this->repository->create($data);
+        if ($id) {
+            $url[] = array('url' => U('Business/Service/index'), 'title' => '返回列表');
+            $url[] = array('url' => U('Business/Service/create'), 'title' => '继续添加');
+            $this->showMessage('添加成功', $url);
+        } else {
+            $url[] = array('url' => U('Business/Service/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.business.service.edit', compact('data'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _updateSave()
+    {
+        $data = (array)request('data');
+        $ok = $this->repository->update(request('id'), $data);
+        if ($ok) {
+            $url[] = array('url' => U('Business/Service/index'), 'title' => '返回列表');
+            return $this->showMessage('操作成功', urldecode(request('_referer')));
+        } else {
+            $url[] = array('url' => U('Business/Service/index'), 'title' => '返回列表');
+            return $this->showWarning('操作失败', $url);
+        }
+    }
+
+    public function view(Request $request)
+    {
+        $data = $this->repository->find(request('id'));
+        return view('admin.business.service.view', compact('data'));
+    }
+
+
+    /**
+     *
+     * 状态改变
+     *
+     */
+    public function status(Request $request)
+    {
+        $business = BusinessServiceModel::find(request('id'));
+        $business->status = 1;
+        $ok = $business->save();
+        if ($ok) {
+            return $this->showMessage('操作成功');
+        } else {
+            return $this->showWarning('操作失败');
+        }
+    }
+
+    /**
+     * 删除
+     */
+    public function destroy(Request $request)
+    {
+        $bool = $this->repository->destroy($request->get('id'));
+        if ($bool) {
+            return $this->showMessage('操作成功');
+        } else {
+            return $this->showWarning("操作失败");
+        }
+    }
+}

+ 2 - 2
app/Http/Controllers/Api/V1/Controller.php

xqd
@@ -21,8 +21,8 @@ class Controller extends BaseController
         $this->middleware('auth:api', [
             'except' => [
                 'upload', 'getCode', 'reset', 'login', 'get', 'register', 'alipayNotify', 'wechatpayNotify',
-                'get', 'area', 'get_province', 'get_city', 'get_county', 'test','getProducts','getProduct','getStores','getSchedule','orderDetail','notify','activeCard'
-
+                'get', 'area', 'get_province', 'get_city', 'get_county', 'test','getProducts','getProduct','getStores','getSchedule','orderDetail','notify','activeCard',
+'createBusiness'
             ]
         ]);
 

+ 69 - 0
app/Http/Controllers/Api/V1/HomeController.php

xqd xqd
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api\V1;
 
 use App\Helper\AttachmentHelper;
 use App\Models\BaseAttachmentModel;
+use App\Models\BusinessServiceModel;
 use App\Models\CardInfoModel;
 use App\Models\CouponInfoModel;
 use App\Models\OrderInfoModel;
@@ -651,6 +652,74 @@ class HomeController extends Controller
 
     }
 
+    /**
+     * @api {post} /api/home/createbusiness 创建企业咨询
+     * @apiDescription 创建企业咨询
+     * @apiGroup Order
+     * @apiPermission None
+     * @apiVersion 0.1.0
+     * @apiParam {string}    company         公司名称
+     * @apiParam {string}    username        联系人姓名
+     * @apiParam {string}    phone           联系方式
+     * @apiParam {string}    email           邮箱
+     * @apiParam {string}    comment         拍摄要求
+     * @apiSuccessExample {json} Success-Response:
+     * HTTP/1.1 200 OK
+     * {
+     *     "state": true,
+     *     "code": 0,
+     *     "message": "",
+     *     "data": {
+     *          "company": "斯尔克",
+     *          "username": "梁女士",
+     *          "phone": "13546554325",
+     *          "email": "sdfsa@163.com",
+     *          "comment": "sfaaafda",
+     *          "updated_at": "2018-08-13 06:09:07",
+     *          "created_at": "2018-08-13 06:09:07",
+     *          "id": 4
+     *          }
+     *
+     * }
+     * @apiErrorExample {json} Error-Response:
+     * HTTP/1.1 400 Bad Request
+     * {
+     *     "state": false,
+     *     "code": 1000,
+     *     "message": "传入参数不正确",
+     *     "data": null or []
+     * }
+     */
+    public function createBusiness(Request $request)
+    {
+        $validator = Validator::make($request->all(),
+            [
+                'company' => 'required',
+                'username' => 'required',
+                'phone' => 'required',
+                'email' => 'required',
+                'comment' => 'required',
+
+            ],
+            [
+                'company.required' => 'company不能为空!',
+                'username.required' => 'username不能为空!',
+                'phone.required' => 'phone不能为空!',
+                'email.required' => 'email不能为空!',
+                'comment.required' => 'comment不能为空!',
+
+            ]
+        );
+        if ($validator->fails()) {
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
+        }
+
+        $data = $request->all();
+        $business = BusinessServiceModel::create($data);
+
+        return $this->api($business);
+    }
+
     /**
      * @api {post} /api/home/pay   订单支付
      * @apiDescription  订单支付

+ 45 - 0
app/Models/BusinessServiceModel.php

xqd
@@ -0,0 +1,45 @@
+<?php
+
+namespace App\Models;
+
+use App\Models\BaseModel;
+
+/**
+ * @description 企业咨询
+ * @author  system;
+ * @version    1.0
+ * @date 2018-08-13 03:08:05
+ *
+ */
+class BusinessServiceModel extends BaseModel
+{
+    /**
+     * 数据表名
+     *
+     * @var string
+     *
+     */
+    protected $table = 'business_service';
+    /**
+     * 主键
+     */
+    protected $primaryKey = 'id';
+
+    //分页
+    protected $perPage = PAGE_NUMS;
+
+    /**
+     * 可以被集体附值的表的字段
+     *
+     * @var string
+     */
+    protected $fillable = [
+        'company',
+        'username',
+        'phone',
+        'comment',
+        'email',
+        'status'
+    ];
+
+}

+ 52 - 0
app/Repositories/Business/Criteria/MultiWhere.php

xqd
@@ -0,0 +1,52 @@
+<?php
+/**
+ * User: Mike
+ * Email: m@9026.com
+ * Date: 2017/1/12
+ * Time: 17:52
+ */
+
+namespace App\Repositories\Business\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('company','like','%'.$this->search['keyword'].'%')
+                                        ->orwhere('username','like','%'.$this->search['keyword'].'%')
+                                        ->orwhere('phone','like','%'.$this->search['keyword'].'%')
+                                        ->orwhere('email','like','%'.$this->search['keyword'].'%');
+                                 }
+
+        if(isset($this->search['status']) && $this->search['status']) {
+            $model = $model->where('status',0);
+        }
+
+         return $model;
+    }
+
+}

+ 21 - 0
app/Repositories/Business/ServiceRepository.php

xqd
@@ -0,0 +1,21 @@
+<?php
+/**
+ *   企业咨询
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-08-13 03:08:05
+ *
+ */
+namespace App\Repositories\Business;
+
+use App\Repositories\Base\Repository;
+
+
+class ServiceRepository extends Repository {
+
+    public function model() {
+        return \App\Models\BusinessServiceModel::class;
+    }
+
+    
+}

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

xqd
@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddBusinessServiceTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('business_service', function (Blueprint $table) {
+            $table->increments('id');
+            $table->string('company',255)->comment('公司');
+            $table->string('username',24)->comment('联系人姓名');
+            $table->string('phone',32)->comment('联系人电话');
+            $table->string('comment',255)->comment('拍摄要求');
+            $table->string('email',255)->comment('邮箱');
+            $table->tinyInteger('status')->default(0)->comment('状态:0:未回复;1:已回复');
+
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('business_service');
+    }
+}

+ 113 - 0
resources/views/admin/business/service/edit.blade.php

xqd
@@ -0,0 +1,113 @@
+@extends('admin.layout')
+
+@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('Business/Service/index'))
+				    <div class="row">
+    					<div class="col-sm-3 pull-right">
+    					   <a href="{{ U('Business/Service/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">
+                                    
+                 <label class="control-label col-sm-3">公司</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_company" name="data[company]" class="form-control" value="{{ $data['company'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">联系人姓名</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_username" name="data[username]" class="form-control" value="{{ $data['username'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-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">
+                                    
+                 <label class="control-label col-sm-3">拍摄要求</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_comment" name="data[comment]" class="form-control" value="{{ $data['comment'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">邮箱</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_email" name="data[email]" class="form-control" value="{{ $data['email'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group">
+                                    
+                 <label class="control-label col-sm-3">状态:0:未回复;1:已回复</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_status" name="data[status]" class="form-control" value="{{ $data['status'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>
+                                
+                                <div class="form-group">
+                                    <label class="control-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

+ 97 - 0
resources/views/admin/business/service/index.blade.php

xqd
@@ -0,0 +1,97 @@
+@extends('admin.layout')
+
+@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="row">
+                        <form method="GET" action="" accept-charset="UTF-8">
+
+                            <div class="col-sm-4">
+                                <div class="input-group">
+                                    <input type="text" value="{{Request::get('keyword')}}" placeholder="请输入关键词"
+                                           name="keyword" class="input-sm form-control">
+                                    <span class="input-group-btn">
+									<button type="submit" class="btn btn-sm btn-primary">搜索</button>
+								</span>
+                                </div>
+                            </div>
+                        </form>
+                        @if(role('Business/Service/create'))
+                            <div class="col-sm-3 pull-right">
+                                <a href="{{ U('Business/Service/create')}}"
+                                   class="btn btn-sm btn-primary pull-right">添加</a>
+                            </div>
+                        @endif
+                    </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="company"> 公司</th>
+                            <th class="sorting" data-sort="username"> 联系人姓名</th>
+                            <th class="sorting" data-sort="phone"> 联系人电话</th>
+                            <th class="sorting" data-sort="comment"> 拍摄要求</th>
+                            <th class="sorting" data-sort="email"> 邮箱</th>
+                            <th class="sorting" data-sort="status"> 状态:0:未回复;1:已回复</th>
+                            <th width="22%">相关操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @if(isset($list))
+                            @foreach($list as $key => $item)
+                                <tr>
+
+                                    <td>{{ $item->id }}</td>
+                                    <td>{{ $item->company }}</td>
+                                    <td>{{ $item->username }}</td>
+                                    <td>{{ $item->phone }}</td>
+                                    <td>{{ $item->comment }}</td>
+                                    <td>{{ $item->email }}</td>
+                                    <td>@if($item->status == 0)<span class="label label-danger">未回复</span>@else<span class="label label-success">已回复</span>@endif</td>
+                                    <td>
+                                        @if($item->status == 0)
+                                            <button onclick="window.location.href='{{ U('Business/service/status',['id'=>$item->id])}}'"
+                                                    class="btn btn-success">设为已回复
+                                            </button>
+                                        @endif
+                                        @if(role('Business/Service/view'))
+                                            <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Business/Service/view',['id'=>$item->id])}}'});"
+                                                    class="btn 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

+ 74 - 0
resources/views/admin/business/service/view.blade.php

xqd
@@ -0,0 +1,74 @@
+@extends('admin.layout')
+
+@section('content')
+<div class="row">
+    <div class="ibox-content">
+        <div class="list-group">
+                                 
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">ID</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['id'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">公司</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['company'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">联系人姓名</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['username'] or ''}}</p>
+                                                 
+               </div>                     
+               <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['comment'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">邮箱</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['email'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">状态:0:未回复;1:已回复</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['status'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">创建时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['created_at'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">更新时间</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['updated_at'] or ''}}</p>
+                                                 
+               </div>
+        </div>
+    </div>
+</div>
+@endsection

+ 4 - 1
routes/api.php

xqd
@@ -94,7 +94,10 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\Api\V1'], function ($a
         'as' => 'home.activeCard',
         'uses' => 'HomeController@activeCard',
     ]);
-
+    $api->post('home/createbusiness', [
+        'as' => 'home.createBusiness',
+        'uses' => 'HomeController@createBusiness',
+    ]);