setName('weworksingle_get_group_statistic') ->setDescription('weworksingle get group statistic'); } protected function execute(Input $input, Output $output) { $list = WeworksingleCompanySetting::where('corp_id', '<>', '')->select(); foreach ($list as $k => $v) { $save_data = []; $chat_config['corp_id'] = $v['corp_id']; $chat_config['secret'] = $v['customer_secret']; $chat_config['token'] = $v['customer_token']; $chat_config['aes_key'] = $v['customer_aes_key']; $chat_config['company_id'] = $v['company_id']; if (!empty($v['customer_secret']) && !empty($v['customer_token']) && !empty($v['customer_aes_key']) && !empty($v['company_id'])) { $root_id = Company::where('id', '=', $v['company_id'])->value('root_id'); $weworksingle_user = Employee::where([['root_id', '=', $root_id], ['state', '=', '在职'], ['weworksingle_uid', '<>', 0]])->column('weworksingle_uid'); if (!empty($weworksingle_user)){ $weworksingle_uid = WeworksingleUser::where('id', 'in', $weworksingle_user)->column('userid'); foreach ($weworksingle_uid as $kk => $vv){ $param = [ 'day_begin_time'=> strtotime(date('Y-m-d', time())), 'day_end_time'=> strtotime(date('Y-m-d', time())), 'owner_filter'=> [ 'userid_list'=> $vv ], 'offset'=> 0, 'limit'=> 1000 ]; $data = (new apiSingle($chat_config))->getGroupChatStatistic($param); $save_data[] = [ 'owner'=> $vv, 'data'=> $data, 'root_id'=> $root_id ]; } } } if (!empty($save_data)){ (new WeworksingleExternalUserRecord())->saveAll($save_data); } } // 指令输出 $output->writeln(date('Y-m-d H:i:s', time()) . '--weworksingle_get_group_statistic--ok'); } }