浏览代码

refactor:
- 放号设置重构
- 其他bug修复

zzb 2 年之前
父节点
当前提交
84572e154c

+ 50 - 56
app/admin/controller/Appointment.php

@@ -4,12 +4,13 @@ namespace app\admin\controller;
 
 use app\admin\controller\base\Permissions;
 use app\common\model\Appointment as appointmentModel;
+use time\DateHelper;
 
 class Appointment extends Permissions
 {
     private function getModel()
     {
-        return new \app\common\model\Appointment();
+        return new appointmentModel();
     }
 
     public function index()
@@ -20,14 +21,14 @@ class Appointment extends Permissions
             $where = [
                 'provider_id' => $pid
             ];
-            if (!empty($post["title"])) {
-                $where["title"] = ['like', '%' . $post["title"] . '%'];
+            if (isset($post['ids']) and !empty($post['ids'])) {
+                $where['id'] = ['in', $post['ids']];
             }
-            if (isset($post["start_time"]) and !empty($post["start_time"])) {
-                $timerang = explode(' - ', $post["start_time"]);
+            if (isset($post["daytime"]) and !empty($post["daytime"])) {
+                $timerang = explode(' - ', $post["daytime"]);
                 $min_time = strtotime($timerang[0]);
                 $max_time = $timerang[0] == $timerang[1] ? $min_time + 24 * 3600 - 1 : strtotime($timerang[1]??'');
-                $where["start_time"] = [['>=', $min_time], ['<=', $max_time]];
+                $where["daytime"] = [['>=', $min_time], ['<=', $max_time]];
             }
             if (isset($post["create_time"]) and !empty($post["create_time"])) {
                 $timerang = explode(' - ', $post["create_time"]);
@@ -38,8 +39,11 @@ class Appointment extends Permissions
 
             $model = $this->getModel();
             $count = $model->where($where)->count();
-            $data = $model->where($where)->page($post['page']??0, $post['limit']??15)->order('id desc')->select();
-
+            $data = $model->where($where)->page($post['page']??0, $post['limit']??15)->order('daytime desc')->select();
+            foreach ($data as $key => $value) {
+                $value['specialist_name'] = $value->specialist->name;
+                $data[$key] = $value;
+            }
             return array('code' => 0, 'count' => $count, 'data' => $data);
         } else {
             return $this->fetch();
@@ -53,7 +57,6 @@ class Appointment extends Permissions
         $pid = $this->request->param('pid', 0, 'intval');
         $this->assign('pid', $pid);
 
-        $model = $this->getModel();
         $post = $this->request->post();
         $post['provider_id'] = $pid;
 
@@ -86,7 +89,7 @@ class Appointment extends Permissions
             $validate = new \think\Validate([
                 ['title|服务名称', 'max:50'],
                 ['provider_id', 'require|number'],
-//                ['phone|咨询电话', 'max:50'],
+                ['phone|咨询电话', 'max:50'],
                 ['start_time', 'number', '排号日期格式不对'],
                 ['end_time', 'number', '排号日期格式不对'],
                 ['morning_num|上午放号个数', 'number'],
@@ -108,64 +111,55 @@ class Appointment extends Permissions
 
         if ($id > 0) {
             //修改
-//            $data = $model->where('id', $id)->find();
-//            if (empty($data)) {
-//                $this->error('id不正确');
-//            }
-//            if ($this->request->isPost()) {
-//                if (false == $model->allowField(true)->save($post, ['id' => $id])) {
-            $this->error('修改失败');
-//                } else {
-//                    $this->success('修改成功', 'index', ['pid' => $pid]);
-//                }
-//            } else {
-//                $this->assign('data', $data);
-//                return $this->fetch();
-//            }
         } else {
             //新增
             if ($this->request->isPost()) {
-
-                //判断是否存在排号
-                $exits = (new \app\common\model\AppointmentTicket())->where(['provider_id' => $pid, 'appointment_daytime' => [['>=', $post['start_time']], ['<=', $post['end_time']]]])->count();
+                //判断是否时间跨度重叠
+                $exits = $this->getModel()->where(['provider_id' => $pid, 'daytime' => [['>=', $post['start_time']], ['<=', $post['end_time']]]])->count();
                 if ($exits > 0) {
                     $this->error('该时间跨度内,已存在排号,请重新选择时间');
                 }
-
-                if (false == $model->allowField(true)->save($post)) {
-                    $this->error('添加失败');
-                } else {
-                    //生成号源
-                    appointmentModel::createTicketFromAllAppointment();
-                    $this->success('添加成功', 'index', ['pid' => $pid]);
+                //生成号源
+                $daylist = DateHelper::dateTimeList(date('Y-m-d', $post['start_time']), date('Y-m-d', $post['end_time']), true);
+                if (count($daylist) == 2 && end($daylist) == current($daylist)) {
+                    array_pop($daylist);
                 }
+                $addressId = (new \app\common\model\Specialist())->where('id', $post['provider_id'])->value('address_id');
+                foreach ($daylist as $datetime) {
+                    $post['daytime'] = strtotime($datetime);
+                    $post['address_id'] = $addressId;
+                    if (false == $this->getModel()->allowField(true)->save($post)) {
+                        $this->error('添加失败');
+                    }
+                }
+                $this->success('添加成功', 'index', ['pid' => $pid]);
             } else {
                 return $this->fetch();
             }
         }
     }
 
-//    public function delete()
-//    {
-//        if ($this->request->isAjax()) {
-//            $id = $this->request->param('id', 0, 'intval');
-//            if (false == $this->getModel()->where('id', $id)->delete()) {
-//                $this->error('删除失败');
-//            } else {
-//                $this->success('删除成功', 'index');
-//            }
-//        }
-//    }
-//
-//    public function deletes()
-//    {
-//        if ($this->request->isAjax()) {
-//            $post = $this->request->param();
-//            $ids = $post['ids'];
-//            if ($this->getModel()->where('id', 'in', $ids)->delete()) {
-//                $this->success('删除成功');
-//            }
-//        }
-//    }
+    public function delete()
+    {
+        if ($this->request->isAjax()) {
+            $id = $this->request->param('id', 0, 'intval');
+            if (false == $this->getModel()->where('id', $id)->delete()) {
+                $this->error('删除失败');
+            } else {
+                $this->success('删除成功', 'index');
+            }
+        }
+    }
+
+    public function deletes()
+    {
+        if ($this->request->isAjax()) {
+            $post = $this->request->param();
+            $ids = $post['ids'];
+            if ($this->getModel()->where('id', 'in', $ids)->delete()) {
+                $this->success('删除成功');
+            }
+        }
+    }
 
 }

+ 0 - 134
app/admin/controller/AppointmentTicket.php

@@ -1,134 +0,0 @@
-<?php
-
-namespace app\admin\controller;
-
-use app\admin\controller\base\Permissions;
-use think\Db;
-
-class AppointmentTicket extends Permissions
-{
-    private function getModel()
-    {
-        return new \app\common\model\AppointmentTicket();
-    }
-
-    public function index()
-    {
-        $pid = $this->request->param('pid', 0, 'intval');
-        if ($this->request->isAjax()) {
-            $post = $this->request->param();
-            $where = [
-                'provider_id' => $pid
-            ];
-            if (isset($post['ids']) and !empty($post['ids'])) {
-                $where['id'] = ['in', $post['ids']];
-            }
-            if (isset($post["appointment_id"]) and "" != $post["appointment_id"]) {
-                $where["appointment_id"] = $post["appointment_id"];
-            }
-            if (isset($post["appointment_daytime"]) and !empty($post["appointment_daytime"])) {
-                $timerang = explode(' - ', $post["appointment_daytime"]);
-                $min_time = strtotime($timerang[0]);
-                $max_time = $timerang[0] == $timerang[1] ? $min_time + 24 * 3600 - 1 : strtotime($timerang[1]??'');
-                $where["appointment_daytime"] = [['>=', $min_time], ['<=', $max_time]];
-            }
-            if (isset($post["provider_id"]) and "" != $post["provider_id"]) {
-                $where["provider_id"] = $post["provider_id"];
-            }
-            if (isset($post["address_id"]) and "" != $post["address_id"]) {
-                $where["address_id"] = $post["address_id"];
-            }
-            if (isset($post["morning_use"]) and "" != $post["morning_use"]) {
-                $where["morning_use"] = $post["morning_use"];
-            }
-            if (isset($post["afternoon_use"]) and "" != $post["afternoon_use"]) {
-                $where["afternoon_use"] = $post["afternoon_use"];
-            }
-            if (isset($post["night_use"]) and "" != $post["night_use"]) {
-                $where["night_use"] = $post["night_use"];
-            }
-
-            $model = $this->getModel();
-            $count = $model->where($where)->count();
-            $data = $model->where($where)->page($post['page']??0, $post['limit']??15)->order('appointment_daytime desc')->select();
-            foreach ($data as $key => $value) {
-                $value['specialist_name'] = $value->specialist->name;
-                $data[$key] = $value;
-            }
-            return array('code' => 0, 'count' => $count, 'data' => $data);
-        } else {
-            return $this->fetch();
-        }
-    }
-
-
-    public function publish()
-    {
-        $id = $this->request->param('id', 0, 'intval');
-        $model = $this->getModel();
-        $post = $this->request->post();
-        if ($this->request->isPost()) {
-
-            if (isset($post['appointment_daytime']) && !empty($post['appointment_daytime'])) {
-                $post['appointment_daytime'] = strtotime($post['appointment_daytime']);
-            }
-
-            //验证
-            $validate = new \think\Validate([
-                ['appointment_id|放号配置', 'require|number'],
-                ['appointment_daytime|排号日期', 'require|number'],
-                ['provider_id|服务人id', 'require|number'],
-                ['address_id|地址id', 'number'],
-                ['morning_use|上午报名个数', 'number'],
-                ['afternoon_use|中午报名个数', 'number'],
-                ['night_use|晚上报名个数', 'number'],
-            ]);
-            if (!$validate->check($post)) {
-                $this->error('提交失败:' . $validate->getError());
-            }
-        }
-
-        if ($id > 0) {
-            //修改
-            $data = $model->where('id', $id)->find();
-            if (empty($data)) {
-                $this->error('id不正确');
-            }
-            if ($this->request->isPost()) {
-                if (false == $model->allowField(true)->save($post, ['id' => $id])) {
-                    $this->error('修改失败');
-                } else {
-                    $this->success('修改成功');
-                }
-            } else {
-                $this->assign('data', $data);
-                return $this->fetch();
-            }
-        } else {
-        }
-    }
-
-    public function delete()
-    {
-        if ($this->request->isAjax()) {
-            $id = $this->request->param('id', 0, 'intval');
-            if (false == $this->getModel()->where('id', $id)->delete()) {
-                $this->error('删除失败');
-            } else {
-                $this->success('删除成功', 'index');
-            }
-        }
-    }
-
-    public function deletes()
-    {
-        if ($this->request->isAjax()) {
-            $post = $this->request->param();
-            $ids = $post['ids'];
-            if ($this->getModel()->where('id', 'in', $ids)->delete()) {
-                $this->success('删除成功');
-            }
-        }
-    }
-
-}

+ 6 - 38
app/admin/view/appointment/index.html

@@ -47,26 +47,15 @@
 
             <div class="layui-input-inline">
                 <input type="text" class="layui-input time_range" id="time_range_start_time" autocomplete="off"
-                       placeholder="排号日期" name="start_time">
+                       placeholder="排号日期" name="daytime">
             </div>
 
-            <div class="layui-input-inline">
-                <input type="text" name="title" autocomplete="off" placeholder="服务名称(模糊搜索)"
-                       class="layui-input layui-btn-sm">
-            </div>
-
-            <div class="layui-input-inline">
-                <input type="text" class="layui-input time_range" id="time_range_create_time" autocomplete="off"
-                       placeholder="创建时间" name="create_time">
-            </div>
             <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
         </div>
     </form>
 
     <script type="text/html" id="barDemo">
         <div class="layui-btn-group">
-            <button class="layui-btn layui-btn-xs a_menu" lay-event="edit"><i class="layui-icon"
-                                                                              style="margin-right: 0;"></i></button>
             <button class="layui-btn layui-btn-xs delete" lay-event="del"><i class="layui-icon"
                                                                              style="margin-right: 0;"></i></button>
         </div>
@@ -93,21 +82,17 @@
                 , page: true //开启分页
                 , cols: [[ //表头
                     {type: 'checkbox'},
-
-                    {field: 'id', title: 'ID', width: 60},
-                    {field: "start_time", title: '排号日期',width: 200,templet:function (row) {
-                        return row.start_time + ' ~ ' + row.end_time;
-                    }},
-//                    {field: "title", title: '服务名称'},
+                    {field: "daytime", title: '排号日期'},
+                    {field: "specialist_name", title: '专家名字'},
                     {field: "morning_num", title: '上午放号个数'},
+                    {field: "morning_use", title: '上午报名个数'},
                     {field: "afternoon_num", title: '下午放号个数'},
+                    {field: "afternoon_use", title: '下午报名个数'},
                     {field: "night_num", title: '晚上放号个数'},
+                    {field: "night_use", title: '晚上报名个数'},
                     {field: 'action', title: '操作', toolbar: '#barDemo', fixed: 'right'}
                 ]],
                 done: function () {
-                    if (isExitsFunction('showThumb')) {
-                        showThumb()
-                    }
                 }
             });
 
@@ -115,7 +100,6 @@
                 elem: '#time_range_start_time'
                 , type: 'datetime'
                 , range: true
-                , max: 0 //最大值0天后
                 , theme: 'molv'
                 , calendar: true
                 , done: function (value, date, endDate) {
@@ -126,21 +110,6 @@
                     }
                 }
             });
-            laydate.render({
-                elem: '#time_range_create_time'
-                , type: 'datetime'
-                , range: true
-                , max: 0 //最大值0天后
-                , theme: 'molv'
-                , calendar: true
-                , done: function (value, date, endDate) {
-                    if (endDate.hours == 0 && endDate.minutes == 0 && endDate.seconds == 0) {
-                        setTimeout(function () {
-                            $('#time_range_create_time').val(value.replace(/00:00:00$/, '23:59:59'))
-                        }, 100)
-                    }
-                }
-            });
 
             form.on('submit(serch)', function (data) {
                 table.reload('table', {
@@ -154,7 +123,6 @@
 
             table.on('tool(table)', function (obj) {
                 if (obj.event == 'edit') {
-                    location.href = "{:url('publish',['pid'=>$Request.param.pid])}?id=" + obj.data.id;
                 }
                 else if (obj.event == 'del') {
                     layer.confirm('确定要删除?', function (index) {

+ 16 - 33
app/admin/view/appointment/publish.html

@@ -34,8 +34,8 @@
 
     <div class="layui-tab">
         <ul class="layui-tab-title">
-            <li><a href="{:url('admin/appointment_ticket/index',['pid'=>$Request.param.pid])}" class="a_menu">列表</a></li>
-            <li class="layui-this">{empty name="$data"}新增{else/}修改{/empty}</li>
+            <li><a href="{:url('admin/appointment/index',['pid'=>$Request.param.pid])}" class="a_menu">列表</a></li>
+            <li class="layui-this">新增</li>
         </ul>
     </div>
 
@@ -48,7 +48,7 @@
             <label class="layui-form-label">排号日期跨度</label>
             <div class="layui-input-inline" style="width:600px;">
                 <input name="start_time" id="start_time" autocomplete="off" placeholder="开始日期 - 结束日期" class="layui-input"
-                       type="text" {notempty name="$data" }value="{$data.start_time}" {/notempty}>
+                       type="text">
             </div>
         </div>
 
@@ -58,12 +58,12 @@
             <label class="layui-form-label">上午放号个数</label>
             <div class="layui-input-inline" style="max-width:300px;">
                 <input name="morning_num" autocomplete="off" placeholder="请输入" class="layui-input" type="number"
-                       value="{notempty name="$data"}{$data.morning_num}{else/}20{/notempty}">
+                       value="20">
             </div>
             <div class="layui-form-mid">时段</div>
             <div class="layui-input-inline" style="width:350px;">
                 <input name="morning_start_time" id="morning_start_time" autocomplete="off" placeholder="开始时间 - 结束时间"
-                       class="layui-input" type="text" {notempty name="$data" }value="{$data.morning_start_time}" {/notempty}>
+                       class="layui-input" type="text" >
             </div>
         </div>
 
@@ -72,12 +72,12 @@
             <label class="layui-form-label">下午放号个数</label>
             <div class="layui-input-inline" style="max-width:300px;">
                 <input name="afternoon_num" autocomplete="off" placeholder="请输入" class="layui-input" type="number"
-                       value="{notempty name="$data"}{$data.afternoon_num}{else/}20{/notempty}">
+                       value="20">
             </div>
             <div class="layui-form-mid">时段</div>
             <div class="layui-input-inline" style="width:350px;">
                 <input name="afternoon_start_time" id="afternoon_start_time" autocomplete="off" placeholder="开始时间 - 结束时间"
-                       class="layui-input" type="text" {notempty name="$data" }value="{$data.afternoon_start_time}" {/notempty}>
+                       class="layui-input" type="text" >
             </div>
         </div>
         <!-- 数字 -->
@@ -85,39 +85,22 @@
             <label class="layui-form-label">晚上放号个数</label>
             <div class="layui-input-inline" style="max-width:300px;">
                 <input name="night_num" autocomplete="off" placeholder="请输入" class="layui-input" type="number"
-                       value="{notempty name="$data"}{$data.night_num}{else/}10{/notempty}">
+                       value="10">
             </div>
             <div class="layui-form-mid">时段</div>
             <div class="layui-input-inline" style="width:350px;">
                 <input name="night_start_time" id="night_start_time" autocomplete="off" placeholder="开始时间 - 结束时间"
-                       class="layui-input" type="text" {notempty name="$data" }value="{$data.night_start_time}" {/notempty}>
+                       class="layui-input" type="text" >
             </div>
         </div>
 
-        <!--<div class="layui-form-item">-->
-            <!--<label class="layui-form-label">服务名称</label>-->
-            <!--<div class="layui-input-inline" style="max-width:300px;">-->
-                <!--<input name="title" autocomplete="off" placeholder="请输入" class="layui-input" type="text"-->
-                       <!--value="{notempty name="$data"}{$data.title}{else/}咨询服务{/notempty}">-->
-            <!--</div>-->
-        <!--</div>-->
-        <!--<div class="layui-form-item">-->
-            <!--<label class="layui-form-label">咨询电话</label>-->
-            <!--<div class="layui-input-inline" style="max-width:300px;">-->
-                <!--<input name="phone" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input"-->
-                       <!--type="text" value="{notempty name="$data"}{notempty name="$data.phone"}{$data.phone}{else/}{$data.specialist.phone}{/notempty}{else/}{$phone}{/notempty}">-->
-            <!--</div>-->
-            <!--<div class="layui-form-mid layui-word-aux">必填</div>-->
-        <!--</div>-->
-
-
         <div class="layui-form-item">
-        <label class="layui-form-label">服务价格</label>
-        <div class="layui-input-inline" style="max-width:300px;">
-        <input name="price" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input"
-        type="text" value="{notempty name="$data"}{$data.price}{/notempty}">
-        </div>
-        <div class="layui-form-mid layui-word-aux">必填</div>
+            <label class="layui-form-label">服务价格</label>
+            <div class="layui-input-inline" style="max-width:300px;">
+                <input name="price" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input"
+                type="text" value="">
+            </div>
+            <div class="layui-form-mid layui-word-aux">必填</div>
         </div>
 
 
@@ -152,7 +135,7 @@
                         success: function (res) {
                             if (res.code == 1) {
                                 layer.alert(res.msg, function (index) {
-                                    location.href = "{:url('admin/appointment_ticket/index')}?pid=" + res.data.pid;
+                                    location.href = "{:url('admin/appointment/index')}?pid=" + res.data.pid;
                                 })
                             } else {
                                 layer.msg(res.msg);

+ 1 - 1
app/admin/view/appointment_application/index.html

@@ -240,7 +240,7 @@
                     window.parent.tab.tabAdd({
                         icon: "fa-bookmark",
                         id: "tplay_appointment_application" + obj.data.id,
-                        title: "预约记录:" + obj.data.name,
+                        title: "预约 | " + obj.data.name,
                         url: "/admin/appointment_application/publish?id=" + obj.data.id
                     });
                 }

+ 0 - 181
app/admin/view/appointment_ticket/index.html

@@ -1,181 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <meta charset="utf-8">
-    <title>layui</title>
-    <meta name="renderer" content="webkit">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
-    <link rel="stylesheet" href="/static/public/layui/css/layui.css" media="all">
-    <link rel="stylesheet" href="/static/public/font-awesome/css/font-awesome.min.css" media="all"/>
-    <link rel="stylesheet" href="/static/admin/css/admin.css" media="all">
-    <style type="text/css">
-        /* tooltip */
-        #tooltip {
-            position: absolute;
-            border: 1px solid #ccc;
-            background: #333;
-            padding: 2px;
-            display: none;
-            color: #fff;
-        }
-
-        .tooltip > img {
-            width: 20px;
-            height: 20px;
-        }
-    </style>
-</head>
-<body style="padding:10px;">
-<div class="tplay-body-div">
-
-    <div class="layui-tab">
-        <ul class="layui-tab-title">
-            <li class="layui-this">列表</li>
-            <li><a href="{:url('admin/appointment/publish',['pid'=>$Request.param.pid])}" class="a_menu">新增</a></li>
-        </ul>
-    </div>
-
-    <script type="text/html" id="toolbarDemo">
-        <div class="layui-btn-container">
-            <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="deletes">批量删除</button>
-        </div>
-    </script>
-
-    <form class="layui-form serch" action="index" method="post">
-        <div class="layui-form-item" style="float: left;">
-
-            <div class="layui-input-inline">
-                <input type="text" class="layui-input time_range" id="time_range_appointment_daytime" autocomplete="off"
-                       placeholder="排号日期" name="appointment_daytime">
-            </div>
-            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="serch">立即提交</button>
-        </div>
-    </form>
-
-    <script type="text/html" id="barDemo">
-        <div class="layui-btn-group">
-            <button class="layui-btn layui-btn-xs a_menu" lay-event="edit"><i class="layui-icon"
-                                                                              style="margin-right: 0;"></i></button>
-            <button class="layui-btn layui-btn-xs delete" lay-event="del"><i class="layui-icon"
-                                                                             style="margin-right: 0;"></i></button>
-        </div>
-    </script>
-
-    <table class="layui-table" id="table" lay-filter="table"></table>
-    {include file="public/foot"}
-
-    <script type="text/javascript">
-        layui.use(['table', 'layer', 'form', 'laydate'], function () {
-            var table = layui.table,
-                form = layui.form,
-                layer = layui.layer;
-            var laydate = layui.laydate;
-            //第一个实例
-            table.render({
-                id: 'table'
-                , elem: '#table'
-                , size: 'sm' //小尺寸的表格
-                , toolbar: '#toolbarDemo'
-                , limit: 15
-                , limits: [15, 20, 30, 40, 50, 100]
-                , url: "{:url('index',['pid'=>$Request.param.pid])}" //数据接口
-                , page: true //开启分页
-                , cols: [[ //表头
-                    {type: 'checkbox'},
-                    {field: "appointment_daytime", title: '排号日期'},
-                    {field: "specialist_name", title: '专家名字'},
-                    {field: "morning_use", title: '上午报名个数'},
-                    {field: "afternoon_use", title: '中午报名个数'},
-                    {field: "night_use", title: '晚上报名个数'},
-                    {field: 'action', title: '操作', toolbar: '#barDemo', fixed: 'right'}
-                ]],
-                done: function () {
-                    if (isExitsFunction('showThumb')) {
-                        showThumb()
-                    }
-                }
-            });
-
-            laydate.render({
-                elem: '#time_range_appointment_daytime'
-                , type: 'datetime'
-                , range: true
-                , theme: 'molv'
-                , calendar: true
-                , done: function (value, date, endDate) {
-                    if (endDate.hours == 0 && endDate.minutes == 0 && endDate.seconds == 0) {
-                        setTimeout(function () {
-                            $('#time_range_appointment_daytime').val(value.replace(/00:00:00$/, '23:59:59'))
-                        }, 100)
-                    }
-                }
-            });
-
-            form.on('submit(serch)', function (data) {
-                table.reload('table', {
-                    where: data.field
-                    , page: {
-                        curr: 1 //重新从第 1 页开始
-                    }
-                });
-                return false;
-            });
-
-            table.on('tool(table)', function (obj) {
-                if (obj.event == 'edit') {
-                    location.href = "{:url('publish',['pid'=>$Request.param.pid])}?id=" + obj.data.id;
-                }
-                else if (obj.event == 'del') {
-                    layer.confirm('确定要删除?', function (index) {
-                        $.ajax({
-                            url: "{:url('delete')}",
-                            dataType: 'json',
-                            data: {id: obj.data.id},
-                            success: function (res) {
-                                layer.msg(res.msg);
-                                if (res.code == 1) {
-                                    table.reload('table');
-                                }
-                            }
-                        })
-                    })
-                }
-            });
-            //监听事件
-            table.on('toolbar(table)', function (obj) {
-                if (obj.event == 'deletes') {
-                    var checkStatus = table.checkStatus(obj.config.id);//获取选中的数据
-                    var data = checkStatus.data;
-                    if (data.length > 0) {
-                        var ids = [];//数组
-                        data.forEach(function (item, key) {
-                            ids[key] = item.id;
-                        })
-                        layer.confirm('是否删除?', function (index, layero) {
-                            $.ajax({
-                                url: "{:url('deletes')}",
-                                dataType: 'json',
-                                data: {"ids": ids},
-                                type: 'post',
-                                success: function (res) {
-                                    layer.msg(res.msg);
-                                    if (res.code == 1) {
-                                        table.reload('table');
-                                    }
-                                }
-                            })
-                            layer.close(index)
-                        });
-                    } else {
-                        layer.msg('请先勾选需要操作的记录');
-                    }
-                }
-            });
-        });
-    </script>
-
-
-</div>
-</body>
-</html>

+ 0 - 163
app/admin/view/appointment_ticket/publish.html

@@ -1,163 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <meta charset="utf-8">
-    <title>号源管理编辑</title>
-    <meta name="renderer" content="webkit">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
-    <link rel="stylesheet" href="/static/public/layui/css/layui.css" media="all">
-    <link rel="stylesheet" href="/static/public/font-awesome/css/font-awesome.min.css" media="all"/>
-    <link rel="stylesheet" href="/static/admin/css/admin.css" media="all">
-    <script src="/static/public/layui/layui.js"></script>
-    <script src="/static/public/jquery/jquery.min.js"></script>
-</head>
-<style>
-    .layui-upload-img {
-        cursor: pointer;
-        width: 150px;
-        height: 150px;
-        background: url('/static/public/images/uploadimg.jpg');
-        background-size: contain;
-        border-radius: 2px;
-        border-width: 1px;
-        border-style: solid;
-        border-color: #e6e6e6;
-    }
-</style>
-<body style="padding:10px;">
-<div class="tplay-body-div">
-
-    <div class="layui-tab">
-        <ul class="layui-tab-title">
-            <li><a href="{:url('admin/appointment_ticket/index',['pid'=>$Request.param.pid])}" class="a_menu">列表</a></li>
-            <li class="layui-this">{empty name="$data"}新增{else/}修改{/empty}</li>
-        </ul>
-    </div>
-
-    <div style="margin-top: 20px;"></div>
-    <form class="layui-form" id="publish" method="post">
-
-        <!-- 数字 -->
-        <div class="layui-form-item">
-            <label class="layui-form-label">放号配置</label>
-            <div class="layui-input-inline" style="max-width:300px;">
-                <input name="appointment_id" lay-verify="required" autocomplete="off" placeholder="请输入"
-                       class="layui-input" type="number" {notempty name="$data" }value="{$data.appointment_id}" {/notempty}>
-            </div>
-            <div class="layui-form-mid layui-word-aux">必填</div>
-        </div>
-        <!-- 时间 -->
-        <div class="layui-form-item">
-            <label class="layui-form-label">排号日期</label>
-            <div class="layui-input-inline" style="max-width:300px;">
-                <input name="appointment_daytime" id="appointment_daytime" lay-verify="required" autocomplete="off"
-                       placeholder="请输入" class="layui-input" type="text" {notempty name="$data"
-                       }value="{$data.appointment_daytime}" {/notempty}>
-            </div>
-            <div class="layui-form-mid layui-word-aux">必填</div>
-        </div>
-        <!-- 数字 -->
-        <div class="layui-form-item">
-            <label class="layui-form-label">服务人id</label>
-            <div class="layui-input-inline" style="max-width:300px;">
-                <input name="provider_id" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input"
-                       type="number" {notempty name="$data" }value="{$data.provider_id}" {/notempty}>
-            </div>
-            <div class="layui-form-mid layui-word-aux">必填</div>
-        </div>
-        <!-- 数字 -->
-        <div class="layui-form-item">
-            <label class="layui-form-label">地址id</label>
-            <div class="layui-input-inline" style="max-width:300px;">
-                <input name="address_id" autocomplete="off" placeholder="请输入" class="layui-input" type="number"
-                       {notempty name="$data" }value="{$data.address_id}" {/notempty}>
-            </div>
-        </div>
-        <!-- 数字 -->
-        <div class="layui-form-item">
-            <label class="layui-form-label">上午报名个数</label>
-            <div class="layui-input-inline" style="max-width:300px;">
-                <input name="morning_use" autocomplete="off" placeholder="请输入" class="layui-input" type="number"
-                       {notempty name="$data" }value="{$data.morning_use}" {/notempty}>
-            </div>
-        </div>
-        <!-- 数字 -->
-        <div class="layui-form-item">
-            <label class="layui-form-label">中午报名个数</label>
-            <div class="layui-input-inline" style="max-width:300px;">
-                <input name="afternoon_use" autocomplete="off" placeholder="请输入" class="layui-input" type="number"
-                       {notempty name="$data" }value="{$data.afternoon_use}" {/notempty}>
-            </div>
-        </div>
-        <!-- 数字 -->
-        <div class="layui-form-item">
-            <label class="layui-form-label">晚上报名个数</label>
-            <div class="layui-input-inline" style="max-width:300px;">
-                <input name="night_use" autocomplete="off" placeholder="请输入" class="layui-input" type="number" {notempty
-                       name="$data" }value="{$data.night_use}" {/notempty}>
-            </div>
-        </div>
-
-
-        {notempty name="$data"}
-        <input type="hidden" name="id" value="{$data.id}">
-        {/notempty}
-
-        <div class="layui-form-item">
-            <div class="layui-input-block">
-                <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
-                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
-            </div>
-        </div>
-    </form>
-
-    <script>
-        layui.use(['layer', 'form', 'laydate'], function () {
-            var layer = layui.layer,
-                $ = layui.jquery,
-                form = layui.form;
-            var laydate = layui.laydate;
-
-            $(window).on('load', function () {
-                form.on('submit(admin)', function (data) {
-                    $.ajax({
-                        url: "{:url('publish')}",
-                        data: $('#publish').serialize(),
-                        type: 'post',
-                        dataType: 'json',
-                        async: false,
-                        success: function (res) {
-                            if (res.code == 1) {
-                                if (res.msg == "添加成功") {
-                                    layer.alert(res.msg, function (index) {
-                                        location.href = res.url;
-                                    })
-                                } else {
-                                    layer.confirm(res.msg, {
-                                        btn: ['关闭', '继续编辑']
-                                    }, function (index) {
-                                        window.parent.tab.close('tplay_appointment_ticket{$data.id|default=0}');
-                                    }, function (index, layero) {
-                                        location.href = res.url;
-                                    });
-                                }
-                            } else {
-                                layer.msg(res.msg);
-                            }
-                        }
-                    })
-                    return false;
-                });
-
-                laydate.render({
-                    elem: '#appointment_daytime', //指定元素
-                    type: 'datetime',
-                });
-
-            });
-        });
-    </script>
-</div>
-</body>
-</html>

+ 2 - 2
app/admin/view/feedback/index.html

@@ -48,7 +48,7 @@
                        class="layui-input layui-btn-sm">
             </div>
             <div class="layui-input-inline" style="width:100px">
-                <input type="number" name="user_id" autocomplete="off" placeholder="发布人"
+                <input type="number" name="user_id" autocomplete="off" placeholder="用户ID"
                        class="layui-input layui-btn-sm">
             </div>
             <div class="layui-input-inline">
@@ -90,7 +90,7 @@
 
                     {field: 'id', title: 'ID', width: 60},
                     {field: "content", title: '内容'},
-                    {field: "user_id", title: '发布人'},
+                    {field: "user_id", title: '用户ID'},
                     {field: "create_time", title: '日期'},
                     {field: 'action', title: '操作', toolbar: '#barDemo', fixed: 'right'}
                 ]],

+ 0 - 123
app/admin/view/feedback/publish.html

@@ -1,123 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <meta charset="utf-8">
-    <title>反馈表编辑</title>
-    <meta name="renderer" content="webkit">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
-    <link rel="stylesheet" href="/static/public/layui/css/layui.css"  media="all">
-    <link rel="stylesheet" href="/static/public/font-awesome/css/font-awesome.min.css" media="all" />
-    <link rel="stylesheet" href="/static/admin/css/admin.css"  media="all">
-    <script src="/static/public/layui/layui.js"></script>
-    <script src="/static/public/jquery/jquery.min.js"></script>
-</head>
-<style>
-  .layui-upload-img{
-    cursor: pointer;
-    width:150px;
-    height:150px;
-    background: url('/static/public/images/uploadimg.jpg');
-    background-size:contain;
-    border-radius: 2px;
-    border-width: 1px;
-    border-style: solid;
-    border-color: #e6e6e6;
-  }
-</style>
-<body style="padding:10px;">
-  <div class="tplay-body-div">
-
-    {empty name="$data"}
-    <div class="layui-tab">
-      <ul class="layui-tab-title">
-        <li><a href="index" class="a_menu">列表</a></li>
-        <li class="layui-this">新增</li>
-      </ul>
-    </div>
-    {/empty}
-
-    <div style="margin-top: 20px;"></div>
-    <form class="layui-form" id="publish" method="post">
-
-                      <!-- 输入框 -->
-              <div class="layui-form-item">
-                <label class="layui-form-label">标题</label>
-                <div class="layui-input-inline" style="max-width:300px;">
-                  <input name="title"  autocomplete="off" placeholder="请输入" class="layui-input" type="text" {notempty name="$data"}value="{$data.title}"{/notempty}>
-                </div>
-                                </div>
-                          <!-- 输入框 -->
-              <div class="layui-form-item">
-                <label class="layui-form-label">内容</label>
-                <div class="layui-input-inline" style="max-width:300px;">
-                  <input name="content"  autocomplete="off" placeholder="请输入" class="layui-input" type="text" {notempty name="$data"}value="{$data.content}"{/notempty}>
-                </div>
-                                </div>
-                            <!-- 数字 -->
-              <div class="layui-form-item">
-                <label class="layui-form-label">发布人</label>
-                <div class="layui-input-inline" style="max-width:300px;">
-                  <input name="user_id"  autocomplete="off" placeholder="请输入" class="layui-input" type="number" {notempty name="$data"}value="{$data.user_id}"{/notempty}>
-                </div>
-                                </div>
-            
-
-        
-        {notempty name="$data"}
-          <input type="hidden" name="id" value="{$data.id}">
-        {/notempty}
-       
-      <div class="layui-form-item">
-        <div class="layui-input-block">
-          <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
-          <button type="reset" class="layui-btn layui-btn-primary">重置</button>
-        </div>
-      </div>
-    </form>
-
-    <script>
-        layui.use(['layer', 'form' ,'laydate'], function () {
-            var layer = layui.layer,
-                $ = layui.jquery,
-                form = layui.form;
-            var laydate = layui.laydate;
-
-            $(window).on('load', function () {
-                form.on('submit(admin)', function (data) {
-                    $.ajax({
-                        url: "{:url('publish')}",
-                        data: $('#publish').serialize(),
-                        type: 'post',
-                        dataType: 'json',
-                        async: false,
-                        success: function (res) {
-                            if (res.code == 1) {
-                                if (res.msg == "添加成功") {
-                                    layer.alert(res.msg, function (index) {
-                                        location.href = res.url;
-                                    })
-                                }else{
-                                    layer.confirm(res.msg, {
-                                        btn: ['关闭', '继续编辑']
-                                    }, function (index) {
-                                        window.parent.tab.close('tplay_feedback{$data.id|default=0}');
-                                    }, function (index, layero) {
-                                        location.href = res.url;
-                                    });
-                                }
-                            } else {
-                                layer.msg(res.msg);
-                            }
-                        }
-                    })
-                    return false;
-                });
-
-                
-            });
-        });
-    </script>
-  </div>
-</body>
-</html>

+ 34 - 11
app/admin/view/file_manage/index.html

@@ -37,18 +37,11 @@
             <button class="layui-btn layui-btn-sm" lay-event="createDir">新建目录</button>
             {notempty name="relative_path"}
             <span style="display: inline-block;margin-right: 10px;"><i class="layui-icon">当前目录 {$Think.DS}{$relative_path}</i></span>
-            <button class="layui-btn layui-btn-sm" lay-event="goback">返回上级</button>
+            <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="goback">返回上级</button>
             {/notempty}
         </div>
     </script>
 
-    <script type="text/html" id="barDemo">
-        <div class="layui-btn-group">
-            <button class="layui-btn layui-btn-xs a_menu" lay-event="edit" title="打开">打开</button>
-            <button class="layui-btn layui-btn-xs a_menu" lay-event="rename" title="改名">改名</button>
-            <button class="layui-btn layui-btn-xs a_menu" lay-event="del" title="删除">删除</button>
-        </div>
-    </script>
 
     <table class="layui-table" id="table" lay-filter="table"></table>
 
@@ -74,7 +67,7 @@
                 , cols: [[ //表头
                     {type: 'checkbox'},
                     {
-                        field: 'filename', title: '名称', minWidth: 120, templet: function (row) {
+                        field: 'filename', title: '名称 (可点击)', minWidth: 120, templet: function (row) {
                         var fullname = getfullname(row.filename, row.fileext, row.filetype);
                         var relative_path = "{notempty name='$relative_path'}{$relative_path|replaceUrlDS}/{/notempty}";
                         if(row.filetype == 'dir'){
@@ -103,7 +96,18 @@
                     {field: 'fileatime', title: '最后访问时间', width: 150},
                     {field: 'filectime', title: '索引修改时间', width: 150},
                     {field: 'filemtime', title: '内容修改时间', width: 150},
-                    {field: 'action', title: '操作', align: 'center', toolbar: '#barDemo', fixed: 'right', width: 150}
+                    {field: 'action', title: '操作', align: 'center', fixed: 'right', width: 160 ,templet:function (row) {
+                        var html = '<div class="layui-btn-group">';
+                        if(row.filetype == 'dir'){
+                            html+='<button class="layui-btn layui-btn-xs a_menu" lay-event="down" title="打开">打开</button>';
+                        }else{
+                            html+='<button class="layui-btn layui-btn-xs a_menu" lay-event="down" title="下载">下载</button>';
+                        }
+
+                        return html +'<button class="layui-btn layui-btn-xs a_menu" lay-event="rename" title="改名">改名</button>'
+                            +'<button class="layui-btn layui-btn-xs a_menu" lay-event="del" title="删除">删除</button>'
+                            + '</div>';
+                    }}
                 ]],
                 done: function (res, curr, count) {
                     if (res.url) {
@@ -191,6 +195,25 @@
                     download.click();
 
                 }
+                else if (obj.event == 'down') {
+
+                    var filename = obj.data.filename;
+                    var fileext = obj.data.fileext;
+                    var filetype = obj.data.filetype;
+                    var relative_path = "{notempty name='$relative_path'}{$relative_path|replaceUrlDS}/{/notempty}";
+                    var fullname = getfullname(filename, fileext, filetype);
+
+                    if (filetype == 'dir') {
+                        location.href = "{:url('index')}?relative_path=" + relative_path + fullname;
+                        return;
+                    }
+
+                    var src = "/uploads/q1464674022/" + relative_path + fullname;
+                    var download = document.getElementById('down');
+                    download.setAttribute('href', src);
+                    download.setAttribute('download', fullname);
+                    download.click();
+                }
                 else if (obj.event == 'del') {
                     var fullname = getfullname(obj.data.filename, obj.data.fileext, obj.data.filetype);
                     layer.confirm('确定要删除?', function (index) {
@@ -345,7 +368,7 @@
                 , url: "{:url('upload')}?relative_path={$relative_path|replaceUrlDS}"
                 , accept: 'file' //普通文件
                 , multiple: true
-                , exts: 'html|js|css|mp4|jpg|png|gif|zip' //只允许上传的文件
+//                , exts: 'html|js|css|mp4|jpg|png|gif|zip' //只允许上传的文件
                 , allDone: function (obj) { //当文件全部被提交后,才触发
                     console.log('总文件数:' + obj.total + '  成功的文件数:' + obj.successful + '  失败的文件数:' + obj.aborted);
                     setTimeout(function () {

+ 2 - 2
app/admin/view/specialist/index.html

@@ -150,7 +150,7 @@
                     window.parent.tab.tabAdd({
                         icon: "fa-bookmark",
                         id: "tplay_specialist" + obj.data.id,
-                        title: obj.data.title == null ? "专家" + obj.data.id : obj.data.title,
+                        title: "专家 | " + obj.data.name,
                         url: "/admin/specialist/publish?id=" + obj.data.id
                     });
                 }
@@ -176,7 +176,7 @@
                         area: ['80%', '90%'],
                         maxmin: true,
                         id: 'layerDemo', //防止重复弹出
-                        content: "{:url('admin/appointment_ticket/index')}?pid=" + obj.data.id
+                        content: "{:url('admin/appointment/index')}?pid=" + obj.data.id
                     });
                 }
             });

+ 17 - 25
app/api/controller/Appointment.php

@@ -6,7 +6,6 @@ use app\api\controller\base\Base;
 use app\common\model\Address;
 use app\common\model\Appointment as appointmentModel;
 use app\common\model\AppointmentApplication;
-use app\common\model\AppointmentTicket;
 use time\DateHelper;
 
 class Appointment extends Base
@@ -29,7 +28,7 @@ class Appointment extends Base
             $this->json_error("没有数据");
         }
         foreach ($datalist as $key => $item) {
-            $item['thumb'] = geturl($item->thumb, '', true);
+            $item['thumb_url'] = geturl($item->thumb, '', true);
             $datalist[$key] = $item;
         }
         $this->json_success("查询成功", $datalist);
@@ -49,7 +48,7 @@ class Appointment extends Base
         }
 
         $where = [];
-        $addressIds = (new appointmentModel())->availableAddressIds();
+        $addressIds = (new appointmentModel())->where('daytime', '>=', strtotime(date('Y-m-d')))->distinct(true)->column('address_id');
         $where['id'] = ['in', $addressIds];
         $pagenum = $this->request->param('pagenum', 20, 'intval');
         $datalist = (new Address())->where($where)->paginate($pagenum, true);
@@ -57,7 +56,7 @@ class Appointment extends Base
             $this->json_error("没有数据");
         }
         foreach ($datalist as $key => $item) {
-            $item['thumb'] = geturl($item->thumb, '', true);
+            $item['thumb_url'] = geturl($item->thumb, '', true);
             $datalist[$key] = $item;
         }
         $this->json_success("查询成功", $datalist);
@@ -79,26 +78,22 @@ class Appointment extends Base
         $address_id = $this->request->param('address_id');
         $daytime = $this->request->param('daytime', date('Y-m-d'));
 
-        $ticketModel = new AppointmentTicket();
-        $tickets = $ticketModel->where('address_id', $address_id)->where('appointment_daytime', strtotime($daytime))->select();
+        $ticketModel = new appointmentModel();
+        $tickets = $ticketModel->where('address_id', $address_id)->where('daytime', strtotime($daytime))->select();
 
         foreach ($tickets as $k => $item) {
-            $appoint = $item->appointment;
-            $item['price'] = $appoint->price;
-            //日期
-            $item['appointment_daytime_text'] = date('Y-m-d', $item->appointment_daytime);
             //专家信息
             $item->specialist;
             $item->specialist->head_pic = geturl($item->specialist->head_pic, '', true);
             //剩余预约号码
-            $item['morning_remaining'] = $appoint->morning_num - $item->morning_use;
-            $item['afternoon_remaining'] = $appoint->afternoon_num - $item->afternoon_use;
-            $item['night_remaining'] = $appoint->night_num - $item->night_use;
+            $item['morning_remaining'] = $item->morning_num - $item->morning_use;
+            $item['afternoon_remaining'] = $item->afternoon_num - $item->afternoon_use;
+            $item['night_remaining'] = $item->night_num - $item->night_use;
             //拆分预约时段
             $ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $item->id)->column('appointment_time');
-            $item['morning_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($appoint->morning_start_time, $appoint->morning_end_time, $appoint->morning_num), $ticketPeriods);
-            $item['afternoon_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($appoint->afternoon_start_time, $appoint->afternoon_end_time, $appoint->afternoon_num), $ticketPeriods);
-            $item['night_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($appoint->night_start_time, $appoint->night_end_time, $appoint->night_num), $ticketPeriods);
+            $item['morning_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->morning_start_time, $item->morning_end_time, $item->morning_num), $ticketPeriods);
+            $item['afternoon_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->afternoon_start_time, $item->afternoon_end_time, $item->afternoon_num), $ticketPeriods);
+            $item['night_time_period'] = $this->setPeriodStatus(DateHelper::splitTimePeriod($item->night_start_time, $item->night_end_time, $item->night_num), $ticketPeriods);
 
             $tickets[$k] = $item;
         }
@@ -128,14 +123,7 @@ class Appointment extends Base
     //按时间获取地址列表
     public function addressListByDayTime()
     {
-        appointmentModel::createTicketFromAllAppointment();
-        $ticketModel = new AppointmentTicket();
-
-        //可预约日期列表
-//        $maxEndTime = $ticketModel->max('end_time');
-//        $daylist = DateHelper::getDateList(date('Y-m-d'), date('Y-m-d', $maxEndTime), true);
-
-
+        $ticketModel = new appointmentModel();
         $post = $this->request->param();
         $validate = new \think\Validate([
             ['daytime', 'date|dateFormat:Y-m-d'],
@@ -147,7 +135,7 @@ class Appointment extends Base
         }
 
         $daytime = $this->request->param('daytime', date('Y-m-d'));
-        $addressIds = $ticketModel->where('appointment_daytime', strtotime($daytime))->column('address_id');
+        $addressIds = $ticketModel->where('daytime', strtotime($daytime))->distinct(true)->column('address_id');
 
         $where = [];
         $where['id'] = ['in', $addressIds];
@@ -156,6 +144,10 @@ class Appointment extends Base
         if (empty($datalist)) {
             $this->json_error("没有数据");
         }
+        foreach ($datalist as $key => $item) {
+            $item['thumb_url'] = geturl($item->thumb, '', true);
+            $datalist[$key] = $item;
+        }
         $this->json_success("查询成功", $datalist);
     }
 }

+ 6 - 8
app/api/controller/User.php

@@ -11,7 +11,7 @@ namespace app\api\controller;
 
 use app\api\controller\base\Permissions;
 use app\common\model\AppointmentApplication;
-use app\common\model\AppointmentTicket;
+use app\common\model\Appointment;
 use app\common\model\Feedback;
 use app\common\model\Webconfig;
 
@@ -37,8 +37,6 @@ class User extends Permissions
             ['childs_num|子女数量', 'number'],
             ['problem_desc|问题描述', 'max:200'],
             ['requirement_desc|需求描述', 'max:200'],
-            ['address_id', 'require|number'],
-            ['provider_id', 'require|number'],
             ['appointment_ticket_id', 'require|number'],
             ['appointment_period', 'require|number|in:1,2,3'],
             ['appointment_time|预约时间段', 'require|dateFormat:H:i:s - H:i:s'],
@@ -65,13 +63,13 @@ class User extends Permissions
         }
 
         //检测预约号源是否可预约
-        $ticket = AppointmentTicket::get($post['appointment_ticket_id']);
+        $ticket = Appointment::get($post['appointment_ticket_id']);
         if (!$ticket) {
             $this->json_error("获取预约号失败");
         }
 
         //已经预约的时间段
-        $ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $ticket->appointment_id)->column('appointment_time');
+        $ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $ticket->id)->column('appointment_time');
         foreach ($ticketPeriods as $period) {
             if ($period == $post['appointment_time']) {
                 $this->json_error("该时间已经被预约了,请重新选择时间");
@@ -90,8 +88,8 @@ class User extends Permissions
             'childs_num' => $post['childs_num']??0,
             'problem_desc' => $post['problem_desc']??'',
             'requirement_desc' => $post['requirement_desc']??'',
-            'address_id' => $post['address_id'],
-            'provider_id' => $post['provider_id'],
+            'address_id' => $ticket->address_id,
+            'provider_id' => $ticket->provider_id,
             'appointment_ticket_id' => $post['appointment_ticket_id'],
             'appointment_time' => $post['appointment_time'],
             'appointment_period' => $post['appointment_period'],
@@ -150,7 +148,7 @@ class User extends Permissions
             ['content|内容', 'require|max:500'],
         ]);
         if (!$validate->check($post)) {
-            $this->error('提交失败:' . $validate->getError());
+            $this->json_error('提交失败:' . $validate->getError());
         }
 
         $model = new Feedback();

+ 16 - 23
app/api/controller/接口文档.md

@@ -174,11 +174,13 @@
             {
                 "id": 1,
                 "title": "厦门曙光医院",
+                "thumb_url": "http://local.appointment.com/uploads/admin/article_content/20230421/ee2a2b125a3c174e11683530a931a69e.jpg"
                 "address": "福建省厦门市湖里区金尚路127号"
             },
             {
                 "id": 2,
                 "title": "厦门前埔医院",
+                "thumb_url": "http://local.appointment.com/uploads/admin/article_content/20230421/ee2a2b125a3c174e11683530a931a69e.jpg"
                 "address": "地址 : 福建省厦门市湖里区仙岳路3777号\r\n电话 : 0592-5262666"
             }
         ]
@@ -219,6 +221,17 @@
             "morning_remaining": 29,      // 上午剩余(预约号个数)
             "afternoon_remaining": 10,    // 下午剩余
             "night_remaining": 10,        // 晚上剩余
+            "morning_num": 30,          // 上午放号个数
+            "morning_start_time": "08:00:00",
+            "morning_end_time": "12:00:00",
+            "afternoon_num": 1,          // 下午放号个数
+            "afternoon_start_time": "14:00:00",
+            "afternoon_end_time": "18:00:00",
+            "night_num": 10,             //晚上放号个数
+            "night_start_time": "20:00:00",
+            "night_end_time": "23:59:59",
+            "status": 1,
+            "create_time": "2023-04-22 16:24:02",
             "morning_time_period": [
                 {
                     "period": "08:00:00 - 08:08:00",   // 上午可预约时间段
@@ -261,27 +274,6 @@
                     "status": 0
                 }
             ],
-            "appointment": { // 放号设置信息
-                "id": 1,
-                "provider_id": 3,
-                "title": "咨询服务",
-                "phone": "12121",
-                "price": 12,
-                "start_time": "2023-04-22", //排号开始日期
-                "end_time": "2023-04-30",   //排号结束日期
-                "morning_num": 30,          // 上午放号个数
-                "morning_start_time": "08:00:00",
-                "morning_end_time": "12:00:00",
-                "afternoon_num": 1,          // 下午放号个数
-                "afternoon_start_time": "14:00:00",
-                "afternoon_end_time": "18:00:00",
-                "night_num": 10,             //晚上放号个数
-                "night_start_time": "20:00:00",
-                "night_end_time": "23:59:59",
-                "status": 1,
-                "ticket_status": 1,
-                "create_time": "2023-04-22 16:24:02"
-            },
             "specialist": {        //专家信息
                 "id": 3,
                 "name": "王医生",
@@ -339,6 +331,7 @@
             {
                 "id": 1,
                 "title": "厦门曙光医院",
+                "thumb_url": "",
                 "address": "福建省厦门市湖里区金尚路127号"
             }
         ]
@@ -364,8 +357,6 @@
 | childs_num   | 子女数量 |  int |
 | problem_desc   | 问题描述 |  max:200 |
 | requirement_desc   | 需求描述 |  max:200 |
-| address_id   | 地址id |  require, int |
-| provider_id   | 专家id |  require, int |
 | appointment_ticket_id   | 号源id |  require, int |
 | appointment_period   | 时段:1上午,2下午,3晚上 |  require, int |
 | appointment_time   | 预约时间段 |  require, dateFormat: H:i:s - H:i:s |
@@ -439,6 +430,7 @@
                 "address": {
                     "id": 1,
                     "title": "厦门曙光医院",
+                    "thumb_url":"",
                     "address": "福建省厦门市湖里区金尚路127号"
                 },
                 "specialist": {
@@ -476,6 +468,7 @@
                 "address": {
                     "id": 1,
                     "title": "厦门曙光医院",
+                    "thumb_url":"",
                     "address": "福建省厦门市湖里区金尚路127号"
                 },
                 "specialist": {

+ 5 - 0
app/common/behavior/AdminLogBehavior.php

@@ -79,9 +79,14 @@ class AdminLogBehavior
      * 更新最新一条日志
      * @param $param string  [新的param]
      * @param $cover boolean [true覆盖param,false追加param]
+     * @return bool
      */
     public function updateLastLog($param, $cover = true)
     {
+        $islog = Webconfig::getValue('is_log', 3600 * 24);
+        if (empty($islog) || $islog != 1) {
+            return true;//关闭了日志
+        }
         $model = new \app\admin\model\AdminLog();
         $last = $model->order('id desc')->find();
         $param = $cover ? $param : limitStrLen('params', $last->params . ' ' . $param, 2000);

+ 7 - 59
app/common/model/Appointment.php

@@ -10,75 +10,23 @@ class Appointment extends Model
 {
     protected $updateTime = false;
 
-    public function getStartTimeAttr($value, $data)
+    //daytime
+    public function getDaytimeAttr($value, $data)
     {
         return $value ? date('Y-m-d', $value) : '';
     }
 
-    public function getEndTimeAttr($value, $data)
-    {
-        return $value ? date('Y-m-d', $value) : '';
-    }
-
-    //生成号源配置
-    public function createTicket()
-    {
-        if (!$this->ifExitsTicket()) {
-            $daylist = DateHelper::dateTimeList($this->start_time, $this->end_time, true);
-            foreach ($daylist as $datetime) {
-                (new AppointmentTicket())->save([
-                    'appointment_id' => $this->id,
-                    'appointment_daytime' => strtotime($datetime),
-                    'provider_id' => $this->provider_id,
-                    'address_id' => $this->specialist->address_id,
-                ]);
-            }
-            $this->save(['ticket_status' => 1]);
-        }
-    }
-
-    //是否已生成号源配置
-    public function ifExitsTicket()
-    {
-        return $this->ticket_status > 0;
-    }
-
-
-    /**
-     * 生成号源,保证预约取号正常运行
-     */
-    public static function createTicketFromAllAppointment()
-    {
-        $all = (new Appointment())->where('end_time', '>', time())->where('ticket_status', 0)->select();
-        /** @var  $item Appointment */
-        foreach ($all as $item) {
-            $item->createTicket();
-        }
-    }
 
     /**
-     * 获取可预约地点列表
-     * @return array
+     * 可预约日期列表
      */
-    public static function availableAddressIds()
+    public static function availableDayList()
     {
-        self::createTicketFromAllAppointment();
-        $addressIds = (new AppointmentTicket())->where('appointment_daytime', '>=', strtotime(date('Y-m-d')))->distinct('true')->column('address_id');
-        return $addressIds;
+        $maxEndTime = (new Appointment())->max('daytime');
+        $daylist = DateHelper::dateTimeList(date('Y-m-d'), date('Y-m-d', $maxEndTime), true);
+        return $daylist;
     }
 
-    //按时间预约列表接口
-    public static function listByDayTime()
-    {
-        self::createTicketFromAllAppointment();
-
-    }
-
-    //是否已存在预约订单
-    public function ifExitsAppointmentApplication()
-    {
-
-    }
 
     //关联专家
     public function specialist()

+ 0 - 28
app/common/model/AppointmentTicket.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace app\common\model;
-
-use think\Model;
-
-class AppointmentTicket extends Model
-{
-    protected $autoWriteTimestamp = false;
-
-    public function getAppointmentDaytimeAttr($value, $data)
-    {
-        return $value ? date('Y-m-d', $value) : '';
-    }
-
-    //关联专家
-    public function specialist()
-    {
-        return $this->belongsTo('Specialist', 'provider_id');
-    }
-
-    //关联放号配置
-    public function appointment()
-    {
-        return $this->belongsTo('Appointment');
-    }
-
-}

+ 20 - 3
app/install/data/db.sql

@@ -844,14 +844,31 @@ ALTER TABLE `tplay_address`
 
 
 
-ALTER TABLE `tplay_appointment_ticket`
-	ADD COLUMN `status` TINYINT NOT NULL DEFAULT '1' COMMENT '状态:1启用0停用' AFTER `night_use`;
-
 ALTER TABLE `tplay_appointment`
 	CHANGE COLUMN `phone` `phone` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '咨询电话' COLLATE 'utf8_general_ci' AFTER `title`;
 
 
 
+ALTER TABLE `tplay_appointment`
+	ADD COLUMN `daytime` INT(11) NOT NULL COMMENT '排号日期' AFTER `price`,
+	DROP COLUMN `start_time`,
+	DROP COLUMN `end_time`;
+ALTER TABLE `tplay_appointment`
+	ADD COLUMN `morning_use` INT(11) NOT NULL DEFAULT '20' COMMENT '上午报名个数' AFTER `morning_num`,
+	ADD COLUMN `afternoon_use` INT(11) NOT NULL DEFAULT '20' COMMENT '下午报名个数' AFTER `afternoon_num`,
+	ADD COLUMN `night_use` INT(11) NOT NULL DEFAULT '10' COMMENT '晚上报名个数' AFTER `night_num`;
 
+DROP TABLE `tplay_appointment_ticket`;
 
+ALTER TABLE `tplay_appointment`
+	DROP COLUMN `ticket_status`;
 
+ALTER TABLE `tplay_appointment`
+	ADD COLUMN `address_id` INT(11) NOT NULL COMMENT '地址id' AFTER `provider_id`;
+ALTER TABLE `tplay_appointment`
+	DROP COLUMN `title`,
+	DROP COLUMN `phone`;
+ALTER TABLE `tplay_appointment`
+	CHANGE COLUMN `morning_use` `morning_use` INT(11) NOT NULL DEFAULT '0' COMMENT '上午报名个数' AFTER `morning_num`,
+	CHANGE COLUMN `afternoon_use` `afternoon_use` INT(11) NOT NULL DEFAULT '0' COMMENT '下午报名个数' AFTER `afternoon_num`,
+	CHANGE COLUMN `night_use` `night_use` INT(11) NOT NULL DEFAULT '0' COMMENT '晚上报名个数' AFTER `night_num`;

+ 4 - 4
extend/time/DateHelper.php

@@ -144,10 +144,10 @@ class DateHelper
 
     /**
      * 拆分时段
-     * @param $start
-     * @param $end
-     * @param $count
-     * @param $format string 返回的日期格式
+     * @param $start string 时间格式H:i:s
+     * @param $end string 时间格式H:i:s
+     * @param $count int 拆分个数
+     * @param $format string 返回的日期格式H:i:s
      * @return array
      */
     public static function splitTimePeriod($start, $end, $count, $format = 'H:i:s')