$file =input('post.avatar');
if(!$file){
$this->error('请上传需要导入的表格!支持csv,xls,xlsx格式!');
}
$filePath = ROOT_PATH . DS . 'public' . DS . $file;
if (!is_file($filePath)) {
$this->error('上传的表格不存在,请核实');
}
$PHPReader = new \PHPExcel_Reader_Excel2007();
if (!$PHPReader->canRead($filePath)) {
$PHPReader = new \PHPExcel_Reader_Excel5();
if (!$PHPReader->canRead($filePath)) {
$PHPReader = new \PHPExcel_Reader_CSV();
$PHPReader->setInputEncoding('GBK');
if (!$PHPReader->canRead($filePath)) {
$this->error(__('Unknown data format'));
}
}
}
for($i=2;$i<=$allRow;$i++){
switch ($express_id) {
case 1:
//接口请求参数
$post_info = [
];
//请求接口
$json = sendRequest('',$post_info,'POST');
$return = json_decode($json,1);
$code = $return['code'];
if($code==0){
$return_data = $return['data'];
$taskid = $return_data['recordId'];
//处理成功时的业务逻辑
$result = [];
$result[$i] = [
];
//更新用户信息
$yu_money = $yu_money-$total_fee;
\app\common\model\User::score($score=0,'-'.$total_fee,$uid,',编号'.$retu[$i]['id']);
$continue_num = $continue_num+1;
}else{
$this->error($return['msg']);
}
break;
default:
# code...
break;
}
}
//循环结束执行业务逻辑
```用户上传表格->php后台解析表格->通过for循环在循环体内请求外部接口 表格有多少记录循环多少次->当所有for循环执行结束后 处理其他业务
现在的问题就是当表格有500以上的数据时 整个for循环体执行时间太长 导致服务器超时
请问这种情况该怎么解决 对方接口一次最多接收5调数据
上面是我代码的示例 请问这种问题该怎么解决 如果改变请求时间用户体验不好 等待时间过长