Files
liche/api/controllers/plan/Temp.php
T
2021-09-18 14:09:29 +08:00

63 lines
2.2 KiB
PHP

<?php
/**
* Notes:临时数据操作
* Created on: 2021/9/18 17:15
* Created by: dengbw
*/
class Temp extends HD_Controller
{
private $log_file;
public function __construct()
{
parent::__construct();
$this->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 '<br>本次更新客户来源id完成了:';
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
echo '<br><br><a href="/plan/xmcard/tem_wxqy">点击将再次更新客户来源id>>></a>';
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 '<br>成功更新:';
$log && print_r($log);
echo '<br><br>数据库获取:';
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();//输出全部内容到浏览器
}
}