Bläddra i källkod

数据导入修改

whj 4 år sedan
förälder
incheckning
e74de60bc8
3 ändrade filer med 20 tillägg och 72 borttagningar
  1. 10 37
      app/Imports/Order/chatOrder.php
  2. 7 32
      app/Imports/Order/phoneOrder.php
  3. 3 3
      app/Imports/Order/vaccineSheet.php

+ 10 - 37
app/Imports/Order/chatOrder.php

xqd xqd
@@ -29,46 +29,24 @@ class chatOrder implements ToCollection,WithBatchInserts,WithChunkReading
 
         foreach ($collection as $row) {
             if ($row[0] == '订单编号') continue;
-//            dd($row);
-
-//        [
-//            0 => "im20210118173813522",
-//            1 => "云南运营主体",
-//            2 => "熊振宇",
-//            3 => "13708872753",
-//            4 => "文菊焱",
-//            5 => "",
-//            6 => "云南省昆明市昆明市盘龙区联盟街道金康园社区卫生服务站",
-//            7 => "妇保科",
-//            8 => "否",
-//            9 => "进行中",
-//            10 => "",
-//            11 => "否",
-//            12 => "1.99",
-//            13 => "0.00",
-//            14 => "1.99",
-//            15 => "1.99",
-//            16 => "微信支付",
-//            17 => "单次图文咨询",
-//            18 => "已付款",
-//            19 => "2021-01-18 17:38:13",
-//        ];
             //检查是否有该订单
             $isHave = $this->getValue(new Order(), ['order_sn' => $row[0]], 'id');
-            if ($isHave) return null;
+            if ($isHave) continue;
 
             $user_id = $this->getValue(new User(), ['phone' => $row[3]], 'id');
             if (empty($user_id)) {
                 echo $row[3] . '用户缺失' . PHP_EOL;
-                return null;
+                continue;
             }
             //患者信息
-            $patientInfo = Patient::where(['name' => $row[4]])->first();
+            $patientInfo = Patient::where(['name' => $row[2]])->first();
             if (empty($patientInfo)) {
-                echo $row[4] . '患者缺失' . PHP_EOL;
+//                $pp = Patient::where('user_id',$user_id)->get()->toArray();
+                echo $row[2] . '患者缺失' . PHP_EOL;
                 continue;
             }
-            $org_id = $this->getValue(new Organization(), ['name' => $row[6]], 'id');
+            $org_name = substr($row[6],18);
+            $org_id = $this->getValue(new Organization(), ['name' => $org_name], 'id');
             if (empty($org_id)) {
                 echo $row[6] . '机构缺失' . PHP_EOL;
                 continue;
@@ -79,23 +57,18 @@ class chatOrder implements ToCollection,WithBatchInserts,WithChunkReading
                 Log::info('订单没有用户信息,订单编号: ' . $row[0] . PHP_EOL);
                 continue;
             }
-            //  1 => "未支付"
-            //  2 => "待支付"
-            //  3 => "进行中"
-            //  4 => "已完成"
-            //  5 => "已取消"
-            //  6 => "已超时"
-            //  7 => "已预约"
+
             //订单状态
             $status = Order::getStatus();
             //订单状态
             $paystatus = Order::getPayStatus();
             $pay_status = array_search($row[18], $paystatus);
             $order_status = array_search($row[9], $status);
+            if($row[9] == '已过期') $order_status = 6;
+            if($row[18] == '未付款' || empty($row[18])) $pay_status = 1;
 
 
             $docter_id = $this->getValue(new Docter(), ['name' => $row[4]], 'id');
-            $org_id = $this->getValue(new Organization(), ['name' => $row[6]], 'id');
             $evaluate = $row[10] == '已评价' ? 1 : 0;
             $pay_types = [1 => '微信支付', 2 => '余额支付', 3 => '服务包支付'];
             //支付方式

+ 7 - 32
app/Imports/Order/phoneOrder.php

xqd xqd xqd xqd
@@ -21,37 +21,15 @@ class phoneOrder implements ToCollection
         foreach ($collection as $row){
             if ($row[0] == '订单编号') continue;
 
-//        [
-//            0 => "MNC20210131110722347"
-//    1 => "云南运营主体"
-//    2 => "王洛染"
-//    3 => "18669008017"
-//    4 => "姚正"
-//    5 => "昆明儿科联盟"
-//    6 => "云南省昆明市昆明市西山区前卫佳湖社区卫生服务站"
-//    7 => "全科医学科"
-//    8 => "否"
-//    9 => "已完成"
-//    10 => "已评价"
-//    11 => "否"
-//    12 => "19.99"
-//    13 => "0.00"
-//    14 => "19.99"
-//    15 => "19.99"
-//    16 => "微信支付"
-//    17 => "自费"
-//    18 => "已付款"
-//    19 => "2021-01-31 11:07:23"
-
-//        ];
             //检查是否有该订单
             $isHave = $this->getValue(new Order(), ['order_sn' => $row[0]], 'id');
-            if ($isHave) return null;
-
+            if ($isHave) continue;
+            //支付状态(1.待付款 2.已付款 3.退款中 4.已退款 5.待退款)
+            //如果没有用户不导入该订单
             $user_id = $this->getValue(new User(), ['phone' => $row[3]], 'id');
             if (empty($user_id)) {
                 echo $row[3] . '用户缺失' . PHP_EOL;
-                return null;
+                continue;
             }
             //患者信息
             $patientInfo = Patient::where(['name' => $row[2]])->first();
@@ -66,12 +44,6 @@ class phoneOrder implements ToCollection
                 continue;
             }
 
-            //如果没有用户不导入该订单
-            if (empty($user_id)) {
-                Log::info('订单没有用户信息,订单编号: ' . $row[0] . PHP_EOL);
-                continue;
-            }
-
             //订单状态
             $status = Order::getStatus();
             //订单状态
@@ -79,6 +51,8 @@ class phoneOrder implements ToCollection
             $pay_status = array_search($row[18], $paystatus);
             $order_status = array_search($row[9], $status);
 
+            if( $row[18] == '已退款') $pay_status = 4;
+            if($row[9] == '已过期') $order_status = 6;
 
             $docter_id = $this->getValue(new Docter(), ['name' => $row[4]], 'id');
             $evaluate = $row[10] == '已评价' ? 1 : 0;
@@ -118,6 +92,7 @@ class phoneOrder implements ToCollection
             ];
             OrderPatient::insert($orderPatient);
         }
+        return null;
     }
 
     public function getValue($model,$where,$field)

+ 3 - 3
app/Imports/Order/vaccineSheet.php

xqd xqd xqd xqd
@@ -36,7 +36,6 @@ class vaccineSheet implements ToCollection
                 echo $row[2].'机构缺失'.PHP_EOL;
                 //todo 没有机构直接跳过
                 continue;
-                $org_id = 0;
             }
 
             $vaccine_id = $this->getValue(new Vaccine(),['name'=>$row[3]],'id');
@@ -54,6 +53,7 @@ class vaccineSheet implements ToCollection
             }
 
             if(empty($user_id)){
+                echo $row[1].'用户不存在'.PHP_EOL;
                 Log::info('订单没有用户信息: '.$row[0].' 电话:'.$row[1].' 时间:'.$row[4].PHP_EOL);
                continue;
             }
@@ -61,7 +61,6 @@ class vaccineSheet implements ToCollection
             $status = Order::getStatus();
             //订单状态
             $order_status = array_search($row[5],$status);
-            if(empty($org_id)) $org_id = 0;
 //            $order_sn = build_sn($i);
             //todo 写入计免订单表,订单患者表
             $time = explode(' ',$row[4]);
@@ -108,8 +107,9 @@ class vaccineSheet implements ToCollection
                 'order_patient_id'=>$orderPid,
                 'vaccine_name'=>$row[3],
             ];
-            return OrderVaccine::insert($vaccineOrder);
+            OrderVaccine::insert($vaccineOrder);
         }
+        return null;
     }
 
     public function getValue($model,$where,$field)