Explorar o código

fix:
- 按地址获取号源信息
- 我的预约列表接口
- 预约报名接口

zzb %!s(int64=2) %!d(string=hai) anos
pai
achega
5baa028670

+ 7 - 1
app/admin/view/webconfig/appointment_config.html

@@ -21,11 +21,17 @@
 
         <div class="layui-form-item">
             <div class="layui-inline">
-                <label class="layui-form-label">爽约</label>
+                <label class="layui-form-label">限制</label>
+                <div class="layui-input-inline" style="width: 100px;">
+                    <input type="number" name="break_the_promise_day_range" placeholder="0" autocomplete="off" class="layui-input" value="{$web_config.break_the_promise_day_range}">
+                </div>
+                <div class="layui-form-mid">天内</div>
+                <div class="layui-form-mid">用户爽约</div>
                 <div class="layui-input-inline" style="width: 100px;">
                     <input type="number" name="break_the_promise_times" placeholder="0" autocomplete="off" class="layui-input" value="{$web_config.break_the_promise_times}">
                 </div>
                 <div class="layui-form-mid">次</div>
+                <div class="layui-form-mid">则后面</div>
                 <div class="layui-input-inline" style="width: 100px;">
                     <input type="number" name="stop_appointment_day" placeholder="0" autocomplete="off" class="layui-input" value="{$web_config.stop_appointment_day}">
                 </div>

+ 1 - 0
app/api/controller/Announcement.php

@@ -34,6 +34,7 @@ class Announcement extends Base
         } else {
             $pagenum = $this->request->param('pagenum', 20, 'intval');
             $datalist = ($this->getModel())->where($where)->order('id desc')->paginate($pagenum, true);
+            /** @var \app\common\model\Announcement $item */
             foreach ($datalist as $key => $item) {
                 $item['create_day'] = DateHelper::dateFormat($item->getData('create_time'), 'Y-m-d');
                 $item['thumb_url'] = $item->getThumb();

+ 37 - 3
app/api/controller/Appointment.php

@@ -4,7 +4,10 @@ namespace app\api\controller;
 
 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
 {
@@ -21,7 +24,7 @@ class Appointment extends Base
         }
 
         $where = [];
-        $addressIds = (new \app\common\model\Appointment())->availableAddressIds();
+        $addressIds = (new appointmentModel())->availableAddressIds();
         $where['id'] = ['in', $addressIds];
         $pagenum = $this->request->param('pagenum', 20, 'intval');
         $datalist = (new Address())->where($where)->paginate($pagenum, true);
@@ -51,21 +54,52 @@ class Appointment extends Base
         $tickets = $ticketModel->where('address_id', $address_id)->where('appointment_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;
             //拆分预约时段
-            //价格?
+            $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);
+
             $tickets[$k] = $item;
         }
 
         $this->json_success($tickets);
     }
 
+
+    /**
+     * @param $timePeriods array 拆分的时间段
+     * @param $ticketPeriods array 已经预约的时间段
+     * @return array
+     */
+    private function setPeriodStatus($timePeriods, $ticketPeriods)
+    {
+        $arr = [];
+        foreach ($timePeriods as $ticket => $period) {
+            if (in_array($period, $ticketPeriods)) {
+                $arr[] = ['period' => $period, 'status' => 1];
+            } else {
+                $arr[] = ['period' => $period, 'status' => 0];
+            }
+        }
+        return $arr;
+    }
+
     //按时间获取地址列表
     public function addressListByDayTime()
     {
-        \app\common\model\Appointment::createTicketFromAllAppointment();
+        appointmentModel::createTicketFromAllAppointment();
         $ticketModel = new AppointmentTicket();
 
         //可预约日期列表

+ 1 - 1
app/api/controller/Common.php

@@ -100,6 +100,6 @@ class Common extends Base
 
         //登入成功 ,返回 前端
         $return_url = session('return_url', '', 'login');
-        $this->redirect($return_url . '?jwt=' . Permissions::createJwt($user->id, $user->login_time));
+        $this->redirect($return_url . '?jwt=' . Permissions::createJwt($user->id, $user->login_time, 3600 * 24));
     }
 }

+ 5 - 0
app/api/controller/Specialist.php

@@ -33,6 +33,11 @@ class Specialist extends Base
         } else {
             $pagenum = $this->request->param('pagenum', 20, 'intval');
             $datalist = ($this->getModel())->where($where)->paginate($pagenum, true);
+            /** @var \app\common\model\Specialist $item */
+            foreach ($datalist as $key => $item) {
+                $item['head_pic'] = geturl($item->head_pic, '', true);
+                $datalist[$key] = $item;
+            }
         }
         if (empty($datalist)) {
             $this->json_error("没有数据");

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

@@ -9,8 +9,11 @@
 namespace app\api\controller;
 
 
-use app\common\model\Feedback;
 use app\api\controller\base\Permissions;
+use app\common\model\AppointmentApplication;
+use app\common\model\AppointmentTicket;
+use app\common\model\Feedback;
+use app\common\model\Webconfig;
 
 class User extends Permissions
 {
@@ -20,6 +23,124 @@ class User extends Permissions
         $this->json_success('success', $this->getUser());
     }
 
+    //预约申请
+    public function application()
+    {
+        $post = $this->request->param();
+        $validate = new \think\Validate([
+            ['name|姓名', 'require|max:50'],
+            ['age|年龄', 'number'],
+            ['birthday|出生年月', 'max:50'],
+            ['sex|性别', 'number|in:1,2'],
+            ['phone|电话', 'require|max:50'],
+            ['id_card|身份证', 'max:50'],
+            ['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'],
+        ]);
+        if (!$validate->check($post)) {
+            $this->json_error('提交失败:' . $validate->getError());
+        }
+
+        $model = new AppointmentApplication();
+
+        //爽约多少次后,多少天内不能再预约
+        $break_the_promise_day_range = Webconfig::getValue('break_the_promise_day_range');
+        $break_the_promise_times = Webconfig::getValue('break_the_promise_times');
+        $stop_appointment_day = Webconfig::getValue('stop_appointment_day');
+        //
+        if ($stop_appointment_day && $break_the_promise_times && $break_the_promise_day_range) {
+            $break_the_promise_count = $model->where('status', AppointmentApplication::STATUS_NOT_COME)->whereTime('finish_time', "-$break_the_promise_day_range day")->count();
+            if ($break_the_promise_count >= $break_the_promise_times) {
+                $maxtime = $model->where('status', AppointmentApplication::STATUS_NOT_COME)->max('finish_time');
+                if (time() < ($maxtime + $stop_appointment_day * 3600 * 24)) {
+                    $this->json_error("此账号 $break_the_promise_day_range 天内爽约 $break_the_promise_count 次, $stop_appointment_day 天内不能再预约");
+                }
+            }
+        }
+
+        //检测预约号源是否可预约
+        $ticket = AppointmentTicket::get($post['appointment_ticket_id']);
+        if (!$ticket) {
+            $this->json_error("获取预约号失败");
+        }
+
+        //已经预约的时间段
+        $ticketPeriods = (new AppointmentApplication())->where('appointment_ticket_id', $ticket->appointment_id)->column('appointment_time');
+        foreach ($ticketPeriods as $period) {
+            if ($period == $post['appointment_time']) {
+                $this->json_error("该时间已经被预约了,请重新选择时间");
+            }
+        }
+
+        //入库
+        $data = [
+            'name' => $post['name'],
+            'user_id' => $this->getUserId(),
+            'age' => $post['age']??0,
+            'birthday' => $post['birthday']??'',
+            'sex' => $post['sex']??0,
+            'phone' => $post['phone'],
+            'id_card' => $post['id_card']??'',
+            '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'],
+            'appointment_ticket_id' => $post['appointment_ticket_id'],
+            'appointment_time' => $post['appointment_time'],
+            'appointment_period' => $post['appointment_period'],
+            'status' => AppointmentApplication::STATUS_NOT_SIGN
+        ];
+        if (false === $model->allowField(true)->save($data)) {
+            $this->json_error("预约入库失败");
+        } else {
+            $this->json_success("预约成功");
+        }
+    }
+
+
+    //我的预约列表接口
+    public function applicationList()
+    {
+        $post = $this->request->param();
+        $validate = new \think\Validate([
+            ['status', 'number'],
+            ['page', 'number'],
+            ['pagenum', 'number|<=:1000']
+        ]);
+        if (!$validate->check($post)) {
+            $this->json_error('提交失败:' . $validate->getError());
+        }
+
+        $where = ['user_id' => $this->getUserId()];
+        $status = $this->request->param('status', 0, 'intval');
+        if ($status == 1) {
+            $where = ['finish_time' => 0];
+        } elseif ($status == 2) {
+            $where = ['finish_time' => ['>', 0]];
+        }
+        $pagenum = $this->request->param('pagenum', 20, 'intval');
+        $datalist = (new AppointmentApplication())->where($where)->order('create_time desc')->paginate($pagenum, true);
+        foreach ($datalist as $key => $item) {
+            //专家信息
+            $item->address;
+            $item->specialist;
+            $item->specialist->head_pic = geturl($item->specialist->head_pic, '', true);
+            $datalist[$key] = $item;
+        }
+        if (empty($datalist)) {
+            $this->json_error("没有数据");
+        }
+        $this->json_success("查询成功", $datalist);
+    }
+
+
     //提交反馈接口
     public function feedback()
     {
@@ -33,12 +154,14 @@ class User extends Permissions
         }
 
         $model = new Feedback();
-        $post['user_id'] = $this->getUserId();
-        $res = $model->allowField(true)->save($post);
-        if ($res) {
-            $this->json_success("成功");
-        } else {
+        $data = [
+            'user_id' => $this->getUserId(),
+            'content' => $post['content']
+        ];
+        if (false === $model->allowField(true)->save($data)) {
             $this->json_error("失败");
+        } else {
+            $this->json_success("成功");
         }
     }
 }

+ 2 - 0
app/api/controller/base/Base.php

@@ -20,6 +20,8 @@ use think\Request;
  */
 class Base extends Controller
 {
+    const ERR_CODE_LOGIN = 1;
+
     protected function _initialize()
     {
         (new WebService())->checkInstalled();

+ 19 - 23
app/api/controller/base/Permissions.php

@@ -37,12 +37,12 @@ class Permissions extends Base
             if (!$jwt) {
                 $callbackBody = file_get_contents('php://input');
                 if (!$callbackBody) {
-                    $this->json_error('请先登入');
+                    $this->json_error('请先登入', null, self::ERR_CODE_LOGIN);
                 }
                 $callbackJson = json_decode($callbackBody, true);
                 $jwt = isset($callbackJson['x-token']) ? $callbackJson['x-token'] : '';
                 if (!$jwt) {
-                    $this->json_error('请先登入');
+                    $this->json_error('请先登入', null, self::ERR_CODE_LOGIN);
                 }
             }
         }
@@ -72,29 +72,25 @@ class Permissions extends Base
                 return;
             }
         } catch (Exception $e) {
-            $this->json_error($this->getErrorMsg($e));
+            if ($e instanceof HttpResponseException) {
+                $this->json_error($e->getResponse()->getData()['msg']);
+            }
+            switch ($e->getMessage()) {
+                case "Expired token":
+                    self::clear_session();
+                    $this->json_error('登入超时,请重新登录', null, self::ERR_CODE_LOGIN);
+                    break;
+                case "Wrong number of segments":
+                    self::clear_session();
+                    $this->json_error('Token验证失败,请重新登录', null, self::ERR_CODE_LOGIN);
+                    break;
+                default:
+                    $msg = "error:" . $e->getMessage();
+                    $this->json_error($msg);
+            }
         }
     }
 
-    private function getErrorMsg(Exception $e)
-    {
-        if ($e instanceof HttpResponseException) {
-            return $e->getResponse()->getData()['msg'];
-        }
-        switch ($e->getMessage()) {
-            case "Expired token":
-                self::clear_session();
-                $msg = '登入超时,请重新登录';
-                break;
-            case "Wrong number of segments":
-                self::clear_session();
-                $msg = 'Token验证失败,请重新登录';
-                break;
-            default:
-                $msg = "error:" . $e->getMessage();
-        }
-        return $msg;
-    }
 
     /**
      * 获取登入token,并设置登入状态
@@ -137,7 +133,7 @@ class Permissions extends Base
         if (!$this->user) {
             $user = User::get($this->userId);
             if (!$user) {
-                $this->json_error('找不到用户信息,请重新登入');
+                $this->json_error('找不到用户信息,请重新登入', null, self::ERR_CODE_LOGIN);
             }
             $this->user = $user;
         }

+ 277 - 8
app/api/controller/接口文档.md

@@ -15,7 +15,19 @@
 登入成功将跳到地址: return_url?jwt={登入令牌}
 前端需获取jwt,用于后续部分用户权限接口
 ```
-
+```$xslt
+如何使用jwt:
+推荐在header里携带 x-token:jwt(安全性比较好),也可以get/post提交
+```
+```$xslt
+前端需要处理登入过期时的响应:
+{
+    "code": 0, // 返回状态,1代表成功,0代表失败
+    "msg": "登入过期", // 返回消息
+    "time": "1586490789", // 响应时间戳
+    "err_code" : 1 //判断code=0 且 err_code=1 时,表示需要重新登入
+}
+```
 
 # 提交反馈
 
@@ -31,7 +43,7 @@
 | content | 内容 |  max:500 |
 
 
-响应数据:
+响应数据:(json格式)
 ```json
 {
     "code": 1, // 返回状态,1代表成功,0代表失败
@@ -121,11 +133,12 @@
                 "id": 1,
                 "name": "张站长", //姓名
                 "title": "心里医生", //职称
-                "head_pic": "6", //头像
+                "head_pic": "http://xxxxxxxx", //头像
                 "sex": 1, //性别:0未知 1男 2女
-                "desc": "心里医生",
-                "consultation_direction": "心里医生",
-                "address_id": 1
+                "desc": "心里医生", //简介
+                "consultation_direction": "心里医生",//咨询方向
+                "address_id": 1, //地址id
+                "phone":"123123" //联系电话
             }
         ]
     }
@@ -181,9 +194,116 @@
 
 请求数据:
 
+| 参数名 | 说明  | 备注  |
+| ---   | ---   | ---  |
+|  address_id    | 地址ID           |  必填,int   |
+|  daytime     |  日期,默认今天     |  dateFormat:y-m-d   |
+
 响应数据:(json格式)
 ```json
-
+{
+    "code": 1,
+    "err_code": 0,
+    "msg": [
+        {
+            "id": 3,               //号源ID
+            "appointment_id": 1,
+            "appointment_daytime": 1682265600,         //排号日期
+            "appointment_daytime_text": "2023-04-24",   //排号日期
+            "provider_id": 3,
+            "address_id": 1,
+            "morning_use": 1,              // 上午已被领取(预约号个数)
+            "afternoon_use": 11,           // 下午已被领取
+            "night_use": 0,               // 晚上已被领取
+            "price": 12,                  //服务价格
+            "morning_remaining": 29,      // 上午剩余(预约号个数)
+            "afternoon_remaining": 10,    // 下午剩余
+            "night_remaining": 10,        // 晚上剩余
+            "morning_time_period": [
+                {
+                    "period": "08:00:00 - 08:08:00",   // 上午可预约时间段
+                    "status": 0                        // 状态 , 0 可预约 , 1 已被预约
+                },
+                {
+                    "period": "08:08:00 - 08:16:00",
+                    "status": 0
+                },
+                {
+                    "period": "08:16:00 - 08:24:00",
+                    "status": 0
+                },
+                {
+                    "period": "08:24:00 - 08:32:00",
+                    "status": 0
+                },
+                {
+                    "period": "08:32:00 - 08:40:00",
+                    "status": 0
+                }
+            ],
+            "afternoon_time_period": [                 // 下午可预约时间段
+                {
+                    "period": "14:00:00 - 18:00:00",
+                    "status": 0
+                }
+            ],
+            "night_time_period": [                     // 晚上可预约时间段
+                {
+                    "period": "20:00:00 - 20:23:59",
+                    "status": 0
+                },
+                {
+                    "period": "20:23:59 - 20:47:58",
+                    "status": 0
+                },
+                {
+                    "period": "20:47:58 - 21:11:57",
+                    "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": "王医生",
+                "title": "妇科大夫",
+                "head_pic": "",
+                "sex": 0,
+                "desc": "妇科大夫",
+                "consultation_direction": "妇科大夫",
+                "address_id": 1,
+                "phone": ""
+            }
+        },
+        {
+            //其他号源信息
+        },
+        {
+            //其他号源信息
+        }
+    ],
+    "time": "1682318054",
+    "data": null
+}
 ```
 
 
@@ -224,4 +344,153 @@
         ]
     }
 }
-```
+```
+
+# 预约申请
+
+接口地址:/api/user/application
+
+请求方式:get / post
+
+| 参数名 | 说明  | 备注  |
+| ---   | ---   | ---  |
+| x-token   | 登入令牌jwt |  require必填 |
+| name   | 姓名 |  require , max:50 |
+| age     | 年龄 |  int  |
+| birthday   | 出生年月 |  string , max:50 |
+| sex   | 性别:1男 2女 |  int |
+| phone   | 电话 |  require,max:50 |
+| id_card   | 身份证 |  max:50 |
+| 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 |
+
+响应数据:
+```json
+{
+    "code": 0,
+    "err_code": 0,
+    "msg": "此账号 30 天内爽约 3 次, 2 天内不能再预约",
+    "time": "1682333036",
+    "data": null
+}
+```
+```json
+{
+    "code": 1,
+    "err_code": 0,
+    "msg": " 预约成功",
+    "time": "1682332924",
+    "data": null
+}
+```
+
+# 我的预约列表
+
+接口地址:/api/user/applicationList
+
+请求方式:get / post
+
+| 参数名 | 说明  | 备注  |
+| ---   | ---   | ---  |
+| x-token   | 登入令牌jwt      |  必填 |
+| status   | 状态 (默认0): 0全部,1待完成,2已完成   |  int  |
+|  page    | 第几页,默认1      |  int   |
+|  pagenum | 每页几条,默认20   |  int,<=:1000 |
+
+响应数据:
+```json
+{
+    "code": 1,
+    "err_code": 0,
+    "msg": "查询成功",
+    "time": "1682333270",
+    "data": {
+        "per_page": 20,
+        "current_page": 1,
+        "has_more": false,
+        "next_item": null,
+        "data": [
+            {
+                "id": 3,
+                "name": "小明",
+                "user_id": 1,
+                "age": 0,
+                "birthday": "",
+                "sex": 0,
+                "phone": "1231214545",
+                "id_card": "",
+                "childs_num": 0,
+                "problem_desc": "",
+                "requirement_desc": "",
+                "address_id": "1",
+                "provider_id": 1,
+                "appointment_ticket_id": 1,
+                "appointment_time": "08:00:00 - 12:00:00",
+                "status": 0,
+                "remark": "",
+                "create_time": "2023-04-24 18:42:04",
+                "finish_time": "",
+                "address": {
+                    "id": 1,
+                    "title": "厦门曙光医院",
+                    "address": "福建省厦门市湖里区金尚路127号"
+                },
+                "specialist": {
+                    "id": 1,
+                    "name": "张站长",
+                    "title": "心里医生",
+                    "head_pic": "https:\/\/iph.href.lu\/400x200\/?text=%E5%BF%83%E9%87%8C%E5%92%A8%E8%AF%A2&fg=666666&bg=cccccc",
+                    "sex": 2,
+                    "desc": "心里医生",
+                    "consultation_direction": "心里医生",
+                    "address_id": 1,
+                    "phone": "12121212"
+                }
+            },
+            {
+                "id": 2,
+                "name": "小明",
+                "user_id": 1,
+                "age": 0,
+                "birthday": "",
+                "sex": 0,
+                "phone": "1231214545",
+                "id_card": "",
+                "childs_num": 0,
+                "problem_desc": "",
+                "requirement_desc": "",
+                "address_id": "1",
+                "provider_id": 1,
+                "appointment_ticket_id": 1,
+                "appointment_time": "08:00:00 - 12:00:00",
+                "status": 0,
+                "remark": "",
+                "create_time": "2023-04-24 18:42:02",
+                "finish_time": "",
+                "address": {
+                    "id": 1,
+                    "title": "厦门曙光医院",
+                    "address": "福建省厦门市湖里区金尚路127号"
+                },
+                "specialist": {
+                    "id": 1,
+                    "name": "张站长",
+                    "title": "心里医生",
+                    "head_pic": "https:\/\/iph.href.lu\/400x200\/?text=%E5%BF%83%E9%87%8C%E5%92%A8%E8%AF%A2&fg=666666&bg=cccccc",
+                    "sex": 2,
+                    "desc": "心里医生",
+                    "consultation_direction": "心里医生",
+                    "address_id": 1,
+                    "phone": "12121212"
+                }
+            }
+        ]
+    }
+}
+```

+ 2 - 7
app/common/model/Announcement.php

@@ -39,19 +39,14 @@ class Announcement extends Model
     public function getThumb($host = true)
     {
         if ($this->thumb) {
-            $thumb_url = geturl($this->thumb);
-            if (startWith($thumb_url, 'http')) {
-                return $thumb_url;
-            } else {
-                return url($thumb_url, '', false, $host);
-            }
+            return geturl($this->thumb, '', $host);
         } else {
             //尝试从内容中提取图片
             if (empty($this->content)) {
                 return "";
             }
             $imgs = matchImg($this->content);
-            return count($imgs) == 0 ? "" : $imgs[0];
+            return count($imgs) == 0 ? "" : url($imgs[0], '', false, $host);
         }
     }
 }

+ 1 - 4
app/common/model/Appointment.php

@@ -24,16 +24,13 @@ class Appointment extends Model
     public function createTicket()
     {
         if (!$this->ifExitsTicket()) {
-            $daylist = DateHelper::getDateList($this->start_time, $this->end_time, true);
+            $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,
-                    'morning_num' => $this->morning_num,
-                    'afternoon_num' => $this->afternoon_num,
-                    'night_num' => $this->night_num,
                 ]);
             }
             $this->save(['ticket_status' => 1]);

+ 16 - 0
app/common/model/AppointmentApplication.php

@@ -8,9 +8,25 @@ class AppointmentApplication extends Model
 {
     protected $updateTime = false;
 
+    const STATUS_NOT_SIGN = 0;
+    const STATUS_SIGN = 1;
+    const STATUS_NOT_COME = 2;
+
+    //finish_time
     public function getFinishTimeAttr($value, $data)
     {
         return $value ? date('Y-m-d H:i:s', $value) : '';
     }
 
+    //关联地址
+    public function address()
+    {
+        return $this->belongsTo('Address');
+    }
+
+    //关联专家
+    public function specialist()
+    {
+        return $this->belongsTo('Specialist', 'provider_id');
+    }
 }

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

@@ -13,4 +13,11 @@ class AppointmentTicket extends Model
     {
         return $this->belongsTo('Specialist', 'provider_id');
     }
+
+    //关联放号配置
+    public function appointment()
+    {
+        return $this->belongsTo('Appointment');
+    }
+
 }

+ 6 - 4
app/common/model/Article.php

@@ -47,19 +47,21 @@ class Article extends Model
     }
 
     /**
-     * 获取缩略图,尝试从内容中提取
+     * 获取缩略图
+     * @param $host bool/string 可指定域名,默认当前域名
      * @return bool|mixed|string
      */
-    public function getThumb()
+    public function getThumb($host = true)
     {
         if ($this->thumb) {
-            return geturl($this->thumb);
+            return geturl($this->thumb, '', $host);
         } else {
+            //尝试从内容中提取图片
             if (empty($this->content)) {
                 return "";
             }
             $imgs = matchImg($this->content);
-            return count($imgs) == 0 ? "" : $imgs[0];
+            return count($imgs) == 0 ? "" : url($imgs[0], '', false, $host);
         }
     }
 

+ 10 - 4
app/helper_env.php

@@ -122,9 +122,10 @@ function system_salt()
  * 获取附件表的url
  * @param $id int 附件表的id
  * @param $default string 设置空时的默认值
+ * @param $host bool/string 可指定域名,默认当前域名
  * @return bool|mixed|string
  */
-function geturl($id, $default = '')
+function geturl($id, $default = '', $host = true)
 {
     if ($id) {
         $attachment = \think\Db::name("attachment")->where(['id' => $id])->find();
@@ -133,13 +134,18 @@ function geturl($id, $default = '')
         }
         if ($attachment['status'] == 1) {
             //审核通过
-            return replaceUrlDS($attachment['filepath']);
+            $thumb_url = replaceUrlDS($attachment['filepath']);
         } elseif ($attachment['status'] == 0) {
             //待审核
-            return '/static/public/images/shenhe.jpg';
+            $thumb_url = '/static/public/images/shenhe.jpg';
         } else {
             //不通过
-            return '/static/public/images/shenhe.jpg';
+            $thumb_url = '/static/public/images/shenhe.jpg';
+        }
+        if (startWith($thumb_url, 'http')) {
+            return $thumb_url;
+        } else {
+            return url($thumb_url, '', false, $host);
         }
     }
     return $default;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 92 - 85
app/install/data/db.sql


+ 31 - 1
extend/time/DateHelper.php

@@ -100,7 +100,7 @@ class DateHelper
      * @return array
      * @throws Exception
      */
-    public static function getDateList($startTime, $endTime, $inclued = false, $format = 'Y-m-d', $interval = 'tomorrow')
+    public static function dateTimeList($startTime, $endTime, $inclued = false, $format = 'Y-m-d', $interval = 'tomorrow')
     {
         $starttime = strtotime($startTime);
         $endtime = strtotime($endTime);
@@ -142,4 +142,34 @@ class DateHelper
         return $arr;
     }
 
+    /**
+     * 拆分时段
+     * @param $start
+     * @param $end
+     * @param $count
+     * @param $format string 返回的日期格式
+     * @return array
+     */
+    public static function splitTimePeriod($start, $end, $count, $format = 'H:i:s')
+    {
+        $count = $count <= 0 ? 1 : $count;
+        $second_total = strtotime($end) - strtotime($start);
+        $arr = [];
+        if ($count > 1) {
+            $interval = floor($second_total / $count);
+            $time_period = DateHelper::dateTimeList($start, $end, false, $format, "+ $interval seconds");
+            foreach ($time_period as $k => $period) {
+                if ($k == 0) {
+                    $arr[] = $start . " - " . $period;
+                } else {
+                    $arr[] = $time_period[$k - 1] . " - " . $period;
+                }
+            }
+            $arr[] = end($time_period) . " - " . $end;
+        } else {
+            $arr[] = $start . " - " . $end;
+        }
+        return $arr;
+    }
+
 }

+ 1 - 1
extend/time/Timestamp.php

@@ -65,7 +65,7 @@ class Timestamp
      * @param $endTime
      * @return array
      */
-    public static function getDayTimestampList($startTime, $endTime)
+    public static function dayTimeRangeList($startTime, $endTime)
     {
         $begin = self::dayStart($endTime);
         $arr = [];

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio