From b0f72e8cbb434f230f7e0fdfb485301d64e445a2 Mon Sep 17 00:00:00 2001 From: dengbw Date: Thu, 2 Jun 2022 17:22:48 +0800 Subject: [PATCH] temp_602 --- api/controllers/plan/Temp.php | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/api/controllers/plan/Temp.php b/api/controllers/plan/Temp.php index e78128f0..5cb1c69e 100644 --- a/api/controllers/plan/Temp.php +++ b/api/controllers/plan/Temp.php @@ -16,6 +16,58 @@ class Temp extends HD_Controller $this->log_file = 'temp.log'; } + /** + * Notes:更新企微好友 + * Created on: 2022/5/27 11:58 + * Created by: dengbw + * https://liche-api-dev.xiaoyu.com/plan/temp/customers_wxqy + * https://api.liche.cn/plan/temp/customers_wxqy + */ + public function customers_wxqy() + { + $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); + $this->load->model('app/licheb/App_licheb_users_model', 'mdUsers'); + $this->load->model('app/app_lichene_qy_model', 'mdWechatqy'); + $param = $this->input->get(); + $param['page'] = intval($param['page']); + $param['size'] = intval($param['size']); + !$param['size'] && $param['size'] = 100; + !$param['page'] && $param['page'] = 1; + $counts = intval($param['counts']); + ob_start(); //打开缓冲区 + $where = ["status" => 1]; + $res = $this->mdWechatqy->select($where, 'id ASC', $param['page'], $param['size'], 'userid,mobile'); + if (!$res) { + echo '
本次更新完成了:'; + echo '

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

点击将再次更新>>>'; + exit; + } + $log = array(); + foreach ($res as $key => $value) { + if ($value['userid'] && $value['mobile']) { + $mobile = $value['mobile']; + $re_use = $this->mdUsers->get(array('userid' => $value['userid'])); + $biz_id = $re_use && $re_use['biz_id'] ? intval($re_use['biz_id']) : 0; + if ($biz_id) { + $where_cust = ['biz_id' => $biz_id, 'mobile' => $mobile, 'wxqy' => 0]; + $re_cust = $this->mdCustomers->get($where_cust); + if ($re_cust) { + $this->mdCustomers->update(['wxqy' => 1], $where_cust); + $log[] = ['mobile' => $value['mobile'], 'biz_id' => $biz_id]; + $counts++; + } + } + } + } + echo '
成功更新:'; + $log && print_r($log); + echo '

数据库获取:'; + echo json_encode($res, JSON_UNESCAPED_UNICODE); + //header('refresh:3;url=/plan/temp/customers_wxqy?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1)); + ob_end_flush();//输出全部内容到浏览器 + } + /** * Notes:更新下架门店人员 * Created on: 2022/5/27 11:58