log_file = 'temp.log'; } /** * Notes:更新客户表来源id * Created on: 2021/9/18 11:58 * Created by: dengbw * https://liche-api-dev.xiaoyu.com/plan/temp/receiver_customer * https://api.liche.cn/plan/temp/receiver_customer */ public function receiver_customer() { $this->load->model('receiver/receiver_clues_model', 'mdClues'); $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $param = $this->input->get(); $param['page'] = intval($param['page']); $param['size'] = intval($param['size']); !$param['size'] && $param['size'] = 50; !$param['page'] && $param['page'] = 1; $counts = intval($param['counts']); ob_start(); //打开缓冲区 $where = array('rid >' => 0); $res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,rid,cf_id'); if (!$res) { echo '
本次更新客户来源id完成了:'; echo '

成功更新 ' . $counts . ' 条'; echo '

点击将再次更新客户来源id>>>'; exit; } $log = array(); foreach ($res as $key => $value) { $re_c = $this->mdClues->get(array('id' => $value['rid'])); if ($re_c['cf_id']) { $this->mdCustomers->update(array('cf_id' => $re_c['cf_id']), array('id' => $value['id'])); $log[] = array('id' => $value['id'], 'cf_id' => $re_c['cf_id']); $counts++; } } echo '
成功更新:'; $log && print_r($log); echo '

数据库获取:'; echo json_encode($res, JSON_UNESCAPED_UNICODE); header('refresh:3;url=/plan/temp/receiver_customer?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1)); ob_end_flush();//输出全部内容到浏览器 } }