代码优化
This commit is contained in:
@@ -50,10 +50,23 @@ class WechatController extends BaseController
|
||||
// 发送请求获取基本信息
|
||||
$result = requestCurl($this->baseUrl . 'api/WechatAccount/list', $params, 'GET', $header);
|
||||
$response = handleApiResponse($result);
|
||||
|
||||
// 确保 response 是数组格式
|
||||
if (!is_array($response)) {
|
||||
$response = [];
|
||||
}
|
||||
|
||||
// 确保 results 字段存在且是数组
|
||||
if (!isset($response['results']) || !is_array($response['results'])) {
|
||||
$response['results'] = [];
|
||||
}
|
||||
|
||||
// 保存基本数据到数据库
|
||||
if (!empty($response['results'])) {
|
||||
foreach ($response['results'] as $item) {
|
||||
$this->saveWechatAccount($item);
|
||||
if (is_array($item)) {
|
||||
$this->saveWechatAccount($item);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取并更新微信账号状态信息
|
||||
|
||||
Reference in New Issue
Block a user