浏览代码

后台修改

wesley.chen 7 年之前
父节点
当前提交
23ef829ecc

+ 177 - 0
app/Http/Controllers/Admin/User/ScheduleController.php

xqd
@@ -0,0 +1,177 @@
+<?php
+/**
+ *  预约管理
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-07-18 01:53:05
+ *
+ */
+namespace App\Http\Controllers\Admin\User;
+use App\Http\Controllers\Admin\Controller;
+use App\Models\ProductScheduleModel;
+use App\Models\StoreInfoModel;
+use App\Models\UserScheduleModel;
+use Illuminate\Http\Request;
+use App\Repositories\Base\Criteria\OrderBy;
+use App\Repositories\User\Criteria\MultiWhere;
+use App\Repositories\User\ScheduleRepository;
+
+class ScheduleController extends Controller
+{
+    private $repository;
+
+    public function __construct(ScheduleRepository $repository) {
+        if(!$this->repository) $this->repository = $repository;
+    }
+
+    function index(Request $request) {
+        $search['keyword'] = $request->input('keyword');
+        $search['expire'] = $request->input('expire');
+
+        $order = array();
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+            $order[$request['sort_field']] = $request['sort_field_by'];
+        }else{
+            if(isset($search['expire'])){
+                $order['time']='DESC';
+                $order['user_schedule.id']='ASC';
+            }else{
+                $order['time']='ASC';
+                $order['user_schedule.id']='ASC';
+            }
+
+
+        }
+
+        $list = $this->repository->searchSchedule($search,$order);
+
+        return view('admin.user.schedule.index',compact('list'));
+    }
+
+
+    function check(Request $request) {
+        $request = $request->all();
+        $search['keyword'] = $request->input('keyword');
+        $orderby = array();
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+            $orderby[$request['sort_field']] = $request['sort_field_by'];
+        }
+        $list = $this->repository->search($search,$orderby);
+        return view('admin.user.schedule.check',compact('list'));
+    }
+
+
+    /**
+     * 添加
+     * 
+     */
+    public function create(Request $request)
+    {
+        if($request->method() == 'POST') {
+            return $this->_createSave();
+        }
+
+        $stores = StoreInfoModel::all();
+        return view('admin.user.schedule.edit',compact('stores'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _createSave(){
+        $data = (array) request('data');
+        if(!$this->canOrder($data['time'],$data['store_id'])){
+            $url[] = array('url'=>U( 'User/Schedule/index'),'title'=>'返回列表');
+            return $this->showWarning('改时间段预约人数已满',$url);
+        }
+        $id = $this->repository->create($data);
+        if($id) {
+            $url[] = array('url'=>U( 'User/Schedule/index'),'title'=>'返回列表');
+            $url[] = array('url'=>U( 'User/Schedule/create'),'title'=>'继续添加');
+            $this->showMessage('添加成功',$url);
+        }else{
+            $url[] = array('url'=>U( 'User/Schedule/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'));
+        $stores = StoreInfoModel::all();
+
+        return view('admin.user.schedule.edit',compact('data','stores'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _updateSave() {
+        $data = (array) request('data');
+        if(!$this->canOrder($data['time'],$data['store_id'])){
+            $url[] = array('url'=>U( 'User/Schedule/index'),'title'=>'返回列表');
+            return $this->showWarning('改时间段预约人数已满',$url);
+        }
+        $ok = $this->repository->update(request('id'),$data);
+        if($ok) {
+            $url[] = array('url'=>U( 'User/Schedule/index'),'title'=>'返回列表');
+            return $this->showMessage('操作成功',urldecode(request('_referer')));
+        }else{
+            $url[] = array('url'=>U( 'User/Schedule/index'),'title'=>'返回列表');
+            return $this->showWarning('操作失败',$url);
+        }
+    }
+
+    public function view(Request $request) {
+        $data = $this->repository->find(request('id'));
+        return view('admin.user.schedule.view',compact('data'));
+    }
+
+
+    /**
+     *
+     * 状态改变
+     *
+     */
+    public function status(Request $request) {
+        $ok = $this->repository->updateStatus(request('id'),request('status'));
+        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("操作失败");
+        }
+    }
+
+    public function canOrder($time,$storeid){
+        $max = ProductScheduleModel::first()->max;
+        $count = UserScheduleModel::where('time',$time)->where('store_id',$storeid)->count();
+
+        if($count >= $max){
+            return false;
+        }
+        else{
+            return true;
+        }
+
+    }
+}

+ 48 - 0
app/Models/UserScheduleModel.php

xqd
@@ -0,0 +1,48 @@
+<?php
+
+namespace App\Models;
+
+use App\Models\BaseModel;
+
+/**
+ * @description 预约管理
+ * @author  system;
+ * @version    1.0
+ * @date 2018-07-18 01:53:05
+ *
+ */
+class UserScheduleModel extends BaseModel
+{
+    /**
+     * 数据表名
+     *
+     * @var string
+     *
+     */
+    protected $table = 'user_schedule';
+    /**
+     * 主键
+     */
+    protected $primaryKey = 'id';
+
+    //分页
+    protected $perPage = PAGE_NUMS;
+
+    /**
+     * 可以被集体附值的表的字段
+     *
+     * @var string
+     */
+    protected $fillable = [
+        'time',
+        'user_id',
+        'username',
+        'phone',
+        'store_id'
+    ];
+
+    public function store(){
+        return (new StoreInfoModel())->find($this->store_id)->name;
+    }
+
+}

+ 5 - 8
app/Repositories/User/Criteria/MultiWhere.php

xqd
@@ -35,14 +35,11 @@ class MultiWhere extends Criteria {
     */
     public function apply($model, Repository $repository)
     {
-        if(isset($this->search['keyword']) && ! empty($this->search['keyword'])) {
-            $keywords = '%' . $this->search['keyword'] . '%';
-            $model = $model->where(function ($query) use ($keywords) {
-                $query->where('id'  , 'like', $keywords)
-                    ->orwhere('mobile', 'like', $keywords);
-            });
-        }
-        return $model;
+          if(isset($this->search['updated_at']) && $this->search['updated_at']) {
+                                    $model = $model->where('updated_at',$this->search['updated_at']);
+                                 }
+
+         return $model;
     }
 
 }

+ 65 - 0
app/Repositories/User/ScheduleRepository.php

xqd
@@ -0,0 +1,65 @@
+<?php
+/**
+ *   预约管理
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-07-18 01:53:05
+ *
+ */
+namespace App\Repositories\User;
+
+use App\Repositories\Base\Repository;
+use Carbon\Carbon;
+
+
+class ScheduleRepository extends Repository {
+
+    public function model() {
+        return \App\Models\UserScheduleModel::class;
+    }
+
+    public function searchSchedule(array $search,array $orderby=['time'=>'desc'],$pagesize=10)
+    {
+        $currentQuery = $this->model;
+        if(isset($search['keyword']) && ! empty($search['keyword'])) {
+            $keywords = '%' . $search['keyword'] . '%';
+            $currentQuery = $currentQuery->leftJoin('store_info','store_info.id','=','user_schedule.store_id')->where(function ($query) use ($keywords) {
+                $query->where('username'  , 'like', $keywords)
+                    ->orwhere('store_info.name'  , 'like', $keywords)
+                    ->orwhere('user_schedule.phone', 'like', $keywords);
+            });
+        }
+
+
+        if(isset($search['expire']) && ! empty($search['expire'])) {
+            $currentQuery = $currentQuery->where(function ($query) use ($search) {
+                $query->where('time','<=',Carbon::now('Asia/Shanghai'));
+            });
+            if($orderby && is_array($orderby)){
+                foreach ($orderby AS $field => $value){
+                    $currentQuery = $currentQuery -> orderBy($field, $value);
+                }
+            }
+
+
+        }else{
+            $currentQuery = $currentQuery->where(function ($query) use ($search) {
+                $query->where('time','>',Carbon::now('Asia/Shanghai'));
+            });
+
+            if($orderby && is_array($orderby)){
+                foreach ($orderby AS $field => $value){
+                    $currentQuery = $currentQuery -> orderBy($field, $value);
+                }
+            }
+
+        }
+
+        $currentQuery = $currentQuery->paginate($pagesize);
+        return $currentQuery;
+
+
+    }
+
+    
+}

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

xqd
@@ -15,7 +15,7 @@ class CreateUserScheduleTable extends Migration
     {
         Schema::create('user_schedule', function (Blueprint $table) {
             $table->increments('id');
-            $table->string('time',64)->comment('时间段');
+            $table->date('time')->default(null)->comment('时间段');
             $table->tinyInteger('count')->comment('剩余可预约人数');
 
             $table->softDeletes();

+ 36 - 0
database/migrations/2018_07_18_014709_add_username_to_user_schedule_table.php

xqd
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AddUsernameToUserScheduleTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('user_schedule', function (Blueprint $table) {
+            $table->dropColumn('count');
+            $table->integer('user_id')->after('time')->nullable()->comment('用户ID');
+            $table->string('username',255)->after('user_id')->nullable()->comment('用户姓名');
+            $table->string('phone',11)->after('username')->nullable()->comment('联系方式');
+            $table->integer('store_id')->after('phone')->nullable()->comment('店铺名称');
+
+        });}
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('user_schedule', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 52 - 31
resources/views/admin/coupon/info/create.blade.php

xqd xqd xqd xqd xqd xqd
@@ -1,8 +1,8 @@
 @extends('admin.layout')
 
 @section('content')
-    <link href="/css/time/jquery.datetimepicker.css"rel="stylesheet">
-    <link href="/css/time/jquery-ui-1.10.1.css"rel="stylesheet">
+    <link href="/css/time/jquery.datetimepicker.css" rel="stylesheet">
+    <link href="/css/time/jquery-ui-1.10.1.css" rel="stylesheet">
     <?php
     if (!isset($data)) $data = array();
     if (!$data && session("data")) {
@@ -48,23 +48,24 @@
 
                                 </div>
 
+
                                 <div class="form-group">
 
                                     <label class="control-label col-sm-3">优惠券类型:</label>
 
                                     <div class="col-sm-9">
-                                        <div class="radio i-checks">
-                                            <label>
-                                                <input type="radio"
-                                                       @if((isset($data['type']) && $data['type'] == 1)  ) checked="checked"
-                                                       @endif value="1" name="data[type]"> <i></i>折扣</label>
-
-                                            <label>
-                                                <input type="radio"
-                                                       @if((isset($data['type']) && $data['type'] == 0) ) checked="checked"
-                                                       @endif value="0" name="data[type]"> <i></i> 固定金额</label>
-
-                                        </div>
+                                        <select id="data_type" class="form-control" name="data[type]" required>
+
+                                            <option value="0"
+                                                    @if(isset($data['type']) && $data['type'] == 0) selected @endif>
+                                                固定金额
+                                            </option>
+                                            <option value="1"
+                                                    @if(isset($data['type']) && $data['type'] == 1) selected @endif>
+                                                折扣
+                                            </option>
+
+                                        </select>
                                     </div>
 
                                 </div>
@@ -79,33 +80,34 @@
                                     </div>
 
                                 </div>
-                                <div class="form-group">
+                                <div class="form-group"  id="data_discount">
 
                                     <label class="control-label col-sm-3">折扣</label>
 
                                     <div class="col-sm-9">
-                                        <input id="data_discount" name="data[discount]" class="form-control"
-                                               value="{{ $data['discount'] or ''}}"
-                                               placeholder="">
+                                        <input  name="data[discount]" class="form-control"
+                                                value="{{ $data['discount'] or ''}}"
+                                                placeholder="">
                                     </div>
 
                                 </div>
-                                <div class="form-group">
+                                <div class="form-group" id="data_discount_price">
 
                                     <label class="control-label col-sm-3">优惠金额</label>
 
                                     <div class="col-sm-9">
-                                        <input id="data_discount_price" name="data[discount_price]" class="form-control"
-                                               value="{{ $data['discount_price'] or ''}}"  placeholder="">
+                                        <input  name="data[discount_price]" class="form-control"
+                                                value="{{ $data['discount_price'] or ''}}" placeholder="">
                                     </div>
 
                                 </div>
 
                                 <div class="form-group">
 
-                                    <label class="control-label col-sm-3">所属分类</label>
+                                    <label class="control-label col-sm-3">可用产品</label>
                                     <div class="col-md-6">
-                                        <select name="product_id[]" multiple="multiple" id="product-select" class="form-control">
+                                        <select name="product_id[]" multiple="multiple" id="product-select"
+                                                class="form-control">
                                             @foreach($product as $item)
                                                 <option value="{{$item->id}}">
                                                     {{$item->name}}
@@ -168,7 +170,7 @@
     <script src="/js/time/jquery-ui-1.10.1.min.js"></script>
     <script>
         //        时间选择js
-        $(function() {
+        $(function () {
             $.datepicker.regional['zh-CN'] = {
                 clearText: '清除',
                 clearStatus: '清除已选日期',
@@ -184,24 +186,25 @@
                 nextBigStatus: '显示下一年',
                 currentText: '今天',
                 currentStatus: '显示本月',
-                monthNames: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'],
-                monthNamesShort: ['一','二','三','四','五','六', '七','八','九','十','十一','十二'],
+                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
+                monthNamesShort: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
                 monthStatus: '选择月份',
                 yearStatus: '选择年份',
                 weekHeader: '周',
                 weekStatus: '年内周次',
-                dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
-                dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
-                dayNamesMin: ['日','一','二','三','四','五','六'],
+                dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
+                dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
+                dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
                 dayStatus: '设置 DD 为一周起始',
                 dateStatus: '选择 m月 d日, DD',
                 dateFormat: 'yy-mm-dd',
                 firstDay: 1,
                 initStatus: '请选择日期',
-                isRTL: false};
+                isRTL: false
+            };
             $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
 
-            $( "#end_time" ).datepicker({
+            $("#end_time").datepicker({
                 inline: true,
                 showOtherMonths: true
             })
@@ -215,5 +218,23 @@
         $(function () {
             $('#product-select').multiSelect();
         });
+
+        if($('#data_type').val() ==1 ){
+            $('#data_discount').show();
+            $('#data_discount_price').hide()
+        }else {
+            $('#data_discount').hide();
+            $('#data_discount_price').show()
+        }
+
+        $('#data_type').change(function () {
+            if($(this).val() ==1 ){
+                $('#data_discount').show();
+                $('#data_discount_price').hide()
+            }else {
+                $('#data_discount').hide();
+                $('#data_discount_price').show()
+            }
+        })
     </script>
 @endsection

+ 51 - 29
resources/views/admin/coupon/info/edit.blade.php

xqd xqd xqd xqd xqd xqd
@@ -1,8 +1,8 @@
 @extends('admin.layout')
 
 @section('content')
-    <link href="/css/time/jquery.datetimepicker.css"rel="stylesheet">
-    <link href="/css/time/jquery-ui-1.10.1.css"rel="stylesheet">
+    <link href="/css/time/jquery.datetimepicker.css" rel="stylesheet">
+    <link href="/css/time/jquery-ui-1.10.1.css" rel="stylesheet">
     <?php
     if (!isset($data)) $data = array();
     if (!$data && session("data")) {
@@ -54,18 +54,18 @@
                                     <label class="control-label col-sm-3">优惠券类型:</label>
 
                                     <div class="col-sm-9">
-                                        <div class="radio i-checks">
-                                            <label>
-                                                <input type="radio"
-                                                       @if((isset($data['type']) && $data['type'] == 1)  ) checked="checked"
-                                                       @endif value="1" name="data[type]"> <i></i>折扣</label>
-
-                                            <label>
-                                                <input type="radio"
-                                                       @if((isset($data['type']) && $data['type'] == 0) ) checked="checked"
-                                                       @endif value="0" name="data[type]"> <i></i> 固定金额</label>
-
-                                        </div>
+                                        <select id="data_type" class="form-control" name="data[type]" required>
+
+                                            <option value="0"
+                                                    @if(isset($data['type']) && $data['type'] == 0) selected @endif>
+                                                固定金额
+                                            </option>
+                                            <option value="1"
+                                                    @if(isset($data['type']) && $data['type'] == 1) selected @endif>
+                                                折扣
+                                            </option>
+
+                                        </select>
                                     </div>
 
                                 </div>
@@ -80,33 +80,34 @@
                                     </div>
 
                                 </div>
-                                <div class="form-group">
+                                <div class="form-group"  id="data_discount">
 
                                     <label class="control-label col-sm-3">折扣</label>
 
                                     <div class="col-sm-9">
-                                        <input id="data_discount" name="data[discount]" class="form-control"
+                                        <input  name="data[discount]" class="form-control"
                                                value="{{ $data['discount'] or ''}}"
                                                placeholder="">
                                     </div>
 
                                 </div>
-                                <div class="form-group">
+                                <div class="form-group" id="data_discount_price">
 
                                     <label class="control-label col-sm-3">优惠金额</label>
 
                                     <div class="col-sm-9">
-                                        <input id="data_discount_price" name="data[discount_price]" class="form-control"
-                                               value="{{ $data['discount_price'] or ''}}"  placeholder="">
+                                        <input  name="data[discount_price]" class="form-control"
+                                               value="{{ $data['discount_price'] or ''}}" placeholder="">
                                     </div>
 
                                 </div>
 
                                 <div class="form-group">
 
-                                    <label class="control-label col-sm-3">所属分类</label>
+                                    <label class="control-label col-sm-3">可用产品</label>
                                     <div class="col-md-6">
-                                        <select name="product_id[]" multiple="multiple" id="product-select" class="form-control">
+                                        <select name="product_id[]" multiple="multiple" id="product-select"
+                                                class="form-control">
                                             @foreach($product as $item)
                                                 <option value="{{$item->id}}">
                                                     {{$item->name}}
@@ -169,7 +170,7 @@
     <script src="/js/time/jquery-ui-1.10.1.min.js"></script>
     <script>
         //        时间选择js
-        $(function() {
+        $(function () {
             $.datepicker.regional['zh-CN'] = {
                 clearText: '清除',
                 clearStatus: '清除已选日期',
@@ -185,24 +186,25 @@
                 nextBigStatus: '显示下一年',
                 currentText: '今天',
                 currentStatus: '显示本月',
-                monthNames: ['一月','二月','三月','四月','五月','六月', '七月','八月','九月','十月','十一月','十二月'],
-                monthNamesShort: ['一','二','三','四','五','六', '七','八','九','十','十一','十二'],
+                monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
+                monthNamesShort: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
                 monthStatus: '选择月份',
                 yearStatus: '选择年份',
                 weekHeader: '周',
                 weekStatus: '年内周次',
-                dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
-                dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
-                dayNamesMin: ['日','一','二','三','四','五','六'],
+                dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
+                dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
+                dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
                 dayStatus: '设置 DD 为一周起始',
                 dateStatus: '选择 m月 d日, DD',
                 dateFormat: 'yy-mm-dd',
                 firstDay: 1,
                 initStatus: '请选择日期',
-                isRTL: false};
+                isRTL: false
+            };
             $.datepicker.setDefaults($.datepicker.regional['zh-CN']);
 
-            $( "#end_time" ).datepicker({
+            $("#end_time").datepicker({
                 inline: true,
                 showOtherMonths: true
             })
@@ -218,5 +220,25 @@
             product_ids = product_ids.split(',');
             $('#product-select').multiSelect('select', product_ids);
         });
+
+
+        if($('#data_type').val() ==1 ){
+            $('#data_discount').show();
+            $('#data_discount_price').hide()
+        }else {
+            $('#data_discount').hide();
+            $('#data_discount_price').show()
+        }
+
+        $('#data_type').change(function () {
+            if($(this).val() ==1 ){
+                $('#data_discount').show();
+                $('#data_discount_price').hide()
+            }else {
+                $('#data_discount').hide();
+                $('#data_discount_price').show()
+            }
+        })
+
     </script>
 @endsection

+ 103 - 94
resources/views/admin/product/schedule/index.blade.php

xqd
@@ -1,105 +1,114 @@
-@extends('admin.layout') 
+@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="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">
+                            <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('Product/Schedule/create'))
-    					<div class="col-sm-3 pull-right">
-    					   <a href="{{ U('Product/Schedule/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="am_time"> 营业时间:上午 </th>
-            <th class="sorting" data-sort="pm_time"> 营业时间:下午 </th>
-            <th class="sorting" data-sort="interval"> 时间间隔:分钟 </th>
-            <th class="sorting" data-sort="max"> 人数上限 </th>
-            <th class="sorting" data-sort="created_at"> 创建时间 </th>
-            <th class="sorting" data-sort="updated_at"> 更新时间 </th>
-        						<th width="22%">相关操作</th>
-        					</tr>
-						</thead>
-						<tbody>
-						@if(isset($list))
-							@foreach($list as $key => $item)							<tr>
-								
-            <td>{{ $item->id }}</td>
-            <td>{{ $item->am_time }}</td>
-            <td>{{ $item->pm_time }}</td>
-            <td>{{ $item->interval }}</td>
-            <td>{{ $item->max }}</td>
-            <td>{{ $item->created_at }}</td>
-            <td>{{ $item->updated_at }}</td>
-								<td>
-									<div class="btn-group">
-										<button data-toggle="dropdown"
-											class="btn btn-warning btn-sm dropdown-toggle"
-											aria-expanded="false">
-											操作 <span class="caret"></span>
-										</button>
-										<ul class="dropdown-menu">
+                                </div>
+                            </div>
+                        </form>
+                        @if(role('Product/Schedule/create'))
+                            <div class="col-sm-3 pull-right">
+                                <a href="{{ U('Product/Schedule/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>
 
-											@if(role('Product/Schedule/update'))
-											<li><a href="{{ U('Product/Schedule/update',['id'=>$item->id])}}" class="font-bold">修改</a></li>
-											@endif
+                            <th class="sorting" data-sort="id"> ID</th>
+                            <th class="sorting" data-sort="am_time"> 营业时间:上午</th>
+                            <th class="sorting" data-sort="pm_time"> 营业时间:下午</th>
+                            <th class="sorting" data-sort="interval"> 时间间隔:分钟</th>
+                            <th class="sorting" data-sort="max"> 人数上限</th>
+                            <th class="sorting" data-sort="created_at"> 创建时间</th>
+                            <th class="sorting" data-sort="updated_at"> 更新时间</th>
+                            <th width="22%">相关操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @if(isset($list))
+                            @foreach($list as $key => $item)
+                                <tr>
 
-											@if(role('Product/Schedule/destroy'))
-											<li class="divider"></li>
-											<li><a href="{{ U('Product/Schedule/destroy',['id'=>$item->id])}}" onclick="return confirm('你确定执行删除操作?');">删除</a></li>
-											@endif
+                                    <td>{{ $item->id }}</td>
+                                    <td>{{ $item->am_time }}</td>
+                                    <td>{{ $item->pm_time }}</td>
+                                    <td>{{ $item->interval }}</td>
+                                    <td>{{ $item->max }}</td>
+                                    <td>{{ $item->created_at }}</td>
+                                    <td>{{ $item->updated_at }}</td>
+                                    <td>
+                                        <div class="btn-group">
+                                            <button data-toggle="dropdown"
+                                                    class="btn btn-warning btn-sm dropdown-toggle"
+                                                    aria-expanded="false">
+                                                操作 <span class="caret"></span>
+                                            </button>
+                                            <ul class="dropdown-menu">
 
-										</ul>
-									</div>
-								@if(role('Product/Schedule/view'))
-										<button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Product/Schedule/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>
+                                                @if(role('Product/Schedule/update'))
+                                                    <li><a href="{{ U('Product/Schedule/update',['id'=>$item->id])}}"
+                                                           class="font-bold">修改</a></li>
+                                                @endif
+
+                                                @if(role('Product/Schedule/destroy'))
+                                                    <li class="divider"></li>
+                                                    <li><a href="{{ U('Product/Schedule/destroy',['id'=>$item->id])}}"
+                                                           onclick="return confirm('你确定执行删除操作?');">删除</a></li>
+                                                @endif
+
+                                            </ul>
+                                        </div>
+                                        @if(role('Product/Schedule/view'))
+                                            <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Product/Schedule/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

+ 90 - 0
resources/views/admin/user/schedule/check.blade.php

xqd
@@ -0,0 +1,90 @@
+@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('User/Schedule/create'))
+								<div class="col-sm-3 pull-right">
+									<a href="{{ U('User/Schedule/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 dataCheckTable">
+							<thead>
+							<tr>
+								<th><input class="btSelectAll" name="btSelectAll" type="checkbox"></th>
+								
+            <th class="sorting" data-sort="id"> ID </th>
+            <th class="sorting" data-sort="time"> 时间段 </th>
+            <th class="sorting" data-sort="user_id"> 用户ID </th>
+            <th class="sorting" data-sort="username"> 用户姓名 </th>
+            <th class="sorting" data-sort="phone"> 联系方式 </th>
+            <th class="sorting" data-sort="created_at"> 创建时间 </th>
+            <th class="sorting" data-sort="updated_at"> 更新时间 </th>
+								<th width="22%">相关操作</th>
+							</tr>
+							</thead>
+							<tbody>
+							@if(isset($list))
+								@foreach($list as $key => $item)
+									<tr>
+									<td><input data-json='{!! json_encode($item) !!}'  name="btSelectItem" class="data_key" type="checkbox" value="{{ $item->id or 0 }}" /></td>
+									
+            <td>{{ $item->id }}</td>
+            <td>{{ $item->time }}</td>
+            <td>{{ $item->user_id }}</td>
+            <td>{{ $item->username }}</td>
+            <td>{{ $item->phone }}</td>
+            <td>{{ $item->created_at }}</td>
+            <td>{{ $item->updated_at }}</td>
+									<td>
+										@if(role('User/Schedule/view'))
+											<button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('User/Schedule/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>
+	@include('admin.tools.check_script');
+
+@endsection

+ 113 - 0
resources/views/admin/user/schedule/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('User/Schedule/index'))
+                        <div class="row">
+                            <div class="col-sm-3 pull-right">
+                                <a href="{{ U('User/Schedule/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 class="form-control layer-date" id="data_time" name="data[time]" placeholder="YYYY-MM-DD hh:mm:ss"
+                                               onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})" value="{{ $data['time'] or ''}}">
+                                    </div>
+
+                                </div>
+
+                                <div class="form-group">
+
+                                    <label class="control-label col-sm-3">预约店铺</label>
+
+                                    <div class="col-sm-9">
+                                        <select class="form-control" name="data[store_id]" required>
+                                            @foreach($stores as $item)
+                                                <option value="{{$item->id}}"
+                                                        @if(isset($data['store_id']) && $data['store_id'] == $item->id) selected @endif>
+                                                    {{$item->name}}
+                                                </option>
+                                            @endforeach
+                                        </select>
+                                    </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">&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

+ 114 - 0
resources/views/admin/user/schedule/index.blade.php

xqd
@@ -0,0 +1,114 @@
+@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('User/Schedule/create'))
+                            <div class="col-sm-3 pull-right">
+                                <a href="{{ U('User/Schedule/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="time"> 预约时间</th>
+                            <th class="sorting" data-sort="store_id"> 预约店铺</th>
+                            <th class="sorting" data-sort="username"> 用户姓名</th>
+                            <th class="sorting" data-sort="phone"> 联系方式</th>
+                            <th class="sorting" data-sort="created_at"> 创建时间</th>
+                            <th class="sorting" data-sort="updated_at"> 更新时间</th>
+                            <th width="22%">相关操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @if(isset($list))
+                            @foreach($list as $key => $item)
+                                <tr>
+
+                                    <td>{{ $item->id }}</td>
+                                    <td>{{ $item->time }}</td>
+                                    <td>{{ $item->store() }}</td>
+                                    <td>{{ $item->username }}</td>
+                                    <td>{{ $item->phone }}</td>
+                                    <td>{{ $item->created_at }}</td>
+                                    <td>{{ $item->updated_at }}</td>
+                                    <td>
+                                        <div class="btn-group">
+                                            <button data-toggle="dropdown"
+                                                    class="btn btn-warning btn-sm dropdown-toggle"
+                                                    aria-expanded="false">
+                                                操作 <span class="caret"></span>
+                                            </button>
+                                            <ul class="dropdown-menu">
+
+
+                                                @if(role('User/Schedule/update'))
+                                                    <li><a href="{{ U('User/Schedule/update',['id'=>$item->id])}}"
+                                                           class="font-bold">修改</a></li>
+                                                @endif
+
+                                                @if(role('User/Schedule/destroy'))
+                                                    <li class="divider"></li>
+                                                    <li><a href="{{ U('User/Schedule/destroy',['id'=>$item->id])}}"
+                                                           onclick="return confirm('你确定执行删除操作?');">删除</a></li>
+                                                @endif
+
+                                            </ul>
+                                        </div>
+                                        @if(role('User/Schedule/view'))
+                                            <button onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('User/Schedule/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

+ 67 - 0
resources/views/admin/user/schedule/view.blade.php

xqd
@@ -0,0 +1,67 @@
+@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['time'] or ''}}</p>
+                                                 
+               </div>                     
+               <div class="list-group-item">
+                                                  
+                   <h3 class="list-group-item-heading">用户ID</h3>
+                                                   
+                   <p class="list-group-item-text"> {{ $data['user_id'] 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['deleted_at'] 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