getCorpList($page, $page_size); // print_r($corpList['body']['list'][0]['createAt']);exit; // print_r($corpList);exit; $totalPage = $corpList['body']['totalPage']; $update_num = 0; $create_num = 0; for($page; $page<=$totalPage; $page++) { $corpLists = AghApiService::getInstance()->getCorpList($page, $page_size); if (empty($corpLists)) { return '数据为空'; } else { foreach ($corpLists['body']['list'] as $k => $v) { $query = []; $query['source_id'] = $v['enterpriseId']; $query['source_type'] = 'agh'; $query['corp_name'] = $v['fullName']; $query['corp_short_name'] = $v['abbName']; $query['contact_name'] = $v['contact']; $query['contact_phone'] = $v['cellPhone']; $query['contact_email'] = $v['email']; $query['contact_address'] = $v['address']; $query['status'] = $v['state'] == true ? 1 : 0; $query['register_time'] = round($v['createAt']/1000); $query['update_time'] = time(); $res = Corps::where('source_id', $query['source_id'])->where('source_type', $query['source_type'])->first(); if ($res) { Corps::where('source_id', $query['source_id'])->where('source_type', $query['source_type'])->update($query); $update_num += 1; } else { $query['create_time'] = time(); Corps::insert($query); $create_num += 1; } } } } echo '更新企业信息:' . $update_num . '条;' . PHP_EOL . '插入企业信息:' . $create_num . '条!'.PHP_EOL; } }