"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; $patient_id = $this->getValue(new Patient(),['name'=>$row[2]],'id'); $user_id = $this->getValue(new User(),['phone'=>$row[3]],'id'); //如果没有用户不导入该订单 if(empty($user_id)){ Log::info('订单没有用户信息,订单编号: '.$row[0].PHP_EOL); return null; } // 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); $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=>'服务包支付']; //支付方式 $payType = array_search($row[16],$pay_types) + 1; if($payType == 1) $payType = 2; $orderInfo = [ 'order_sn'=>$row[0], 'patient_id'=>$patient_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'=>$row[12]*100, 'discount_amount'=>$row[13]*100, 'payment_amount'=>$row[15]*100, 'payment_type'=>$payType, 'payment_status'=>$pay_status, 'product_type'=>1, 'created_at'=>$row[19], ]; //处理逻辑 return new Order($orderInfo); } public function startRow(): int { return 2; } public function batchSize(): int { return 20; } public function chunkSize(): int { return 20; } public function getValue($model,$where,$field) { return $model->where($where)->value($field); } }