find(array('key' => $account)); } if (!$account) { Dever::error('账户无效'); } if (!is_array($func)) { $func = Dever::db('app_func', 'api')->find(array('app_id' => $account['app_id'], 'key' => $func)); } if (!$func) { Dever::error('功能无效'); } $api = Dever::load('app', 'api')->getApi($func['id'], $env); if (!$api) { Dever::error('接口无效'); } $param['account_project'] = $project; $param['account_id'] = $account['id']; $result = array(); if ($func['type'] == 1) { # 仅执行第一个 $result = Dever::load('api', 'api')->$method($api[0], $param); if (is_array($result)) { $result['account_id'] = $account['id']; $result['api_id'] = $api[0]['id']; } } elseif ($func['type'] == 2) { # 同步执行 foreach ($api as $k => $v) { $result = Dever::load('api', 'api')->$method($v, $param); if ($result && is_array($result)) { $param = array_merge($result, $param); } } } elseif ($func['type'] == 3) { # 异步执行 $result = true; foreach ($api as $k => $v) { $param['api_id'] = $v['id']; \Dever\Helper\Cmd::run('task.api', $param, 'api'); } } return $result; } }