getValue(new Order(), ['order_sn' => $row[0]], 'id'); 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; continue; } //患者信息 $patientInfo = Patient::where(['name' => $row[2]])->first(); if (empty($patientInfo)) { echo $row[2] . '患者缺失' . PHP_EOL; continue; } $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; } //订单状态 $status = Order::getStatus(); //订单状态 $paystatus = Order::getPayStatus(); $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; $pay_types = [1 => '微信支付', 2 => '余额支付', 3 => '服务包支付']; //支付方式 $payType = array_search($row[16], $pay_types) + 1; if ($payType == 1) $payType = 2; $orderInfo = [ 'order_sn' => $row[0], 'patient_id' => $patientInfo->id, 'user_id' => $user_id, 'docter_id' => $docter_id, 'order_status' => $order_status, 'organization_id' => $org_id, 'is_evaluate' => $evaluate, 'is_discount' => $row[11], 'total_amount' => intval($row[12]) * 100, 'discount_amount' => intval($row[13]) * 100, 'payment_amount' => intval($row[15]) * 100, 'payment_type' => $payType, 'payment_status' => $pay_status, 'product_type' => 1, 'created_at' => $row[19], ]; $order = Order::create($orderInfo); $orderId = $order['id']; $orderPatient = [ 'patient_id' => $patientInfo->id, 'name' => $row[2], 'order_id' => $orderId, 'patient_id' => $patientInfo->id, 'address' => $patientInfo->address, 'sex' => $patientInfo->sex, 'organization_id' => $org_id, ]; OrderPatient::insert($orderPatient); } return null; } public function getValue($model,$where,$field) { return $model->where($where)->value($field); } }