Browse Source

问诊,医生

lizhen_gitee 10 months ago
parent
commit
f6d54045cb
1 changed files with 57 additions and 7 deletions
  1. 57 7
      application/api/controller/doctor/Wenzhen.php

+ 57 - 7
application/api/controller/doctor/Wenzhen.php

@@ -107,7 +107,11 @@ class Wenzhen extends Apic
         $order_id = input('order_id',0);
 
         //订单详情
-        $wenzhen_order = Db::name('wenzhen_order')->where('doctor_id',$this->auth->id)->where('id',$order_id)->find();
+        $field = [
+            'id','order_no','user_id','member_id','doctor_id','ordertype','total_fee','book_time','createtime','status','cancel_time','cancel_reason',
+            'pay_type','pay_time','accept_time','video_time','finish_time','feedback_time','feedback_remark','feedback_images',
+        ];
+        $wenzhen_order = Db::name('wenzhen_order')->field($field)->where('doctor_id',$this->auth->id)->where('id',$order_id)->find();
         if(empty($wenzhen_order)){
             $this->error('不存在的订单');
         }
@@ -171,9 +175,17 @@ class Wenzhen extends Apic
         //余额支付的直接退款
         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);
+            $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']);
+            }
+
+            //用户加钱
+            $logtype = $wenzhen_order['ordertype'] == 1 ? 13 : 14;
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($wenzhen_order['user_id'],'money',$wenzhen_order['total_fee'],$logtype,$remark='问诊退珍','wenzhen_order',$order_id);
             if($rs_wallet['status'] === false){
                 Db::rollback();
                 $this->error($rs_wallet['msg']);
@@ -279,12 +291,18 @@ class Wenzhen extends Apic
             $this->error('不存在的订单');
         }
 
-        if($wenzhen_order['ordertype'] == 1 && $wenzhen_order['status'] != 20){
-            $this->error('已接诊订单才能完成');
+        if($wenzhen_order['ordertype'] == 1){
+            if($wenzhen_order['status'] != 20){
+                $this->error('已接诊订单才能完成');
+            }
+
             $old_status = 20;
         }
-        if($wenzhen_order['ordertype'] == 2 && $wenzhen_order['status'] != 25){
-            $this->error('尚未发起视频,不能结束');
+        if($wenzhen_order['ordertype'] == 2){
+            if($wenzhen_order['status'] != 25){
+                $this->error('尚未发起视频,不能结束');
+            }
+
             $old_status = 25;
         }
 
@@ -304,4 +322,36 @@ class Wenzhen extends Apic
     }
 
     //反馈
+    public function feedback(){
+        $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'] != 30){
+            $this->error('已完成订单才能反馈');
+        }
+
+        //修改订单
+        $nowtime = time();
+        $update = [
+            'feedback_time' => $nowtime,
+            'feedback_remark' => input('feedback_remark',''),
+            'feedback_images' => input('feedback_images',''),
+        ];
+
+        $update_rs = Db::name('wenzhen_order')->where('id',$order_id)->where('status',30)->update($update);
+        if(!$update_rs){
+            $this->error('反馈失败');
+        }
+
+        $this->success(1,'反馈成功');
+    }
 }