zilong %!s(int64=4) %!d(string=hai) anos
pai
achega
f39b729768

+ 4 - 0
app/Community/Controllers/VaccineController.php

xqd
@@ -65,6 +65,10 @@ class VaccineController extends AdminController
 //        });
         $grid->column('supplier', __('厂家'));
         $grid->column('remark', __('备注'));
+        $grid->column('appoint_week_text', __('可预约时间'))->display(function ($appoint_week_text) {
+            $id = $this->id;
+            return '<a href="/cdms/community/vaccineSetting/table?id='.$id.'">'.$appoint_week_text.'</a>';
+        });
         $grid->filter(function ($fliter){
             $fliter->like('name','疫苗');
             $fliter->equal('type','疫苗类型')->select(Vaccine::getType());

+ 69 - 0
app/Community/Controllers/VaccineSettingController.php

xqd
@@ -0,0 +1,69 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 2021/3/9
+ * Time: 11:10 下午
+ */
+
+namespace App\Community\Controllers;
+
+use App\Models\Vaccine;
+use App\Models\VaccineAppoint;
+use Encore\Admin\Controllers\AdminController;
+use Encore\Admin\Layout\Content;
+use Encore\Admin\Facades\Admin;
+
+class VaccineSettingController extends AdminController
+{
+    public function table()
+    {
+        $req = request()->query();
+        $vaccine = Vaccine::where('id', $req['id'])->first()->toArray();
+        $arr = VaccineAppoint::where('vaccine_id', $req['id'])->pluck('week_appoint')->toArray();
+
+        $content = new Content();
+        Admin::disablePjax();
+        $title = '['.$vaccine['name'].'] 可预约时间设置';
+        $data['req'] = $req;
+        $data['data'] = $arr;
+
+        return $content->title($title)->view('cdms/vaccine_setting_table', $data);
+    }
+
+    public function sumbit()
+    {
+        $req = request()->post();
+        if (empty($req['week_time_point_all']) && empty($req['week_time_point'])) {
+            return out(null, 10001, '请勾选');
+        }
+
+        VaccineAppoint::where('vaccine_id', $req['id'])->delete();
+        $appoint_week_arr = [];
+        $map = [11 => '周一上午', 12 => '周二上午', 13 => '周三上午', 14 => '周四上午', 15 => '周五上午', 16 => '周六上午', 17 => '周日上午', 21 => '周一下午', 22 => '周二下午', 23 => '周三下午', 24 => '周四下午', 25 => '周五下午', 26 => '周六下午', 27 => '周日下午'];
+        $tmp = [];
+        if (empty($req['week_time_point_all']) && !empty($req['week_time_point'])) {
+            foreach ($req['week_time_point'] as $k => $v) {
+                VaccineAppoint::create(['vaccine_id' => $req['id'], 'week_appoint' => $v]);
+                $i = $v + 10;
+                if (in_array($i, $req['week_time_point'])) {
+                    $appoint_week_arr[] = mb_substr($map[$v], 0, 2).'全天';
+                    $tmp[] = $i;
+                }
+                else {
+                    if (!in_array($v, $tmp)) {
+                        $appoint_week_arr[] = $map[$v];
+                    }
+                }
+            }
+        }
+
+        $appoint_week_text = '不限';
+        if (!empty($appoint_week_arr)) {
+            $appoint_week_text = implode(',', $appoint_week_arr);
+        }
+        Vaccine::where('id', $req['id'])->update(['appoint_week_text' => $appoint_week_text]);
+
+        return out();
+    }
+}

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

xqd xqd
@@ -167,7 +167,7 @@ class OrderController extends AuthController
                 return out(null, 10012, '医生无该时间段的排班');
             }
             $docterSettings = DocterSetting::select(['service_num'])->where('docter_id', $req['docter_id'])->where('type', 1)->first();
-            if ($docterSettings['service_num'] <= $schedulePeriod['order_sn']) {
+            if ($docterSettings['service_num'] <= $schedulePeriod['order_num']) {
                 return out(null, 10014, '医生该时间段已经预约满了');
             }
         }
@@ -178,7 +178,7 @@ class OrderController extends AuthController
                 return out(null, 10013, '机构无该时间段的排班');
             }
             $docterSettings = DocterSetting::select(['service_num'])->where('org_id', $req['organization_id'])->where('type', $schedule_type_map[$product_type])->first();
-            if ($docterSettings['service_num'] <= $schedulePeriod['order_sn']) {
+            if ($docterSettings['service_num'] <= $schedulePeriod['order_num']) {
                 return out(null, 10015, '机构该时间段已经预约满了');
             }
         }

+ 6 - 4
app/Models/Order.php

xqd xqd xqd
@@ -162,11 +162,13 @@ class Order extends BaseModel
             UserMessage::saveMessage($order['user_id'], 7, $order_id, [round($order['total_amount']/100, 2), round($user['balance']/100, 2)]);
         }
         //发送余额付款成功消息
-        if ($order['payment_type'] == 2) {
+        if ($order['payment_type'] == 2 && $order['product_type'] != 4) {
             UserMessage::saveMessage($order['user_id'], 8, $order_id, [round($order['payment_amount']/100, 2), round($user['balance']/100, 2)]);
         }
         //发送医生端消息
-        DocterMessage::saveMessage($order['docter_id'], $order['user_id'], 1, $order_id, [$order['order_sn']]);
+        if (!empty($order['docter_id'])) {
+            DocterMessage::saveMessage($order['docter_id'], $order['user_id'], 1, $order_id, [$order['order_sn']]);
+        }
 
         //如果是服务包支付的,就扣服务包的次数
         if ($order['payment_type'] == 3) {
@@ -389,7 +391,7 @@ class Order extends BaseModel
                 exit_out(null, 10012, '医生无该时间段的排班');
             }
             $docterSettings = DocterSetting::select(['service_num'])->where('docter_id', $order['docter_id'])->where('type', 1)->first();
-            if ($docterSettings['service_num'] <= $schedulePeriod['order_sn']) {
+            if ($docterSettings['service_num'] <= $schedulePeriod['order_num']) {
                 exit_out(null, 10014, '医生该时间段已经预约满了');
             }
         }
@@ -405,7 +407,7 @@ class Order extends BaseModel
                 exit_out(null, 10013, '机构无该时间段的排班');
             }
             $docterSettings = DocterSetting::select(['service_num'])->where('org_id', $order['organization_id'])->where('type', $schedule_type_map[$product_type])->first();
-            if ($docterSettings['service_num'] <= $schedulePeriod['order_sn']) {
+            if ($docterSettings['service_num'] <= $schedulePeriod['order_num']) {
                 exit_out(null, 10015, '机构该时间段已经预约满了');
             }
         }

+ 5 - 0
app/Models/Vaccine.php

xqd
@@ -43,4 +43,9 @@ class Vaccine extends BaseModel
     public function organizationvaccines(){
         return $this->hasMany(OrganizationVaccines::class,'vaccine_id');
     }
+
+    public function vaccineAppoint()
+    {
+        return $this->hasMany(VaccineAppoint::class);
+    }
 }

+ 14 - 0
app/Models/VaccineAppoint.php

xqd
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: zilongs
+ * Date: 2021/3/10
+ * Time: 11:44 上午
+ */
+
+namespace App\Models;
+
+class VaccineAppoint extends BaseModel
+{
+
+}

+ 66 - 0
resources/views/cdms/vaccine_setting_table.blade.php

xqd
@@ -0,0 +1,66 @@
+<form id="commentForm">
+    <div class="row">
+        <input name="id" type="hidden" value="{{$req['id']}}">
+        <div class="col-lg-12" style="margin-bottom: 10px;margin-left: 10px;">
+            <input class="week_time_point_all" name="week_time_point_all" <?php if (empty($data)) { echo 'checked'; } ?> type="checkbox" value="1"><span style="margin-left: 6px;">不限</span>
+        </div>
+        <div class="col-lg-12">
+            <div class="box-body table-responsive no-padding">
+                <table class="table table-bordered table-hover table-striped" style="text-align: center;">
+                    <tbody>
+                        <tr style="color: #ecf0f4;background-color: #3c8dbc;">
+                            <th></th>
+                            <th style="text-align: center">周一</th>
+                            <th style="text-align: center">周二</th>
+                            <th style="text-align: center">周三</th>
+                            <th style="text-align: center">周四</th>
+                            <th style="text-align: center">周五</th>
+                            <th style="text-align: center">周六</th>
+                            <th style="text-align: center">周日</th>
+                        </tr>
+                        <tr>
+                            <td>上午</td>
+                            <?php for ($i = 11; $i <= 17; $i++) { ?>
+                                <td><input class="week_time_point" <?php if (in_array($i, $data)) { echo 'checked'; } ?> name="week_time_point[]" type="checkbox" value="{{$i}}"></td>
+                            <?php } ?>
+                        </tr>
+                        <tr>
+                            <td>下午</td>
+                            <?php for ($i = 21; $i <= 27; $i++) { ?>
+                            <td><input class="week_time_point" <?php if (in_array($i, $data)) { echo 'checked'; } ?> name="week_time_point[]" type="checkbox" value="{{$i}}"></td>
+                            <?php } ?>
+                        </tr>
+                    </tbody>
+                </table>
+            </div>
+        </div>
+        <div class="col-lg-12" style="text-align: center;margin-top: 10px;">
+            <button type="button" class="btn btn-primary" onclick="sub()">提 交</button>
+        </div>
+    </div>
+</form>
+
+<script src="/layui/layer/layer.js"></script>
+<script>
+    $(function () {
+        $('.week_time_point').click(function () {
+            $('.week_time_point_all').removeAttr('checked');
+        });
+
+        $('.week_time_point_all').click(function () {
+            $('.week_time_point').removeAttr('checked');
+        });
+    })
+
+    function sub()
+    {
+        $.post('{{url("/cdms/community/vaccineSetting/sumbit")}}', $('#commentForm').serialize(), function (res) {
+            if (res.status == 0){
+                window.location.href = document.referrer;
+            }
+            else {
+                layer.msg(res.message, {icon: 5, time: 3000});
+            }
+        });
+    }
+</script>

+ 20 - 0
upgrade.md

xqd
@@ -2,6 +2,26 @@
 - 执行以下sql:
     ALTER TABLE `bm_orders` 
     ADD COLUMN `cancel_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '取消订单时间' AFTER `receiving_time`;
+
 - 线上.env添加如下配置
     DOCTER_WECHAT_APPID=wx6df68b725662f8a3
     DOCTER_MNWECHAT_APPID=wx1dcbf8ce4bca6870
+    
+----以上线上已更新----
+
+###后台疫苗排班的更新
+- 执行以下sql:
+    ALTER TABLE `bm_vaccines` 
+    ADD COLUMN `appoint_week_text` varchar(255) NOT NULL DEFAULT '不限' COMMENT '预约周的具体时间点描述' AFTER `states`;
+    
+    CREATE TABLE `bm_vaccine_appoints` (
+      `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
+      `vaccine_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '疫苗ID',
+      `week_appoint` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '周的可接种的具体时间点',
+      `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+      `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+      PRIMARY KEY (`id`),
+      KEY `vaccine_id` (`vaccine_id`)
+    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+- 线上在社区端后台改消息通知的菜单链接为:/cdms/community/noticeManage/noticelist