owners_621
This commit is contained in:
@@ -12,6 +12,75 @@ class Liche extends HD_Controller
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:更新车主企业微信
|
||||
* Created on: 2022/6/21 16:00
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/liche/owners_wxqy?rds=1
|
||||
* https://api.liche.cn/plan/liche/owners_wxqy
|
||||
*/
|
||||
public function owners_wxqy()
|
||||
{
|
||||
$params = $this->input->get();
|
||||
$size = 100;//每次最多处理多少条
|
||||
$rds = intval($this->input->get('rds'));
|
||||
$redis = &load_cache('redis');
|
||||
$redisKey = 'update_owners_wxqy_c_time';
|
||||
if ($rds) {
|
||||
$redis->delete($redisKey);
|
||||
}
|
||||
$c_time = $redis->get($redisKey);
|
||||
!$c_time && $c_time = strtotime(date('Y-m-d') . ' 00:00:00');
|
||||
$log = [];
|
||||
$this->load->model('app/app_lichene_qy_log_model', 'mdWechatqyLog');
|
||||
$this->load->model('app/app_lichene_qy_model', 'mdWechatqy');
|
||||
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
|
||||
$this->load->model('app/liche/app_liche_users_model', 'mdUsers');
|
||||
$res = $this->mdWechatqyLog->select(["c_time>=" => $c_time, "change_type in('add_external_contact','edit_external_contact')" => null]
|
||||
, 'c_time asc', 1, $size, 'change_type,external_userid,c_time');
|
||||
if (!$res) {
|
||||
if ($params['rds']) {
|
||||
echo '1执行到当前c_time:' . date('Y-m-d H:i:s', $c_time) . '暂无数据';
|
||||
}
|
||||
return;
|
||||
}
|
||||
foreach ($res as $key => $value) {
|
||||
$c_time = $value['c_time'];
|
||||
if ($value['external_userid']) {
|
||||
$re_qy = $this->mdWechatqy->get(['external_userid' => $value['external_userid']]);
|
||||
$mobile = $re_qy['mobile'];
|
||||
$type = 1;
|
||||
if (!$mobile && $re_qy['unionid']) {
|
||||
$re_use = $this->mdUsers->get(['unionid' => $re_qy['unionid']]);
|
||||
if ($re_use['mobile']) {
|
||||
$type = 2;
|
||||
$mobile = $re_use['mobile'];
|
||||
}
|
||||
}
|
||||
if ($mobile) {
|
||||
$re_own = $this->mdOwners->get(['mobile' => $mobile]);
|
||||
if ($re_own) {
|
||||
$this->mdOwners->update(['wxqy' => 1], ['id' => $re_own['id']]);
|
||||
if ($params['rds']) {
|
||||
$log[] = ['mobile' => $mobile, 'type' => $type];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$redis->save($redisKey, $c_time);
|
||||
if ($params['rds']) {
|
||||
echo '<br>2执行到当前c_time:' . date('Y-m-d H:i:s', $c_time);
|
||||
echo '<br>成功新增:<br>';
|
||||
if ($log) {
|
||||
echo json_encode($log, JSON_UNESCAPED_UNICODE);
|
||||
echo '<br>';
|
||||
}
|
||||
echo '数据库获取:<br>';
|
||||
echo json_encode($res, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:新增车主信息
|
||||
* Created on: 2022/6/14 17:15
|
||||
@@ -78,7 +147,9 @@ class Liche extends HD_Controller
|
||||
} else {
|
||||
$data['c_time'] = time();
|
||||
$id = $this->mdOwners->add($data);
|
||||
$id && $log[] = ['id' => $id, 'name' => $data['name'], 'mobile' => $data['mobile']];
|
||||
if ($id && $params['rds']) {
|
||||
$log[] = ['id' => $id, 'name' => $data['name'], 'mobile' => $data['mobile']];
|
||||
}
|
||||
}
|
||||
}
|
||||
$redis->save($redisKey, $c_time);
|
||||
|
||||
@@ -38,6 +38,7 @@ class Plan extends CI_Controller
|
||||
$plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志
|
||||
|
||||
$plan[] = array('url' => base_url(array('plan', 'liche', 'add_owners')), 'interval' => 5);//新增车主
|
||||
$plan[] = array('url' => base_url(array('plan', 'liche', 'owners_wxqy')), 'interval' => 60);//更新车主企业微信
|
||||
|
||||
$plan[] = array('url' => base_url(array('plan', 'items', 'stock_log')), 'interval' => 5);//库存车辆日志
|
||||
|
||||
|
||||
@@ -16,6 +16,81 @@ class Temp extends HD_Controller
|
||||
$this->log_file = 'temp.log';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:车主企业微信/城市
|
||||
* Created on: 2022/6/21 11:58
|
||||
* Created by: dengbw
|
||||
* https://liche-api-dev.xiaoyu.com/plan/temp/receiver_owners_wxqy
|
||||
* https://api.liche.cn/plan/temp/receiver_owners_wxqy
|
||||
*/
|
||||
public function receiver_owners_wxqy()
|
||||
{
|
||||
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
|
||||
$mobile = '1113860199646';
|
||||
$ret = $this->mdOwners->update(['wxqy' => 1], ['mobile' => $mobile]);
|
||||
print_r($ret);
|
||||
exit;
|
||||
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$this->load->model('app/liche/app_liche_users_model', 'mdUsers');
|
||||
$this->load->model('receiver/receiver_owners_model', 'mdOwners');
|
||||
$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(); //打开缓冲区
|
||||
$res = $this->mdOwners->select(['status>=' => 0], 'id asc', $param['page'], $param['size'], 'id,o_id,mobile');
|
||||
if (!$res) {
|
||||
echo '<br>本次更新完成了:';
|
||||
echo '<br><br>成功更新 <span style="color: red;">' . $counts . '</span> 条';
|
||||
echo '<br><br><a href="/plan/temp/receiver_owners_wxqy">点击将再次更新>>></a>';
|
||||
exit;
|
||||
}
|
||||
$log = array();
|
||||
foreach ($res as $key => $value) {
|
||||
$update = '';
|
||||
if ($value['o_id']) {//查找门店城市
|
||||
$re_ord = $this->mdOrders->get(['id' => $value['o_id']]);
|
||||
if ($re_ord['biz_id']) {
|
||||
$re_biz = $this->mdBiz->get(['id' => $re_ord['biz_id']]);
|
||||
if ($re_biz) {
|
||||
$update['province_id'] = $re_biz['province_id'];
|
||||
$update['city_id'] = $re_biz['city_id'];
|
||||
$update['county_id'] = $re_biz['county_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['mobile']) {//查找企微
|
||||
$re_qy = $this->mdWechatqy->get(['mobile' => $value['mobile']]);
|
||||
if ($re_qy) {
|
||||
$update['wxqy'] = 1;
|
||||
} else {
|
||||
$re_use = $this->mdUsers->get(['mobile' => $value['mobile'], 'status<>' => -1]);
|
||||
if ($re_use['unionid']) {
|
||||
$re_qy = $this->mdWechatqy->get(['unionid' => $re_use['unionid']]);
|
||||
$re_qy && $update['wxqy'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($update) {
|
||||
$this->mdOwners->update($update, ['id' => $value['id']]);
|
||||
$log[] = array_merge($update, ['mobile' => $value['mobile']]);
|
||||
$counts++;
|
||||
}
|
||||
}
|
||||
echo '<br>成功更新:';
|
||||
if ($log) {
|
||||
echo json_encode($log, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
echo '<br><br>数据库获取:';
|
||||
echo json_encode($res, JSON_UNESCAPED_UNICODE);
|
||||
header('refresh:3;url=/plan/temp/receiver_owners_wxqy?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
|
||||
ob_end_flush();//输出全部内容到浏览器
|
||||
}
|
||||
|
||||
/**
|
||||
* Notes:加车主(状态交易完成)
|
||||
* Created on: 2022/5/27 11:58
|
||||
|
||||
@@ -229,8 +229,13 @@ class Persona extends CI_Controller
|
||||
$c_id = $userInfo['c_id'];
|
||||
$result = $re_cus = '';
|
||||
if ($c_id) {//已存在客户,更新资料
|
||||
$up_data = ['of_id' => $params['of_id'], 'of2_id' => $params['of2_id'], 'buddy_type' => $params['buddy_type']
|
||||
, 'wxqy' => 1];
|
||||
$up_data = ['of_id' => $params['of_id'], 'of2_id' => $params['of2_id'], 'buddy_type' => $params['buddy_type']];
|
||||
$re_cus2 = $this->mdCustomers->get(['id' => $c_id, 'status<>' => -1]);
|
||||
if (!$re_cus2) {
|
||||
$this->show_json(200, '客户不存在');
|
||||
}
|
||||
$re_cus2['wxqy'] != 1 && $up_data['wxqy'] = 1;
|
||||
!$re_cus2['unionid'] && $up_data['unionid'] = $userInfo['unionid'];
|
||||
$result = $this->mdCustomers->update($up_data, ['id' => $c_id]);
|
||||
$this->customers_entity->add_log($c_id, $userInfo['admin_id'], $userInfo['admin_name'], '修改用户基本信息');
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user