Forráskód Böngészése

fix:
- 生成号源配置
- 公告管理添加配图
- 公告管理接口返回图带上域名
- 按地点预约列表接口

zzb 2 éve
szülő
commit
e63df852ae

+ 2 - 0
app/admin/controller/Announcement.php

@@ -6,6 +6,7 @@ use app\admin\controller\base\Permissions;
 use think\Db;
 use think\Session;
 
+//公告管理
 class Announcement extends Permissions
 {
     private function getModel()
@@ -42,6 +43,7 @@ class Announcement extends Permissions
             $adminIdAndName = $adminModel->column('nickname', 'id');
             foreach ($data as $key => $value) {
                 $value['admin_name'] = $adminIdAndName[$value['admin_id']]??"";
+                $value['thumb_url'] = geturl($value['thumb']);
                 $data[$key] = $value;
             }
             return array('code' => 0, 'count' => $count, 'data' => $data);

+ 2 - 0
app/admin/controller/Appointment.php

@@ -102,6 +102,8 @@ class Appointment extends Permissions
             if (!$validate->check($post)) {
                 $this->error('提交失败:' . $validate->getError());
             }
+        } else {
+            $this->assign('phone', (new \app\common\model\Specialist())->where('id', $pid)->value('phone'));
         }
 
         if ($id > 0) {

+ 1 - 0
app/admin/controller/Specialist.php

@@ -75,6 +75,7 @@ class Specialist extends Permissions
                 ['desc|简介', 'max:500'],
                 ['consultation_direction|咨询方向', 'max:500'],
                 ['address_id|地址', 'require|number'],
+                ['phone|联系电话', 'max:50'],
             ]);
             if (!$validate->check($post)) {
                 $this->error('提交失败:' . $validate->getError());

+ 5 - 0
app/admin/view/announcement/index.html

@@ -104,6 +104,11 @@
 
                     {field: 'id', title: 'ID', width: 60},
                     {field: "title", title: '标题'},
+                    {
+                        field: 'image', title: '缩略图', width: 70, align: 'center', templet: function (row) {
+                        return (row.thumb_url == '') ? '' : '<a href="' + row.thumb_url + '" class="tooltip" target="_blank"><img src="' + row.thumb_url + '" width="20" height="20"></a>';
+                    }
+                    },
                     {field: "admin_name", title: '创建人'},
                     {field: "create_time", title: '日期'},
                     {field: 'action', title: '操作', toolbar: '#barDemo', fixed: 'right'}

+ 28 - 0
app/admin/view/announcement/publish.html

@@ -48,6 +48,16 @@
                        name="$data" }value="{$data.title}" {/notempty}>
             </div>
         </div>
+
+        <div class="layui-upload">
+            <label class="layui-form-label">配图</label>
+            <div class="layui-upload-list" style="margin-top: 0px">
+                <img class="layui-upload-img" id="upload_img" {notempty name="$data.thumb"}src='{$data.thumb|geturl}'{/notempty}>
+                <input type="hidden" name="thumb" id="upload_value" value='{notempty name="$data.thumb"}{$data.thumb}{/notempty}'>
+            </div>
+        </div>
+
+
         <!-- 文章富文本 -->
 
         {php}$web_config = \think\Db::name('webconfig')->where('id', 1)->find();{/php}
@@ -113,6 +123,24 @@
             });
         });
     </script>
+
+    <script>
+        $(function () {
+            $('#upload_img').click(function () {
+                layer.open({
+                    type: 2,
+                    title: '选择图片',
+                    area: ['570px', '485px'],
+                    id: 'layerDemo', //防止重复弹出
+                    anim: 4,
+                    content: "{:url('Attachment/selectimage')}",
+                    cancel: function () {
+                        //右上角关闭回调
+                    }
+                });
+            })
+        })
+    </script>
 </div>
 </body>
 </html>

+ 1 - 1
app/admin/view/appointment/publish.html

@@ -107,7 +107,7 @@
             <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" {notempty name="$data" }value="{$data.phone}" {/notempty}>
+                       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>

+ 24 - 14
app/admin/view/specialist/publish.html

@@ -78,20 +78,7 @@
                        value="2" } checked {/eq}{/notempty}>
             </div>
         </div>
-        <!-- 纯文本段落 -->
-        <div class="layui-form-item layui-form-text">
-            <label class="layui-form-label">简介</label>
-            <div class="layui-input-inline" style="width:80%;">
-                <textarea name="desc" class="layui-textarea">{notempty name="$data"}{$data.desc}{/notempty}</textarea>
-            </div>
-        </div>
-        <!-- 纯文本段落 -->
-        <div class="layui-form-item layui-form-text">
-            <label class="layui-form-label">咨询方向</label>
-            <div class="layui-input-inline" style="width:80%;">
-                <textarea name="consultation_direction" class="layui-textarea">{notempty name="$data"}{$data.consultation_direction}{/notempty}</textarea>
-            </div>
-        </div>
+
         <!-- 下拉框 -->
         <div class="layui-form-item">
             <label class="layui-form-label">地址</label>
@@ -108,6 +95,29 @@
             <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="phone" lay-verify="" autocomplete="off" placeholder="请输入" class="layui-input"
+                       type="text" {notempty name="$data" }value="{$data.phone}" {/notempty}>
+            </div>
+        </div>
+
+        <!-- 纯文本段落 -->
+        <div class="layui-form-item layui-form-text">
+            <label class="layui-form-label">简介</label>
+            <div class="layui-input-inline" style="width:80%;">
+                <textarea name="desc" class="layui-textarea">{notempty name="$data"}{$data.desc}{/notempty}</textarea>
+            </div>
+        </div>
+        <!-- 纯文本段落 -->
+        <div class="layui-form-item layui-form-text">
+            <label class="layui-form-label">咨询方向</label>
+            <div class="layui-input-inline" style="width:80%;">
+                <textarea name="consultation_direction" class="layui-textarea">{notempty name="$data"}{$data.consultation_direction}{/notempty}</textarea>
+            </div>
+        </div>
 
         {notempty name="$data"}
         <input type="hidden" name="id" value="{$data.id}">

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

@@ -36,6 +36,8 @@ class Announcement extends Base
             $datalist = ($this->getModel())->where($where)->order('id desc')->paginate($pagenum, true);
             foreach ($datalist as $key => $item) {
                 $item['create_day'] = DateHelper::dateFormat($item->getData('create_time'), 'Y-m-d');
+                $item['thumb_url'] = $item->getThumb();
+                $item['content'] = $item->getContent();
                 $datalist[$key] = $item;
             }
         }

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

@@ -0,0 +1,25 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\controller\base\Base;
+
+class Appointment extends Base
+{
+    private function getModel()
+    {
+        return new \app\common\model\Appointment();
+    }
+
+    //按地点预约列表接口
+    public function listByAddress()
+    {
+        $this->json_success("查询成功", $this->getModel()->listByAddress());
+    }
+
+    //按时间预约列表接口
+    public function listByDayTime()
+    {
+
+    }
+}

+ 31 - 0
app/api/controller/接口文档.md

@@ -69,6 +69,7 @@
             {
                 "id": 1,
                 "title": "联系我们",
+                "thumb_url": "http://local.appointment.com/uploads/admin/article_content/20230421/ee2a2b125a3c174e11683530a931a69e.jpg"
                 "content": "<p>我们的地址是 xxx 市区 xxx 街道 xxx 号<\/p><p><br\/><\/p><p><img src=\"http:\/\/local.appointment.com\/static\/public\/images\/tx.jpg\" style=\"max-width:100%;\"\/><br\/><\/p>",
                 "admin_id": 1,
                 "create_time": "2023-04-20 23:48:32"
@@ -76,6 +77,7 @@
             {
                 "id": 2,
                 "title": "测试",
+                "thumb_url": "http://local.appointment.com/uploads/admin/article_content/20230421/ee2a2b125a3c174e11683530a931a69e.jpg"
                 "content": "<p>测试<img src=\"\/uploads\/admin\/article_content\/20230421\/ee2a2b125a3c174e11683530a931a69e.jpg\" style=\"max-width: 100%;\"\/><\/p>",
                 "admin_id": 2,
                 "create_time": "2023-04-21 18:58:00"
@@ -124,4 +126,33 @@
         ]
     }
 }
+```
+
+# 按地点预约列表接口
+接口地址:/api/appointment/listByAddress
+
+请求方式:get / post
+
+请求数据:无
+
+响应数据:(json格式)
+```
+{
+    "code": 1,
+    "err_code": 0,
+    "msg": "查询成功",
+    "time": "1682250564",
+    "data": [
+        {
+            "id": 1,
+            "title": "厦门曙光医院",
+            "address": "福建省厦门市湖里区金尚路127号"
+        },
+        {
+            "id": 2,
+            "title": "厦门前埔医院",
+            "address": "地址 : 福建省厦门市湖里区仙岳路3777号\r\n电话 : 0592-5262666"
+        }
+    ]
+}
 ```

+ 47 - 0
app/common/model/Announcement.php

@@ -4,7 +4,54 @@ namespace app\common\model;
 
 use think\Model;
 
+//公告表
 class Announcement extends Model
 {
     protected $updateTime = false;
+
+    /**
+     * 获取内容
+     * @param $host bool/string 可指定域名,默认当前域名
+     * @return mixed|string
+     */
+    public function getContent($host = true)
+    {
+        if (empty($this->content)) {
+            return "";
+        }
+        $content = $this->content;
+        $imgs = matchImg($this->content);
+        foreach ($imgs as $image) {
+            if (startWith($image, 'http')) {
+                continue;
+            }
+            $full_image = url($image, '', false, $host);//加上域名
+            $content = str_replace($image, $full_image, $content);
+        }
+        return $content;
+    }
+
+    /**
+     * 获取缩略图
+     * @param $host bool/string 可指定域名,默认当前域名
+     * @return bool|mixed|string
+     */
+    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);
+            }
+        } else {
+            //尝试从内容中提取图片
+            if (empty($this->content)) {
+                return "";
+            }
+            $imgs = matchImg($this->content);
+            return count($imgs) == 0 ? "" : $imgs[0];
+        }
+    }
 }

+ 52 - 0
app/common/model/Appointment.php

@@ -2,7 +2,9 @@
 
 namespace app\common\model;
 
+use think\Db;
 use think\Model;
+use time\DateHelper;
 
 class Appointment extends Model
 {
@@ -18,4 +20,54 @@ class Appointment extends Model
         return $value ? date('Y-m-d', $value) : '';
     }
 
+    //生成号源配置
+    public function createTicket()
+    {
+        if (!$this->ifExitsTicket()) {
+            $daylist = DateHelper::getDateList($this->start_time, $this->end_time);
+            foreach ($daylist as $datetime) {
+                (new AppointmentTicket())->save([
+                    'appointment_id' => $this->id,
+                    'appointment_daytime' => strtotime($datetime),
+                    'address_id' => $this->specialist->address_id
+                ]);
+            }
+            $this->save(['ticket_status' => 1]);
+        }
+    }
+
+    //是否已生成号源配置
+    public function ifExitsTicket()
+    {
+        return $this->ticket_status > 0;
+    }
+
+    //是否已存在预约订单
+    public function ifExitsAppointmentApplication()
+    {
+
+    }
+
+    /**
+     * 按地点获取预约列表
+     * @return false|\PDOStatement|string|\think\Collection
+     */
+    public static function listByAddress()
+    {
+        //未结束的预约都保证生成了号源
+        $all = (new Appointment())->where('end_time', '>', time())->select();
+        /** @var  $item Appointment */
+        foreach ($all as $item) {
+            $item->createTicket();
+        }
+
+        $addressIds = (new AppointmentTicket())->where('appointment_daytime', '>=', strtotime(date('Y-m-d')))->distinct('true')->column('address_id');
+        return (new Address())->where('id', 'in', $addressIds)->select();
+    }
+
+    //关联专家
+    public function specialist()
+    {
+        return $this->belongsTo('Specialist', 'provider_id');
+    }
 }

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

@@ -0,0 +1,10 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+class AppointmentTicket extends Model
+{
+    protected $autoWriteTimestamp = false;
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 81 - 35
app/install/data/db.sql


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott