getValue(new User(),['phone'=>$row[1]],'id'); if(empty($user_id)){ Log::info('订单没有用户信息: '.$row[0].' 电话:'.$row[1].' 时间:'.$row[3].PHP_EOL); continue; } //患者信息 $patientInfo = Patient::where(['name'=>$row[0]])->first(); if(empty($patientInfo)){ echo $row[0].'患者缺失'.PHP_EOL; continue; } //下单时间 $time = explode(' ',$row[3]); $appion_time = explode('-',$time[1]); $start =strtotime($time[0].$appion_time[0]); //预约时间大于今天 ($start- 86400) > strtotime('today') ?$createTimer = strtotime('-1 days') : $createTimer = ($start- 86400) > strtotime('today'); $created_at = date('Y-m-d H:i:s',$createTimer); $end = strtotime($time[0].$appion_time[1]); $org_id = $this->getValue(new Organization(),['name'=>$row[2]],'id'); if(empty($org_id)){ $org_id = 0; echo $row[2].'机构缺失'.PHP_EOL; continue; } // $status = Order::getStatus(); //订单状态 $status = [2=>'待就诊',4=>'已完成',5=>'用户取消',6=>'已过期',7=>'机构取消']; //状态监测 // $cacheStatus = Cache::get('nurse_status'); // if(empty($cacheStatus)){ // $cacheStatus[0] = 'begin'; // Cache::set('nurse_status',$cacheStatus); // } else { // dump($cacheStatus); // } // if(!in_array($row[4],$cacheStatus)){ // $cacheStatus[] = $row[4]; // Cache::set('nurse_status',$cacheStatus); // } // continue; $order_status = array_search($row[4],$status); $notes = ''; if($order_status == 5){ $notes = '用户取消'; } if($order_status == 6){ $order_status = 5; $notes = '机构取消'; } if(!in_array($row[4],$status)){ echo $row[4].PHP_EOL; } //todo 写入计免订单表,订单患者表 $orderInfo= [ 'user_id'=>$user_id, 'docter_id'=>0, 'order_status'=>$order_status, 'organization_id'=>$org_id, 'product_type'=>5, 'patient_id'=>$patientInfo->id, 'order_notes'=>$notes, 'created_at'=>$created_at, ]; $order = Order::create($orderInfo); $orderId = $order['id']; $order_sn = build_sn($orderId); Order::where('id', $orderId)->update(['order_sn' => $order_sn]); //没有患者名称不存数据 if(empty($patientInfo)) continue; $orderPatient = [ 'name'=>$row[0], 'order_id'=>$orderId, 'patient_id'=>$patientInfo->id, 'address'=>$patientInfo->address, 'sex'=>$patientInfo->sex, 'appoint_start_time'=>$start, 'appoint_end_time'=>$end, 'organization_id'=>$org_id, ]; OrderPatient::insertGetId($orderPatient); } return null; } public function getValue($model,$where,$field) { return $model->where($where)->value($field); } }