瀏覽代碼

修改代码

fuyu 5 年之前
父節點
當前提交
929ee1d3f2
共有 2 個文件被更改,包括 45 次插入7 次删除
  1. 5 5
      application/inter/controller/Application.php
  2. 40 2
      application/inter/controller/Writereport.php

+ 5 - 5
application/inter/controller/Application.php

@@ -633,7 +633,7 @@ class Application extends Base
     }
 
     /**订单状态 创建 支付完成 订单完成 取消 */
-    private const ORDER_STATUS = [
+    public const ORDER_STATUS = [
         'CREATE' => 1,
         'PAYCOMPLTET' => 2,
         'CONFIRM' => 3,
@@ -641,13 +641,13 @@ class Application extends Base
     ];
 
     /**流水类型 加 减 */
-    private const WATER_TYPE = [
+    public const WATER_TYPE = [
         'ADD' => 1,
         'REDUCE' => 2
     ];
 
     /**流水原因 远程诊断医院扣款 远程诊断医院收入 远程诊断退款 远程诊断退款收入 */
-    private const WATER_WHY = [
+    public const WATER_WHY = [
         'REMOTEPAY' => 21,
         'REMOTEINCOME' => 11,
         'REMOTEREFUND' => 22,
@@ -655,7 +655,7 @@ class Application extends Base
     ];
     // why 患者支付/远程诊断收入/远程诊断付款/远程诊断退款/提现
     /**支付方式 微信 支付宝 银联 医院扣款*/
-    private const PAY_WAY = [
+    public const PAY_WAY = [
         "HOSPITAL" => 1,
         "WECHAT" => 11,
         "ALIPAY" => 12,
@@ -663,7 +663,7 @@ class Application extends Base
     ];
    
     /**支付类型 医院 微信 */
-    private const PAY_TYPE = [
+    public const PAY_TYPE = [
         "HOSPITAL" => 0,
         "PATIENT" => 1
     ];

+ 40 - 2
application/inter/controller/Writereport.php

@@ -504,8 +504,9 @@ class Writereport extends Base
                 DB::table('exams')->where('id',$id)->update(['exam_status'=>'9']);
             }else{
                 Message::read($doctor['id'],$report_info['remote_application_id'],4);
-                //远程确认
-                DB::table('remote_application')->where('id',$report_info['remote_application_id'])->update(['report_status'=>'9']);
+                //远程
+                $this->confirmReport($report_info['remote_application_id']);
+                // DB::table('remote_application')->where('id',$report_info['remote_application_id'])->update(['report_status'=>'9']);
                 // 添加messages消息
                 $t = '您的报告已确认';
                 $institution = DB::table('institution')->where('id',$doctor['institution_id'])->field('name')->find();
@@ -536,6 +537,43 @@ class Writereport extends Base
 
     }
 
+    private function confirmReport($application_id) {
+        DB::startTrans();
+        try{
+            DB::table('remote_application')->where('id', $application_id)->update(['report_status'=>'9']);
+            $remote_order = DB::table('remote_order')
+            ->where('status', Application::ORDER_STATUS['PAYCOMPLTET'])
+            ->where('application_id', $application_id)
+            ->field('order_money, id, super_hospital_id')
+            ->find();
+            if(!$remote_order) {
+                DB::commit();
+                // todo 微信消息推送
+                return true;
+            }
+            $hospital = DB::table('institution')->where('id', $remote_order['super_hospital_id'])->field('current_money')->find();
+            DB::table('institution')->where('id', $remote_order['super_hospital_id'])->update(['current_money' => $current_money + $remote_order['order_money']]);
+            DB::table('remote_order')->where('id', $remote_order['id'])->update(['status' => Application::ORDER_STATUS['CONFIRM']]);
+            DB::table('remote_water')->insert([
+                'id' => UUIDs::uuid16(),
+                'hospital_id' => $remote_order['super_hospital_id'],
+                'order_id' => $remote_order['id'],
+                'money' =>$remote_order['order_money'],
+                'type' => Application::WATER_TYPE['ADD'],
+                'why' =>  Application::WATER_WHY['REMOTEINCOME'],
+                'timestamp' => time(),
+            ]);
+            // 提交事务
+            DB::commit();
+            // todo 消息推送
+            return true;
+        } catch (\Exception $e) {
+            // 回滚事务
+            DB::rollback();
+        }
+        return json_encode(['status'=>'fail','code'=>'2110','确认报告失败']);
+    }
+
     /**
      * 审核报告
      *