Ver código fonte

医院管理员修改

fuyu 5 anos atrás
pai
commit
859833a469
1 arquivos alterados com 20 adições e 1 exclusões
  1. 20 1
      application/inter/controller/Application.php

+ 20 - 1
application/inter/controller/Application.php

@@ -500,6 +500,15 @@ class Application extends Base
         DB::startTrans();
         try{
             $order_id = UUIDs::uuid16();
+            $remote_order =  DB::table('remote_order')
+            ->where('application_id', $application_id)
+            ->where('status', 'not', self::ORDER_STATUS['CANCEL'])
+            ->filed('id')
+            ->find();
+            if($remote_order) {
+                DB::rollback();
+                return json_encode(['status'=>'fail','code'=>'2019','已存在订单,请勿重复发起']);
+            }
             DB::table('remote_order')->insert([
                 'id' => $order_id,
                 'hospital_id' => $hospital_id,
@@ -512,6 +521,7 @@ class Application extends Base
                 'pay_type' => $pay_type,
                 'pay_way' => $pay_way,
                 'timestamp' => time(),
+                'status' => self::ORDER_STATUS['CREATE']
             ]);
             DB::table('remote_application')->where('id',$application_id)->update(['report_status'=>4]);
             DB::commit();
@@ -519,9 +529,18 @@ class Application extends Base
         } catch (\Exception $e) {
             DB::rollback();
         }
-        return json_encode(['status'=>'fail','code'=>'2019','远程诊断发起失败']);
+        return json_encode(['status'=>'fail','code'=>'2020','远程诊断发起失败']);
     }
 
+    /**订单状态 创建 支付完成 订单完成 取消 */
+    private const ORDER_STATUS = [
+        'CREATE' => 1,
+        'PAYCOMPLTET' => 2,
+        'CONFIRM' => 3,
+        'CANCEL' => 4
+    ];
+
+
     private const WATER_TYPE = [
         'ADD' => 1,
         'REDUCE' => 2