فهرست منبع

问诊订单,医生

lizhen_gitee 10 ماه پیش
والد
کامیت
2930dffcee
3فایلهای تغییر یافته به همراه135 افزوده شده و 3 حذف شده
  1. 1 1
      application/api/controller/Wenzhen.php
  2. 129 2
      application/api/controller/doctor/Wenzhen.php
  3. 5 0
      application/extra/wallet.php

+ 1 - 1
application/api/controller/Wenzhen.php

@@ -213,7 +213,7 @@ class Wenzhen extends Api
         }
 
         $field = [
-            'order.id','order.order_no','order.createtime','order.status','order.ordertype','order.accept_time','order.video_time',
+            'order.id','order.order_no','order.createtime','order.status','order.ordertype','order.accept_time','order.video_time','order.doctor_id',
             'doctor.avatar as doctor_avatar','doctor.nickname as doctor_nickname',
         ];
         $list = Db::name('wenzhen_order')->alias('order')

+ 129 - 2
application/api/controller/doctor/Wenzhen.php

@@ -147,9 +147,8 @@ class Wenzhen extends Apic
             $this->error('操作频繁');
         }
 
-        $order_id = input('order_id',0);
-
         //订单详情
+        $order_id = input('order_id',0);
         $wenzhen_order = Db::name('wenzhen_order')->where('doctor_id',$this->auth->id)->where('id',$order_id)->find();
         if(empty($wenzhen_order)){
             $this->error('不存在的订单');
@@ -169,12 +168,140 @@ class Wenzhen extends Apic
         ];
         Db::startTrans();
 
+        //余额支付的直接退款
+        if($wenzhen_order['pay_type'] == 'wallet'){
+
+            //退钱
+            $logtype = $wenzhen_order['ordertype'] == 1 ? 113 : 114;
+            $rs_wallet = model('walletdoctor')->lockChangeAccountRemain($this->auth->id,'money',$wenzhen_order['total_fee'],$logtype,$remark='问诊退珍','wenzhen_order',$order_id);
+            if($rs_wallet['status'] === false){
+                Db::rollback();
+                $this->error($rs_wallet['msg']);
+            }
+
+            //订单退款参数
+            $update['refund_price']  = $wenzhen_order['total_fee'];
+            $update['refund_status'] = 3;
+        }else{
+            //订单退款参数
+            $update['refund_status'] = 1; //异步退款
+        }
+
         $update_rs = Db::name('wenzhen_order')->where('id',$order_id)->where('status',10)->update($update);
         if(!$update_rs){
             Db::rollback();
+            $this->error('退珍失败');
         }
+
+        Db::commit();
+        $this->success(1,'退珍成功');
+
     }
     //接珍
+    public function jiezhen(){
+        $apilimit = $this->apiLimit();
+        if(!$apilimit){
+            $this->error('操作频繁');
+        }
+
+        //订单详情
+        $order_id = input('order_id',0);
+        $wenzhen_order = Db::name('wenzhen_order')->where('doctor_id',$this->auth->id)->where('id',$order_id)->find();
+        if(empty($wenzhen_order)){
+            $this->error('不存在的订单');
+        }
+
+        if($wenzhen_order['status'] != 10){
+            $this->error('待接诊订单才能接诊');
+        }
+
+        //修改订单
+        $nowtime = time();
+        $update = [
+            'status' => 20,
+            'accept_time' => $nowtime,
+        ];
+
+        $update_rs = Db::name('wenzhen_order')->where('id',$order_id)->where('status',10)->update($update);
+        if(!$update_rs){
+            Db::rollback();
+            $this->error('接诊失败');
+        }
+
+        Db::commit();
+        $this->success(1,'接珍成功');
+    }
+
+    //第一次拨打视频
+    public function first_video(){
+        $apilimit = $this->apiLimit();
+        if(!$apilimit){
+            $this->error('操作频繁');
+        }
+
+        //订单详情
+        $order_id = input('order_id',0);
+        $wenzhen_order = Db::name('wenzhen_order')->where('doctor_id',$this->auth->id)->where('id',$order_id)->find();
+        if(empty($wenzhen_order)){
+            $this->error('不存在的订单');
+        }
+
+        if($wenzhen_order['ordertype'] != 2 || $wenzhen_order['status'] != 20){
+            $this->error('已接诊的视频订单才能拨打视频');
+        }
+
+        //修改订单
+        $nowtime = time();
+        $update = [
+            'status' => 25,
+            'video_time' => $nowtime,
+        ];
+
+        $update_rs = Db::name('wenzhen_order')->where('id',$order_id)->where('status',20)->update($update);
+        if(!$update_rs){
+            $this->error('操作失败');
+        }
+
+        $this->success(1,'操作成功');
+    }
+
     //完成
+    public function finish(){
+        $apilimit = $this->apiLimit();
+        if(!$apilimit){
+            $this->error('操作频繁');
+        }
+
+        //订单详情
+        $order_id = input('order_id',0);
+        $wenzhen_order = Db::name('wenzhen_order')->where('doctor_id',$this->auth->id)->where('id',$order_id)->find();
+        if(empty($wenzhen_order)){
+            $this->error('不存在的订单');
+        }
+
+        if($wenzhen_order['ordertype'] == 1 && $wenzhen_order['status'] != 20){
+            $this->error('已接诊订单才能完成');
+            $old_status = 20;
+        }
+        if($wenzhen_order['ordertype'] == 2 && $wenzhen_order['status'] != 25){
+            $this->error('尚未发起视频,不能结束');
+            $old_status = 25;
+        }
+
+        //修改订单
+        $nowtime = time();
+        $update = [
+            'status' => 30,
+            'finish_time' => $nowtime,
+        ];
+
+        $update_rs = Db::name('wenzhen_order')->where('id',$order_id)->where('status',$old_status)->update($update);
+        if(!$update_rs){
+            $this->error('操作失败');
+        }
+
+        $this->success(1,'操作成功');
+    }
+
     //反馈
 }

+ 5 - 0
application/extra/wallet.php

@@ -12,6 +12,8 @@ return [
 
         11 => '图文问诊',//money -
         12 => '视频问诊',//money -
+        13 => '图文问诊退款',//money +
+        14 => '视频问诊退款',//money +
 
 
         21 => '钱包余额提现',//money -
@@ -23,11 +25,14 @@ return [
 
         111 => '图文问诊', //money +
         112 => '视频问诊', //money +
+        113 => '图文问诊退款', //money -
+        114 => '视频问诊退款', //money -
 
         121 => '钱包余额提现', //money -
         122 => '提现拒绝返回', //money +
 
 
+
     ],
     'logtype_en' => [