소스 검색

Merge branch 'master' of ssh://git.9026.com:2212/swdz-WangHaijun/BaoMa into develop

Mike 4 년 전
부모
커밋
911984f9cc

+ 3 - 2
app/Admin/Controllers/UserManagement/DocterManagement/DoctorManagementController.php

xqd
@@ -94,8 +94,9 @@ class DoctorManagementController extends AdminController
                 return $name;
             }
         })->label('info');
-        $grid->column('serviceapply', __('开通服务'))->where('status',2)->pluck('service_type')->display(function ($type){
-//            dd($type);
+        $grid->column('serviceapply', __('开通服务'))->where('status',2)->pluck('service_type')->toArray()->display(function ($type){
+            $type = array_unique($type);
+            dd($type);
             $type_arr = [];
             foreach ($type as $value)
             {

+ 0 - 7
app/Admin/Controllers/VaccinesManagement/VaccinesController.php

xqd xqd
@@ -32,12 +32,6 @@ class VaccinesController extends AdminController
         $grid->column('id', __('Id'));
         $grid->column('type', '类型')->using([1=>'Ⅰ类疫苗',2=>'Ⅱ类疫苗']);
         $grid->column('name', __('名称'));
-//        $grid->column('introduction','简介');
-        $grid->column('price', __('价钱'))->display(function ($v){
-            return round($v/100,4).'元';
-        });
-        $grid->column('remark', __('备注'));
-        $grid->column('supplier', __('厂家'));
         $states = [
             'on'  => ['value' => 1, 'text' => '启用', 'color' => 'success'],
             'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
@@ -60,7 +54,6 @@ class VaccinesController extends AdminController
 
         $grid->column('kc','库存');
         $grid->column('states','状态')->switch($states);
-        $grid->column('created_at', __('创建时间'));
         $grid->column('updated_at', __('更新时间'));
 
         $grid->filter(function($filter){

+ 3 - 3
app/Http/Controllers/Api/V1/DocterController.php

xqd
@@ -187,9 +187,9 @@ class DocterController extends AuthController
         ]);
         $user = $this->user;
         $builder = Schedule::with(['schedulePeriod.timePeriod', 'schedulePeriod.organization'])->where('docter_id', $req['docter_id'])->where('schedule_type', 1)->where('schedule_day', '>=', date('Ymd'))->orderBy('schedule_day');
-//        if (!empty($req['organization_id'])) {
-//            $builder->where('organization_id', $req['organization_id']);
-//        }
+        if (!empty($req['organization_id'])) {
+            $builder->where('organization_id', $req['organization_id']);
+        }
         $data = $builder->paginate($req['per_page']??15)->toArray();
         \Log::info($data);
         if (!empty($data)) {

+ 9 - 3
app/Http/Controllers/Api/V1/OrderController.php

xqd xqd xqd
@@ -14,6 +14,7 @@ use App\Models\OrderNurse;
 use App\Models\OrderPack;
 use App\Models\OrderPatient;
 use App\Models\OrderVaccine;
+use App\Models\OrganizationVaccine;
 use App\Models\Patient;
 use App\Models\Payment;
 use App\Models\ServicePack;
@@ -244,6 +245,14 @@ class OrderController extends AuthController
             }
         }
 
+        //疫苗预约检查库存是否足够
+        if ($req['product_type'] == 4) {
+            $stock = OrganizationVaccine::where('org_id', $req['organization_id'])->where('vaccine_id', $req['vaccine_id'])->value('stock');
+            if ($stock <= 0) {
+                return out(null, 10009, '该疫苗库存不足');
+            }
+        }
+
         if ($req['payment_type'] == 3) {
             OrderPack::checkUserServicePack($req['order_pack_id'], $user['id'], $req['product_type'], $payment_amount);
         }
@@ -399,9 +408,6 @@ class OrderController extends AuthController
         }
 
         $addPatient = Patient::select(['name', 'sex', 'avatar', 'birthday', 'relationship_type', 'info', 'card_type', 'card_number', 'card_img_url', 'card_back_img_url', 'email', 'phone as patient_phone', 'social_card_number', 'born_hospital', 'guardian_name', 'address'])->where('id', $req['patient_id'])->first()->getOriginal();
-        if (empty($addPatient['card_img_url'])) {
-            return out(null, 70011, '该患者未上传身份证');
-        }
 
         $payment_amount = $req['total_amount'] - $discount_amount;
         $payment_amount = $payment_amount < 0 ? 0 : $payment_amount;

+ 34 - 19
app/Models/Order.php

xqd xqd xqd xqd xqd xqd
@@ -10,7 +10,7 @@ namespace App\Models;
 
 class Order extends BaseModel
 {
-    protected $appends = ['is_evaluate', 'order_duration'];
+    protected $appends = ['is_evaluate', 'consult_duration', 'callback_phone'];
 
     CONST UNPAID = 1, NOTACCEPT = 2, ISING = 3, FINISHED = 4,CANCELED=5,ISOUT=6; //订单状态(1.未支付 2.进行中 3.已完成 4.已取消)
     public static  $_order_status = [
@@ -44,7 +44,7 @@ class Order extends BaseModel
      * Create By 2020/11/18 11:06
      */
     public function userDocter(){
-        return $this->hasOne(UserDocter::class,'user_id','user_id')->select(['id', 'remark']);;
+        return $this->hasOne(UserDocter::class,'user_id','user_id')->select(['id', 'remark']);
     }
 
     public function patients(){
@@ -120,10 +120,10 @@ class Order extends BaseModel
             OrderPack::deductPackData($order['pay_order_pack_id'], $order['product_type'], $order['payment_amount']);
         }
 
-        if (!empty($order['docter_id'])) {
+       /* if (!empty($order['docter_id'])) {
             //更新医生的服务人数
             Docter::where('id', $order['docter_id'])->increment('service_persons');
-        }
+        }*/
 
         //如果是门诊预约,预约时间段的订单数要加1
         if ($order['product_type'] == 3) {
@@ -132,6 +132,12 @@ class Order extends BaseModel
             SchedulePeriod::where('docter_id', $order['docter_id'])->where('organization_id', $order['organization_id'])->where('time_period_id', $orderPatient['time_period_id'])->where('schedule_date', $schedule_date)->increment('order_num');
         }
 
+        //如果是疫苗就减少疫苗库存
+        if ($order['product_type'] == 4) {
+            $orderVaccine = OrderVaccine::where('order_id', $order_id)->first();
+            OrganizationVaccine::where('org_id', $order['organization_id'])->where('vaccine_id', $orderVaccine['vaccine_id'])->decrement('stock');
+        }
+
         return true;
     }
 
@@ -153,21 +159,6 @@ class Order extends BaseModel
         return $is_evaluate;
     }
 
-    public function getOrderDurationAttribute()
-    {
-        if (!empty($this->outtime) && !empty($this->receiving_time)) {
-            $diff = $this->outtime - $this->receiving_time;
-            $hour = round($diff/3600);
-            if ($hour == 0) {
-                return round($diff/60).'分钟';
-            }
-
-            return $hour.'小时';
-        }
-
-        return '';
-    }
-
     //取消订单,建议是在事务里面去调用
     public static function orderCancel($order_id)
     {
@@ -188,4 +179,28 @@ class Order extends BaseModel
 
         return true;
     }
+
+    public function getConsultDurationAttribute()
+    {
+        $duration = 0;
+        if ($this->product_type == 1) {
+            $duration = CallLog::where('order_id', $this->id)->where('talk_time', '<>', null)->sum('talk_time');
+            $duration = !empty($duration) ? $duration : 0;
+        }
+        elseif ($this->product_type == 2) {
+            $duration = $this->end_time - $this->receiving_time;
+        }
+
+        return $duration > 0 ? $duration : 0;
+    }
+
+    public function getCallbackPhoneAttribute()
+    {
+        $secret_no = '';
+        if ($this->product_type == 1) {
+            $secret_no = CallLog::where('order_id', $this->id)->orderBy('id', 'desc')->value('secret_no');
+        }
+
+        return !empty($secret_no) ? $secret_no : '';
+    }
 }